0
votes

I've been using Stripe. When checkout X will create a Payment Intent every time a customer arrives on the checkout. This will result into an "Incomplete" payment.

enter image description here

I integrete STRIPE in my .Net Core application. Here the code below :

 public void Pay(CardInfo cardInfo, double amount)
        {
            StripeConfiguration.ApiKey = _paramList["secretKey"];
            State = PaymentState.Pending;
            try
            {
                var options = new SessionCreateOptions
                {
                    Mode = "payment",
                    SuccessUrl = "https://example.com/success",
                    CancelUrl = "https://example.com/cancel",
                    Customer = cardInfo.Owner,
                    CustomerEmail = cardInfo.ParamList["email"],                                    
                    PaymentMethodTypes = new List<string>
                    {
                        "card",
                    },
                    LineItems = new List<SessionLineItemOptions>
                {
                  new SessionLineItemOptions
                  {
                    Amount = Convert.ToInt64(amount.ToString().Replace(",","")),
                    Currency = "eur",
                    Quantity = 1,
                    Name = _paramList["account"]                  
                  },
                },
                    
                };

                var service = new SessionService();
                service.Create(options);
                State = PaymentState.Accepted;
            }
            catch (StripeException error)
            {        
                State = PaymentState.Error;
                PaymentReturn = error.Message;
                Logger.Write(string.Format("Error STRIPE payment status {0} : ",PaymentReturn));
            }
      }

In my form payment, I'm not using stripe form but I've created one and I retrieve all information that I need (Card Number, CVV, Expiration, Email and Amount)

1
If you are looking the latest solution of Stripe checkout integration in ASP.NET Core MVC, check out the demo ==> techtolia.com/StripeLeo

1 Answers

1
votes

When using Stripe Checkout, a PaymentIntent is created under the hood to support the SCA compliant payment. If the session is not completed, the PaymentIntent will remain in state incomplete. This. part is entirely normal.

Integrating with Stripe using a checkout session, but not redirecting to the Stripe hosted Checkout is not a supported integration. If you would like to support handling the card fields yourself, then an integration using Stripe.js and Elements is the best way forward [1]. If you would like to continue using Stripe Checkout as it offers so much functionality out of the box, then once the session is created, you should use redirectToCheckout() from Stripe.js [2] to send the user to Stripe Checkout.

[1] https://stripe.com/docs/payments/accept-a-payment?integration=elements

[2] https://stripe.com/docs/payments/accept-a-payment#redirect-customers