#cajazzer_best-practices

1 messages ¡ Page 1 of 1 (latest)

lusty flowerBOT
drowsy needleBOT
#

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.

lusty flowerBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1252679182077394956

📝 Have more to share? Add details, code, screenshots, videos, etc. below.

north crypt
#

Hello! Stripe's terms of service do not allow for testing in live mode. As such, we can't provide guidance for testing in live mode.

blissful condor
#

I actually want to test in "test mode" but using our website (not localhost with stripe listen).

north crypt
#

Ah, I see. You would need to set up an actual Webhook Endpoint in test mode in that case.

#

Or you can do it via the Dashboard.

blissful condor
#

I have done that. It keeps failing with a 400 Bad Request.

#

Sorry Invalid request

north crypt
blissful condor
#

Is this it: evt_1PSp4rC4T1iPI2rAF8sYB6Xc

north crypt
#

That's an Event ID, not a request ID. Request IDs start with req_.

#

I'm looking for the request ID showing the 400 invalid request error you mentioned.

blissful condor
#

Hold on, seeing the error in the webhooks log but not the general logs section

north crypt
#

To clarify, are you seeing that error when attempting to create the Webhook Endpoint itself, or have you already done that and you're seeing 400 responses from your own server when we attempt to send an Event to it?

blissful condor
#

I am verifying that in my server code an error is coming from: event = stripe.webhooks.constructEvent(body, signature, SECRET_STRIPE_WEBHOOK_KEY)

north crypt
#

I thought you were talking about the former, but now it sounds like you're talking about the latter?

blissful condor
#

Sorry, the later yes.

north crypt
#

I do see 400 responses from your server on evt_1PSp4rC4T1iPI2rAF8sYB6Xc. Those are coming from your code and are something you need to fix on your end.

blissful condor
#

My code worked using localhost and stripe listen. Just trying to figure out the delta on our real server. I assume the test keys should still work.

north crypt
#

What does "test keys" refer to? If you're talking about the webhook signing secret, it's going to be different for an actual Webhook Endpoint vs. the one the CLI provides.

blissful condor
#

Ah! I bet that is it.

north crypt
#

Did that get it working for you?

blissful condor
#

No, I used the signing secret for the webhookj endpoint in test mode but it did not work.

north crypt
#

Same error or different?

blissful condor
#

same error: Webhook signature verification failed. No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe?

north crypt
#

Usually that error is caused by using the wrong webhook secret or by not passing the raw, unaltered body.

#

You need to pass the exact raw body you get in the request. It can't be parsed or changed in any way. Even whitespace changes will cause verification to fail.

blissful condor
north crypt
#

I doubt const body = await request.text() is going to give you the raw, unaltered body. It might... but I'm dubious.

#

When using Node it's often hard to get the raw body, and there's no one solution that always works. Generally you want to extract the raw body first thing, before any middleware or other logic. There's a long thread of possible solutions/approaches you can try here: https://github.com/stripe/stripe-node/issues/341

blissful condor
#

Thanks. I will take a look at the docs. Thanks for the help.

north crypt
#

No problem, good luck with it!