使用 Reactjs 中的付款请求按钮付款成功后,我收到错误消息。
错误:未捕获(承诺中)IntegrationError:您有一个正在运行的confirmCardPayment!请确保在调用 confirmCardPayment 时禁用您的表单提交按钮。
代码:
paymentRequest.on("paymentmethod", async (ev) => {
// Confirm the PaymentIntent without handling potential next actions (yet).
const {
paymentIntent,
error: confirmError,
} = await stripe.confirmCardPayment(
key,
{ payment_method: ev.paymentMethod.id },
{ handleActions: false }
);
if (confirmError) {
// Report to the browser that the payment failed, prompting it to
// re-show the payment interface, or show an error message and close
// the payment interface.
ev.complete("fail");
} else {
// Report to the browser that the confirmation was successful, prompting
// it to close the browser payment method collection interface.
ev.complete("success");
// Check if the PaymentIntent requires any actions and if so let Stripe.js
// handle the flow. If using an API version older than "2019-02-11" instead
// instead check for: `paymentIntent.status === "requires_source_action"`.
if (paymentIntent.status === "requires_action") {
// Let Stripe.js handle the rest of the payment flow.
const { error } = await stripe.confirmCardPayment(key);
if (error) {
// The payment failed -- ask your customer for a new payment method.
} else {
// The payment has succeeded.
}
} else {
// The payment has succeeded.
}
}
});
组件很简单:
if (paymentRequest) { return <PaymentRequestButtonElement options={options} />; }
我在哪里搞砸了?