Background: Purchasing power parity
npm install @lorensr/ppp
If we had a product that cost $50 USD in the United States, and we had a customer in India, then we would charge them 26.5% of the full cost—$13.27 USD:
const originalPrice = 50;const countryCode = 'IN';
132690310135currenciesCountry: code: 'INR' name: 'Indian rupee' symbol: '₹'countryCodeIsoAlpha3: 'IND'currencyMain:exchangeRate: 6739code: 'INR'name: 'Indian rupee'symbol: '₹'ppp: 17884pppConversionFactor: 026538062027006976
We recommend running this code on the server, as deciding pricing on the client is insecure. To determine the client's location, you can use their IP address and a geolocation API like ipstack, or if you use Cloudflare, you use their
CF_IPCOUNTRY HTTP header, which contains the client's country code. The latter method is less able to be tricked by proxies and VPNs.