STRIPE API 付款意向未完成付款

STRIPE API Payment Intent incomplete payment

我一直在使用 Stripe。每次结账时,X 都会在客户到达结账处时创建一个付款意向。这将导致“未完成”付款。

我在我的 .Net Core 应用程序中集成了 STRIPE。下面是代码:

 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));
            }
      }

在我的表格付款中,我没有使用条纹表格,但我创建了一个表格并检索了我需要的所有信息(卡号、CVV、有效期、电子邮件和金额)

使用 Stripe Checkout 时,会在后台创建一个 PaymentIntent 以支持符合 SCA 的支付。如果会话未完成,PaymentIntent 将保持状态 incomplete。这个。部分完全正常

使用结帐会话与 Stripe 集成,但不重定向到 Stripe 托管的结帐不是受支持的集成。如果您想支持自己处理卡片字段,那么使用 Stripe.js 和 Elements 的集成是最好的方法 [1]。如果您想继续使用 Stripe Checkout,因为它提供了如此多的开箱即用功能,那么在创建会话后,您应该使用 Stripe.js [2] 中的 redirectToCheckout() 将用户发送到 Stripe Checkout。

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

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