#ayushh_webhooks
1 messages ¡ Page 1 of 1 (latest)
đ 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/1326113239930634250
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi! what does the complete code of your webhook endpoint look like?
also the error message should link to the stripe-node repository which has some working examples + more info
I already have the webhook secret in my env
yeah you're using Express so look at
https://github.com/stripe/stripe-node/tree/master/examples/webhook-signing
https://github.com/stripe/stripe-node/blob/master/examples/webhook-signing/express/main.ts
which shows to use exempt the webhook route from JSON parsing
the code is pretty much similar
I have just created a controller and mapped to a route
router.post("/api/webhook", stripeWebhookController)
yeah but look specifically at the docs and example about using a raw parser, that is the important part. https://github.com/stripe/stripe-node/blob/master/examples/webhook-signing/express/main.ts#L16-L34
no.
please check the code shared. You want to not use express.json for the webhook route, that is what the code is doing
oh
ok
thanks
lemme try it
{
"error": "Webhook Error: No webhook payload was provided."
}
I'd need to see your complete code again to say anything
isn't your definition missing the middleware for the raw body?
https://github.com/stripe/stripe-node/blob/master/examples/webhook-signing/express/main.ts#L33-L34
and what is stripeWebhookController
I am adding
it's the webhook function that I shared
This one
then the issue is probably missing the middleware as I described
checking
I'd also suggest just using the exact sample we provide, confirming that works for receiving the webhook, and then slowly integrate it with the rest of your code
oh
oka
I will definitely use the same code snippet
hey
it worked
thanks
I have another question if we can do in this thread
as I said, I will have a rideshare app where users can select the drivers. so the driver is also doing business and the company is also doing business. We want to automate payment process. The driver will need to connect their stripe account on the site.
The driver needs to pay 15%, but the payment is going to company's account now from the checkout, so is it possible that the rest 85% goes to the driver's stripe account automatically
sure, you can collect fees/split funds with Connect e.g. https://docs.stripe.com/connect/destination-charges?platform=web&ui=stripe-hosted#collect-fees
suppose if the ride costs 100$ and the 15% which is 15$ needs to be in the
payment_intent_data: {
application_fee_amount: 1500,
transfer_data: {
destination: '{{CONNECTED_ACCOUNT_ID}}',
},
},
Over here? in the application_fee_amount?
you'd write code to determine what amount the platform should keep, and you pass that amount as application_fee_amount yes