#seor_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/1397167745824587839
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi there!
i tried to trigger via stripe cli the invoice.payment_failed but i did not succeed
what do you mean by "it did not suceed"? what's the issue exactly?
when I type stripe trigger invoice.payment_failed, I do get the event generated
hello, i get the event generated but not for the customer i need
i don't know how to ovverride the customer value and also how to attach a failing payment method in order to trigger the invoice.payment_failed event
e,g, i ran this command:
stripe trigger invoice.payment_failed --override payment_method:customer="cus_SitR4T1wjSUMwZ" --override invoiceitem:customer="cus_SitR4T1wjSUMwZ" --override invoice:customer="cus_SitR4T1wjSUMwZ"
the cli says everything is good but on the UI dashboard or in the webhook local logs i see no such event
I just copy pasted your code, and replaced your cus_xxx ID with my own customer ID. and I did receive a invoice.payment_failed for the correct customer.
and you can find your events here: https://dashboard.stripe.com/test/workbench/events
When you run stripe trigger ... does it emit a evt_xxx ID? Can you share it?
here we go
Please just paste the ID
it does not emit any event id
it just states that the command was executesd
it says check dashboard for event detail but i can't see any
Yes it does, they're right there in the bottom half of the screenshot
but those are older events, from other commands
not this one
the hours is 2h ago as you can see
those are events triggered by my application flow
i need to test only invoice.payment_failed
Can you just share one of the IDs please
evt_1RnclHKKWf9Suo5241Oi4V1l
evt_1RnclHKKWf9Suo5241Oi4V1l was generated via the CLI, not your application flow
Any chance you're authenticated on different accounts in the CLI between the sessions/windows?
yes but still no webhook event sent to my backend
and all the others are sent and received correctly by my handler
Yes, because your endpoint is returning a 400 error
You need to add some code/logs to your handler to debug why
export const getWebhookAction = async ( action: StripeWebhookAction, input: Stripe.Event.Data.Object, ) => { switch (action) { case "customer.subscription.updated": return handleUpdateCustomerSubscription(input as Stripe.Subscription); case "customer.subscription.deleted": return handleDeleteCustomerSubscription(input as Stripe.Subscription); case "checkout.session.completed": return handleCheckoutSessionCompleted(input as Stripe.Checkout.Session); case "invoice.payment_failed": return handleInvoicePaymentFailed(input as Stripe.Invoice); default: break; } };
that's my switch case handler
so either the name of the event i'm handling is incorrect or i don't know
Does it reach the handleInvoicePaymentFailed function? Add some logging to that
it does not reach unfortunately
logger.info("WEBHOOK - INVOICE.PAYMENT_FAILED"); const { status, customer: invoiceCustomer } = invoice; logger.info(invoice is in status: ${status});
those are the first lines of the function called
and there are no such logs
OK, so where in the webhook handler do you return a 400?
on the controller level here
export async function StripeWebhookController( req: express.Request, res: express.Response, ) { logger.info(WEBHOOK_HANDLER_STARTED @${new Date().toLocaleString()}`);
const signature = req.headers["stripe-signature"];
try {
const event = stripeClient.webhooks.constructEvent(
//@ts-ignore
req.rawBody,
signature!,
res.locals.stripeWhSec,
);
await getWebhookAction(
event.type as StripeWebhookAction,
event.data.object,
);
res.status(200).send();
return;
} catch (error: any) {
logger.error(error);
res.status(400).send(`Webhook error: ${error.message}`);
}`
And what does logger.error(error) print? I would guess your secret is the wrong one. Are you using the one that the CLI emits when you start stripe listen?
It's in the screenshot
You need to help me out here and share the actual error thrown in your catch block. I'm flying blind