Skip to content

Conversation

vincent-pochet
Copy link
Collaborator

Context

We are receiving Idempotency::IdempotencyError for progressive billing invoices generation on terminated subscriptions.

Description

We should not generate progressive billing invoices for terminated subscriptions as the usage will be billed anyway with the termination invoice.

This PR simply adds a check on the subscription status before proceeding with the invoice generation.

Copy link
Contributor

@groyoh groyoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that a due to a CRON job that gets triggered after the subscription is terminated ?

@vincent-pochet
Copy link
Collaborator Author

Is that a due to a CRON job that gets triggered after the subscription is terminated ?

It's a race condition:

  • An events is received, so the lifetime usage is flagged for refresh
  • The subscription is terminated
  • A clock job is enqueuing the refresh task on the lifetime usage
  • It fails because we do not recompute the usage for a terminated subscription so it ends up with trying to bill a threshold that was already reached. The Idempotency logic is raising an error

We should not end in this situation anyway as the usage is supposed to be billed with the termination invoice

@vincent-pochet vincent-pochet merged commit bb758ab into main Jul 1, 2025
14 checks passed
@vincent-pochet vincent-pochet deleted the fix-progressive-billing-terminated branch July 1, 2025 10:24
@groyoh
Copy link
Contributor

groyoh commented Jul 1, 2025

Thanks for the explanation @vincent-pochet 🙏

diegocharles pushed a commit that referenced this pull request Jul 11, 2025
…criptions (#3893)

## Context

We are receiving ` Idempotency::IdempotencyError` for progressive
billing invoices generation on terminated subscriptions.

## Description

We should not generate progressive billing invoices for terminated
subscriptions as the usage will be billed anyway with the termination
invoice.

This PR simply adds a check on the subscription status before proceeding
with the invoice generation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants