【发布时间】:2018-08-14 18:40:53
【问题描述】:
我的 ASP.NET 网络表单网页上有快速结帐按钮,但似乎无法弄清楚单击按钮时如何将总变量(存储在页面上的标签中)传递给 PayPal 弹出窗口。
我知道已经有人问过这个问题 (How Can pass order Total to (amount: { total: '0.01', currency: 'USD' } ) in paypal),但答案对我来说意义不大,并且没有像初学者程序员那样详细说明。
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<script>
paypal.Button.render({
env: 'sandbox', // sandbox | production
style: {
label: 'pay',
size: 'small', // small | medium | large | responsive
shape: 'rect', // pill | rect
color: 'gold' // gold | blue | silver | black
},
// PayPal Client IDs - replace with your own
// Create a PayPal app: https://developer.paypal.com/developer/applications/create
client: {
sandbox: 'AWDwdGr-KZK4jJi0WBUZmFowgG6oCtLpNDxtXuiOfAT1UdNUYeSlvoXYkrKW7SRdcYqqjHCo7IcYPmJf',
production: 'Production ClientID'
},
// payment() is called when the button is clicked
payment: function(data, actions) {
// Make a call to the REST api to create the payment
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '0.01' , currency: 'EUR' }
}
]
}
});
},
// onAuthorize() is called when the buyer approves the payment
onAuthorize: function(data, actions) {
// Make a call to the REST api to execute the payment
return actions.payment.execute().then(function() {
window.alert('Payment Complete!');
});
}
}, '#paypal-button-container');
</script>
有人能给我一些指导吗?
【问题讨论】:
标签: javascript asp.net paypal webforms paypal-sandbox