Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Retrieve all products prices with multiple currency options

I have two products A and B with two prices each (1 monthly and 3 months cycle).
Every price has two currency options (USD and EUR).

I’m able to list all the prices using :

const prices = await stripe.prices.list({});

But it doesn’t return the currency options for each product prices. I only get the price in the default currency (USD).
How can retrieve prices with all the currencies ?
I tried this :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

const businessOwnerProduct = await stripe.prices.retrieve(
        'price_xxxxxxxxxxxxxx',
        {expand: ['currency_options']}
    );

But it returns the price per product. Thus i need multiple requests (4).

Is there a way to retrieve a list of products + prices (in multiple currencies) ?

>Solution :

The currency_options property is not returned by default. This is what Stripe calls an "includable" property. The idea is that it’s costly to render as you could have many currencies and so you have to explicitly ask for it when you retrieve it using their Expand feature.

This is what your second example does where you expand it when calling the Retrieve Price API.

The Expand feature also works during a list call as documented here. So your code should look like this:

const prices = await stripe.prices.list({
expand: [‘data.currency_options’],
});

Note the data. prefix as the API return a List which has the data array with 10 Prices by default

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading