예제 #1
0
        private IHttpActionResult StripeCheckout(ChargeDtos charge)
        {
            try
            {
                var customer = _customers.Create(new StripeCustomerCreateOptions
                {
                    Email       = charge.Email,
                    SourceToken = charge.Token
                });

                var chargeOptions = new StripeChargeCreateOptions()
                {
                    Amount      = charge.Amount,
                    Currency    = "usd",
                    Description = "Charge for " + charge.Email ?? charge.Name,
                    CustomerId  = customer.Id,
                    SourceTokenOrExistingSourceId = charge.Token // obtained with Stripe.js
                };

                var stripeCharge = _charges.Create(chargeOptions);

                return(Ok());
            }
            catch (Exception)
            {
                return(StatusCode(HttpStatusCode.InternalServerError));
            }
        }
예제 #2
0
 public IHttpActionResult Checkout(ChargeDtos charge)
 {
     if (System.Configuration.ConfigurationManager.AppSettings["PaymentSystem"].ToUpper() == "STRIPE")
     {
         return(StripeCheckout(charge));
     }
     else
     {
         return(StatusCode(HttpStatusCode.InternalServerError));
     }
 }