#viking66
1 messages · Page 1 of 1 (latest)
Yeah, but its invoice.payment_failed, not invoice.payment.failed
the documentation here is incorrect https://stripe.com/docs/billing/subscriptions/overview#build-your-own-handling-for-recurring-charge-failures
it says invoice.payment.failed
anyways, how can i generate one of those events?
stripe trigger invoice.payment_failed
The event is detailed in this table from the docs you linked to: https://stripe.com/docs/billing/subscriptions/overview#subscription-events
i did that but it gives me an invoice.payment_succeded
2023-04-12 16:16:54 --> payment_method.attached [evt_1MwB2ADRMj5iVNZBS8ntRGai]
2023-04-12 16:16:54 <-- [200] POST http://localhost:4242/webhook [evt_1MwB2ADRMj5iVNZBS8ntRGai]
2023-04-12 16:16:54 --> customer.source.created [evt_1MwB2ADRMj5iVNZBVYVIwmNx]
2023-04-12 16:16:54 <-- [200] POST http://localhost:4242/webhook [evt_1MwB2ADRMj5iVNZBVYVIwmNx]
2023-04-12 16:16:54 --> customer.created [evt_1MwB2ADRMj5iVNZBkn72nXBo]
2023-04-12 16:16:54 <-- [200] POST http://localhost:4242/webhook [evt_1MwB2ADRMj5iVNZBkn72nXBo]
2023-04-12 16:16:55 --> customer.updated [evt_1MwB2BDRMj5iVNZBnaf8hvXr]
2023-04-12 16:16:55 <-- [200] POST http://localhost:4242/webhook [evt_1MwB2BDRMj5iVNZBnaf8hvXr]
2023-04-12 16:16:55 --> invoiceitem.created [evt_1MwB2BDRMj5iVNZBW6VsPi5B]
2023-04-12 16:16:55 <-- [200] POST http://localhost:4242/webhook [evt_1MwB2BDRMj5iVNZBW6VsPi5B]
2023-04-12 16:16:55 --> invoice.created [evt_1MwB2BDRMj5iVNZB9pnI3lTo]
2023-04-12 16:16:55 <-- [200] POST http://localhost:4242/webhook [evt_1MwB2BDRMj5iVNZB9pnI3lTo]
2023-04-12 16:16:56 --> invoice.updated [evt_1MwB2CDRMj5iVNZBFvdKGtaf]
2023-04-12 16:16:56 <-- [200] POST http://localhost:4242/webhook [evt_1MwB2CDRMj5iVNZBFvdKGtaf]
2023-04-12 16:16:56 --> invoice.finalized [evt_1MwB2CDRMj5iVNZBalyLSs4Z]
2023-04-12 16:16:56 <-- [200] POST http://localhost:4242/webhook [evt_1MwB2CDRMj5iVNZBalyLSs4Z]
2023-04-12 16:16:56 --> invoice.paid [evt_1MwB2CDRMj5iVNZBCxpMb8b4]
2023-04-12 16:16:56 <-- [200] POST http://localhost:4242/webhook [evt_1MwB2CDRMj5iVNZBCxpMb8b4]
2023-04-12 16:16:56 --> invoice.payment_succeeded [evt_1MwB2CDRMj5iVNZBZ3qiHEHj]
2023-04-12 16:16:56 <-- [200] POST http://localhost:4242/webhook [evt_1MwB2CDRMj5iVNZBZ3qiHEHj]
i ran: ```
❯ stripe trigger invoice.payment_failed
A newer version of the Stripe CLI is available, please update to: v1.14.0
Setting up fixture for: customer
Running fixture for: customer
Setting up fixture for: invoiceitem
Running fixture for: invoiceitem
Setting up fixture for: invoice
Running fixture for: invoice
Setting up fixture for: invoice_pay
Running fixture for: invoice_pay
Trigger succeeded! Check dashboard for event details.
also, this works for my local listener but i want to trigger the event on my test account with the webhooks sent to my handler in aws. is there a way i can do that?
Stripe CLI can be run from the command line pretty much wherever you have access to the command line
As for the command output, that's either a bug, or something is getting lost somewhere. Are you sure that the events are related to the stripe trigger invoice.payment_failed command?
yes, i'm sure
❯ stripe --version
stripe version 1.10.3
Can you try upgrading the CLI to the most recent version? https://stripe.com/docs/stripe-cli/upgrade
We're at 1.14.0 right now
thanks, that worked
if the payment that fails is related to a subscription, will the subscription fields be populated?
Which Subscription fields?
there are two fields, one inside lines and the other inside data if i'm reading the response correct
Can you point to specific fields so I can tell if they are or are not populated? Hard to infer which ones you're looking for
So when you trigger an invoice.payment_failed event, it doesn't create a Subscription. It just creates an Invoice, Customer, and Payment Method.
What are you trying to do specifically with this?
i have a specific use case for my service where i'm trying to keep track of failed payments. all of my payments are part of subscriptions. so i want to know what the event will look like in my use case so i can properly handle it. i need to know which subscription had a failed payment
Hmmm, I'm not sure if that's possible with CLI, but let me check
that's why i've been asking if i can trigger it from my test account. i've been going into the dashboard and making subscriptions and whatnot and i can trigger webhooks for some use cases from the dashboard but i can't figure out how to do it for a failed payment
i tried using one of the test credit cards that i found in some stripe documentation but that did not trigger the failed payment event like i had hoped
I think for this particular use-case, you would want to use Test Clocks, but let me see if --override will work for this use-case
So it doesn't look like you can simulate this exact scenario via CLI. You would need to use Test Clocks to advance through the Subscription lifecycle: https://stripe.com/docs/billing/testing/test-clocks
Once you have a Customer with a Test Clock, you can attach a test card number as a Payment Method that successfully pays for the first Subscription payment (see these docs: https://stripe.com/docs/testing). Once that Customer has made the first successful payment, you can detach their payment method and use one of the decline cards from the test card docs, and advance the test clock past the next payment (which will decline) in order to simulate the failed payment for the Subscription.