#lunar_api
1 messages ยท Page 1 of 1 (latest)
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.
- lunar_code, 47 minutes ago, 8 messages
๐ 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.
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.
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?
yep
i copied the exact env from the prod to local and it errors
on my local
but on prod, it works just fine
Hm. And you're certain there's no leading or trailing space or anything like that?
nope
i even copied the whole .env
What IP address are you making the failed requests from?
its the same ip as the one the prod server is running
Can you give me that IP?
can i send it via dms? (just did)
No, we don't use DMs here, we help in public. If you don't want to share the IP or other details publicly you can contact support for private help: https://support.stripe.com/contact/email
okay, but can i delete my ip after? you seen it?
its my home ip hahah ๐
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?
yes
req_Nv2SupzMvo6X28
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?
wait pk is public and sk is secret?
Yes.
Also, can you check the status of that key in your Dashboard? https://dashboard.stripe.com/apikeys
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.
check this req_CCzEpMXEsrjz2n
That's a Dashboard request, it's not coming from your code and didn't use any of those keys.
oh thats dashboard req
alr sec
req_vs23qees3o51hf
i cant see much info of that log
That request was made with the secret key that ends in zkzI, not the one from the error message.
You should be able to see these details in your Dashboard here: https://dashboard.stripe.com/logs/req_vs23qees3o51hf
where do i see which secret key was used?
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.
There are different keys for live mode and test mode.
Live mode keys have _live_ in the prefix, test mode keys have _test_.
So pk_live_... and sk_live_... are your live keys, for example.
ye
Local vs server doesn't matter.
This is regarding Stripe's live mode vs. test mode.
idk il try and make new api sk and see if that works
You may want to read through our API keys documentation here: https://docs.stripe.com/keys
hmmm i just noticed when i updated my env it still says WfA4RK in the error
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?
js stopping the cmd and rerunning bun run dev
Hm, I dunno then. Is the key hardcoded somewhere, perhaps?
haha never xd its in env
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?
i tried doing console.log(process.env) and still the old value is here.
Have you made changes to the .env file since you last restarted your server?
yes
Try restarting the server
i did too
Okay. Did you run export in a CLI to check if maybe the old value is there?
Wait, the old API key is showing in the export command?
Okay, try running export SEC_KEY=sk_abc123
Then access your API key in your code with process.env.SEC_KEY
instead od SEC_KEY i used the old env var name and it changed when running export
so i think it resolved my issue :d
sec im tryin w sec_key
That works too. Let me know how it goes
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.
Okay, so when you export do you see SEC_KEY=<your new api key>?
So you're running export in your terminal and you're not seeing SEC_KEY anywhere?
yes lol
Okay. Did you run export SEC_KEY=<your new api key> in your terminal?
Run those 2 commands in the same terminal
looks better now
i jus started my server lets see if api key is valid
yay!! it works ๐
thank you so much
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.
yes, do you know how i can globally purge the env?
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
oh i see
well tbh i dont need to set it globally haha, but tysm for ur offer ๐
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
tyyyyyy
do i need to make another ticket if i have a question regarding promotion codes/coupons?
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
Sure thing!
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?
Sort of. You have to use the discounts array to pass in discounts.promotion_code: https://docs.stripe.com/api/subscriptions/create#create_subscription-discounts-promotion_code
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
oh perfect thanks ๐
is there any way to pass the id of the promotion_code?
That's what that parameter is for. The ID of the Promotion Code goes into the request as discounts.promotion_code
amazing tysm
oh hi hanzo
๐
i guess the shift from two-shoes is over?
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?
correct
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?
no, it should be the ID. this seems right... Just wanted to make sure you're not passing the coupon value to promo field
๐
idk whats up with my mind today
๐
i forgot to enter the coupon code hahahah ๐ญ
will stripe charge me for invoices that are automatically made?
and if yes, how do i disable it?
I don't believe any fees are charged for test mode invoices. Are you asking about live mode?
yes
My team won't know much about fees. I'd recommend talking to our support team:
https://support.stripe.com/?contact=true
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
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.
There's a parameter called cancel_at_period_end
https://docs.stripe.com/billing/subscriptions/cancel#cancel-at-the-end-of-the-current-billing-cycle