#pro-pooja_webhooks
1 messages · Page 1 of 1 (latest)
👋 Welcome to your new thread!
⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1235257308058226711
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- pro-pooja_api, 1 day ago, 25 messages
- pro-pooja_webhooks, 5 days ago, 28 messages
Hello! When a new Subscription period starts a new Invoice is created, so it sounds like you want to listen for invoice.created which will have details about the amount due.
How can I differentiate the invoice is for new billing cycle only, not created by other action
Look at the billing_reason property on the Invoice: https://docs.stripe.com/api/invoices/object#invoice_object-billing_reason
Another question I have is, how can I implement this?
if a customer has downgraded in the same month and adds the same amount £ of items in the same month, they wouldn’t be charged any additional money that month because they’ve returned to the same level plan. If they go above the plan amount they were on before with items they’d be charged immediately.
Sounds like you want to look at prorations: https://docs.stripe.com/billing/subscriptions/prorations
If I apply the proration, let's say I have 2 products a and b, user subscribes with 1a and 2b => total = 3 , then downgrades to 1a and 0b => total = 1 then user should not be charged anything, but again if user upgrades to 1a and 3b => total = 4 user should be charged for the difference, of max which 4-3 and charged for 1 item only. Proration is agian charging for 3 items.
Is this behavior you're seeing in test mode? If so, do you have a specific question about it?
yes, check this subscription - sub_1PBFvXGVCe8mF8QWo0iiS1G7
Here , Intially user paid , £30 for 2+3 => 5, then downgrades 0+3=> 3 charged nothing, then upgrades 3+3 = 6 and charged £15 , instead of £5 (Last max total was 5 - current total is 6 = 1)
Proration is not working in this scenarion
Not sure I understand. The latest Invoice on this Subscription is charging them for quantity 3 of a 5.00 item, and the proration calculation is coming out to 14.996 behind the scenes because basically no time has passed, so that's being rounded up to the 15.00 they're being charged. This seems normal and expected to me.
in this case, User has already paid £30.00 for 5 items and now after downgrading and upgrading users total is 6 items £35.00, which should be charged like £35.00 - £30.00 = £5, irrespective of the how much time is passed.
One moment, grabbing someone who's better equipped to explain this in detail than I am. 🙂
👋 hopping in here - the key thing to remember with prorations is that they're only calculated based on the most recent state of the Subscription. So if you were to do multiple upgrades like this:
- downgrade from quantity 3 -> 1
- upgrade from quantity 1 -> 3
The prorations we calculate for that last upgrade will be based on the Subscripton having quantity 1 when the upgrade occurs.
Okay, then what is the workaround to charge customer as per the scenario I described
Also I just want to clarify one thing - the way we calculate prorations wouldn't give you £5 irrespective of time in the scenario you laid out. Our prorations are calculated to the second, so for an upgrade from 5 -> 6 exactly halfway through the cycle you'd see something more like:
- £15 credit back (£30 / 2 to credit back for the half of the cycle we paid at the £30 price since we're upgrading halfway)
- £17.5 debit (£35 / 2 to debit for the half of the remaining cycle we're going to pay at the new £35 price since we're upgrading halfway)
To get the behavior you want you'd need to disable the prorations Stripe calculates/creates and calculate your own prorations. Based on those calculations you can create Invoice Items that you can choose to immediately Invoice for, or have them rolled into the next Invoice of the Subscription automatically
If I create an invoice halfway through the month with new charges, will it affect the invoice for the next billing cycle?
No, it shouldn't have any affect on the next Invoice that's automatically generated
If i want to create Invoice with multiple line items , how can I do that?
I am a little consfused in this APIs - https://docs.stripe.com/api/invoices/create and https://docs.stripe.com/api/invoiceitems/create
Are you there?
I can jump back in and answer this one. What specifically is giving you trouble? What have you tried?
If I want to charge the user for 2 items, then how to generate an invoice - https://docs.stripe.com/api/invoiceitems/create, here there is no option to attach multiple items there?
What is the difference between this 2 apis?
Correct, you can't add line items when you create the Invoice. Generally you create the Invoice first, then you create the line items and specify the Invoice you want them on: https://docs.stripe.com/api/invoiceitems/create#create_invoiceitem-invoice
So, to add multiple line items, do I need call this API multiple times - https://docs.stripe.com/api/invoiceitems/create,
Yes.
What is the parameter to attach the line items to invoice , I don't see any parameter like invoice id in - https://docs.stripe.com/api/invoiceitems/create
is it not mentioned in the doc, or I can't find it?
I linked directly to it: https://docs.stripe.com/api/invoiceitems/create#create_invoiceitem-invoice
That screenshot is from that link.
What do you see when you click on that link?
Seeing it, thanks
How can I apply this tax id - txr_1NhXbEGVCe8mF8QWAiKDGU0h, while creating invoices item?
What have you tried so far?
is it tax_rates prameter
Please take your time and be more clear with your wording. It's very difficult for us to respond to partial sentences without URLs to the API reference where the parameter you're talking about exists
sorry for the confusion - https://docs.stripe.com/api/invoiceitems/create#create_invoiceitem-invoice, in this api how to apply tax ? I've this tax id - txr_1NhXbEGVCe8mF8QWAiKDGU0h in my account
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Have you tried creating a test-mode Invoice Item with that Tax ID? What happens when you do?
it applies 20% vat on invoice.
I just want to know here - https://docs.stripe.com/api/invoiceitems/create#create_invoiceitem-invoice for tax_rates param which value should be there?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
It sounds like you already know: the value is a tax rate
Unless I'm missing something. Again, please explain more thoroughly. You passed a Tax Rate to the tax_rate parameter and it's showing the Tax Rate applied 20% VAT to your Invoice Item. All of this is very normal and expected, so if something is not looking correct, please try to be more descriptive.
I haven't applied this tax rate while creating invoice I've applied it when creating a checkout session where the param name is different, so that wanted to confirm it is same or not?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
What do you mean by "the same"? Isn't the behavior what you would expect?
Its same I just checked by applying
Great!
https://dashboard.stripe.com/test/invoices/in_1PBhR4GVCe8mF8QWDDnYzZ6W , i've created this invoice via code but its status is in draft
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
while I need to charge it immediately
$stripe->invoices->create([
'customer' => $customerId,
'collection_method' => 'charge_automatically',
]);
Does the Customer have a valid default Payment Method set in invoice_settings.default_payment_method?
https://docs.stripe.com/api/customers/update#update_customer-invoice_settings-default_payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Yes, default payment method is card, currently in test mode, test card is attached.
I'd recommend reading through this: https://docs.stripe.com/invoicing/overview?dashboard-or-api=api
If you're creating Invoices outside of a Subscription, then you need to manually transition it through its status from draft to open and/or make an API call to pay the Invoice: https://docs.stripe.com/invoicing/overview?dashboard-or-api=api&lang=python#paid
$invoice = $this->stripe->invoices->create([
'customer' => $customerId,
'collection_method' => 'charge_automatically',
'subscription' => 'sub_1PBXKVGVCe8mF8QW4VMFUJJA',
]);
Tried this, invoice is attached to subscription but still in draft status
Hold on, let's back up. This is a Subscription integration? What are you actually trying to do here? Why are you adding the Invoice to the Subscription instead of letting the Subscription create the Invoice automatically?