【问题标题】:Stripe Subscriptions with 3d secure card and next_action null带 3d 安全卡和 next_action 的条带订阅 null
【发布时间】:2019-10-20 21:35:27
【问题描述】:

我们正在努力准备 Stripe 订阅工作流程,以符合 2019 年 9 月 14 日生效的在线支付的新 SCA 要求。在尝试调整 Javascript 和 PHP 代码以接受 3d 安全时,我们遇到了一些问题创建订阅时使用信用卡。

我们已经尝试过here 指出的内容,但没有成功。我们从服务器端创建订阅时发送enable_incomplete_payments = true,但响应返回next_action = null,尽管订阅状态为pending

这是我们一步一步做的:

(客户端)我们开始元素

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

(客户端)我们使用测试卡4000000000003220(3d 安全)

(client) createToken() -> 发送令牌到服务器

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

(服务器)从客户端获取令牌并创建客户:

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

(服务器)创建订阅

    $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
    }

这里我们应该有status=requires_action 作为响应,但我们收到的是status=null。在下一步中:

    stripe.handleCardPayment(paymentIntentSecret, element)

这里失败(没有其他操作或弹出窗口),错误:

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

谢谢你, 马可

【问题讨论】:

    标签: javascript php stripe-payments 3d-secure


    【解决方案1】:

    这是因为您使用的是不完整状态之前的旧 API 版本。要使用此 SCA 就绪流,您可以在创建订阅时通过传递 "enable_incomplete_payments" => true 来选择加入,或者使用 https://stripe.com/docs/api/versioning 使用更新的 API 版本发出 API 请求。这里有详细描述:

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

    【讨论】:

    • 您好!谢谢!但正如您在提供的代码中看到的那样,我们在使用 Subscription::create 从服务器端创建订阅时已经传递了参数 enable_incomplete_payments。
    猜你喜欢
    • 2021-04-11
    • 2018-09-20
    • 2015-02-20
    • 2018-11-29
    • 1970-01-01
    • 2021-08-21
    • 2019-06-13
    • 2020-01-16
    • 2021-05-30
    相关资源
    最近更新 更多