public dynamic confirmPayment(ConfirmPaymentInfo confirmPaymentInfo) { string stripeRedirectUrl = String.IsNullOrEmpty(confirmPaymentInfo.RedirectUrl)? GetEnvironmentConfigVar(StripeConfigKey, this.configuration.GetValue <string>(StripeConfigRedirectUrl)) + "/Home/ConfirmPayment":confirmPaymentInfo.RedirectUrl; var paymentIntentService = new PaymentIntentService(); PaymentIntent paymentIntent = null; try { if (confirmPaymentInfo.PaymentIntentId != null) { paymentIntent = paymentIntentService.Get(confirmPaymentInfo.PaymentIntentId); if (paymentIntent.Status == "requires_payment_method") { generatePaymentResponse(paymentIntent); } else { var confirmOptions = new PaymentIntentConfirmOptions { ReturnUrl = stripeRedirectUrl }; paymentIntent = paymentIntentService.Confirm( confirmPaymentInfo.PaymentIntentId, confirmOptions ); } } } catch (StripeException e) { return(new { error = e.StripeError.Message }); } return(generatePaymentResponse(paymentIntent)); }
public object ConfirmPayment([FromBody] ConfirmPaymentInfo confirmPaymentInfo) { return((new StripeInfoProvider(this.configuration)).confirmPayment(confirmPaymentInfo)); }