#dalel.elth-api-key
1 messages Β· Page 1 of 1 (latest)
Hey @vestal vale !
Thatβs what I thought but all use of my api key in my app originated from the environment variables
Which contain the brand new API keys
I think you assume they do, but if you were to log the API key you're using you'd see the old expired key
you must not have updated your environment variables properly or restarted your app to pick up new values
I would add a log line before the code that initializes Stripe.
Alright let me see what I can do π
Can't imagine how I would have done this wrong - all I did was change the values in my .env file
Doesn't seem like a lot of room for error
@dense atlas well you could have changed the wrong file. Or not restarted your app (the env file is read on app load that's it)
ahh okay
@vestal vale I logged the keys
it is indeed the updated key
the brand new one
any idea what could be going wrong?
is there a reason why the key provided in the error message begins with "rk" when my secret key (the one I am using in my application) begins with sk?
"rk_test_*********************************************************************************************iLVHWL""
that is a restricted access API key, so secret keys are sk_test_123 and restricted access ones are rk_test_4566 etc
are you using Restricted Access keys anywhere ? have you ever generated one?
i have not
where were you getting that error, do you know what Stripe API endpoint that occurred on? (the original 401)
I got that error @mellow lagoon when running "stripe listen --forward-to"
for webhooks
but I'm also unable to load a stripe checkout session on the frontend
you should have started with that haha
sorry sorry π
but I'm also unable to load a stripe checkout session on the frontend
that would be a separate issue aside from CLI
would have to do with what API keys are being used considering you just rolled them
for CLI, do a new stripe login and that generates a new restricted Stripe CLI keyu for you
gotcha
let me see how that works
are you able to help me troubleshoot the frontend issue if this works? π
1/share with me what CheckoutSession you created (the request ID)
2/ and how you are redirecting to it
that should give me direction
okay got the cli running!
so the checkout session stuff has been working
for months
the only thing that has changed is that I rolled the keys
I don't think it's an implementation issue for that reason
is a checkout session ID created if the request fails?
there are 2 steps
1/ create CheckoutSession
2/ redirect to it (either server-side or client-side)
so if 1/ does not work, you'd see a 400'ing request in your logs and no CheckoutSession
So i've got this here....on click of my submit button it calls my payments endpoint to create the checkout session ~
session = stripe.checkout.Session.create(
payment_method_types=["card"],
line_items=[{"price": request.data["price_id"], "quantity": 1}],
mode="subscription",
client_reference_id=request.user.id,
success_url=FRONTEND_URL + "/profile/" + str(request.user.id),
cancel_url=FRONTEND_URL,
customer_email=request.user.email,
metadata=metadata
)
then the redirect happens
so should I just print session.id before redirect?
to get that for you?
cs_test_a1aszrXWtw9izflFlmJ8bm4Z7EcpbWs1mvRKMr4pRK1QbYLZsRIFlzrsAb
@mellow lagoon
that's the session.id that I got!
ok the the CheckoutSession is being created
so step 2, how are you redirecting to it?
using Stripe.js? or a server-side redirect?
here's the function -
const stripe = await stripePromise;
const stripeSessionData = await axios.post(
${API_ENDPOINT}/payments/session/,
{ price_id: ANNUAL_PRICE_ID }
);
const sessionId = stripeSessionData.data["session_id"];
await stripe.redirectToCheckout({
sessionId,
});
perfect, that is what I thought, so something tells me that the publishable key you're using in intializing Stripe here is not the same account as the serverside secret key
can you double check those
AH
right you are
I totally forgot I had it stored with my frontend endpoints
one more question @mellow lagoon
ask away, a team member is around and will answer
I am now running webhooks and got my checkout session to render as expected...redirect works fine!
the only thing is...with webhooks running, I expected to see a "checkout session created" event roll in
but not seeing anything on my webhooks server
I am testing something very specific regarding the checkout session completed event
so I want to be sure before I go through that checkout process that the webhooks in general are being received on the CLI server
does that make sense?
Hello! Yep, that makes sense. Can you give me the ID of the Checkout Session which you expected to generate the checkout.session.completed event?
cs_test_a19AVgeaz6IcakcbDSQ9IhVyZh1FVv2qRQQGosaKQsRx52jXmNho5EXipO
thanks @jagged charm π
man you guys are quick haha
It doesn't look like that Checkout Session was never completed, which explains why there's no event.
Did you load the Checkout page and successfully pay?
have not successfully paid
I'm watching for "checkout session created" tho
want to make sure that works before completing the session
There is no such event.
Sorry, I misread your earlier message. π
But yeah, there's only checkout.session.completed, no creation event.
You can find a list of all events here: https://stripe.com/docs/api/events/types
Let me take a look, hang on...
thanks!
Here's the checkout.session.completed event: https://dashboard.stripe.com/test/events/evt_1JpJXRDBs6ED6M9vMSTkNpAi
shitttt π
strange
this webhooks configuration has worked for me before
actually - I was missing the webhook secret value in .env
ahhh that didn't do it
Yes indeed!
What do you see in the output of the stripe listen command? Does the event show up there?
No - no output at all
"Ready! Your webhook signing secret is whsec_AWw15sktkMmPSTOymCmSGOfenx6Wd***(^C to quit)"
this is all I see
Is Stripe CLI logged in to the same account as the one you're testing on?
What's the exact stripe listen command you're using?
It is, yes
stripe listen --forward-to http://localhost:8000/api/payments/stripe/webhook/
Try adding --latest to that command and try again.
as I mentioned before, this has worked for months
but okay I'll try that
so:
stripe listen --forward-to --latest http://localhost:8000/api/payments/stripe/webhook/
Yeah, see if that makes a difference or not.
"stripe listen does not take any positional arguments. See stripe listen --help for supported flags and usage"
Oh, my fault...
stripe listen --latest --forward-to http://localhost:8000/api/payments/stripe/webhook/
--latest needs to go in front of --forward-to.
WOOOOOOOO
that did it
thank you!
oh man
sometimes it is just so reassuring to see things work the way they're supposed to π
but the bug that I have been trying to fix through all of this manual testing is still broken
I take it that's not something you guys can help me with...it is related to the dj-stripe library for Django
Glad that worked! It sounds like you're hitting this Stripe CLI bug, unfortunately: https://github.com/stripe/stripe-cli/issues/600
The --latest is a workaround until we fix the issue.