#aaparth-subscriptions
1 messages ยท Page 1 of 1 (latest)
@lean oxide a prorated amount from the time you create the subscription to when the billing anchor is
like if the price is $100 and you create it on the 15th of the month and the anchor is the 1st of the month, the prorated amount they're charged today is roughly $50, for example.
yeah that I have got it but is there anyway or any api in which I can pass on the price id and billing anchor to check how much will they be charged
yes, you want the upcoming invoice endpoint.
I have not yet created the subscription
https://stripe.com/docs/api/invoices/upcoming with the details of the subscription you're going to create
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
doesn't matter, it still works! I'd suggest trying it.
okay let me check
@gloomy osprey
I tried it but it didn't worked
can you elaborate? what did you see versus what you expected to see?
I wants to create a subscription with the price_id= price_1K01PICmxQwltEUMcvD9VJSd, and I am passing the billing anchor = 1638316800000
so now stripe will not charge the full amount of 67.32 from the customer it will only charge till the billing anchor.
Now I want to know how stripe calculate the amount to be charged so that I will be able to show the same amount to my customer
sounds good! What code did you try to call that upcoming invoice endpoint then?
I tried it on the postman
actually I am unsure on what param to pass to get the upcoming invoice
what did you try?
if it helps I did it just now in Node, it's these parameters :
const invoice = await stripe.invoices.retrieveUpcoming({
customer: customer.id,
subscription_items:[{price:"plan_DQYe83yUGgx1LE"}],
subscription_billing_cycle_anchor:"1638316800",
});
you pass the items you want, and the billing anchor. It's all in the API reference. https://stripe.com/docs/api/invoices/upcoming?lang=node#upcoming_invoice-subscription_billing_cycle_anchor
the response will have a line item for the amount. ($14.54 in my particular case, would be different for you).
I'd suggest giving it a try! if you're stuck with something please share exactly what you're tried so far.
Thank you so much @gloomy osprey ๐๐ป