#mike_error

1 messages ยท Page 1 of 1 (latest)

snow fulcrumBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1298087220397342813

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

cunning stirrup
#

hello! can you log process.env.STRIPE_SECRET_KEY just before const stripeCustomer = await stripe.customers.create to see what is output?

#

don't paste the secret key here, we just want to be sure that there actually is a correct value in process.env.STRIPE_SECRET_KEY

vapid agate
#

Yea i get the key

#

I was thinking about that to, But I do get the key and it does create the account on stripe. It just spits that error in the terminal.

cunning stirrup
#

i guess the other point to check is if that's actually the correct place that the error is originating from? what if you hardcode the secret key instead of reading from the env variable, does the error message go away?

vapid agate
#

The error message does not go away

#

would there be another way that you suggest to create the users account? Or would this just be a stripe issue?

#

I do have it setup like
const stripe = require("stripe")(process.env.STRIPE_SECRET_KEY);

cunning stirrup
#

this definitely isn't a stripe issue, i tried your code and it works fine for me. I'm wondering if the error is actually occurring at the snippet of code that you shared.

I'm a bit confused as to what you're trying to do though, if you're using the same secret key as when you initialize stripe, why are you also defining the apiKey when creating a Customer?

vapid agate
#

If I dont add apiKey when trying to create the customer, it just wont create the customer with the error..

cunning stirrup
#

if i understand correctly, do you mean the customer won't be created and it'll throw that same error?

vapid agate
#

correct, if I add the apiKey it will create the customer and throw the error. If I dont add it, it will just throw the error without creating the customer

cunning stirrup
#

then the issue is elsewhere and not at that section of code. Can you share the full stack trace of that error?

#

slight correction, remove the below section and share the full stack trace of that error

 {
          apiKey: process.env.STRIPE_SECRET_KEY, 
        }
vapid agate
cunning stirrup
#

Can you try to replace everywhere where you need the secret key with a hardcoded stripe secret key? If that works, that means somewhere, your key isn't being loaded as you expect or possibly doesn't exist

#

if that still doesn't work, then share with me an example (remember to omit your secret key) that replicates the issue using code like JSFiddle, CodeSandbox, or Glitch. Without being able to see the full code, it's really difficult to troubleshoot

vapid agate
#

I do have a question. if it isnt being loaded somewhere why would it still create an account and show up in the logs as a 200 in stripe?

#

I think I found the issue. I hard coded into const stripe =require("stripe")( "the key"); and it worked

cunning stirrup
#

that's because you explicitly defined the apiKey in the individual request

#

it sounds like process.env.STRIPE_SECRET_KEY isn't loaded when you initialize Stripe then. you can try logging process.env.STRIPE_SECRET_KEY prior to initializing stripe and see what you get