我试图为PayPal API设置货币,但我无法这样做。当您单击PayPal按钮时,它将显示以美元为单位的总金额( cart图标旁边)。在“支付”项下,它显示转换为CAD的金额,而这不是我想要的。我希望以createOrder设置的金额以我设置的货币表示。
<script src="https://www.paypal.com/sdk/js?currency=CAD&client-id="></script>
<script>
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
intent: "CAPTURE",
purchase_units: [{
amount: {
value: "150"
}
}]
});
},
onError: function (err) {
alert(err);
}
}).render('#paypal-button-container');
</script>我已经尝试了currency_code: "CAD"的数量,但我得到了:
Error: Unexpected currency: CAD passed to order.create. Please ensure you are passing /sdk/js?currency=CAD in the PayPal script tag.发布于 2020-08-04 16:57:52
不知道哪里出错了,因为如果代码完成了,代码就可以工作了。以下是一个有用的例子:
<script src="https://www.paypal.com/sdk/js?currency=CAD&client-id=sb"></script>
<script>
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
intent: "CAPTURE",
purchase_units: [{
amount: {
value: "150",
currency_code: "CAD"
}
}]
});
},
onError: function (err) {
alert(err);
}
}).render('body');
</script>https://stackoverflow.com/questions/63250791
复制相似问题