public StripeCustomer CreateCustomer(StripeCustomerInfo customer)
        {
            if (customer == null)
                throw new ArgumentNullException ("customer");

            return CreateOrUpdateCustomer (null, customer);
        }
示例#2
0
 static void TestCustomer(StripeApi gateway)
 {
     StripeCustomerInfo customer = new StripeCustomerInfo ();
     //customer.Card = GetCC ();
     StripeCustomer customer_resp = gateway.CreateCustomer(customer);
     string customer_id = customer_resp.ID;
     StripeCustomer customer_info = gateway.GetCustomer(customer_id);
     Console.WriteLine (customer_info);
     StripeCustomer ci2 = gateway.DeleteCustomer(customer_id);
     if (ci2.Deleted == false)
         throw new Exception ("Failed to delete " + customer_id);
 }
示例#3
0
 static void TestCustomerAndCharge(StripeApi gateway)
 {
     StripeCustomerInfo customer = new StripeCustomerInfo ();
     //customer.Card = GetCC ();
     StripeCustomer response = gateway.CreateCustomer(customer);
     string customer_id = response.ID;
     StripeCustomer customer_info = gateway.GetCustomer(customer_id);
     Console.WriteLine (customer_info);
     StripeCustomerInfo info_update = new StripeCustomerInfo ();
     info_update.Card = GetCC ();
     StripeCustomer update_resp = gateway.UpdateCustomer(customer_id, info_update);
     Console.Write ("Customer updated with CC. Press ENTER to continue...");
     Console.Out.Flush ();
     Console.ReadLine ();
     StripeCustomer ci2 = gateway.DeleteCustomer(customer_id);
     if (ci2.Deleted == false)
         throw new Exception ("Failed to delete " + customer_id);
 }
        StripeCustomer CreateOrUpdateCustomer(string id, StripeCustomerInfo customer)
        {
            StringBuilder str = new StringBuilder ();
            customer.UrlEncode (str);
            if (str.Length > 0)
                str.Length--;

            string format = "{0}/customers"; // Create
            if (id != null)
                format = "{0}/customers/{1}"; // Update
            string ep = String.Format (format, api_endpoint, HttpUtility.UrlEncode (id));
            string json = DoRequest (ep, "POST", str.ToString ());
            return JsonConvert.DeserializeObject<StripeCustomer> (json);
        }
        public StripeCustomer UpdateCustomer(string id, StripeCustomerInfo customer)
        {
            if (String.IsNullOrEmpty (id))
                throw new ArgumentNullException ("id");
            if (customer == null)
                throw new ArgumentNullException ("customer");

            return CreateOrUpdateCustomer (id, customer);
        }