【问题标题】:Setting up custom stripe checkout using the default stripe form使用默认条带表单设置自定义条带结帐
【发布时间】:2023-03-18 05:50:01
【问题描述】:

所以,我一直在尝试为我获取自定义条纹结帐表单。我无法使用简单版本,因为我需要能够更改要支付的金额和每次购买的描述,其中标准条纹结帐表单仅设置了这两个无法更改的变量的值。但是,我不想使用自定义表单,我只想使用标准表单进行结帐。我的问题是尝试将此数据发送到服务器,我尝试了许多不同的方法,但我似乎无法让它工作。这是我的代码:

            <p><input id="buy-submit-button" class="button" type="submit" value="チェックアウト"></input></p>

            <script> 
            var handler = StripeCheckout.configure({
                key: 'pk_test_g6do5S237ekq10r65BnxO6S0',
                locale: 'auto',
                token: function(token) {

                        //don't know what needs to go here

                }
            });

                document.getElementById("buy-submit-button").addEventListener('click', function(e) {
                setTimeout(function(){ 
                    var totalCost = 0; 
                    var totalCartLoad = ""; 
                    totalCost = localStorage.getItem('totalCartPrice'); 
                    totalCartLoad = localStorage.getItem('whatsInCart'); 
                    totalCartLoad = totalCartLoad.replace('undefined',''); 

                    // Open Checkout with further options:
                    handler.open({
                        name: "チェックアウト",
                        description: totalCartLoad,
                        shippingAddress: true,
                        billingAddress: true,
                        zipCode: true,
                        allowRememberMe: true,
                        currency: 'JPY',
                        amount: totalCost

                    });
                    e.preventDefault();

                }, 500);

            });

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

所以我将再次重申这一点。我想要做的就是使用当您按下按钮时弹出的条纹默认表单然后将其提交到服务器,这样做的正确方法是什么?

【问题讨论】:

标签: javascript html stripe-payments


【解决方案1】:

我能够使用此处提供的另一个问题的答案来解决这个问题:make-stripe-data-amount-use-a-dynamic-with-a-variable

【讨论】:

    猜你喜欢
    • 2015-04-11
    • 1970-01-01
    • 1970-01-01
    • 2014-01-31
    • 2017-10-09
    • 2016-03-23
    • 2015-10-02
    • 2019-01-18
    • 2017-12-31
    相关资源
    最近更新 更多