![](/img/trans.png)
[英]Stripe Subscriptions - Charing a 3D Secure card number returning subscription_payment_intent_requires_action
[英]Stripe Subscriptions with 3d secure card and next_action null
我们正在努力准备我们的Stripe Subscription订阅工作流,以使其符合2019年9月14日生效的在线支付的新SCA要求。当尝试改编Javascript和PHP代码以在3D安全信用卡接受时,我们面临一些问题。创建订阅。
我们已经尝试过这里指出的内容,但是没有运气。 从服务器端创建订阅时,我们将发送enable_incomplete_payments = true
,但是尽管订阅的状态为pending
,但响应返回next_action = null
。
这是我们正在逐步执行的操作:
(客户)我们开始要素
let stripe = window.Stripe(key);
let elements = stripe.elements();
[...]
let card = elements.create('card', {style: style});
[...]
(客户端)我们使用测试卡4000000000003220
(安全3d)
(客户端)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.",
[...]
谢谢Marco
这是因为您使用的是较早的API版本(存在不完整状态之前)。 要使用此支持SCA的流程,您可以在创建订阅时通过传递"enable_incomplete_payments" => true
来选择加入,或者使用https://stripe.com/docs/api/versioning使用更新版本的API请求API版本。 这里有详细描述:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.