Javascript SDK currency code error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I try to pass to my create order request a EUR currency code and I get this Javascript error:
Expected USD got EUR.Please make sure you are passing EUR to the SDK. Could anyone help me with this issue?
Thank you.
- Labels:
-
Payments REST APIs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try passing currency in your script tag like this
Might be it will help
<script src="https://paypal.com/sdk/js?client-id=YOUR_CLIENT_ID¤cy=EUR"></script>
and make sure you pass currency_code whenever you use amount object
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
m facing the same issue.
But i want a dynamic currency to be accepted here.
As m accepting payments in multiple currencies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Then you can load dynamically the paypal script depending on the currency needed, and inject it on your page. Example :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your answer.
But M accepting amount and currency from a form.
So how can I call SDK dynamically based on the user selects the currency
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- "System error. Please try again later" when connecting to paypal sandbox account with my android app in Sandbox Environment
- Are there any restrictions to charge using only html, vanilla javascript and php with rest api? in REST APIs
- Getting 400 Bad Request error when rendering PayPal Button using JS SDK in SDKs
- PayPal Redirection Issue After Successful Payment in Photobooth Integration in Sandbox Environment
- paypal.ApplePay().confirmOrder() returns applepay_payment_error. in SDKs