public StripeCustomer CreateCustomer(StripeCustomerInfo customer) { if (customer == null) throw new ArgumentNullException ("customer"); return CreateOrUpdateCustomer (null, customer); }
public StripeCustomer CreateCustomer(StripeCustomerInfo customer) { if (customer == null) { throw new ArgumentNullException("customer"); } return(CreateOrUpdateCustomer(null, customer)); }
static void TestCustomer(StripePayment payment) { StripeCustomerInfo customer = new StripeCustomerInfo (); //customer.Card = GetCC (); StripeCustomer customer_resp = payment.CreateCustomer (customer); string customer_id = customer_resp.ID; StripeCustomer customer_info = payment.GetCustomer (customer_id); Console.WriteLine (customer_info); StripeCustomer ci2 = payment.DeleteCustomer (customer_id); if (ci2.Deleted == false) throw new Exception ("Failed to delete " + customer_id); }
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)); }
StripeCustomer CreateOrUpdateCustomer(string id, StripeCustomerInfo customer) { StringBuilder str = UrlEncode(customer); string format = "{0}/customers"; // Create if (id != null) { format = "{0}/customers/{1}"; // Update } string ep = String.Format(format, api_endpoint, HttpUtility.UrlEncode(id)); return(DoRequest <StripeCustomer> (ep, "POST", str.ToString())); }
static void TestCustomerAndCharge(StripePayment payment) { StripeCustomerInfo customer = new StripeCustomerInfo (); //customer.Card = GetCC (); StripeCustomer response = payment.CreateCustomer (customer); string customer_id = response.ID; StripeCustomer customer_info = payment.GetCustomer (customer_id); Console.WriteLine (customer_info); StripeCustomerInfo info_update = new StripeCustomerInfo (); info_update.Card = GetCC (); StripeCustomer update_resp = payment.UpdateCustomer (customer_id, info_update); Console.Write ("Customer updated with CC. Press ENTER to continue..."); Console.Out.Flush (); Console.ReadLine (); StripeCustomer ci2 = payment.DeleteCustomer (customer_id); if (ci2.Deleted == false) throw new Exception ("Failed to delete " + customer_id); }
public string ProcessPayment(string FirstName, string LastName, string EmailAddress, string CardNumber, string ExpMonth, string ExpYear, string Cvv) { StripePayment payment = new StripePayment("OxGcTunKYwFuBr6JPDpX1mehWlXHIJ7k"); StripeCustomerInfo customer = new StripeCustomerInfo { Email = EmailAddress, Card = new StripeCreditCardInfo { Number = CardNumber, ExpirationMonth = Convert.ToInt32(ExpMonth), ExpirationYear = Convert.ToInt32(ExpYear), FullName = FirstName + " " + LastName } }; StripeCustomer response = payment.CreateCustomer(customer); string customerId = response.ID; return payment.Charge(2500, "usd", customerId, "QuadAutomotive Group Application Fee").ID; }
StripeCustomer CreateOrUpdateCustomer(string id, StripeCustomerInfo customer) { StringBuilder str = UrlEncode (customer); 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); }
private void TestStripePayment() { string stripeApiKey = Util.GetAppSetting(Constants.AppSettingKeys.StripeApiKey); StripePayment payment = new StripePayment(stripeApiKey); StripeCreditCardInfo cc = new StripeCreditCardInfo(); cc.CVC = "1234"; cc.ExpirationMonth = 6; cc.ExpirationYear = 2013; cc.Number = "4242424242424242"; StripeCustomerInfo customerInfo = new StripeCustomerInfo(); customerInfo.Card = cc; customerInfo.Description = "Test User"; customerInfo.Email = UserSession.Current.Email; customerInfo.Validate = false; try { StripeCustomer customer = payment.CreateCustomer(customerInfo); int userID = UserSession.Current.UserID; StripeUser stripeUser = new StripeUser() { UserID = userID, StripeCustomerID = customer.ID, LiveMode = customer.LiveMode, Description = customer.Description, DateCreated = DateTime.UtcNow }; int stripeUserID = StripeUserService.AddStripeUser(stripeUser); StripeCustomer customerFromPayment = payment.GetCustomer(customer.ID); customerInfo.Description = "Other Description"; StripeCustomer updatedCustomer = payment.UpdateCustomer(customerFromPayment.ID, customerInfo); StripeCharge charge = payment.Charge(5001, "usd", customer.ID, "Another Test Charge"); List<StripeUser> stripeUsers = StripeUserService.GetStripeUsers(userID, customer.ID); } catch (Exception ex) { string error = "Error Processing Request"; LoggingFactory.GetLogger().LogError(error, ex); } //StripeCharge charge = payment.Charge(5001, "usd", cc, "Test charge"); //string charge_id = charge.ID; //StripeCharge charge_info = payment.GetCharge(charge_id); //StripeCharge refund = payment.Refund(charge_info.ID); }
public void CustomerAndCharge() { StripeCustomerInfo customer = new StripeCustomerInfo(); //customer.Card = GetCC (); StripeCustomer response = _payment.CreateCustomer(customer); string customer_id = response.Id; StripeCustomer customer_info = _payment.GetCustomer(customer_id); Console.WriteLine(customer_info); StripeCustomerInfo info_update = new StripeCustomerInfo(); info_update.Card = GetValidCreditCard(); StripeCustomer update_resp = _payment.UpdateCustomer(customer_id, info_update); Console.Write("Customer updated with CC. Press ENTER to continue..."); Console.Out.Flush(); Console.ReadLine(); StripeCustomer ci2 = _payment.DeleteCustomer(customer_id); //if (ci2.Deleted == false) throw new Exception("Failed to delete " + customer_id); Assert.IsTrue(ci2.Deleted, "Failed to delete " + customer_id); }
public void Customer() { StripeCustomerInfo customer = new StripeCustomerInfo(); //customer.Card = GetCC (); StripeCustomer customer_resp = _payment.CreateCustomer(customer); string customer_id = customer_resp.Id; StripeCustomer customer_info = _payment.GetCustomer(customer_id); Console.WriteLine(customer_info); StripeCustomer ci2 = _payment.DeleteCustomer(customer_id); //if (ci2.Deleted == false) throw new Exception("Failed to delete " + customer_id); Assert.IsTrue(ci2.Deleted, "Failed to delete " + customer_id); }