/// <summary> /// Creates a new customer record in Stripe for the given user /// NOTE: Save changes on the underlying context for the model after calling this method /// </summary> /// <param name="user"></param> public static void CreateCustomer(IStripeUser user, string paymentToken = null) { // Do not overwrite the user, ever if (user.HasPaymentInfo()) { return; } var newCustomer = new StripeCustomerCreateOptions(); newCustomer.Email = user.Email; if (paymentToken != null) { newCustomer.Card = new StripeCreditCardOptions() { TokenId = paymentToken } } ; var customerService = new StripeCustomerService(); StripeCustomer stripeCustomer = customerService.Create(newCustomer); // Set the accounting info user.PaymentSystemId = stripeCustomer.Id; System.Diagnostics.Trace.TraceInformation("Created customer in stripe: '{0}' with id '{1}", user.Email, user.PaymentSystemId); }
/// <summary> /// Creates or update a customer /// </summary> /// <param name="user"></param> /// <param name="paymentToken"></param> public static void CreateOrUpdateCustomer(IStripeUser user, string paymentToken = null) { if (user.HasPaymentInfo()) { UpdateCustomer(user, paymentToken); } else { CreateCustomer(user, paymentToken); } }
/// <summary> /// Creates a new customer record in Stripe for the given user /// NOTE: Save changes on the underlying context for the model after calling this method /// </summary> /// <param name="user"></param> public static void CreateCustomer(IStripeUser user, string paymentToken = null) { // Do not overwrite the user, ever if (user.HasPaymentInfo()) return; var newCustomer = new StripeCustomerCreateOptions(); newCustomer.Email = user.Email; if (paymentToken != null) newCustomer.Card = new StripeCreditCardOptions() { TokenId = paymentToken }; var customerService = new StripeCustomerService(); StripeCustomer stripeCustomer = customerService.Create(newCustomer); // Set the accounting info user.PaymentSystemId = stripeCustomer.Id; System.Diagnostics.Trace.TraceInformation("Created customer in stripe: '{0}' with id '{1}", user.Email, user.PaymentSystemId); }
/// <summary> /// Creates or update a customer /// </summary> /// <param name="user"></param> /// <param name="paymentToken"></param> public static void CreateOrUpdateCustomer(IStripeUser user, string paymentToken = null) { if (user.HasPaymentInfo()) UpdateCustomer(user, paymentToken); else CreateCustomer(user, paymentToken); }