#lunar_api

1 messages ยท Page 1 of 1 (latest)

zenith pikeBOT
coarse hatchBOT
#

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.

zenith pikeBOT
#

๐Ÿ‘‹ 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/1272955681800192102

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

frosty flower
#

basically on prod theres no issues with the exact same secret and public

#

but when i use it on local, it just errors and wont let me do anything, i tried rolling the keys etc wont work.

barren wraith
#

Hello! To clarify, you're using the exact same key on your server and locally, and when you use it locally you get that expired error?

frosty flower
#

yep

#

i copied the exact env from the prod to local and it errors

#

on my local

#

but on prod, it works just fine

barren wraith
#

Hm. And you're certain there's no leading or trailing space or anything like that?

frosty flower
#

i even copied the whole .env

barren wraith
#

What IP address are you making the failed requests from?

frosty flower
barren wraith
#

Can you give me that IP?

frosty flower
barren wraith
frosty flower
#

its my home ip hahah ๐Ÿ˜…

barren wraith
#

If you're worried about sharing your IP it might be best to write in to support. ๐Ÿ™‚

#

You're certain this same key is working in production?

#

Can you give me the request ID of a recent successful request with this key?

barren wraith
#

That request is using a publishable key (starts with pk_live_), not the secret key you mentioned.

#

Can you share a recent request that succeeded which used the sk_live_*********************************************************************************************WfA4RK key?

frosty flower
barren wraith
#

Yes.

#

That seems like a different key?

#

Right, that's different. The key mentioned in the error message ends with a different set of characters: sk_live_*********************************************************************************************WfA4RK

#

zkzI is different from A4RK.

#

So it's a different key.

frosty flower
#

check this req_CCzEpMXEsrjz2n

barren wraith
#

That's a Dashboard request, it's not coming from your code and didn't use any of those keys.

frosty flower
#

oh thats dashboard req

#

alr sec

#

req_vs23qees3o51hf

#

i cant see much info of that log

barren wraith
#

That request was made with the secret key that ends in zkzI, not the one from the error message.

frosty flower
#

where do i see which secret key was used?

barren wraith
#

Oh, that's right, the Dashboard doesn't show which key.

#

In any case, I'm pretty sure the key ending in WfA4RK is expired, and the error message is accurate.

#

The successful request you're seeing are all using a different key entirely.

frosty flower
#

this key?

#

cause i use these 2 in both prod and local

barren wraith
#

There are different keys for live mode and test mode.

#

Live mode keys have _live_ in the prefix, test mode keys have _test_.

frosty flower
#

live wont work in local?

#

for testing

barren wraith
#

So pk_live_... and sk_live_... are your live keys, for example.

frosty flower
#

ye

barren wraith
#

Local vs server doesn't matter.

#

This is regarding Stripe's live mode vs. test mode.

frosty flower
#

idk il try and make new api sk and see if that works

barren wraith
zenith pikeBOT
frosty flower
barren wraith
#

Sounds like your code isn't picking up the new key.

#

Do you need to rebuild or redeploy or something?

#

Restart the server process maybe?

frosty flower
#

yea i did multiple times

#

i even deleted node_modules and reinstalled

barren wraith
#

That won't restart the current process though.

#

How are you starting your app?

frosty flower
barren wraith
#

Hm, I dunno then. Is the key hardcoded somewhere, perhaps?

frosty flower
pliant basalt
#

Hi there ๐Ÿ‘‹ taking over, as my colleague needs to step away

It seems like we have more or less exhausted our steps for troubleshooting here. One last thing, if you use the export command in a terminal/shell, do you see your key pop up as expected? Like, is it possible that your environment is looking for an API key outside of your .env file?

frosty flower
pliant basalt
#

Have you made changes to the .env file since you last restarted your server?

frosty flower
#

yes

pliant basalt
#

Try restarting the server

frosty flower
#

i did too

pliant basalt
#

Okay. Did you run export in a CLI to check if maybe the old value is there?

frosty flower
#

yup

#

still old value here

pliant basalt
#

Wait, the old API key is showing in the export command?

frosty flower
#

yeah

#

kinda weird i dunno lol

#

export command is pretty neat thanks for that haha

pliant basalt
#

Okay, try running export SEC_KEY=sk_abc123

Then access your API key in your code with process.env.SEC_KEY

frosty flower
#

so i think it resolved my issue :d

#

sec im tryin w sec_key

pliant basalt
#

That works too. Let me know how it goes

frosty flower
#

Invariant failed: Stripe secret key is not definied

pliant basalt
#

Whatever you name the variable is arbitrary. You could use SEC_KEY or SUPER_AWESOME_SECRET_KEY_THAT_ONLY_I_KNOW and, as long as you call that specific variable in your code it should work.

pliant basalt
frosty flower
#

noope

pliant basalt
#

So you're running export in your terminal and you're not seeing SEC_KEY anywhere?

frosty flower
#

yes lol

pliant basalt
#

Okay. Did you run export SEC_KEY=<your new api key> in your terminal?

frosty flower
#

mhm

#

yes

#

oh i had 2 terminals in vsc open

#

thats prolly why

pliant basalt
#

Run those 2 commands in the same terminal

frosty flower
#

looks better now

#

i jus started my server lets see if api key is valid

#

yay!! it works ๐Ÿ˜„

#

thank you so much

pliant basalt
#

Woo! ๐Ÿ™Œ

#

Sure thing!

frosty flower
#

i learnt export

#

pretty useful imo

#

hahah

pliant basalt
#

So there are 2 different methods for safely accessing your API keys. There's the method I just showed you, which makes the API key available globally on your computer, then there's a different method which uses a .env file. I would recommend researching both on your own time.

frosty flower
#

yes, do you know how i can globally purge the env?

pliant basalt
#

One thing to note with the method we just used: that API key will not persist if you restart your computer. If you want it to persist, you need to edit your ~/.bashrc or ~/.zshrc file so that the export command happens automatically each time you open a terminal.

#

Lucky for you, the server isn't busy right now, so I can walk you through that if you want. If the server gets busy though, I'll likely have you research that on your own

frosty flower
#

well tbh i dont need to set it globally haha, but tysm for ur offer ๐Ÿ˜„

pliant basalt
#

No worries! I mostly just wanted to get you up and running so you can continue coding, so I'm glad I was able to help you do that

frosty flower
#

tyyyyyy

#

do i need to make another ticket if i have a question regarding promotion codes/coupons?

pliant basalt
#

If you have follow ups later after I close the thread, then just post again in the main channel. If you have follow ups while this thread is open, you're welcome to post them here

frosty flower
#

alright

#

thanks

pliant basalt
#

Sure thing!

frosty flower
#

okay so

#

i was experiementing a few minutes ago with coupons and promo codes

#

how do i apply the promo code

#

well with the couponId it was like this

#

i would assume its the same right?

pliant basalt
frosty flower
#

is there any way to pass the id of the promotion_code?

pliant basalt
#

That's what that parameter is for. The ID of the Promotion Code goes into the request as discounts.promotion_code

frosty flower
#

amazing tysm

zenith pikeBOT
frosty flower
#

oh hi hanzo

crisp canopy
#

๐Ÿ‘‹

frosty flower
#

i guess the shift from two-shoes is over?

crisp canopy
#

yup

frosty flower
# crisp canopy yup

pretty much i just tried adding it to the discounts array but it wont subtract the promotion code?

#

promo_1PnNFiCb8QayhLskQ41LDuAQ

#

thats a promotion id right?

crisp canopy
#

correct

frosty flower
#

im applying it here, but idk it still wants to charge me the full amount the coupon is supposed to subtract 100%

#

if thats correct ^, then i assume its something else which il have to take a look, but does it sofar look correct?

crisp canopy
#

I think so

#

wait

#

does coupon == "promo_1PnNFiCb8QayhLskQ41LDuAQ"?

frosty flower
#

yes

#

should it be the promo code in clear text?

#

lol nevermind it worked

crisp canopy
#

no, it should be the ID. this seems right... Just wanted to make sure you're not passing the coupon value to promo field

#

๐Ÿ‘

frosty flower
#

idk whats up with my mind today

#

๐Ÿ˜‚

#

i forgot to enter the coupon code hahahah ๐Ÿ˜ญ

frosty flower
#

will stripe charge me for invoices that are automatically made?

#

and if yes, how do i disable it?

crisp canopy
#

I don't believe any fees are charged for test mode invoices. Are you asking about live mode?

frosty flower
#

yes

crisp canopy
#

My team won't know much about fees. I'd recommend talking to our support team:
https://support.stripe.com/?contact=true

frosty flower
#

thankss

#
const canceledSubscription = await stripe.subscriptions.cancel(subscriptionId)
#

atm im using this to cancel subscriptions, but i just noticed, when someone cancels, it DOES IT JUS RN, how can i make it so it will cancel after their billing period.

crisp canopy
frosty flower
#

idk is it common to do what im trying to do or is it just me that is trying to do something like this lmao?

#

thank u