'How to accept payment in requested currency in PayPal through integration via Javascript?
Currently, I am able to accept payment only in one currency with this code
<script src="https://www.paypal.com/sdk/js?client-id=Your Client ID¤cy=AUD"></script> -->
If make USD over there like this..
<script src="https://www.paypal.com/sdk/js?client-id=Your Client ID¤cy=USD"></script> -->
I can accept the payment in USD on my website
if will do GBP
<script src="https://www.paypal.com/sdk/js?client-id=Your Client ID¤cy=GBP"></script> -->
I can accept the payment in GBP on my website
But when I add multiple currencies like this...
<script src="https://www.paypal.com/sdk/js?client-id=Your Client ID¤cy=AUD,USD, AUD,NZD,GBP"></script> -->
The button doesn't work
Solution 1:[1]
The currency determines which buttons are eligible, so an SDK load is only usable with 1 currency at a time.
To support multiple currencies, you must reload the SDK on the page and re-render any buttons afterward (and createOrder, when called, must specify amounts in the single currency that matches).
A new alternative you can try is to load the SDK multiple times on the page using the data-namespace parameter, to specify a name other than the default paypal.
An example....
<h3>USD buttons...</h3>
<div id="paypal-button-container-1" />
<script src="https://www.paypal.com/sdk/js?client-id=test¤cy=USD" data-namespace="paypalUSD"></script>
<script>
paypalUSD.Buttons({
//...
}).render('#paypal-button-container-1');
</script>
<hr />
<h3>AUD buttons...</h3>
<div id="paypal-button-container-2" />
<script src="https://www.paypal.com/sdk/js?client-id=test¤cy=AUD" data-namespace="paypalAUD"></script>
<script>
paypalAUD.Buttons({
//...
}).render('#paypal-button-container-2');
</script>
</script>
In general, unless you have a specific business need to receive multiple currencies in your account, it's simpler to just use an international currency like USD or EUR and let PayPal show the conversion at payment time if the buyer is going to use a funding source in a differrent currency like GBP, NZD, etc
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Preston PHX |
