确认服务器端的PaymentIntent



我在一个叫车平台工作,客户直接向司机付款

我使用标准帐户Stripe。我在平台上保存客户和PaymentMethods,因此,在客户端,客户选择一种支付方式,它被发送并存储在我的服务器数据库

因此,当客户要付款时,我在服务器端将PaymentMethod克隆到将接收付款的Connected Account。我的服务器端代码看起来像这样

RequestOptions requestOptions = RequestOptions.builder()
.setStripeAccount("{{CONNECTED_STRIPE_ACCOUNT_ID}}")
.build();
PaymentMethodCreateParams paramsClone = PaymentMethodCreateParams.builder()
.setCustomer("cus_1")//Id of the customer in the platform
.setPaymentMethod("payment_method_id")//One of the payment methods of the cus_1
.build();
PaymentMethod newPaymentMethod = PaymentMethod.create(paramsClone, requestOptions);
然后我创建一个PaymentIntent
PaymentIntentCreateParams params = PaymentIntentCreateParams.builder()
.setAmount(100)
.setPaymentMethod(newPaymentMethod.getId())
.setCurrency("usd")
.setApplicationFeeAmount(10)
.build();
PaymentIntent paymentIntent = PaymentIntent.create(params, requestOptions);

支付意图返回条纹客户端秘密,如'pi_1231abCD_secret_ABcD',状态为'requires_confirmation"。

但是,我不希望Customer在客户端确认。我希望是透明的,客户不需要采取任何行动(像在优步,一旦司机点击"完成乘车")。即使乘客关闭应用程序,付款也会完成)

谁能解释一下如何避免确认或自动执行确认?的问候!

您需要确认付款意图。您可以使用如下的API调用在服务器端完成此操作:https://stripe.com/docs/api/payment_intents/confirm?lang=java

如果发证行要求额外的身份验证,您可能仍然需要准备好将用户带回会话。

这个用例被称为商家发起的支付。

请确保在payment_intent API中添加两个标志

  1. confirm = true
  2. off_session = true

如果您正在处理美国市场的付款,则上述更改应该有效。如果这是针对需要认证的欧洲/其他市场,请参阅此页面(https://stripe.com/docs/strong-customer-authentication/sca-enforcement)

最新更新