【问题标题】:how to check response of stripe transaction using simple form and js如何使用简单的表单和js检查条带交易的响应
【发布时间】: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


    【解决方案1】:

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

    https://stripe.com/docs/checkout

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

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

    希望对您有所帮助, 拉里

    PS 我在 Stripe 从事支持工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-25
      • 2020-11-05
      • 2014-02-18
      • 1970-01-01
      相关资源
      最近更新 更多