예제 #1
0
        /// <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);
        }
예제 #2
0
 /// <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);
     }
 }
예제 #3
0
        /// <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);
        }
예제 #4
0
 /// <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);
 }