You can't delete invoices created by subscriptions.
See original GitHub issueHi, we are retrieving an invoice from an user that has been update to a new subscription.
We retrive the invoice:
const invoice = await stripe.invoices.retrieve('in_1EudqzBn82mIxvX2CQAf****');
And the status of the invoice is draft (status: 'draft'
), but when I try to delete the invoice like this:
await stripe.invoices.del('in_1EudqzBn82mIxvX2CQAfLwPZ');
I have this error:
You can’t delete invoices created by subscriptions.
Why I can’t delete this invoice?
This is all the flow:
// update the subscription of the user to a new plan
await stripe.subscriptions.update('sub_XXXXXX', {
plan: 'NEW_PLAN_ID',
prorate: true
});
// We need to do the INVOICE to the user:
invoice = await stripe.invoices.create({
customer: 'cus_XXXX',
subscription: 'sub_XXXXXX'
});
// The user pay the invoice, but sometimes, the customer
// don't have enough funds in the credit card, and I want to rollback the operation
const payment = await stripe.invoices.pay(invoice.id);
Thanks!!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Delete a draft invoice - Stripe API reference
Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to delete invoices that are no longer in a draft state will...
Read more >Cannot be deleted as this subscription's invoice has allocation ...
You will not be able to delete a subscription if the subscription's invoice amount is adjusted with another subscription's payment under the ...
Read more >Delete Or Void Invoice with the Stripe API - Pipedream
Delete a draft invoice, or void a non-draft or subscription invoice. [See the docs](https://stripe.com/docs/api/invoiceitems/delete) for more information.
Read more >Subscriptions & Subscription Items - Objects & Stripe Modeling
You 'll know the Subscription was successfully created in Stripe if you see the ... You can't delete the last Subscription Item record, ......
Read more >Can I delete an invoice or rollback subscription update on ...
My bad. I cannot delete an invoice, but I can close it like: stripe.invoices.update(invoiceId, { closed: true });.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is horrible. We shifted a customer from monthly to annual billing via the UI, and this incorrectly created a new subscription from today as opposed to the 1st of next month.
I then went to cancel this subscription, since there was no way to edit it, and the draft invoice still remained in place, with no way for us to delete it. Really poor experience, and I fail to see why we shouldn’t be allowed to delete automatically created invoices.
Now the customer will receive an invoice for a subscription that has already been cancelled, and I have to explain to them why this happened, and why they will receive another invoice for the actual new subscription that I have to create now… 😩
@remi-stripe Thanks for getting back! Good to know that you can’t edit a sub line item in any way. That’s definitely something (along with the inability to delete subscription invoices) that I think would be great to have reflected in the documentation.
I actually have been on two calls with Stripe support in the past two days about how to best handle this state. The first person suggested doing what you said, which is adding another item to the invoice to offset the charge. The other person I talked to in support actually didn’t know that you couldn’t delete subscription invoices, and made a note of it and said he would talk to the rest of the team.
Because I’m also intending to cancel someone’s subscription in this moment, the flow I ultimately landed on, which was suggested by the second person I talked to, was to void the invoice. However because you can’t directly void a draft invoice, this ended up being my function chain to void an invoice and cancel a subscription:
This successfully “kills” an invoice generated by a subscription and doesn’t leave something hanging out in draft mode.