Stripe Payment Intent - how to tell customer's country (and currency)?

Viewed 30

I'm building a custom Stripe integration based on Stripe Payment Element JS library. In order to launch the Payment Element, I'm creating a Payment Intent on my server, using the Stripe PaymentIntents REST API. For this API, I need to specify the amount and currency in the input parameters.

The problem is, how do I choose the right currency for the PaymentIntent API, that would correspond to the customer's country (IP address)?

Both Stripe Prebuilt Checkout and the Payment Element JS UI detect and display the customer's country in their own UI, but there seems no way to extract it. Neither there is a Stripe backend API for that.

I just don't get it, how this whole thing is supposed to work, because I believe knowing the country (and therefore the currency) is essential for creating any payment intent. Am I missing something, how do you guys do it?

1 Answers

Stripe's "JS UI" doesn't determine currency and neither does Checkout in most cases. That's why there's no API for it or feature.

Usually, you, as a business, know what currency you sell your product in. For example if you navigate on the US version of Amazon, prices are in USD and in France they are in EUR.

If you want to support multiple currencies on your website, you often have a default currency and then customers can change it in their settings. I see this on many websites like airbnb and such in the bottom right corner.

The way to determine the right default depends a lot on your preference and business model. Some websites will assume a default currency always of USD for example. Others will try to guess based on your IP address or your browser's locale. This is something Stripe doesn't do for you, you have to build this yourself and then create the underlying PaymentIntent in the currency of your choice. You could also just ask your customer upfront too.

It is true that with multi-currency Prices, Checkout does support detecting the currency on load. The idea is that you add a Price with currency options in USD, EUR and GBP and then on Checkout page load Stripe can determine the customer's most likely currency based on their IP address for example and "pin" that Checkout Session to the right one. The customer can't control or change it though.

Related