我们正在努力准备我们的条带订阅工作流程,以符合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安全)
(客户端) 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.",
[...]
谢谢你,马可
发布于 2019-06-05 19:32:20
这是因为您使用的是不完整状态存在之前的较旧的API版本。要使用这个支持SCA的流程,您可以选择在创建订阅时传递API,或者使用https://stripe.com/docs/api/versioning使用更新的"enable_incomplete_payments" => true
版本发出API请求。这里有详细的描述:
https://stackoverflow.com/questions/56459396
复制相似问题