我有一个带有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>