我一直在尝试通过订阅选项实现PayPal结帐;我可以执行一次一次性交易,但不知道如何处理定期订阅。
<script>
paypal.Button.render({
// Configure environment
env: '<?php echo $paypal->paypalEnv; ?>',
client: {
sandbox: '<?php echo $paypal->paypalClientID; ?>',
production: '<?php echo $paypal->paypalClientID; ?>'
},
// Customize button (optional)
locale: 'en_US',
style: {
size: 'small',
color: 'gold',
shape: 'pill',
},
// Set up a payment
payment: function (data, actions) {
return actions.payment.create({
transactions: [{
amount: {
total: '1.00',
currency: 'USD'
}
}]
});
},
// Execute the payment
onAuthorize: function (data, actions) {
return actions.payment.execute()
.then(function () {
// Show a confirmation message to the buyer
//window.alert('Thank you for your purchase!');
// Redirect to the payment process page
window.location = "process.php?paymentID="+data.paymentID+"&token="+data.paymentToken+"&payerID="+data.payerID+"&pid=<?php echo $productData['id']; ?>";
});
}
}, '#paypal-button');
</script>
通过定期付款快速结帐。