简体   繁体   English

带3d安全卡的条带化订阅,next_action为null

[英]Stripe Subscriptions with 3d secure card and next_action null

We are working to prepare our Stripe Subscription workflow to comply with the new SCA requirements for online payments coming into effect the 14th September 2019. We are facing some issues when trying to adapt out Javascript and PHP code in order to accept 3d secure credit cards when creating subscriptions. 我们正在努力准备我们的Stripe Subscription订阅工作流,以使其符合2019年9月14日生效的在线支付的新SCA要求。当尝试改编Javascript和PHP代码以在3D安全信用卡接受时,我们面临一些问题。创建订阅。

We've already tried the what was pointed here but with no luck. 我们已经尝试过这里指出的内容但是没有运气。 We are sending the enable_incomplete_payments = true when creating the Subscription from the server side, but the response return next_action = null although the status of the subscription is pending . 从服务器端创建订阅时,我们将发送enable_incomplete_payments = true ,但是尽管订阅的状态为pending ,但响应返回next_action = null

This is what we are doing step by step: 这是我们正在逐步执行的操作:

(client) We start elements (客户)我们开始要素

let stripe = window.Stripe(key);
let elements = stripe.elements();
[...]
let card = elements.create('card', {style: style});
[...]

(client) we use the test card 4000000000003220 (3d secured) (客户端)我们使用测试卡4000000000003220 (安全3d)

(client) createToken() -> send token to server (客户端)createToken()->将令牌发送到服务器

createToken(formId).then((result)=>{
    if (result.error) {
        //handle errors
    } else{
        //send result.token to backend
    }
})

(server) get token from client and create customer: (服务器)从客户端获取令牌并创建客户:

Customer::create([
    "description" => $user->name,
    "email" => $user->email,
    "source" => $token, // obtained with Stripe.js
]);

(server) create subscription (服务器)创建订阅

    $response = Subscription::create([
            "customer" => $customerId,
            "items" => [
                ["plan" => $planId],
            ],
            "prorate" => false,
            "expand" => ["latest_invoice.payment_intent"],
            'enable_incomplete_payments' => true
        ]);

    if ($response->status == 'incomplete') {
        $payment_intent = $response->latest_invoice->payment_intent->client_secret;
        //send payment intent client secret to frontend to perform authorization
    }

Here we should have the status=requires_action as a response but we are receiving the status=null instead. 在这里,我们应该以status=requires_action作为响应,但我们收到的是status=null And in the next step: 并在下一步中:

    stripe.handleCardPayment(paymentIntentSecret, element)

And here fails (no other action or popup), with error: 此处失败(没有其他操作或弹出窗口),并显示错误:

"error": {
    "charge": "ch_1EhvwjBqa3pLeb3ypVgXafhI",
    "code": "authentication_required",
    "decline_code": "authentication_required",
    "message": "Your card was declined. This transaction requires two-factor authentication.",
[...]

Thank you, Marco 谢谢Marco

This is because you're using an older API version from before the incomplete status existed. 这是因为您使用的是较早的API版本(存在不完整状态之前)。 To use this SCA-ready flow, you can either opt in by passing "enable_incomplete_payments" => true when creating the subscription, or use https://stripe.com/docs/api/versioning to make the API requests using a more recent API version. 要使用此支持SCA的流程,您可以在创建订阅时通过传递"enable_incomplete_payments" => true来选择加入,或者使用https://stripe.com/docs/api/versioning使用更新版本的API请求API版本。 It's described in detail here: 这里有详细描述:

https://stripe.com/docs/billing/lifecycle#incomplete-opt-in https://stripe.com/docs/billing/lifecycle#incomplete-opt-in

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM