#mekhami
1 messages ยท Page 1 of 1 (latest)
It covers all invoices. For one-off payments, are you using invoices or Payment Intents?
payment intent
If you just use a payment intent, then invoice.paid wouldn't be generated
You would want to listen for: https://stripe.com/docs/api/events/types#event_types-payment_intent.succeeded
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
okay great. that works just fine for me.
curious.. using stripe cli, i triggered the invoice.paid event and that also ended up firing the payment_intent.succeeded event
so i ended up firing that event that i'm trying not to fire
Yeah so invoices use payment intents under the hood. Invoices will generate payment_intent.succeeded events but payment intents won't generate invoice.paid events. One thing you could do to differentiate the one-time payment_intent.succeeded events from the subscription ones is to see if the invoice field is populated (it will be for subscription payments but not one-time): https://stripe.com/docs/api/payment_intents/object#payment_intent_object-invoice
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Or you could set some metadata to differentiate: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-metadata
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
okay great. i'll try these options, thank you!
Is it then possible to get the Subscription object for a given Invoice?
Yeah there's a subscription field on the invoice: https://stripe.com/docs/api/invoices/object#invoice_object-subscription
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ahh my eyes glossed over it cause it's null in the documentation haha. sorry for the bother.
No worries
I'm trying to test this with the stripe cli webhook system, and I'm getting the following error:
~ ๎ฐ stripe trigger invoice.paid --override invoice:subscription=sub_1LnNEqFwUgn76hu7CYT4rJOT
Setting up fixture for: customer
Running fixture for: customer
Setting up fixture for: payment_method
Running fixture for: payment_method
Setting up fixture for: invoiceitem
Running fixture for: invoiceitem
Setting up fixture for: invoice
Running fixture for: invoice
Trigger failed: Request failed, status=400, body={
"error": {
"message": "You may only specify one of these parameters: pending_invoice_items_behavior, subscription.",
"param": "pending_invoice_items_behavior",
"type": "invalid_request_error"
}
}
I'm trying to override the subscription id to be one that I have locally in my system, but I'm sure I'm getting the wrong path or something?
Ok let me take a look
So yeah looks like the fixture sets pending_invoice_items_behavior behind the scenes
And you can only specify one of pending_invoice_items_behavior or subscription
Let me try one thing
Yeah unfortunately it doesn't seem currently possible to do it this way. One thing you could do is use the https://stripe.com/docs/cli/events/resend command to resend an actual event related to that subscription
it's sorta hard to resend an event when i'm testing subscription renewal :/ hmm.
i have to trigger the subscription renewal somehow.
Gotcha. You could use test clocks to advance time: https://stripe.com/docs/billing/testing/test-clocks
That's the recommended way to test subscription renewal out currently
right but that's via the dashboard, and isn't automatable as far as i can tell?
Nah you can do it through the API. Just select the API tab on that page
oooh okay. thank you ๐
and apparently test clocks are only available to paying customers? :/ i'm a consultancy, my clients have paying accounts, i just have a test account for development purposes. so that's a bit brutal
Sure but that .5% is only on live charges
You can use test clocks in testmode without any charge
that's... a bit ridiculous. why in the world would you paywall a testing feature.
it'd be one thing if the CLI worked to renew a subscription but it doesn't.
Are you using an older account?
i don't really know how old the account is.
There are also many ways to test renewal events without using test clocks. Like you can update a Sub to test a renewal.
I think you are seeing that banner because you are on an older account with grandfathered pricing. If you created a new account for instance I believe that test clocks would be included but that the default pricing is 0.5%
I don't know a ton about pricing though
Like you can update a Sub to test a renewal.
Can you clarify that?
For instance, if you reset the billing cycle anchor on a Subscription then a "renewal" would occur. You can turn off proration to just have a new invoice be generated
It wouldn't be exactly like a natural renewal as there will be a couple pieces of different data in your customer.subscription.updated event
But if you are just looking to generate the events
Then it would work fine
okay i'll give that a shot.