【发布时间】:2021-12-28 14:33:37
【问题描述】:
我使用 PayPal Javascript SDK 创建了我的第一个立即购买按钮。我发现了如何添加“不发货”(这是针对数字商品的),但我不知道如何添加商品编号和描述。谁能给我一些指点?
<!-- Include the PayPal JavaScript SDK -->
<script src="https://www.paypal.com/sdk/js?client-id=CLIENT ID IS CORRECTLY ADDED¤cy=USD"></script>
<script>
paypal.Buttons({
// Sets up the transaction when a payment button is clicked
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '1'
},
}],
application_context: {
shipping_preference: "NO_SHIPPING",
}
});
},
// Finalize the transaction after payer approval
onApprove: function(data, actions) {
return actions.order.capture().then(function(orderData) {
// Successful capture! For dev/demo purposes:
// console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
// var transaction = orderData.purchase_units[0].payments.captures[0];
// alert('Transaction '+ transaction.status + ': ' + transaction.id + '\n\nSee console for all available details');
// When ready to go live, remove the alert and show a success message within this page. For example:
// var element = document.getElementById('paypal-button-container');
// element.innerHTML = '';
// element.innerHTML = '<h3>Thank you for your payment!</h3>';
actions.redirect('https://wwwwebsite.com/att_thanks.php?id=1640035591');
});
}
}).render('#paypal-button-container');
</script>
【问题讨论】:
标签: paypal