【发布时间】:2015-01-17 23:22:51
【问题描述】:
我正在尝试设置stripe 结帐,我可以启动付款表单并正常运行,但是我需要在付款成功后将用户重定向到另一个页面。这是我用来显示和处理表单的 javascript,但我需要知道如何以及在哪里添加重定向代码?
<script src="https://checkout.stripe.com/checkout.js"></script>
<button id="customButton" style="border: none" ><img src="/orange_pay_now.png" style="width: 265px;height: 66px;"></button>
<script>
var handler = StripeCheckout.configure({
key: 'pk_test_..............',
image: '/orange_pay_now.png',
token: function(token) {
// Use the token to create the charge with a server-side script.
// You can access the token ID with `token.id`
}
});
document.getElementById('customButton').addEventListener('click', function(e) {
// Open Checkout with further options
handler.open({
name: 'Name of Product',
description: 'description goes here',
amount: 800,
currency: 'GBP'
});
e.preventDefault();
});
// Close Checkout on page navigation
window.addEventListener('popstate', function() {
handler.close();
});
</script>
我将非常感谢任何帮助。
【问题讨论】:
标签: javascript php payment-gateway stripe-payments payment-processing