Laravel 带确认方法的Stripe PaymentIntent手册每次都失败
我使用的是个人集成了Stripe API的Laravel(使用github的Stripe API)。Laravel 带确认方法的Stripe PaymentIntent手册每次都失败,laravel,stripe-payments,payment,Laravel,Stripe Payments,Payment,我使用的是个人集成了Stripe API的Laravel(使用github的Stripe API)。 在我切换到手动确认模式之前,一切正常,现在我收到以下错误: This PaymentIntent pi_**************uVme cannot be confirmed using your publishable key because its `confirmation_method` is set to `manual`. Please use your secret key
在我切换到手动确认模式之前,一切正常,现在我收到以下错误:
This PaymentIntent pi_**************uVme cannot be confirmed using your publishable key because its `confirmation_method` is set to `manual`. Please use your secret key instead, or create a PaymentIntent with `confirmation_method` set to `automatic`.
有什么想法吗?这是我的当前代码(不工作): JS前端:
<button class="myButtonPayment" id="card-button" type="button" data-secret="{!!$stripePaymentIntent->client_secret!!}" ><span>Pay</span></button>
...
<script>
cardButton.addEventListener('click', function() {
if(!document.getElementById('order_telephone_number').value || /^\+?[0-9 ]{6,20}$/.test(document.getElementById('order_telephone_number').value)){
stripe.handleCardPayment(
clientSecret, cardElement, {
payment_method_data: {
billing_details: {name: cardholderName.value}
}
}
).then(function (result) {
if (result.error) {
console.log(result.error);
} else {
document.getElementById('myForm').submit();
}
});
}
});
</script>
付款意图的手动确认仅用于服务器端确认(即使用您的API密钥,而不是您的可发布密钥)。将支付意图上的
confirmation\u method
设置为manual
,与“此支付意图只能在服务器端确认”相同
您可以在条带的文档中了解更多信息。是的,当然,在表单指向的端点上,我有
PaymentIntent::retrieve($o->payment\u id)->confirm()
,在一些验证之后,但是我无法验证在提交表单之前我在哪里确认付款,我明白你的意思<代码>条带。handleCardPayment尝试在客户端确认付款意图。您很可能想改用stripe.createPaymentMethod,如下所示:哦,非常感谢,非常感谢。。该方法是否适用于所有进行手卡支付的验证?与SCA的2阶段自动验证一样,检查是否有足够的资金、卡是否过期等等?否,如果使用手动确认,则还需要手动处理这些步骤。请看这里:
<button class="myButtonPayment" id="card-button" type="button" data-secret="{!!$stripePaymentIntent->client_secret!!}" ><span>Pay</span></button>
...
<script>
cardButton.addEventListener('click', function() {
if(!document.getElementById('order_telephone_number').value || /^\+?[0-9 ]{6,20}$/.test(document.getElementById('order_telephone_number').value)){
stripe.handleCardPayment(
clientSecret, cardElement, {
payment_method_data: {
billing_details: {name: cardholderName.value}
}
}
).then(function (result) {
if (result.error) {
console.log(result.error);
} else {
document.getElementById('myForm').submit();
}
});
}
});
</script>
{
"type":"invalid_request_error",
"code":"payment_intent_invalid_parameter",
"doc_url":"https://stripe.com/docs/error-codes/payment-intent-invalid-parameter",
"message":"This PaymentIntent pi_1H3TQ*********T00uVme cannot be confirmed using your publishable key because its `confirmation_method` is set to `manual`. Please use your secret key instead, or create a PaymentIntent with `confirmation_method` set to `automatic`.",
"payment_intent":{
"id":"pi_1H3***********uVme",
"object":"payment_intent",
"amount":2060,
"canceled_at":null,
"cancellation_reason":null,
"capture_method":"automatic",
"client_secret":"pi_1H3TQ********T00uVme_secret_2T7Di*********nkoaceKx",
"confirmation_method":"manual",
"created":1594415166,
"currency":"eur",
"description":"....",
"last_payment_error":null,
"livemode":false,
"next_action":null,
"payment_method":null,
"payment_method_types":[
"card"
],
"receipt_email":null,
"setup_future_usage":null,
"shipping":null,
"source":null,
"status":"requires_payment_method"
}
}