satyashetty
satyashetty

Reputation: 1

How to void a invoice automatically in stripe after automated retries have failed for a subscription as a result Subscription is Canceled

I am trying to void a invoice associated with a Subscription in stripe. Below is the scenerio:

  1. Customer starts free trial or is currently subscribed with payment on file
  2. On trying to charge the customer payment fails & Invoice goes into overdue state
  3. Subscription Cancelled - After repeated automated tries the subscription is automatically cancelled since invoice wasnt paid
  4. At this point i would like the invoice to be voided

I want the invoice to be voided as if the customer comes back and updates his payment method stripe gives the customer the option to pay the invoice. If the customer pays the invoice this would clear the invoice however, the sbscription is still in the cancelled state. So, the customer might raise a dispute stating that he wanted to continue the subscription, however he paid for a canceled subscription. I would rather that the customer subscribes to a fresh subscription , since the previous subscription is already in cancelled state

Any Ideas? how to voide a invoice automatically Or Any other ways to look at solving the problem

i tried making the invoice uncollectable. However, even in this state the invoice can be paid by customer

Upvotes: 0

Views: 826

Answers (1)

Jonathan Steele
Jonathan Steele

Reputation: 1938

The only terminal invoice status that will prevent payment is void. An uncollectible invoice can still be paid, as you note.

Voiding invoices on subscription cancellation cannot be enabled automatically. The only way is via the API. My recommendation:

  1. Configure a webhook to listen for customer.subscription.deleted events, which fire on subscription cancellation.
  2. Look up any open invoices for the cancelled subscription via the list endpoint, passing the subscription and status parameters.
  3. Loop through the request response, calling the void endpoint for each returned Invoice object.

Upvotes: 1

Related Questions