Closed aress31 closed 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.
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:
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
.
@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.
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.
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.
@karlr-stripe, I am trying your workaround and the fixtures still do not seem to apply, see:
Triggering an invoice.paid
event - as suggested - with a set customer
and invoice
:
./stripe.exe trigger invoice.paid --add payment_intent:customer=cus_QMPm8fmp1p6Xgf --add payment_intent:invoice=in_1PVgxNAotHECEdB6z8ZLO0c6
On the handler side, you can observe discrepancies in the id.
console.log({ customerId: customer.id, invoiceId: invoice.id });
{
customerId: 'cus_QMdQGtGKb5kHD3',
invoiceId: 'in_1PVuA1AotHECEdB6eFwtQ21t'
}
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:
-add
is to add additional parameters to the requests that fixture makes, but it already includes a customer
parameter so -add
is ignored. So instead you want --override
to change the value it passes.--add payment_intent:invoice=in_1PVgxNAotHECEdB6z8ZLO0c6
doesn't make sense, since you can't control the Invoice ID here. What happens is the fixture calls the API to create a new Invoice(which will have a new random ID), that Invoice creates a PaymentIntent, and that PaymentIntent has the id
of that invoice for its invoice
field.
Does anyone know why essentials
invoice
andsubscription
are not yet supported when triggering thepayment_intent.succeeded
event with thecli
for testing purposes, see:payment_intent:invoice
:payment_intent:subscription
: