我需要在服务器集成中使用 PayPal createorder 函数将我的金额从应用程序传递到PayPal. 我怎样才能


<script>
// Render the PayPal button into #paypal-button-container
paypal.Buttons({
// Set up the transaction
createOrder: function(data, actions) {
return fetch('payPalPayment.html', {
method: 'post',
body: JSON.stringify( {
"purchase_units": [
{
"amount": {
"currency_code": "USD",
"value": 100.00
}
}]
})
}).then(function(res) {
return res.json();
}).then(function(data) {
return data.paypalToken;
});
},
// Finalize the transaction
onApprove: function(data, actions) {
return fetch('paypalGetExpressCheckout.html', {
method: 'post'
}).then(function(res) {
return res.json();
}).then(function(details) {
// Show a success message to the buyer
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
}

}).render('#paypal-button-container');
</script>
this above code does not show the amount when I login

我遇到了类似的问题,对我有用的是我使用了createOrder的基本集成,因为我需要的驻留在客户端中。

https://developer.paypal.com/docs/checkout/integrate/#4-set-up-the-transaction

paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
currency_code: "USD",
value: '100.00'
}
}]
});
},
onApprove: function(data, actions) {
return fetch('paypalGetExpressCheckout.html', {
method: 'post'
}).then(function(res) {
return res.json();
}).then(function(details) {
// Show a success message to the buyer
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
}
}).render('#paypal-button-container');

最新更新