#nacho_446
1 messages · Page 1 of 1 (latest)
hi! the error message seems self explanatory
you need to create a recurring Price inside price_data.
Hold on so I check that
So with this now I set
recurring: { interval: 'month' },
I normally set a metadata to transfer the user before, but I don’t know if the metadata will return on the next payment
How can u track the payment to the user when the next payment in a month comes
use subscription_data.metadata instead
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
then when you get recurring Invoice webhooks, you can look at the Subscription object to find that metadata
The reoccurring invoice webhook is on invoice.paid right?
The only problem am having now is handling the webhook
public static handleStripeWebHook = async (req: Request, res: Response) => {
const result = await SchoolService.stripeWebHook({
data: req.body,
sig: req.headers['stripe-signature'] as string,
});
return res.send(
successResponse({
status: 200,
data: result,
}),
);
};
Instead the stripeWebhook
export default wrapServiceAction({
schema: StripeEvent,
handler: async (params: StripeEvent) => {
const { sig, data } = params;
console.log(data.body);
console.log(sig);
switch (data.body.type) {
case 'checkout.session.completed':
break;
case 'checkout.session.successed':
// const paymentMethod = event.data.object;
break;
default:
// Unexpected event type
console.log(`Unhandled event type ${data.body.type as string}.`);
}
},
});
and what problem would you be having?
I don’t know if this is the right way to receive the webhook body
did it work when you ran the code or tested it? 🙂
if you don't know how to test it -> https://stripe.com/docs/webhooks#test-webhook
I tried setting up the webhook locally on my Mac but couldn’t and we’ll it’s live it’s harder to manage
I tried setting up the webhook locally on my Mac but couldn’t
then I suggest trying to fix that! if you have more information about what you tried, what didn't work, what errors you got etc, that's what we are here to help with.
Ok thanks this has been very helpful I will try the local webhook again
Is it subscription_details or subscription_data ?
subscription_data is the parent hash
On the response for invoice.paid I can see subscription_details that has metadata in it
Ok
Yes, we include a snapshot of the metadata from the Subscription on Invoices
Ok for that invoice.paid webhook I should be looking for subscription_data not subscription_details
No, on the invoice.paid event the metdata will be in a subscription_details hash
The subscription_data is the parameter/hash you pass on your metadata to on Checkout Session creation
What error(s) are you seeing?
When the user makes his first payment that starts the recurring payment what webhook should I check customer.subscription.created?
Http 500
Sounds like an error thrown by your webhook code. You should add logging yo your code to determine where that is thrown
Generally checkout.session.completed is sufficient
Depends what data you want/need I guess
I just need the metadata so I can get the userId from it.
The error is on the stripe dashboard, under webhook that’s where am getting the 500
Yep, that 500 is what your webhook endpoint is returning to us. A 500 error is generally indicative of code throwing an error, so I suspect there's an issue in your webhook logic
You'll need to add logging to your code to determine what the issue is
Can this error occur when am using one test details for two different applications.
On one application am check for checkout.session.completed, so it hitting that endpoint with this details will try 500