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); }
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; }
private static void TestInvoices(StripePayment payment) { List<StripeInvoice> invoices = payment.GetInvoices(10, 10); StripeInvoice inv = payment.GetInvoice(invoices[0].Id); StripeCustomer cust = payment.CreateCustomer(new StripeCustomerInfo()); StripeSubscription sub = payment.Subscribe(cust.Id, new StripeSubscriptionInfo { Card = GetCC() }); StripeInvoice inv2 = payment.GetUpcomingInvoice(cust.Id); payment.Unsubscribe(cust.Id, true); payment.DeleteCustomer(cust.Id); }
private static void TestCreateSubscription(StripePayment payment) { StripeCustomer cust = payment.CreateCustomer(new StripeCustomerInfo { Card = GetCC() }); //StripePlan temp = new StripePlan { Id = "myplan" }; //DeletePlan (temp, payment); StripePlan plan = CreatePlan(payment); StripeSubscription sub = payment.Subscribe( cust.Id, new StripeSubscriptionInfo { Card = GetCC(), Plan = "myplan", Prorate = true }); StripeSubscription sub2 = payment.GetSubscription(sub.CustomerID); TestDeleteSubscription(cust, payment); DeletePlan(plan, payment); }
private static void TestCreateInvoiceItems(StripePayment payment) { StripeCustomer cust = payment.CreateCustomer(new StripeCustomerInfo()); StripeInvoiceItemInfo info = GetInvoiceItemInfo(); info.CustomerId = cust.Id; StripeInvoiceItem item = payment.CreateInvoiceItem(info); StripeInvoiceItemUpdateInfo updateInfo = GetInvoiceItemUpdateInfo(); updateInfo.Description = "Invoice item: " + Guid.NewGuid().ToString(); StripeInvoiceItem item2 = payment.UpdateInvoiceItem(item.Id, updateInfo); StripeInvoiceItem item3 = payment.GetInvoiceItem(item2.Id); if (item.Description == item3.Description) throw new Exception("Update failed"); StripeInvoiceItem deleted = payment.DeleteInvoiceItem(item2.Id); if (!deleted.Deleted.HasValue && deleted.Deleted.Value) throw new Exception("Delete failed"); int total; var items = payment.GetInvoiceItems(10, 10, null, out total); Console.WriteLine(total); payment.DeleteCustomer(cust.Id); }
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); }