Skip to content

feat: updates subscription billing cycle on invoice.issued event#22

Merged
ecktoteckto merged 1 commit into
mainfrom
feat/update-stale-subscriptions
Oct 6, 2024
Merged

feat: updates subscription billing cycle on invoice.issued event#22
ecktoteckto merged 1 commit into
mainfrom
feat/update-stale-subscriptions

Conversation

@ecktoteckto

Copy link
Copy Markdown
Contributor

Orb currently has no webhook whenever a billing cycle is reset, so subscription billing cycle information may be outdated. As a workaround we check whether an issued invoice contains a plan line item. A plan line item bein present means that there was a billing cycle reset and you can find the billing cycle's start and end date in the line item.

billingCycleEnd: string;
}
) {
return postgresClient.update(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it would be safer if this method ensures

  • the billingCycleEnd date is in the future, otherwise skip
  • the billingCycleStart date is in the past at the time of the check, otherwise skip
  • the update statement should ideally have an additional condition in the where clause ensuring it only gets updated if the current end_date is in the past

I'd prefer having a very specific update SQL statement for this function instead of a generic upsert to ensure that

Comment thread packages/orb-sync-lib/src/invoice-utils.ts
Comment thread apps/node-fastify/src/utils/config.ts
Comment thread packages/orb-sync-lib/src/database/postgres.ts
Comment thread packages/orb-sync-lib/src/invoice-utils.ts Outdated
Comment thread packages/orb-sync-lib/src/schemas/subscription.ts Outdated
Orb currently has no webhook whenever a billing cycle is reset, so subscription billing cycle information may be outdated.
As a workaround we check whether an issued invoice contains a plan line item. A plan line item bein present means that there
was a billing cycle reset and you can find the billing cycle's start and end date in the line item.
@ecktoteckto
ecktoteckto force-pushed the feat/update-stale-subscriptions branch from 2556be2 to f6793a2 Compare October 6, 2024 11:11
@ecktoteckto
ecktoteckto merged commit 040c874 into main Oct 6, 2024
@ecktoteckto
ecktoteckto deleted the feat/update-stale-subscriptions branch October 6, 2024 11:14
@github-actions

github-actions Bot commented Oct 6, 2024

Copy link
Copy Markdown

🎉 This PR is included in version 1.6.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants