#vm1172
1 messages · Page 1 of 1 (latest)
"stripe": "^11.14.0",
Can you find the errored request in Dashboard, or is it errored on client?
I also have the STRIPE_SECRET_KEY inside the .env files (since all other calls are being made properly
sure one second
There is no error request in my logs here - https://dashboard.stripe.com/logs?method[0]=post&method[1]=delete&direction[0]=connect_in&direction[1]=self
request id = req_jN2N84YttjLVAm
tax API is never being hit, it just shows up as undefined property on the stripe singleton
Hmm that's a normal PaymentIntent creation and it succeeded
Can you share your code?
public async calculateTax(amount: number, gentlyId: string, postal_code: string): Promise<number> {
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, { apiVersion: '2022-11-15' });
console.log({ stripe });
const paymentIntent = await this.getPaymentIntent('pi_3NxtVcCa1hzW9vNX1aCxEdit');
console.log({ paymentIntent });
const params: CalculationCreateParams = {
currency: CURRENCY,
line_items: [
{
amount,
reference: gentlyId,
},
],
customer_details: {
address: {
postal_code,
country: ALLOWED_COUNTRY,
},
address_source: 'shipping',
},
expand: ['line_items.data.tax_breakdown'],
};
console.log({ params });
const calculation = await stripe.tax.calculations.create(params);
return calculation.tax_breakdown[0].amount;
}
while this works
public async getPaymentIntent(paymentIntentId: string): Promise<Stripe.PaymentIntent> {
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, { apiVersion: '2022-11-15' });
const paymentIntent = await stripe.paymentIntents.retrieve(paymentIntentId);
console.log('paymentIntent: ', paymentIntent);
return paymentIntent;
}
I can try swapping to the latest version but that might require a migration effort and fixing breaking changes
what i dont understand is why it would working in our staging environment and not in the production server
You can try passing the apiVersion per quest, https://stripe.com/docs/libraries/set-version#versioning-basics
Let's try to see if that's really the version which is causing the error
okay makes sense ill upgrade for my calculateTax endpoint only
do you mean just do this?
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, { apiVersion: '2023-08-16' });
No, on the call const calculation = await stripe.tax.calculations.create(params);
ah like this
const calculation = await stripe.tax.calculations.create(
params,
{
stripe_version: '2023-08-16',
}
);
const calculation = await stripe.tax.calculations.create(params, { apiVersion: '2023-08-16' });
Yep yep
got it thank you, trying it out now
still getting the same error
error: TypeError: Cannot read property 'calculations' of undefined
0|server | at CheckoutSessionService.calculateTax (/home/ubuntu/server/src/services/checkoutsession.service.ts:153:42)
Can you upgrade your Node SDK to latest version?
Yeah got it. But just to be sure, which SDK version is your staging server, vs your production server?
both running this npm version of stripe
and we merge from staging into production so its parity ->
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, { apiVersion: '2022-11-15' });
Uhmmm I see...
Only from 12.14.0 you have Tax calculations
I think your Staging may have something else made it working
those just seem like type changes, and not actual implementation of the stripe.tax.calculations
but let me update to the latest version and get back to you
ill need some time upgrading the packages and running some tests, do you mind keeping this thread open?
Sure, but my colleague may take over later
hey, so we cannot upgrade Stripes SDK right now since it will require a lot of changes. Based on the Stripe Change log, Tax Calculations API was added before the version we're currently using (11.14.0)
With no change to our current set up, I could still hit the tax calculations endpoint properly
Also the types wouldn't be available for tax.calculations.create if it was not available in the version i'm on
Hi, could you clarify where do you see this?
Based on the Stripe Change log, Tax Calculations API was added before the version we're currently using (11.14.0)
Hmm okie, could you double (triple!) check your Node version on Production server?
hey, we're just going ahead and upgrading. if there are any issues fortunately we can roll back
Yeah I think the endpoint is available from 12.0.0 https://github.com/stripe/stripe-node/blob/v12.0.0/src/resources.ts#L7