public virtual ActionResult Process(StripePaymentModel model) { try { var provider = GatewayContext.Payment.GetProviderByKey(Constants.Stripe.GatewayProviderSettingsKey); //var paymentMethod = CheckoutManager.Payment.GetPaymentMethod(); var paymentMethod = this.CheckoutManager.Payment.GetPaymentGatewayMethods().FirstOrDefault(x => x.PaymentMethod.ProviderKey == provider.Key).PaymentMethod; if (paymentMethod == null) { var ex = new NullReferenceException("PaymentMethod was null"); return(HandlePaymentException(model, ex)); } var args = new ProcessorArgumentCollection(); args.SetTokenId(model.Token); args.SetCustomerName(model.Name); args.SetCustomerEmail(model.Email); // We can now capture the payment // This will actually make a few more API calls back to Stripe to get required transaction // data so that we can refund the payment later through the back office if needed. var attempt = CheckoutManager.Payment.AuthorizeCapturePayment(paymentMethod.Key, args); // Raise the event to process the email Processed.RaiseEvent(new PaymentAttemptEventArgs <IPaymentResult>(attempt), this); var resultModel = CheckoutPaymentModelFactory.Create(CurrentCustomer, paymentMethod, attempt); resultModel.SuccessRedirectUrl = model.SuccessRedirectUrl; string invoiceId = attempt.Invoice.Key.ToString().EncryptWithMachineKey(); if (attempt.Payment.Success) { CustomerContext.SetValue("invoiceKey", attempt.Invoice.Key.ToString()); } if (!resultModel.ViewData.Success) { var invoiceKey = attempt.Invoice.Key; var paymentKey = attempt.Payment.Result != null ? attempt.Payment.Result.Key : Guid.Empty; EnsureDeleteInvoiceOnCancel(invoiceKey, paymentKey); } return(HandlePaymentSuccess(resultModel, invoiceId)); } catch (Exception ex) { return(HandlePaymentException(model, ex)); } }