#_kevinx

1 messages · Page 1 of 1 (latest)

wet nebulaBOT
#

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
toxic cape
#

what issue

topaz estuary
#

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

toxic cape
#

Old one should work

#

Please share the checkout session creation request

topaz estuary
#

req_dovoKIpLydGeKs

#

I just created this one

toxic cape
#

You're still using the old api version

#

Says it was explicitly set to that old version in the code

wet nebulaBOT
topaz estuary
#

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

exotic marlin
#

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', });

topaz estuary
#

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?

exotic marlin
#

You shouldn't, no

#

Hmmm

topaz estuary
#

yes, I just double checked all require("stripe"), only secret key is involved

exotic marlin
topaz estuary
#

no, nowhere apiVersion is defined in the code base

exotic marlin
#

Alright, let me grab another team member to see if they have any idea what's causing this

topaz estuary
#

ok, thanks

#

to confirm how to upgrade API version, here is what we did

  1. upgrade the API version on dashboard to latest
  2. reinstall NPM packages for stripe and @stripe/stripe-js
  3. rebuild and redeploy
#

these are according to the doc, did we miss anything?

exotic marlin
#

Can you copy/paste the block of code you use to make the request to create a Checkout Session?

topaz estuary
#

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");
  }
}
exotic marlin
topaz estuary
#

how and where did you figure it out?

exotic marlin
topaz estuary
#

Stripe/v1 NodeBindings/12.18.0?

#

can you please advise how to upgrade this one?

#

upgrade node version?

exotic marlin
topaz estuary
#

the highest version we can update to is "stripe": "^12.18.0",

#

with npm install stripe and npm update

exotic marlin
topaz estuary
#

what might cause this blockage ...

exotic marlin
#

I'm not sure. I don't really have visibility beyond that. What does your package.json look like?

topaz estuary
#

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

exotic marlin
#

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

topaz estuary
#

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?

exotic marlin
#

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.

topaz estuary
#

well, I think the question is does stripe need these packages

exotic marlin
#

And you're definitely running all your NPM commands from within the directory that contains package.json, yes?

topaz estuary
#

yes

#

it says the version is pinned to 2022-11-15

#

which is the version I'm stuck at

exotic marlin
#

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.

topaz estuary
#

ok, thank you very much