-
Notifications
You must be signed in to change notification settings - Fork 2
feat(billing): implement promo code functionality #657
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
Open
Dobrunia
wants to merge
34
commits into
master
Choose a base branch
from
feat/promo-code
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
9d1f51a
feat(billing): implement promo code functionality and update related …
Dobrunia d03e093
Bump version up to 1.5.4
github-actions[bot] fb4e419
utm
Dobrunia e85c91e
chore: update @hawk.so/types to version 0.6.3
Dobrunia 0aa6738
fix
Dobrunia 72a6e60
feat(promoCode): enhance discount logic and add tests for plan applic…
Dobrunia 377fa6f
feat(billing): refactor promo code handling and update payment data s…
Dobrunia e926076
lint fix
Dobrunia 4c25dc0
feat(billing): introduce PaymentPromoBenefitType and update promo dat…
Dobrunia 515a9e8
refactor(billing): streamline promo code handling and update payment …
Dobrunia 94001e8
refactor(billing): enhance payment amount validation and improve prom…
Dobrunia 5b2f68a
feat(billing): enhance promo code validation and extend admin checks …
Dobrunia 0b74706
feat(billing): implement previewOrApplyPromoCode function to streamli…
Dobrunia 1197be9
refactor(billing): update promo code handling to calculate payment am…
Dobrunia 210de9f
refactor(billing): move PromoCodeService to services directory and re…
Dobrunia cad0777
fix(billing): improve error handling in workspace billing updates and…
Dobrunia 2f8e5b5
feat(billing): add tests for promo code application and validation in…
Dobrunia be4f3b2
feat(billing): implement promo usage reservation and rollback mechani…
Dobrunia f5b405f
refactor(billing): simplify promo code retrieval and improve index in…
Dobrunia 10f578e
feat(billing): enhance promo validation and payment processing logic …
Dobrunia 7945cdb
refactor(billing): remove unused index initialization logic from prom…
Dobrunia d782e2b
refactor(billing): rename and restructure promo code application logi…
Dobrunia e9ed561
refactor(billing): rename applyPromoCode to verifyPromoCode and updat…
Dobrunia b0ef27a
refactor(billing): streamline promo code pricing calculation logic fo…
Dobrunia 627f8fb
refactor(migrations): update index dropping syntax for promo codes an…
Dobrunia cf31f71
refactor(billing): enhance CloudPayments test suite with additional m…
Dobrunia e0af65c
refactor(billing): improve promo code usage creation logic and enhanc…
Dobrunia 5693467
refactor(billing): remove unused promo code fields and simplify payme…
Dobrunia 158f2ef
refactor(billing): enhance promo billing test suite with improved fix…
Dobrunia 02d13a2
fix (tests)
Dobrunia 910ac27
refactor(billing): enhance CloudPayments webhook handling and improve…
Dobrunia 2e5ad23
test(billing): add tests for subscription renewal data retrieval and …
Dobrunia 36af36d
refactor(billing): remove unused promo code fields and update charge …
Dobrunia 9c2e51e
test(billing): add tests for card-link checksum handling and amount v…
Dobrunia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { Collection, ObjectId } from 'mongodb'; | ||
| import AbstractModel from './abstractModel'; | ||
| import { | ||
| PromoCodeBenefit, | ||
| PromoCodeDBScheme | ||
| } from '@hawk.so/types'; | ||
|
|
||
| /** | ||
| * Model representing promo code settings. | ||
| */ | ||
| export default class PromoCodeModel extends AbstractModel<PromoCodeDBScheme> implements PromoCodeDBScheme { | ||
| /** | ||
| * Promo code id. | ||
| */ | ||
| public _id!: ObjectId; | ||
|
|
||
| /** | ||
| * Normalized promo code value. | ||
| */ | ||
| public value!: string; | ||
|
|
||
| /** | ||
| * Benefit granted by this promo code. | ||
| */ | ||
| public benefit!: PromoCodeBenefit; | ||
|
|
||
| /** | ||
| * Maximum successful usages count. | ||
| */ | ||
| public limit?: number; | ||
|
|
||
| /** | ||
| * Expiration date. | ||
| */ | ||
| public expiresAt?: Date; | ||
|
|
||
| /** | ||
| * Creation date. | ||
| */ | ||
| public createdAt!: Date; | ||
|
|
||
| /** | ||
| * Last update date. | ||
| */ | ||
| public updatedAt!: Date; | ||
|
|
||
| /** | ||
| * Creator id. | ||
| */ | ||
| public createdBy!: string; | ||
|
|
||
| /** | ||
| * Model's collection. | ||
| */ | ||
| protected collection: Collection<PromoCodeDBScheme>; | ||
|
|
||
| /** | ||
| * Create PromoCode instance. | ||
| * | ||
| * @param promoCodeData - promo code data | ||
| */ | ||
| constructor(promoCodeData: PromoCodeDBScheme) { | ||
| super(promoCodeData); | ||
| this.collection = this.dbConnection.collection<PromoCodeDBScheme>('promoCodes'); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import { Collection, ObjectId } from 'mongodb'; | ||
| import AbstractModel from './abstractModel'; | ||
| import { | ||
| PromoCodeBenefitType, | ||
| PromoCodeUsageDBScheme | ||
| } from '@hawk.so/types'; | ||
|
|
||
| /** | ||
| * Model representing successful promo code application. | ||
| */ | ||
| export default class PromoCodeUsageModel extends AbstractModel<PromoCodeUsageDBScheme> implements PromoCodeUsageDBScheme { | ||
| /** | ||
| * Promo code usage id. | ||
| */ | ||
| public _id!: ObjectId; | ||
|
|
||
| /** | ||
| * Applied promo code id. | ||
| */ | ||
| public promoCodeId!: ObjectId; | ||
|
|
||
| /** | ||
| * User who applied promo code. | ||
| */ | ||
| public userId!: string; | ||
|
|
||
| /** | ||
| * Workspace where promo code was applied. | ||
| */ | ||
| public workspaceId!: ObjectId; | ||
|
|
||
| /** | ||
| * Plan to which promo was applied. | ||
| */ | ||
| public planId?: ObjectId; | ||
|
|
||
| /** | ||
| * Benefit type at application time. | ||
| */ | ||
| public benefitType!: PromoCodeBenefitType; | ||
|
|
||
| /** | ||
| * Price before promo. | ||
| */ | ||
| public originalAmount?: number; | ||
|
|
||
| /** | ||
| * Price after promo. | ||
| */ | ||
| public finalAmount?: number; | ||
|
|
||
| /** | ||
| * Actual discount amount. | ||
| */ | ||
| public discountAmount?: number; | ||
|
|
||
| /** | ||
| * UTM parameters captured on apply. | ||
| */ | ||
| public utm?: PromoCodeUsageDBScheme['utm']; | ||
|
|
||
| /** | ||
| * Application date. | ||
| */ | ||
| public appliedAt!: Date; | ||
|
|
||
| /** | ||
| * Model's collection. | ||
| */ | ||
| protected collection: Collection<PromoCodeUsageDBScheme>; | ||
|
|
||
| /** | ||
| * Create PromoCodeUsage instance. | ||
| * | ||
| * @param usageData - usage data | ||
| */ | ||
| constructor(usageData: PromoCodeUsageDBScheme) { | ||
| super(usageData); | ||
| this.collection = this.dbConnection.collection<PromoCodeUsageDBScheme>('promoCodeUsages'); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets wrap it with "promo" property. Also, maybe
promo.idis enough?