#luftjunkie
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. 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.
- luftjunkie, 3 hours ago, 15 messages
- luftie-missing-apikey, 5 days ago, 55 messages
Here is how my function of webhook looks like: exports.accountWebhook=functions.https.onRequest(async (req, res)=>{ let event; try { event = stripe.webhooks.constructEvent( req.rawBody, req.headers["stripe-signature"], whAcc, ); console.log("rawBody", req.rawBody, "rawBody"); if (event.type === "account.updated") { const loginLink = await stripe.accounts.createLoginLink( event.data.object.id, ); await admin .database() .ref(users/${event.data.object.metadata.id}) .update({linkToExpress: loginLink.url}); await admin .database() .ref(users/${event.data.object.metadata.id}/stripeAccountData) .update(event.data.object); await admin .database() .ref(users/${event.data.object.metadata.id}/accountLinkObject) .remove(); } return res.sendStatus(200).end(); } catch (err) { console.log("webhook account failed"); console.log(err); return res.status(err).end(); } });
And it simply return that the webhook account has been failed.
Is rawBody being populated like you expect/assume?
That's something you'd need to ensure is set on your request when you receive them via some custom middleware step
For example, with something like this:
https://github.com/stripe-samples/charging-a-saved-card/blob/eb46e6eec269780a67bfac4ca110bcdf25da0afe/server/node/server.js#L9-L19
Ok, will check if i get the rawBody, give me a moment. But as I delved deeper into that how somebody else dealt with this error than they had this kind of solution.
Sorry, that it takes me so long, but I found something weird in my code. Let me only examine if that was the obstacle or not.
Huh, quite weird as I've corrected the webhook secret keys to the current one, than now the webhook is not calling. Let me check once again if i'm doing something wrong or something else is fault. One more moment please.
Actually as far as I see I do get an req.rawBody.
Meaning i do not get undefined.
I get <Buffer some numbers... />
Well, let me check something more ok, because now it seems to work correctly.
Ok, so currnently the webhook failure has been fixed. But now i'll try to fix another one because as I want to invoke an function that should create an checkout session I get an error of your account cannot currently make live charges.
Ok great, glad you were able to get that part working!
Let us know if you have any other question, or feel free to message again later in #dev-help with any issues with Checkout etc
So just to create new query if i will feel need to do it. Do I apprehend correctly?
Yep!
Alright, thanks even though for your hint.
The issue was that i've run app.use(express.json()); and the same with bodyParser before initializing stripe.
Yep that would do it, the body would be parsed before you have a chance to inspect it then