Stripe Elements 3D Secure卡片自动续费功能异常排查求助
Stripe Elements 3D Secure卡片自动续费功能异常排查求助
各位好,我这边碰到个Stripe自动续费的棘手问题,想请大家帮忙排查下。我们现在用Stripe Elements的payment-element来处理订阅业务,普通卡片的自动续费都正常跑,但带3D Secure验证的卡片自动续费完全失效,实在找不到问题点在哪。
先跟大家说下我们首次结账的配置:
- 首次创建PaymentIntent时,已经设置了
setup_future_usage: 'off_session',同时开启了automatic_payment_methods: { enabled: true }
下面是我们自动续费环节的具体代码,麻烦帮忙看看是不是有遗漏的配置:
PHP 自动续费创建PaymentIntent代码
public function stripeElementAutoRenewPayment($user_id, $brand_data, $card_src, $final_price, $secretKey) { $response = []; $output = null; $stripe = new \Stripe\StripeClient($secretKey); $return_url = "https://" . $brand_data->domain_name . "/subscriptions/payment-subscription.html"; $error = ''; // Create PaymentIntent with amount, currency and description. $paymentIntent = $stripe->paymentIntents->create([ 'amount' => $final_price, 'currency' => 'USD', 'description' => $brand_data->brand_name . "-AUTORENEW-" . $user_id, 'payment_method' => 'pm_card_threeDSecure2Required', 'customer' => $card_src['customer_id'], 'confirm' => true, 'off_session' => true ]); }
JS 前端相关代码
let obj = CheckoutModule.getCheckoutData(); Helpers.CommonUtils.commonGateway('POST', '/v1/orders/createpaymentintent', obj, stripeInitCallback ); function stripeInitCallback(res) { if (res.code == 1 && res.status == 1) { let clientSecret = res.results.client_secret; elements = stripe.elements({ clientSecret }); const paymentElement = elements.create("payment", { layout: "tabs", }); paymentElement.mount("#payment-element"); } } $("#pay-now-button").on('click', async function (event) { event.preventDefault(); if (payForm.valid()) { payNowButton.prop('disabled', true); console.log('payForm.valid', payForm.valid()) const { error, paymentIntent } = await stripe.confirmPayment({ elements, redirect: 'if_required' // Optional }); console.log("----paymentIntent---"+JSON.stringify(paymentIntent)); if (error) { $("#order-resp-msg").addClass("alert-danger").removeClass("hide").text(error.message); console.log('error', error); payNowButton.prop('disabled', false); $("#submitOrder, #pay-now-button").text('Confirm and Pay'); } else { payNowButton.prop('disabled', true); console.log("----paymentIntent---"+JSON.stringify(paymentIntent)+"----"+paymentIntent.id) const payment_id = paymentIntent.id; $("#submitOrder, #pay-now-button").text('PROCESSING ORDER...'); if (localStorage.getItem('l4-utoken')) { let obj = {}; obj.email = localStorage.getItem('l4-uemail') || $('form#userLoginForm input#emailAddress').val(); obj.log = "Add Order from page"; obj.data = ""; obj.domain = CheckoutModule.brandDomain; obj.type = "ADD_ORDER"; Helpers.CommonUtils.commonGateway('POST', '/v1/orders/stripepaymentlog', obj, CheckoutModule.createOrderCallback); CheckoutModule.submitOrder(payment_id); } else { let obj = {}; obj.email = localStorage.getItem('l4-uemail') || $('form#userLoginForm input#emailAddress').val(); obj.log = "Add Anonymous Order from page"; obj.data = ""; obj.domain = CheckoutModule.brandDomain; obj.type = "ADD_ANON_ORDER"; Helpers.CommonUtils.commonGateway('POST', '/v1/orders/stripepaymentlog', obj, CheckoutModule.createOrderCallback); CheckoutModule.submitAnonOrder(payment_id); } } } }
我们特别不确定在处理3D Secure卡片的off-session支付时,是不是漏了什么关键配置,比如有没有需要额外处理的验证流程?麻烦各位大佬帮忙看看问题出在哪,谢谢了!
内容来源于stack exchange
相关产品推荐
相关产品推荐

