#Vinz
1 messages · Page 1 of 1 (latest)
You'd use the preview invoice endpoint: https://stripe.com/docs/api/invoices/upcoming
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I do
return stripe.Invoice.upcoming(
subscription=stripe_subcription_id,
subscription_items=subscription_items
)
Ok, and was the result not what you expected?
but the the invoice.period_end returned is the day of period_start of the current subscruption
(subscription created yesterday in test 22/02/2023) but I want the next invoice to be updated at current_period_end 22/03/2023
I think you'll need to pass subscription_billing_cycle_anchor: https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription_billing_cycle_anchor
Otherwise we'll assume the update is happening 'now'.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Well the invoice.period_end is still today
elif stripe_subcription_id and subscription_items:
return stripe.Invoice.upcoming(
subscription=stripe_subcription_id,
subscription_billing_cycle_anchor="unchanged",
subscription_items=subscription_items
)
elif stripe_customer_id:
return stripe.Invoice.upcoming( # Retrieve next invoice.
customer=stripe_customer_id,
automatic_tax={'enabled': True},
subscription_billing_cycle_anchor="unchanged",
subscription_items=subscription_items
)
You need to pass a timestamp for when you'd want the changes to come into effect (i.e. 22/03/2023)
subscription_start_date ?
it cannot be for subscription_billing_cycle_anchor since it is here for existing subscription
For new subscriptions, a future timestamp to anchor the subscription’s billing cycle. This is used to determine the date of the first full invoice, and, for plans with month or year intervals, the day of the month for subsequent invoices. For existing subscriptions, the value can only be set to now or unchanged.
Hi! I'm taking over this thread. Give me a few minutes to catchup.
You can set the subscription_proration_date if you want to display the preview of the upcoming invoice when a subscription is updated and there'll be a proration.
https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription_proration_date
no, there won't be proration. I want to display price for subscription update for next billing cycle
When calling the upcoming invoice endpoint, you need to set the updated subscription item:
https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription_items
And set the subscription_proration_date at the next billing cycle date. You should get the preview of the Subscription. And as the proration date will be the start of the next billing cycle, you should get proration 0.