It took me forever to find this solution so I thought I should share it with you. Pass the currency in the same place in your JavaScript code that you put your client-id. This is my code which works for dynamically passing currency code. function wtkPayPal(fncPayPalItem, fncAmt, fncPage, fncCurCode='USD') {
window.paypalLoadScript({
"client-id": 'your-client-id-here',
"currency": fncCurCode
}).then((paypal) => {
paypal.Buttons({
createOrder: function(data, actions) {
wtkDebugLog('wtkPayPal createOrder');
wtkDebugLog(fncPayPalItem);
return actions.order.create(fncPayPalItem);
},
onError: function (err) {
wtkDebugLog('Error during purchase:');
wtkDebugLog(err);
M.toast({html: 'Error during purchase - please contact tech support', classes: 'rounded red'});
},
onCancel: function (data) {
// Show a cancel page, or return to cart
wtkDebugLog('Canceled order!');
M.toast({html: 'Your order has been canceled', classes: 'rounded orange'});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
// your custom code here for handling success
}
}).render('#paypal-buttons');
});
} // wtkPayPal
... View more