向Stripe Custom Checkout添加表单操作

问题描述 投票:1回答:1

我有下面的脚本,我只是想弄清楚如何将表单发送到服务器上的文件。我正在使用的表单操作不起作用。条带操作完成后,当前页面将刷新,而不是转到checkout_payment.php。

<form action="checkout_payment.php" method="POST">
    <script src="https://checkout.stripe.com/checkout.js"></script>
        <button class="btn btn-primary" id="customButton">Buy Now</button>
        <script type="text/javascript">
        $(function(){
            $("#customButton").click(function(){
                if(isInt($("#quantity").val())){
                    var token = function(res){
                        var $input = $('<input type=hidden name=stripeToken />').val(res.id);
                        $('form').append($input).submit();
                    };
                    StripeCheckout.open({
                        key: '<?php echo $stripe["publishable"];?>',
                        image: 'img/sgc.png',
                        amount: total,
                        currency: 'usd',
                        name: 'store',
                        description: '<?php echo ucfirst($product_name); ?>',
                        address: '',
                        email: '<?php echo $useremail;?>',
                        panelLabel:  'Checkout',
                        token: token
                      });
                }
                return false;
            });
        });
    </script>
</form> 

提前感谢!

php stripe-payments
1个回答
0
投票

请在按钮代码中输入按钮类型。如下所示。

<button class="btn btn-primary" type="submit" id="customButton">Buy Now</button>

之后将其转到表单操作页面。

© www.soinside.com 2019 - 2024. All rights reserved.