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

[`trigger`] [`payment_intent.succeeded`] No `invoice` and `subscription` Fixtures Support #1211

Closed aress31 closed 3 days ago

aress31 commented 3 days ago

Does anyone know why essentials invoice and subscription are not yet supported when triggering the payment_intent.succeeded event with the cli for testing purposes, see:

karlr-stripe commented 3 days ago

Hi @aress31 , the trigger command just makes some calls to the Stripe API which have the side effect of producing the requested event type. The -add parameter is used to add an additional parameter to those API requests. So if you add something that the API does not support(there's so much thing as passing invoice=in_xxx to the PaymentIntent Create API ) you just get an error.

If you want a PaymentIntent with the invoice field set, the only way to do that is to create and finalize a non-zero Invoice. So the easiest option really is just to do stripe trigger invoice.paid as that also has the side effect of emitting a payment_intent.succeeded event.

On the other point, there is no such thing as a subscription field on the PaymentIntent object so I'm unsure what you're aiming for there.

aress31 commented 3 days ago

That’s why I reported this as a bug. The invoice object/ID is fully supported by the paymentIntent object, as clearly stated in the documentation. See the details here:

image

On the other point, there is no such thing as a subscription field on the PaymentIntent object so I'm unsure what you're aiming for there.

I agree on this point. After reviewing the documentation again, I realised there is no support for subscription within PaymentIntent. However, there is support for invoice.

karlr-stripe commented 3 days ago

@aress31 It's supported as a field , not a parameter. A PaymentIntent can have a field invoice which is the ID of the invoices it's related to. It does not have a parameter that can be set to assign a value to that field. The only way that field can be set is by having the PaymentIntent get created by an Invoice, as described in my reply. Stripe-CLI can not set that field in any way except by what the public API supports.

If you have more questions about how the Stripe API works I'd suggest reaching out to to https://stripe.com/go/developer-chat or https://support.stripe.com/?contact=true.

aress31 commented 3 days ago

That is exactly my point. This should be supported because the normal checkout flow generates a paymentIntent with an invoice set - so for development purposes this behaviour should ideally get replicated with the trigger.

Also, to avoid confusion, it would be helpful if the documentation explicitly distinguished between fields and parameters.

karlr-stripe commented 3 days ago

It depends what you mean by the "normal" Checkout flow, there are multiple ways of integrating payments in Stripe. There's really only two or three that actually set invoice on PaymentIntent(creating Subscriptions, using the Invoicing integration, using post-payment invoices on Checkout), while all of the default one-time integrations of https://stripe.com/docs/payments/accept-a-payment for instance , do not create Invoices at all.

so for development purposes this behaviour should ideally get replicated with the trigger.

I mentioned that stripe trigger invoice.paid will generate a payment_intent.succeeded event that does have invoice set, I hope that helps as a workaround!

Again, this is less about stripe-cli so I'd suggest reaching out to to https://stripe.com/go/developer-chat or https://support.stripe.com/?contact=true for any further clarification.

aress31 commented 3 days ago

@karlr-stripe, I am trying your workaround and the fixtures still do not seem to apply, see:

karlr-stripe commented 3 days ago

Please reach out to https://stripe.com/go/developer-chat or https://support.stripe.com/?contact=true for usage questions.

To unblock you for now: It's just trigger invoice.paid --override invoice:customer=cus_QMPm8fmp1p6Xgf because: