@stigg/react-sdk 5.13.0 → 5.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/checkout/summary/components/getPriceBreakdownString.d.ts +3 -1
- package/dist/react-sdk.cjs.development.js +17 -10
- package/dist/react-sdk.cjs.development.js.map +1 -1
- package/dist/react-sdk.cjs.production.min.js +1 -1
- package/dist/react-sdk.cjs.production.min.js.map +1 -1
- package/dist/react-sdk.esm.js +17 -10
- package/dist/react-sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/checkout/summary/components/GraduatedPriceBreakdown.tsx +2 -0
- package/src/components/checkout/summary/components/LineItems.tsx +5 -1
- package/src/components/checkout/summary/components/getPriceBreakdownString.ts +8 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.
|
|
2
|
+
"version": "5.14.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"@emotion/react": "^11.10.5",
|
|
113
113
|
"@emotion/styled": "^11.10.5",
|
|
114
114
|
"@mui/material": "^5.12.0",
|
|
115
|
-
"@stigg/js-client-sdk": "
|
|
115
|
+
"@stigg/js-client-sdk": "3.16.0",
|
|
116
116
|
"@stripe/react-stripe-js": "^2.1.1",
|
|
117
117
|
"@stripe/stripe-js": "^1.54.1",
|
|
118
118
|
"@types/styled-components": "^5.1.26",
|
|
@@ -56,6 +56,8 @@ export function GraduatedPriceBreakdown({ price, unitQuantity }: GraduatedPriceB
|
|
|
56
56
|
billingPeriod: price.billingPeriod,
|
|
57
57
|
tiers: price.tiers,
|
|
58
58
|
tiersMode: price.tiersMode,
|
|
59
|
+
blockSize: price.blockSize,
|
|
60
|
+
priceAmount: price.amount,
|
|
59
61
|
})}
|
|
60
62
|
</Typography>
|
|
61
63
|
</LineItemRow>
|
|
@@ -67,7 +67,9 @@ export const BilledPriceLineItem = ({
|
|
|
67
67
|
const toggleNestedBreakdown = () => setIsNestedBreakdownOpen((prev) => !prev);
|
|
68
68
|
|
|
69
69
|
const isPayAsYouGo = price.pricingModel === BillingModel.UsageBased;
|
|
70
|
-
const totalAmount = price.isTieredPrice
|
|
70
|
+
const totalAmount = price.isTieredPrice
|
|
71
|
+
? calculateTierPrice(price, quantity)
|
|
72
|
+
: (price.amount || 0) * Math.ceil(quantity / (price.blockSize || 1));
|
|
71
73
|
|
|
72
74
|
let nestedBreakdown: ReactNode;
|
|
73
75
|
const shouldShowGraduatedPriceBreakdown =
|
|
@@ -117,6 +119,8 @@ export const BilledPriceLineItem = ({
|
|
|
117
119
|
billingPeriod: price.billingPeriod,
|
|
118
120
|
tiers: price.tiers,
|
|
119
121
|
tiersMode: price.tiersMode,
|
|
122
|
+
blockSize: price.blockSize,
|
|
123
|
+
priceAmount: price.amount,
|
|
120
124
|
})}
|
|
121
125
|
{isPayAsYouGo && ' / unit'}
|
|
122
126
|
</Typography>
|
|
@@ -11,6 +11,8 @@ export type GetPriceBreakdownStringProps = {
|
|
|
11
11
|
currency: Currency;
|
|
12
12
|
pricingModel: BillingModel;
|
|
13
13
|
billingPeriod: BillingPeriod;
|
|
14
|
+
blockSize?: number | null;
|
|
15
|
+
priceAmount?: Price['amount'];
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
export function formatPricePerUnit({
|
|
@@ -19,12 +21,16 @@ export function formatPricePerUnit({
|
|
|
19
21
|
pricingModel,
|
|
20
22
|
billingPeriod,
|
|
21
23
|
currency,
|
|
24
|
+
blockSize,
|
|
25
|
+
priceAmount,
|
|
22
26
|
}: GetPriceBreakdownStringProps) {
|
|
23
27
|
const isPerUnit = pricingModel === BillingModel.PerUnit;
|
|
24
|
-
const
|
|
28
|
+
const aBlockSize = blockSize || 1;
|
|
29
|
+
const featureUnits =
|
|
30
|
+
quantity && (isPerUnit || quantity > 1) ? `${numberFormatter(quantity)} ${aBlockSize > 1 ? 'for' : 'x'} ` : '';
|
|
25
31
|
const billingPeriodString = billingPeriod === BillingPeriod.Annually ? ' x 12 months' : '';
|
|
26
32
|
|
|
27
|
-
const unitPrice = totalAmount / quantity / (billingPeriod === BillingPeriod.Annually ? 12 : 1);
|
|
33
|
+
const unitPrice = (priceAmount || totalAmount / quantity) / (billingPeriod === BillingPeriod.Annually ? 12 : 1);
|
|
28
34
|
const formattedUnitPrice = currencyPriceFormatter({
|
|
29
35
|
amount: unitPrice,
|
|
30
36
|
currency,
|