#Constant-prices
1 messages ยท Page 1 of 1 (latest)
It seems like stripe does not get initialised
The secret key should be something like sk_xxx which can be obtained from https://dashboard.stripe.com/test/apikeys
Yes it is, I just removed it from the question.
Double checked to make sure it's the right key and still same issue.
If you use a single price retrieval, does it work? https://stripe.com/docs/api/prices/retrieve
Nope got this error: ย Cannot read properties of undefined (reading 'retrieve')
If you log with console.log(stripe), does it return undefined?
No it returns the whole stripe object. Really weird!
Are you using TypeScript?
Yes I am
Can you try following?
import Stripe from 'stripe';
const stripe = new Stripe('sk_test_...', {
apiVersion: '2022-08-01',
});
const prices = await stripe.prices.list({limit: 3,});
TypeScript initialisation is different: https://github.com/stripe/stripe-node#usage-with-typescript
I'm getting this error: Failed to load function definition from source: FirebaseError: Failed to load function definition from source: Failed to generate manifest from function source: TypeError: stripe_1.default is not a constructor
It's really weird because all my other stripe functions are working
That's really strange
Could you compare those that are working with this?
Is there any difference?
Everything is the same. So I just ran:
const customerList = await stripe.customers.list({limit: 1});
And that worked!
So it only doesn't work on prices?
Yes
Which version of Stripe Node do you use?
v10
That's weird, in my root folder's package.json I have v10, but in my functions folder I have v6.
I've update v6 to v10, but still getting the same error
Got IT!!
Amazing! What did you do?
Sorry run the update again restarted everything and is now working! Thanks for your help!
No problem! Happy to help. Glad to hear that it works now ๐
I should probably check for breaking changes from v6 to v10 right?๐
Yes, you can refer to the changlog here: https://github.com/stripe/stripe-node/blob/master/CHANGELOG.md
Thanks! Sorry one last question, the prices only seem to return one currency, the location I'm currently at. How would get all currencies for my prices?
It should return prices with all currencies
Could you give an example?
Constant-prices
So my product has a price in AUD and GBP, but the prices that are returned only gives AUD prices.
Let me check
To retrieve other currency options, expanding data.currency_options should include other currencies. For example,
const prices = stripe.prices.list({
limit: 3,
product: 'prod_xxx',
expand: ['data.currency_options'],
});
Other currency options are under the default price of a product
- Currency options: https://stripe.com/docs/api/prices/object#price_object-currency_options
- Expanding response: https://stripe.com/docs/api/expanding_objects
Ah awesome thank you!
No problem ๐