#Lexmark0381
1 messages · Page 1 of 1 (latest)
hi! could you share the customer ID cus_xxx in question?
Sure, give me a sec...
also not sure why you'd call invoice.upcoming
why not call invoice.retrieve(in_xxx) to get the specific invoice?
the upcoming invoice endpoint doesn't return a real, specific invoice, it returns a preview of what the next invoice might look like
cus_Mgrdxl4AZh6by8
Because the invoice is created by Stripe and i don't know how to access the invoice ID
(btw, the customer id i sent you is in the test mode)
it would be subscription.latest_invoice for example
Okay, i'll give it a try
i.e. when you create the Subscription, you have the latest_invoice field https://dashboard.stripe.com/test/logs/req_JwEWGd5YMHszPq
So, how should i access a Subscription from a customer id?
you could call https://stripe.com/docs/api/subscriptions/list#list_subscriptions-customer for example, or you might have saved the IDs of the customer's subscription in your database when you created it, it really depends on the context
I guess in order to avoid data drifting apart I would prefer to rely on Stripe data
Found the latest_invoice 😍
Do you have any suggestions on how to create an active card, one which should fail paying and one that should succed?
generally you'd use the 'Decline after attaching' card from https://stripe.com/docs/testing#declined-payments
you can attach that card to a customer and then set it as e.g. https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method and advance time in the test clock to see the invoice payments fail
great!
Just for be clear, the Subscription becomes active as soon as invoices for it have been paid, right?
yep