为什么当我使用 3D Secure 测试卡号时,Stripe 没有给我一个 Payment Intents requires_action 状态? [英] Why is Stripe not giving me a Payment Intents requires_action status when I use a 3D Secure test card number?
问题描述
按照账单和订阅的 Stripe 文档,我使用 PaymentIntents 创建订阅.如果我输入不需要 3D Secure 的测试卡,它可以正常工作.但我使用了一个,而不是给我一个 requires_action 的状态,它只是在卡上给出一个错误.
In following the Stripe documentation for Billing and Subscriptions, I'm using PaymentIntents to create a subscription. It works fine if I enter a test card that doesn't require 3D Secure. But it I use one that does, instead of giving me a status of requires_action, it just gives a error on the card.
//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#three-ds-cards
I'm using test cards on this page: https://stripe.com/docs/testing#three-ds-cards
我选择了带有这个号码的卡片:4000 0000 0000 3220
I have chosen the card with this number: 4000 0000 0000 3220
这是我的错误详细信息:状态:402类型:card_error代码:subscription_payment_intent_requires_action消息:此订阅的付款需要额外的用户操作才能成功完成.请在此处参考 enable_incomplete_payments
参数的使用:https://stripe.com/docs/billing/lifecycle#incomplete-opt-in
Here's my error details:
Status:402
Type:card_error
Code:subscription_payment_intent_requires_action
Message:Payment for this subscription requires additional user action before it can be completed successfully. Please refer to the use of the enable_incomplete_payments
parameter here: https://stripe.com/docs/billing/lifecycle#incomplete-opt-in
我的 API 版本是 2018-05-21.
My API version is 2018-05-21.
谁能告诉我我做错了什么?
Can anyone give me a clue to what I'm doing wrong?
推荐答案
已在评论中回答,仅在此处发布以供查看:
Answered in the comments, just posting here for visibility:
嗨安迪,由于您使用的是较旧的 API 版本,要在订阅上支持 3DS,您应该改用本指南:https://stripe.com/docs/billing/migration/strong-customer-authentication#upgrading-integration.
Hi Andy, since you are on an older API version, to support 3DS on subscriptions, you should be using this guide instead: https://stripe.com/docs/billing/migration/strong-customer-authentication#upgrading-integration.
这意味着在创建订阅时更新您的 API 版本或传递 enable_incomplete_payments 标志,如错误消息指出的那样.
This means updating your API version or passing the enable_incomplete_payments flag when creating the subscription, as the error message points out.
这篇关于为什么当我使用 3D Secure 测试卡号时,Stripe 没有给我一个 Payment Intents requires_action 状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!