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?