#fabulousray_webhooks
1 messages ยท Page 1 of 1 (latest)
๐ 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/1251042156941152258
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
hello! You're using the Stripe CLI to forward the webhook to your local endpoint?
hello! yep that's right. here are some of the relevant files
so if you're using the Stripe CLI to forward the event to your local endpoint, the webhook secret you should use is the Stripe CLI's
not the webhook secret on the Dashboard
uhhh... do you mean the stripe secret key? sk_test....?
I used the end point secret key from the CLI that starts with whsec_ but I got the sk_test key from the dashboard
i'll suggest you log during runtime to be sure. You mentioned We have verified that the STRIPE_ENDPOINT_SECRET environment variable is set correctly and matches the webhook secret in our Stripe dashboard.
sorry, as in log out the keys?
yes, log your endpointSecret during runtime to be sure you have the correct key
Also, since you're using Express.js - the sequence of middleware matters. I see that you haveย app.use(express.json());ย prior to your route, this will likely parse the requests in all JSON, not in raw form before reaching to your webhook function.
yep, the endpointSecret that matches with the CLI matches the log during runtime. would i place the app.use(express.json()); after the webhook function then?
I suggest you try commenting it out first to see if your webhook works fine without it i.e. you no longer receive a signature verification error
oh dear I think it did get 200 response. but i got some errors which i don't know why has happened:
runtime:
2024-06-14 15:37:46 warn: Unhandled event type customer.created
2024-06-14 15:37:46 error: [handleWebhook] Cannot set headers after they are sent to the client
2024-06-14 15:37:46 error: There was an uncaught error: Cannot set headers after they are sent to the client
CLI
2024-06-14 15:37:46 <-- [200] POST http://localhost:3080/webhook [evt_1PRSpYRsJfE0QDMTLWtEmQrh]
2024-06-14 15:37:47 --> payment_method.attached [evt_1PRSpZRsJfE0QDMTBFD6KWVE]
2024-06-14 15:37:48 --> customer.updated [evt_1PRSpaRsJfE0QDMT4J5FlzVM]
2024-06-14 15:37:48 --> invoiceitem.created [evt_1PRSpaRsJfE0QDMTvaPev2F0]
2024-06-14 15:37:49 [ERROR] Failed to POST: Post "http://localhost:3080/webhook": dial tcp [::1]:3080: connectex: No connection could be made because the target machine actively refused it.
...
answering your original question, i can't advise where you should place your app.use(express.json()); code instead. You'll need to evaluate and rewrite your code to see where to place it so that it doesn't affect the webhook function.
For the header errors, I would suggest just ignoring for now as long as you're receiving the events fine.
No connection could be made because the target machine actively refused it. - your own local server is likely blocking / refusing the connection for that invoiceitem.created event
I understand. there isn't any logs for the handling of the event of invoice.paid. is it from the issue of the errors?
what's the event id?
evt_1PRStxRsJfE0QDMT1K3zICt6
hrm, i would guess it's because of the connection error, but did you see any failure in the Stripe CLI about it?
i got only the 200 reponse from the first event, all others none. 2024-06-14 15:37:46 <-- [200] POST http://localhost:3080/webhook [evt_1PRSpYRsJfE0QDMTLWtEmQrh]
2024-06-14 15:37:47 --> payment_method.attached [evt_1PRSpZRsJfE0QDMTBFD6KWVE]
2024-06-14 15:37:48 --> customer.updated [evt_1PRSpaRsJfE0QDMT4J5FlzVM]
2024-06-14 15:37:48 --> invoiceitem.created [evt_1PRSpaRsJfE0QDMTvaPev2F0]
2024-06-14 15:37:49 [ERROR] Failed to POST: Post "http://localhost:3080/webhook": dial tcp [::1]:3080: connectex: No connection could be made because the target machine actively refused it.
2024-06-14 15:37:50 --> invoice.created [evt_1PRSpbRsJfE0QDMTn9CkFODq]
2024-06-14 15:37:51 --> charge.succeeded [evt_3PRSpcRsJfE0QDMT0F3UqCZl]
2024-06-14 15:37:51 --> payment_intent.succeeded [evt_3PRSpcRsJfE0QDMT0QnoZTrg]
2024-06-14 15:37:51 --> payment_intent.created [evt_3PRSpcRsJfE0QDMT0OEiOPMU]
2024-06-14 15:37:51 --> invoice.paid [evt_1PRSpdRsJfE0QDMTK6VuFCEC]
2024-06-14 15:37:51 --> invoice.finalized [evt_1PRSpeRsJfE0QDMTZLRyvpqv]
2024-06-14 15:37:52 [ERROR] Failed to POST: Post "http://localhost:3080/webhook": dial tcp [::1]:3080: connectex: No connection could be made because the target machine actively refused it.
2024-06-14 15:37:52 --> invoice.payment_succeeded [evt_1PRSpeRsJfE0QDMTLKF6S13k]
2024-06-14 15:37:52 --> invoice.updated [evt_1PRSpdRsJfE0QDMTocVMEWl1]
2024-06-14 15:37:53 [ERROR] Failed to POST: Post "http://localhost:3080/webhook": dial tcp [::1]:3080: connectex: No connection could be made because the target machine actively refused it.
what's the command you use to forward webhooks in the Stripe CLI? can you paste it here?
stripe trigger invoice.paid
Setting up fixture for: customer
Running fixture for: customer
Setting up fixture for: payment_method
Running fixture for: payment_method
Setting up fixture for: invoiceitem
Running fixture for: invoiceitem
Setting up fixture for: invoice
Running fixture for: invoice
Setting up fixture for: invoice_pay
Running fixture for: invoice_pay
Trigger succeeded! Check dashboard for event details.