当我使用 3D Secure 测试卡号时,为什么 Stripe 不向我提供付款意向 require_action 状态?

问题描述 投票:0回答:3

按照 Stripe 的计费和订阅文档,我使用 PaymentIntents 创建订阅。如果我输入不需要 3D Secure 的测试卡,效果很好。但如果我使用的是这样的,而不是给我一个 require_action 的状态,它只是在卡上给出一个错误。

//Create customer
$customer = \Stripe\Customer::create(array(
      "source" => $token,
      "email" => $subscriber_email)
    );

    // Get customer variables from Stripe response
    $payment_livemode = $customer->livemode;
    $payer_id = $customer->id;

    // Now put customer on subs plan    
    try {   
        $subscription = \Stripe\Subscription::create([
          "customer" => $payer_id,
          "items" => [
            [
              "plan" => $subscription_plan
            ],
          ],
           "expand" => ["latest_invoice.payment_intent"],
        ]);

        $subscription_id = $subscription->id;
        $subscription_plan_id = $subscription->items->data[0]->plan->id;
        $subscription_latest_invoice_status = $subscription->latest_invoice->status;
        $subscription_latest_invoice_id = $subscription->latest_invoice->id;
        $subscription_latest_invoice_payment_intent_status = $subscription->latest_invoice->payment_intent->status;
        $subscription_latest_invoice_payment_intent_client_secret = $subscription->latest_invoice->payment_intent->client_secret;

        $_SESSION['subscription_latest_invoice_payment_intent_client_secret'] = $subscription_latest_invoice_payment_intent_client_secret;

        if ($subscription_latest_invoice_payment_intent_status=='succeeded') {
             header("Location: ../payment-success");
        }
        if ($subscription_latest_invoice_payment_intent_status=='requires_payment_method') {
             header("Location: ../payment?payment_status=failed&inv=$subscription_latest_invoice_id");
        }
        if ($subscription_latest_invoice_payment_intent_status=='requires_action') {
             header("Location: ../payment?payment_status=requires_action");
        }
    } catch(\Stripe\Error\Card $e) {

          $body = $e->getJsonBody();
          $err  = $body['error'];

          if ($err['code']=="subscription_payment_intent_requires_action") {
              header("Location: ../payment/requires_action");
          }

        } catch (\Stripe\Error\RateLimit $e) {
          // Too many requests made to the API too quickly
        } catch (\Stripe\Error\InvalidRequest $e) {
          // Invalid parameters were supplied to Stripe's API
        } catch (\Stripe\Error\Authentication $e) {
          // Authentication with Stripe's API failed
          // (maybe you changed API keys recently)
        } catch (\Stripe\Error\ApiConnection $e) {
          // Network communication with Stripe failed
        } catch (\Stripe\Error\Base $e) {
          // Display a very generic error to the user, and maybe send
          // yourself an email
        } catch (Exception $e) {
          // Something else happened, completely unrelated to Stripe
        }

我在此页面上使用测试卡: https://stripe.com/docs/testing#third-ds-cards

我选择了带有此号码的卡: 4000 0000 0000 3220

这是我的错误详细信息: 状态:402 类型:卡_错误 代码:subscription_ payment_intent_requires_action 消息:此订阅的付款需要额外的用户操作才能成功完成。

enable_incomplete_payments
参数的使用请参考这里:https://stripe.com/docs/billing/lifecycle#incomplete-opt-in

我的API版本是2018-05-21。

任何人都可以告诉我我做错了什么吗?

php stripe-payments
3个回答
5
投票

在评论中回答,只是发布在这里以提高可见性:

安迪,您好,由于您使用的是较旧的 API 版本,为了在订阅上支持 3DS,您应该改用本指南:https://stripe.com/docs/billing/migration/strong-customer-authentication#upgrading-整合

这意味着在创建订阅时更新您的 API 版本或传递启用_不完整_付款标志,如错误消息所示。


3
投票

我也遇到了同样的问题,实际上,API 版本不是您下载的库的版本,您必须在仪表板中更改它,https://dashboard.stripe.com/developers


0
投票

以防万一其他人遇到这个问题,我正在设计一个结账原型,并使用输入模糊上的一些优惠券信息更新付款意图。

原来我是在 3d secure 打开之后、但在确认之前更新了付款意图。

© www.soinside.com 2019 - 2024. All rights reserved.