简体   繁体   中英

How to debug invoice.payment_failed or invoice.payment_succeeded using stripe_event gem?

I don't get how to test those 2 Stripe Webhooks using stripe_event gem without using Stripe Test Webhooks button as they say in stripe_event github page .

  • invoice.payment_failed
  • invoice.payment_succeeded

Someone knows how to fire those events in development ?

You'd need to generate those events "organically", by creating a subscription in test mode. You'd need to use a customer object with a valid test card .

To test invoice.payment_failed events, the simplest way is to create a customer with the test token tok_chargeCustomerFail , then create a subscription with a very short trial period (eg a few seconds). Once the trial expires, a new invoice will be created. Roughly one hour later, payment will be attempted for the invoice and fail, resulting in an invoice.payment_failed event being created. You can also trigger the payment attempt earlier via the API.

That said, that gem uses an outdated method for verifying events. Stripe events have signatures which can be used to verify the event without having to fetch it back using the API. This also works with the test events sent via the "Send test webhook" button.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM