stripe / stripe-cli

A command-line tool for Stripe
https://stripe.com/docs/stripe-cli
Apache License 2.0
1.57k stars 362 forks source link

Stripe CLI for trigger invoice.payment_failed does not pass customer parameter to the event #1119

Closed jpa57 closed 10 months ago

jpa57 commented 10 months ago

Issue

This works: stripe trigger payment_intent.payment_failed --add payment_intent:customer=cus_OW8AfRxISxedrK The invoice flavor doesn't complain but also does not result in the event using the specified customer: stripe trigger invoice.payment_failed --add invoice:customer=cus_OW8AfRxISxedrK01 This could be just a documentation issue, but your customer support team directed me to file an issue here because they can't figure it out. Customer support also told me that when a subscription payment fails, that I will get the invoice event, even though my code does not generate an invoice. Obviously I don't want to test this with real payment failures, so this is a fundamental need.

Expected Behavior

The two flavors should behave the same or, if it is not possible to support for the invoice flavor, it should error out with a message pointing to documentation

Steps to reproduce

Write an event handler. Direct events there with stripe listen --forward-to Detect both flavors of payment failed. Pick a 'real' customer from your test mode and use it in both commands. Log or breakpoint the event handler. Note the id of the customer in the event. For payment intent, you get what was requested. For invoice you get a stripe-invented customer.

Environment

maxOS

karlr-stripe commented 10 months ago

Hi @jpa57 , you need to use --override instead of --add. https://stripe.com/docs/cli/trigger#trigger-override

add doesn't do anything if the parameter already exists as part of the fixture, see: https://github.com/stripe/stripe-cli/blob/45bdfd562fa5cf7c8c3cc96fa5bd77d70ae1b1a2/pkg/fixtures/fixtures.go#L224-L227