由于浏览器弹出窗口阻止程序,我发现除了点击事件之外的任何问题handler.open
,但请参阅我正在使用的以下代码:
HTML
<button type="button" data-stripe data-image="/path/to/image.jpg">The button</button>
JS
export function paymentScreen(form, response) {
const restaurant = form.querySelector('[name="restaurant"]').value,
guests = form.querySelector('[name="guests"]').value,
time = form.querySelector('[name="time"]').value.split(':').slice(0, 2).join(':'),
email = form.querySelector('[name="email"]').value,
stripe = form.querySelector('[data-stripe]');
const handler = window.StripeCheckout.configure({
key: response.StripePublishableKey,
name: `Dim t - ${restaurant}`,
description: `Booking for ${guests} guests at ${time}`,
amount: parseInt(response.PaymentAmount, 10),
email: email,
currency: 'GBP',
locale: 'auto',
token(stripeResponse) {
stripePaymentProcess(form, response, stripeResponse);
}
});
// This part fails, even though we're in a click event listener.
stripe.addEventListener('click', function (e) {
handler.open({
image: this.dataset.image,
zipCode: false
});
});
}
我在控制台中遇到的错误如下:
Stripe Checkout无法打开新窗口,可能是由于a 弹出窗口阻止程序。要为您的用户提供最佳体验,请按关注 导游在 https://stripe.com/docs/checkout#integration-more-runloop
如果我阅读指南,我看不出我做错了什么。
关于如何解决这个问题的任何想法?感谢。