如何使用PayPal按钮提交表单?

我有一个带有id =“ new_form”的表格。贝宝按钮就是这种形式。但是我不知道用户付款后如何提交表格。

PayPal按钮脚本:

<script>
    paypal.Buttons({
        createOrder: function(data,actions) {
            return actions.order.create({
                purchase_units: [{
                    amount: {
                        value: 1
                    }
                }],application_context: {
                    shipping_preference: 'NO_SHIPPING'
                }
            });
        },onApprove: function(data,actions) {
            return actions.order.capture().then(function(details) {
                alert('Transaction completed. Please,update the page.');
            return fetch('/paypal-transaction-complete',{
                    method: 'post',headers: {
                        'content-type': 'application/json'
                    },body: JSON.stringify({
                        orderID: data.orderID
                })
                });
            });
        }
    }).render('#new_form');
</script>

表格:

    <form autocomplete="off" class="new_form" id="new_form" action="" accept-charset="UTF-8" method="post">
        <input type="number" name="size" id="size" required>
        <input type="text" name="username" id="username" required>
        <input type="text" name="url" id="url">
    </form>
wjr349464977 回答:如何使用PayPal按钮提交表单?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3118695.html

大家都在问