#Costia Le Narcissique UwU - API Error

1 messages · Page 1 of 1 (latest)

silver cipher
#

Hello! Do you have the body of the response from Stripe?

frail musk
#

i only have this :

          at IncomingMessage.<anonymous> (/var/www/html/back_end/API/node_modules/stripe/lib/StripeResource.js:170:39)
    at IncomingMessage.emit (node:events:539:35)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'StripeInvalidRequestError',
  rawType: 'invalid_request_error',
  code: undefined,
  param: undefined,
  detail: undefined,
  raw: {
    message: 'Invalid Stripe API version: [object Object]',
    type: 'invalid_request_error',
    headers: {
      server: 'nginx',
      date: 'Thu, 28 Jul 2022 00:23:38 GMT',
      'content-type': 'application/json',
      'content-length': '119',
      connection: 'close',
      'access-control-allow-credentials': 'true',
      'access-control-allow-methods': 'GET, POST, HEAD, OPTIONS, DELETE',
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required',
      'access-control-max-age': '300',
      'cache-control': 'no-cache, no-store',
      'stripe-version': '2020-08-27',
      'strict-transport-security': 'max-age=31556926; includeSubDomains; preload'
    },
    statusCode: 400,
    requestId: undefined
  },
  headers: {
    server: 'nginx',
    date: 'Thu, 28 Jul 2022 00:23:38 GMT',
    'content-type': 'application/json',
    'content-length': '119',
    connection: 'close',
    'access-control-allow-credentials': 'true',
    'access-control-allow-methods': 'GET, POST, HEAD, OPTIONS, DELETE',
    'access-control-allow-origin': '*',
    'access-control-expose-headers': 'Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required',
    'access-control-max-age': '300',
    'cache-control': 'no-cache, no-store',
    'stripe-version': '2020-08-27',
    'strict-transport-security': 'max-age=31556926; includeSubDomains; preload'
  },
  requestId: undefined,
  statusCode: 400
}
#

is thats ok ?

silver cipher
#

Ah, okay, I see the issue. For some reason the API version string you're passing in is getting converted into an object: Invalid Stripe API version: [object Object]

#

Can you see what that object is?

frail musk
#

idk how i can see this

silver cipher
#

Can you log it?

#

Like add a console.log line to log it out?

frail musk
#

i try to console.log but doesn't work may be because the error is not located in my code :

Error: Invalid Stripe API version: [object Object]
    at Constructor._Error (/var/www/html/back_end/API/node_modules/stripe/lib/Error.js:12:17)
    at Constructor (/var/www/html/back_end/API/node_modules/stripe/lib/utils.js:124:13)
    at new Constructor (/var/www/html/back_end/API/node_modules/stripe/lib/utils.js:124:13)
    at Function.StripeError.generate (/var/www/html/back_end/API/node_modules/stripe/lib/Error.js:57:12)
    at IncomingMessage.<anonymous> (/var/www/html/back_end/API/node_modules/stripe/lib/StripeResource.js:170:39)
    at IncomingMessage.emit (node:events:539:35)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
silver cipher
#

Can you share the code that's producing that error? The code making the specific API request?

frail musk
silver cipher
#

Hm. If you alter your Stripe initialization code to this does it make any difference? const stripe = require("stripe")(process.env.STRIPE_SECRET_TEST)

frail musk
#

i try

#

i don't have the version error but i have this error :

TypeError: stripe.accounts.createPerson is not a function

for this line :

const person = await stripe.accounts.createPerson( // si le compte est crée on y ajoute le token perso 
                                account.id,
                                {
                                    person_token: personResult.id,
                                }
                            );
next siren
#

That looks weird. what version value btw?

frail musk
#

'2020-08-27'

#

this one

next siren
#

So you have changed to the suggestion as my colleague suggested

const stripe = require("stripe")(process.env.STRIPE_SECRET_TEST)

then where do you see that 2020-08-27?

frail musk
#

i don't see it but is my api version

next siren
#

How do you know? I guess this isn't resulted in a request log in your Dashboard, right?

frail musk
#

hum ok i see so i don't know the version

next siren
#

No worries, and what version of Stripe Node you are using?

frail musk
#

on my paackage.json i have this version "stripe": "^6.0.0"

next siren
#

That looks super old. Latest version is 9.16.0

#

Can you update and use the latest one? Maybe 6.0.0 didn't have that createPerson API

frail musk
#

yep i will update it

#

AHhhhhhh niceee thanks a lot that's workinggggg

#

thanks for the help and i hope u will have a good night or a good day idk ur location 🙂

next siren
#

Awesome! Hope you have a great time using Stripe!