Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

billing: Start billing cycle on the 1st each month #3748

Merged
merged 5 commits into from
May 17, 2024
Merged

Conversation

ZJvandeWeg
Copy link
Member

For billing insights and understand early in the month about where our revenue is going to end I've updated the billing cycle to start the 1st of each month. The default behaviour is to start the month the date + time they start their subscription.

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production

Labels

  • Backport needed? -> add the backport label
  • Includes a DB migration? -> add the area:migration label

@ZJvandeWeg ZJvandeWeg requested a review from knolleary April 18, 2024 17:28
Copy link

codecov bot commented Apr 18, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 79.25%. Comparing base (05a4c0d) to head (71d525f).
Report is 7 commits behind head on main.

Current head 71d525f differs from pull request most recent head 4b614fe

Please upload reports for the commit 4b614fe to get more accurate results.

Files Patch % Lines
forge/ee/lib/billing/index.js 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3748      +/-   ##
==========================================
- Coverage   79.26%   79.25%   -0.01%     
==========================================
  Files         281      281              
  Lines       12723    12728       +5     
  Branches     2838     2838              
==========================================
+ Hits        10085    10088       +3     
- Misses       2638     2640       +2     
Flag Coverage Δ
backend 79.25% <75.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@knolleary knolleary left a comment

Choose a reason for hiding this comment

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

billing_cycle_anchor_config isn't a valid parameter for the stripe.checkout.sessions.create(..) function we use.

According to the docs, we have to use subscription_data.billing_cycle_anchor which lacks the convenice of billing_cucle_anchor_config as we'll have to calculate the timestamp of the next 1st of the month ourselves.

For billing insights and understand early in the month about where our
revenue is going to end I've updated the billing cycle to start the 1st
of each month. The default behaviour is to start the month the date +
time they start their subscription.
@ZJvandeWeg
Copy link
Member Author

@knolleary I'm sorry; I don't quite now how to validate my changes. The only test I could think of was to spy on the map/hash constructed, which felt silly. But I don't have a great Stripe test setup. Do you know how to achieve this and validate my hacking?

@knolleary
Copy link
Member

@ZJvandeWeg I'll take a look. I have stripe setup locally; what is harder to test is time-based events in the future where you want to check what happens at invoice time etc. That's something we have to do fairly manually.

@knolleary knolleary self-assigned this May 16, 2024
@knolleary
Copy link
Member

Initial test looks good. Here is what the checkout page shows:

image

Are we happy with that?

@ZJvandeWeg
Copy link
Member Author

I like this a lot, thanks @knolleary !

@knolleary knolleary enabled auto-merge May 17, 2024 07:59
@knolleary knolleary merged commit 32d1c89 into main May 17, 2024
10 checks passed
@knolleary knolleary deleted the zj-billing-cycle branch May 17, 2024 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants