Commit ead42c1
feat: SMS credits for free users (calcom#21245)
* Add credits section to billing
* create seperate router for credits
* add stripe checkout session
* schema changes + code improvements
* rename to creditBalance
* custom quantify input with error message
* add checkout session completed webhook endpoint
* fix typo
* UI fixes
* add payCredits handler
* add error toast message
* allow scheduling sms up as close to 15 minutes in the future
* schedule at most 2 hours in advance
* webhook to pay for sent sms
* continued work on twilio callback
* code clean up
* further implementation for credit handling
* add migration
* object as param for scheduleSMS
* object as param for sendSMS
* fix TrpcSessionUser imports
* fix imports
* add db changes
* add cron job for price setting
* twilio status callback to create expense log
* remove unused code
* set up low credit balance email
* fixes for buying credits
* fixes in api/twilio/webhook
* add test to save credits to credits balance
* fix typos
* add new helper function chargeCredits
* expand twilioProvider
* fix type errors
* adjust tests
* type errors
* clean up
* clean up
* fix subscription active check
* remove some user/org related code
* more changes to remove user/org support
* send emails seperatly to admins
* fixes for team billing page
* fix stripe success url
* fixes to creating expense log
* email imrovements and more
* get monthly team price from stripe
* fix import
* fix monthly credits calculation
* finsih low credit balance warning email
* credit balance limit reached email
* create CreditService
* cancel SMS and send as email instead
* add messageDispatcher
* fix type error
* fix type error
* fix type error
* fix import
* fix unit test
* clean up twilioProvider
* clean up chckSmsPrices/route
* add missing translations
* add skeleton loader
* add admin check to get handler
* code clean up + fixes
* improve scheduling with fallback
* fix type error
* add bookingUid to handleSendingSMS
* add unit tests for creditService
* add more tests to credit-service.test.ts
* add test for cancelScheduledMessagesAndScheduleEmails
* fix test and type error
* add back resolve
* fix empty resolve
* adjust limitReachedAt logic
* address mrge comment on styling
* add getAdminMembership to repository
* twilio/webhook clean up (feedback)
* feedback - clean up
* remove todo comment
* clean up twilio/webhook
* code clean up
* add use client
* add createOneTimeCheckout to stripe service
* refactor repository pattern
* small fixes + clean up
* fix type error
* add missing import
* fix hasAvailableCredits for user
* force-dynamic
* rename credits to creditBalance
* fix stripe import
* remove not needed code
* fix e2e tests
* improve low balance warning email
* dynamic-import CreditService
* index.ts
* add user logic checkSmsPrices endpoint
* fix e2e tests
* remove dynamic import CreditService
* Revert "remove dynamic import CreditService"
This reverts commit e272978.
* no need to dynamic-import credit service
* Revert "no need to dynamic-import credit service"
This reverts commit ba5ae48.
* fix twilio webhook
* add userId support in checkout.session.completed
* clean up code
* only select id in getAdminMembership
* revert billing/package.json
* fix type checks
* fix type checks
* adjust hasAvailableCredits function
* fixes for checkout sessioned completed
* add UI for user
* fix type errors
* adds requires credits badge
* remove team check from update.handler
* clean up inlcude statements
* fix credit-service tests
* add tests
* fix type errors
* fix type errors
* fix and add tests
* imrove badge
* code clean up
* add reminderScheduler test
* add additional credits as title
* fixes for warningSentAt and limitReachedAt
* mock stripe
---------
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: hbjORbj <sldisek783@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>1 parent e669996 commit ead42c1
30 files changed
Lines changed: 1147 additions & 488 deletions
File tree
- apps/web
- app/api/cron/checkSmsPrices
- modules/settings/billing/components
- pages/api/twilio
- public/static/locales/en
- packages
- emails
- src/templates
- templates
- features/ee
- billing
- api/webhook
- workflows
- components
- lib
- reminders
- lib/server/repository
- trpc/server/routers/viewer
- credits
- workflows
- ui/components
- badge
- form/select
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
84 | | - | |
85 | | - | |
| 85 | + | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
90 | 94 | | |
91 | | - | |
| 95 | + | |
92 | 96 | | |
93 | 97 | | |
94 | | - | |
95 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
96 | 101 | | |
97 | 102 | | |
98 | 103 | | |
| |||
Lines changed: 33 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 31 | + | |
35 | 32 | | |
36 | 33 | | |
37 | 34 | | |
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
41 | 38 | | |
42 | | - | |
| 39 | + | |
43 | 40 | | |
44 | 41 | | |
45 | 42 | | |
46 | 43 | | |
47 | | - | |
| 44 | + | |
48 | 45 | | |
49 | 46 | | |
50 | 47 | | |
51 | | - | |
52 | | - | |
| 48 | + | |
53 | 49 | | |
54 | 50 | | |
55 | 51 | | |
56 | 52 | | |
57 | 53 | | |
58 | 54 | | |
59 | 55 | | |
60 | | - | |
61 | | - | |
62 | | - | |
| 56 | + | |
| 57 | + | |
63 | 58 | | |
64 | 59 | | |
65 | 60 | | |
| |||
71 | 66 | | |
72 | 67 | | |
73 | 68 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | | - | |
90 | | - | |
91 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
92 | 98 | | |
93 | 99 | | |
94 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
155 | 159 | | |
156 | 160 | | |
157 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3195 | 3195 | | |
3196 | 3196 | | |
3197 | 3197 | | |
| 3198 | + | |
3198 | 3199 | | |
| 3200 | + | |
3199 | 3201 | | |
| 3202 | + | |
3200 | 3203 | | |
| 3204 | + | |
3201 | 3205 | | |
3202 | 3206 | | |
3203 | 3207 | | |
| |||
3211 | 3215 | | |
3212 | 3216 | | |
3213 | 3217 | | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
3214 | 3221 | | |
3215 | 3222 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
762 | 762 | | |
763 | 763 | | |
764 | 764 | | |
765 | | - | |
766 | | - | |
| 765 | + | |
| 766 | + | |
767 | 767 | | |
768 | 768 | | |
769 | | - | |
| 769 | + | |
| 770 | + | |
770 | 771 | | |
771 | 772 | | |
772 | 773 | | |
773 | 774 | | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
774 | 781 | | |
775 | 782 | | |
776 | | - | |
777 | | - | |
778 | | - | |
| 783 | + | |
| 784 | + | |
779 | 785 | | |
780 | | - | |
781 | | - | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
782 | 794 | | |
783 | 795 | | |
784 | | - | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
785 | 799 | | |
786 | 800 | | |
787 | 801 | | |
788 | 802 | | |
| 803 | + | |
789 | 804 | | |
790 | | - | |
| 805 | + | |
791 | 806 | | |
792 | 807 | | |
793 | 808 | | |
794 | | - | |
| 809 | + | |
| 810 | + | |
795 | 811 | | |
796 | 812 | | |
797 | 813 | | |
798 | 814 | | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
799 | 821 | | |
800 | | - | |
801 | | - | |
| 822 | + | |
802 | 823 | | |
803 | | - | |
804 | | - | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
805 | 831 | | |
806 | 832 | | |
807 | | - | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
808 | 836 | | |
Lines changed: 26 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
23 | 44 | | |
24 | | - | |
| 45 | + | |
25 | 46 | | |
26 | 47 | | |
27 | 48 | | |
28 | 49 | | |
29 | | - | |
| 50 | + | |
30 | 51 | | |
31 | 52 | | |
32 | 53 | | |
33 | 54 | | |
34 | | - | |
| 55 | + | |
35 | 56 | | |
36 | 57 | | |
37 | | - | |
| 58 | + | |
38 | 59 | | |
39 | 60 | | |
40 | 61 | | |
0 commit comments