#_kevinx
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- _kevinx, 45 minutes ago, 27 messages
what issue
hi there, I upgraded the API on dashboard, as well as the stripe packages in my code, but the promo code still not working,
do I need to build a new coupon after API upgrade?
does the old coupon still work
You're still using the old api version
Says it was explicitly set to that old version in the code
there is nowhere in the code we setup stripe versions
on the dashboard, it says the default version is the latest
which I just upgraded this morning
I also reinstalled stripe packages in NPM
and redeployed
Hi there 👋 taking over, as my colleague needs to step away
It does look like the API version was explicitly set (e.g. the request isn't using the default global API version that's set on your account). Since you're using Node, you might have a line that looks something like this somewhere:
const stripe = require('stripe')('sk_abc123', { apiVersion: '2023-10-16', });
I just searched the code base, no there is no apiVersion defined
require("stripe") only uses secret key
do we need to use a new secret key after API upgrade?
yes, I just double checked all require("stripe"), only secret key is involved
You don't see the string apiVersion anywhere? It doesn't necessarily have to be in the stripe require code. It could be in the block that actually sends the API request (see here for an example: https://stripe.com/docs/libraries/set-version#setting-the-api-version)
no, nowhere apiVersion is defined in the code base
Alright, let me grab another team member to see if they have any idea what's causing this
ok, thanks
to confirm how to upgrade API version, here is what we did
- upgrade the API version on dashboard to latest
- reinstall NPM packages for stripe and @stripe/stripe-js
- rebuild and redeploy
these are according to the doc, did we miss anything?
Can you copy/paste the block of code you use to make the request to create a Checkout Session?
sure
const stripe = require("stripe")(process.env.STRIPE_SECRET_KEY);
export default async function handler(req, res) {
const session = await getServerSession(req, res, authOptions);
const email = req.body.email;
const currentUserID = session?.user?.id;
// const stripecusid = session?.user?.stripecusid;
const requestHeader = "https://www.zykles.com";
if (req.method === "POST") {
try {
const session = await stripe.checkout.sessions.create({
mode: "payment",
client_reference_id: currentUserID,
allow_promotion_codes: true,
line_items: [
{
price: "price_1Ni0t",
quantity: 1,
},
],
payment_intent_data: {
setup_future_usage: "off_session",
},
success_url: `${requestHeader}/rentout?success=true&session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${requestHeader}/rentout?canceled=true`,
metadata: {
internal_id: currentUserID,
email: email,
},
});
// res.redirect(303, session.url); // this is not working blocked by CORS, need full form submission
res.status(200).json({ url: session.url });
} catch (err) {
res.status(err.statusCode || 500).json(err.message);
}
} else {
res.setHeader("Allow", "POST");
res.status(405).end("Method Not Allowed");
}
}
So it looks like you're not using the latest Stripe SDK version. You're using v12: https://github.com/stripe/stripe-node/blob/master/CHANGELOG.md#1200---2023-04-06
how and where did you figure it out?
You can see that here under Source: https://dashboard.stripe.com/logs/iar_dovoKIpLydGeKs
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Stripe/v1 NodeBindings/12.18.0?
can you please advise how to upgrade this one?
upgrade node version?
You need to run npm update for your Stripe packages: https://docs.npmjs.com/cli/v10/commands/npm-update
Make sure changes are reflected in your package.json file as well
the highest version we can update to is "stripe": "^12.18.0",
with npm install stripe and npm update
There might be some dependency issues, because the latest version is v14: https://github.com/stripe/stripe-node/blob/master/CHANGELOG.md#14130---2024-01-18
what might cause this blockage ...
I'm not sure. I don't really have visibility beyond that. What does your package.json look like?
I upgraded Node to the last version, and just can't upgrade stripe to the lastest version
without specify version
the same thing for @stripe/stripe-js
can't upgrade it to latest either
let me restart my machine
and see how it goes , brb
Can you delete any lock files you have for package.josn and manually modify the version in your package.json file to the latest one? Once you do that you should be able to run npm install again and it should upgrade for you
would it break things?
last time I did that broke a lot things lol
I tried, doesn't work
"node_modules/stripe": {
"version": "12.18.0",
"resolved": "https://registry.npmjs.org/stripe/-/stripe-12.18.0.tgz",
"integrity": "sha512-cYjgBM2SY/dTm8Lr6eMyyONW5WH8FevSRIGAVtXEmBkUXF1fsqe7QvvRgQSGSJZmjDacegGg==",
"dependencies": {
"@types/node": ">=8.1.0",
"qs": "^6.11.0"
},
"engines": {
"node": ">=12.*"
}
},
in the lock file, I noticed it depends on qs and types/node, do you know these package?
I don't. You'll need to look at those dependencies and decide if they're needed or not, as it sounds like they're stopping you from upgrading.
well, I think the question is does stripe need these packages
And you're definitely running all your NPM commands from within the directory that contains package.json, yes?
yes
I just read this doc on github
https://github.com/stripe/stripe-node/wiki/Migration-guide-for-v12
it says the version is pinned to 2022-11-15
which is the version I'm stuck at
Right, so your options are:
(1) explicitly pass the API version in your code as mentioned in that guide, or
(2) debug the dependency issues manually and selectively upgrade only the relevant packages (less prone to error but more work), or
(3) try something a bit more forceful like what's mentioned in this solution: https://stackoverflow.com/a/16074029/18637382 (more prone to error, but potentially less work)
Much of this goes beyond what we can help with though (as it gets into version management with NPM), and we're closing Discord for the day, so you'll need to explore those options on your own from here.
ok, thank you very much