-
Notifications
You must be signed in to change notification settings - Fork 452
feat(clerk-js,shared,ui): Add seats info to payment attempts page #8527
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
aeliox
wants to merge
6
commits into
feat/per-seat-costs
Choose a base branch
from
keiran/BILL-1752
base: feat/per-seat-costs
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
454faa6
add seats info to payment attempts
aeliox 3b80b87
updated layout
aeliox caaf316
Merge branch 'main' into keiran/BILL-1752
aeliox a6ba487
address feedback
aeliox 4d085c4
more feedback
aeliox 0dac161
Merge branch 'feat/per-seat-costs' into keiran/BILL-1752
aeliox 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@clerk/shared': minor | ||
| '@clerk/clerk-js': minor | ||
| '@clerk/ui': minor | ||
| --- | ||
|
|
||
| Surface seat-based billing details on payment attempts. The payment attempt resource now exposes a `totals` field (`BillingPaymentTotals`) carrying optional `baseFee` and `perUnitTotals` breakdowns. The payment-attempt detail page renders a "Seats" line (`{quantity} × {feePerBlock}`, or the tier total for unlimited tiers) between the plan title and subtotal when the subscription item is seat-billed. |
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,70 @@ | ||
| import type { BillingMoneyAmountJSON, BillingPaymentTotalsJSON } from '@clerk/shared/types'; | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { billingPaymentTotalsFromJSON } from '../billing'; | ||
|
|
||
| const moneyJSON = (amount: number): BillingMoneyAmountJSON => ({ | ||
| amount, | ||
| amount_formatted: (amount / 100).toFixed(2), | ||
| currency: 'USD', | ||
| currency_symbol: '$', | ||
| }); | ||
|
|
||
| describe('billingPaymentTotalsFromJSON', () => { | ||
| it('maps subtotal, grand_total, and tax_total', () => { | ||
| const data: BillingPaymentTotalsJSON = { | ||
| subtotal: moneyJSON(4500), | ||
| grand_total: moneyJSON(5000), | ||
| tax_total: moneyJSON(500), | ||
| }; | ||
|
|
||
| const totals = billingPaymentTotalsFromJSON(data); | ||
|
|
||
| expect(totals.subtotal.amount).toBe(4500); | ||
| expect(totals.grandTotal.amount).toBe(5000); | ||
| expect(totals.taxTotal.amount).toBe(500); | ||
| expect(totals.baseFee).toBeNull(); | ||
| expect(totals.perUnitTotals).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('maps base_fee when present', () => { | ||
| const data: BillingPaymentTotalsJSON = { | ||
| subtotal: moneyJSON(5000), | ||
| grand_total: moneyJSON(5000), | ||
| tax_total: moneyJSON(0), | ||
| base_fee: moneyJSON(1000), | ||
| }; | ||
|
|
||
| expect(billingPaymentTotalsFromJSON(data).baseFee?.amount).toBe(1000); | ||
| }); | ||
|
|
||
| it('maps per_unit_totals tiers with snake_case → camelCase conversion', () => { | ||
| const data: BillingPaymentTotalsJSON = { | ||
| subtotal: moneyJSON(5000), | ||
| grand_total: moneyJSON(5000), | ||
| tax_total: moneyJSON(0), | ||
| per_unit_totals: [ | ||
| { | ||
| name: 'seats', | ||
| block_size: 1, | ||
| tiers: [ | ||
| { quantity: 5, fee_per_block: moneyJSON(1000), total: moneyJSON(5000) }, | ||
| { quantity: null, fee_per_block: moneyJSON(0), total: moneyJSON(0) }, | ||
| ], | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| const totals = billingPaymentTotalsFromJSON(data); | ||
|
|
||
| expect(totals.perUnitTotals).toHaveLength(1); | ||
| expect(totals.perUnitTotals?.[0].name).toBe('seats'); | ||
| expect(totals.perUnitTotals?.[0].blockSize).toBe(1); | ||
| expect(totals.perUnitTotals?.[0].tiers[0]).toMatchObject({ | ||
| quantity: 5, | ||
| feePerBlock: { amount: 1000 }, | ||
| total: { amount: 5000 }, | ||
| }); | ||
| expect(totals.perUnitTotals?.[0].tiers[1].quantity).toBeNull(); | ||
| }); | ||
| }); |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.