Stripe Checkout自定义集成。没有回呼网址?

时间:2018-12-03 22:42:32

标签: javascript

在Stripe Checkout的简单版本中,有一个表单操作,我可以在其中采取令牌并提交以验证付款:

<form action="your-server-side-code" method="POST">

,但是在自定义版本中没有任何操作。如果我提交该表格,则该表格将消失并且什么也不会发生。这是代码:

<script src="https://checkout.stripe.com/checkout.js"></script>

<button id="customButton">Purchase</button>

<script>
    var handler = StripeCheckout.configure({
        key: 'pk_test_t0reECQxhkdQGNaoI8WwEjSl',
        image: 'https://stripe.com/img/documentation/checkout/marketplace.png',
        locale: 'auto',
        token: function(token) {
            // You can access the token ID with `token.id`.
            // Get the token ID to your server-side code for use.
        }
    });

    document.getElementById('customButton').addEventListener('click', function(e) {
        // Open Checkout with further options:
        handler.open({
            name: 'Ytfam',
            description: '2 widgets',
            amount: 2000
        });
        e.preventDefault();
    });

    // Close Checkout on page navigation:
    window.addEventListener('popstate', function() {
        handler.close();
    });
</script>

如何提交付款?

0 个答案:

没有答案