繁体   English   中英

如何使用简单的表单和js检查条纹事务的响应

[英]how to check response of stripe transaction using simple form and js

我正在尝试设置条纹结帐,并且可以启动付款表格并正常运行,但是,只有在付款成功后,我才需要将用户重定向到另一页。 这是我用来显示表单和处理表单的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>

我将非常感谢您的协助。

结帐应在该页面上另一种表单的上下文中创建(请参见简单集成):

https://stripe.com/docs/checkout

Checkout完成操作后,它将自动将该其他表单提交给您使用的任何action属性。 然后,您可以使用服务器端代码来处理实际的收费请求。

如果您使用的是自定义集成,则需要向令牌功能添加代码以提交表单或重定向浏览器或其他功能。

希望能有所帮助,拉里

PS我在Stripe负责支持。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM