jmmokeni's avatar

Cashier / Stripe webhook not working

i'm developping a multi tenant application and my billable model is the Tenant Model. I configured everything well, for the subscription payment i'm using stripe checkout, after the payment, on stripe side, everything works and the subscription is created. Locally, i configured stripe cli, the webhookis redirected to my local app and when i look at the logs of my container running the app, i get 200 on post requests to webhook. But in the database, thee subscription is not created, but the stripe_id is added to the tenant record in the database. I tried many things but nothing works

1 like
7 replies
jmmokeni's avatar

container logs example app | 172.18.0.1 - - [04/Apr/2025:12:02:51 +0000] "POST /stripe/webhook HTTP/1.1" 200 11331 "-" "Stripe/1.0 (+https://stripe.com/docs/webhooks)" app | 172.18.0.1 - - [04/Apr/2025:12:02:51 +0000] "POST /stripe/webhook HTTP/1.1" 200 11463 "-" "Stripe/1.0 (+https://stripe.com/docs/webhooks)"

stripe cli logs 2025-04-04 13:02:28 --> customer.created [evt_1RA8x6HDsXv78QJLMqE5rBad] 2025-04-04 13:02:28 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8x6HDsXv78QJLMqE5rBad] 2025-04-04 13:02:51 --> charge.succeeded [evt_3RA8xPHDsXv78QJL1rOnu9WS] 2025-04-04 13:02:51 --> payment_method.attached [evt_1RA8xTHDsXv78QJLzmBfsK4i] 2025-04-04 13:02:51 --> customer.updated [evt_1RA8xTHDsXv78QJLWvU5j6YM] 2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_3RA8xPHDsXv78QJL1rOnu9WS] 2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLzmBfsK4i] 2025-04-04 13:02:51 --> customer.subscription.created [evt_1RA8xTHDsXv78QJLx1Pkqj12] 2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLWvU5j6YM] 2025-04-04 13:02:51 --> customer.subscription.updated [evt_1RA8xTHDsXv78QJLEmpEIdUr] 2025-04-04 13:02:51 --> checkout.session.completed [evt_1RA8xTHDsXv78QJLCjtxuvkV] 2025-04-04 13:02:51 --> payment_intent.succeeded [evt_3RA8xPHDsXv78QJL1tA1u2KN] 2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLx1Pkqj12] 2025-04-04 13:02:51 --> payment_intent.created [evt_3RA8xPHDsXv78QJL1V0DbIde] 2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLEmpEIdUr] 2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLCjtxuvkV] 2025-04-04 13:02:51 --> invoice.created [evt_1RA8xTHDsXv78QJL9KA6O72d] 2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_3RA8xPHDsXv78QJL1tA1u2KN] 2025-04-04 13:02:51 --> invoice.finalized [evt_1RA8xTHDsXv78QJLQZwfsVAv] 2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_3RA8xPHDsXv78QJL1V0DbIde] 2025-04-04 13:02:51 --> invoice.updated [evt_1RA8xTHDsXv78QJLGAPZk7gl] 2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJL9KA6O72d] 2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLQZwfsVAv] 2025-04-04 13:02:52 --> invoice.paid [evt_1RA8xTHDsXv78QJL3EIrgFbA] 2025-04-04 13:02:52 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLGAPZk7gl] 2025-04-04 13:02:52 --> invoice.payment_succeeded [evt_1RA8xTHDsXv78QJLV7sDiOHp] 2025-04-04 13:02:52 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJL3EIrgFbA] 2025-04-04 13:02:52 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLV7sDiOHp]

1 like
martinbean's avatar

@jmmokeni Can you please format the output so we can understand what’s actually going on?

1 like
jmmokeni's avatar

@martinbean sorry for that, i didn't notice it wasnt formatted
container logs example
app | 172.18.0.1 - - [04/Apr/2025:12:02:51 +0000] "POST /stripe/webhook HTTP/1.1" 200 11331 "-" "Stripe/1.0 (+https://stripe.com/docs/webhooks)"
app | 172.18.0.1 - - [04/Apr/2025:12:02:51 +0000] "POST /stripe/webhook HTTP/1.1" 200 11463 "-" "Stripe/1.0 (+https://stripe.com/docs/webhooks)"\

Stripe CLI logs
2025-04-04 13:02:28 --> customer.created [evt_1RA8x6HDsXv78QJLMqE5rBad]
2025-04-04 13:02:28 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8x6HDsXv78QJLMqE5rBad]\

2025-04-04 13:02:51 --> charge.succeeded [evt_3RA8xPHDsXv78QJL1rOnu9WS]
2025-04-04 13:02:51 --> payment_method.attached [evt_1RA8xTHDsXv78QJLzmBfsK4i]
2025-04-04 13:02:51 --> customer.updated [evt_1RA8xTHDsXv78QJLWvU5j6YM]
2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_3RA8xPHDsXv78QJL1rOnu9WS]
2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLzmBfsK4i]\

2025-04-04 13:02:51 --> customer.subscription.created [evt_1RA8xTHDsXv78QJLx1Pkqj12]
2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLWvU5j6YM]\

2025-04-04 13:02:51 --> customer.subscription.updated [evt_1RA8xTHDsXv78QJLEmpEIdUr]
2025-04-04 13:02:51 --> checkout.session.completed [evt_1RA8xTHDsXv78QJLCjtxuvkV]
2025-04-04 13:02:51 --> payment_intent.succeeded [evt_3RA8xPHDsXv78QJL1tA1u2KN]
2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLx1Pkqj12]\

2025-04-04 13:02:51 --> payment_intent.created [evt_3RA8xPHDsXv78QJL1V0DbIde]
2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLEmpEIdUr]
2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLCjtxuvkV]\

2025-04-04 13:02:51 --> invoice.created [evt_1RA8xTHDsXv78QJL9KA6O72d]
2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_3RA8xPHDsXv78QJL1tA1u2KN]\

2025-04-04 13:02:51 --> invoice.finalized [evt_1RA8xTHDsXv78QJLQZwfsVAv]
2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_3RA8xPHDsXv78QJL1V0DbIde]\

2025-04-04 13:02:51 --> invoice.updated [evt_1RA8xTHDsXv78QJLGAPZk7gl]
2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJL9KA6O72d]
2025-04-04 13:02:51 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLQZwfsVAv]\

2025-04-04 13:02:52 --> invoice.paid [evt_1RA8xTHDsXv78QJL3EIrgFbA]
2025-04-04 13:02:52 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLGAPZk7gl]\

2025-04-04 13:02:52 --> invoice.payment_succeeded [evt_1RA8xTHDsXv78QJLV7sDiOHp]
2025-04-04 13:02:52 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJL3EIrgFbA]
2025-04-04 13:02:52 <-- [200] POST http://lecoursier.local/stripe/webhook [evt_1RA8xTHDsXv78QJLV7sDiOHp]\

1 like
jmmokeni's avatar

@vincent15000 yes, and based on the logs, te app gets the post request to webhook with status 200 and stripe cli is successfully forwarding request, i thought it was stripe cli's fault but i ran the app on a vps so i don't have to use stripe cli and it was the same scenario, getting the webhook request 200 but database not syncing

1 like
vincent15000's avatar

@jmmokeni Have you changed something in the database, for example change the primary key to a ULID field ?

jmmokeni's avatar

@vincent15000 I solved the problem, here's how:
I studied and looked up the cashier files (webhook controllers,...) and added more logging info, so i noticed that when receiving the webhook, it tried to do BillableModel::where('stripe_id', $stripeId) but getting null.
Because i forgot to add the getCustomColumns() functions on tenant model, i couldn't do a Tenant::where for other field but the id. The other fields were saved in the data json column, so when i added the stripe_id on custom columns of tenant model, i could do a Tenant::where for stripe_id and the database started to be updated and synced with stripe.
I'm using Stancl tenancy package

Please or to participate in this conversation.