payment-kit 1.13.36 → 1.13.37
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/blocklet.yml +1 -1
- package/package.json +3 -3
- package/src/components/checkout/product-item.tsx +2 -2
- package/src/libs/util.ts +29 -11
package/blocklet.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.37",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"@abtnode/types": "1.16.17-beta-952ef53d",
|
|
104
104
|
"@arcblock/eslint-config": "^0.2.4",
|
|
105
105
|
"@arcblock/eslint-config-ts": "^0.2.4",
|
|
106
|
-
"@did-pay/types": "1.13.
|
|
106
|
+
"@did-pay/types": "1.13.37",
|
|
107
107
|
"@types/cookie-parser": "^1.4.4",
|
|
108
108
|
"@types/cors": "^2.8.14",
|
|
109
109
|
"@types/dotenv-flow": "^3.3.1",
|
|
@@ -140,5 +140,5 @@
|
|
|
140
140
|
"parser": "typescript"
|
|
141
141
|
}
|
|
142
142
|
},
|
|
143
|
-
"gitHead": "
|
|
143
|
+
"gitHead": "8abfed8467fe5ddcee0797fe832c15321c7fd1d9"
|
|
144
144
|
}
|
|
@@ -30,8 +30,8 @@ export default function ProductItem({ item, session, currency, onUpsell, onDowns
|
|
|
30
30
|
description={item.price.product?.description}
|
|
31
31
|
extra={
|
|
32
32
|
item.price.type === 'recurring' && item.price.recurring
|
|
33
|
-
? `
|
|
34
|
-
:
|
|
33
|
+
? [pricing.quantity, `billed ${formatRecurring(item.upsell_price?.recurring || item.price.recurring)} ${metered}`].filter(Boolean).join(', ') // prettier-ignore
|
|
34
|
+
: pricing.quantity
|
|
35
35
|
}
|
|
36
36
|
/>
|
|
37
37
|
<Stack direction="column" alignItems="flex-end" flex={1}>
|
package/src/libs/util.ts
CHANGED
|
@@ -258,33 +258,51 @@ export function formatLineItemPricing(
|
|
|
258
258
|
item: TLineItemExpanded,
|
|
259
259
|
currency: TPaymentCurrency,
|
|
260
260
|
trial: number
|
|
261
|
-
): { primary: string; secondary?: string } {
|
|
261
|
+
): { primary: string; secondary?: string; quantity: string } {
|
|
262
262
|
const price = item.upsell_price || item.price;
|
|
263
|
-
|
|
263
|
+
|
|
264
|
+
let quantity = `Qty ${item.quantity}`;
|
|
265
|
+
if (price.recurring?.usage_type === 'metered' || +item.quantity === 1) {
|
|
266
|
+
quantity = '';
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const total = `${fromUnitToToken(
|
|
264
270
|
new BN(getPriceUintAmountByCurrency(price, currency)).mul(new BN(item.quantity)),
|
|
265
271
|
currency.decimal
|
|
266
|
-
).
|
|
272
|
+
)} ${currency.symbol}`;
|
|
273
|
+
const unit = `${fromUnitToToken(getPriceUintAmountByCurrency(price, currency))} ${currency.symbol}`;
|
|
274
|
+
|
|
275
|
+
const appendUnit = (v: string, alt: string) => {
|
|
276
|
+
if (price.product.unit_label) {
|
|
277
|
+
return `${v} / ${price.product.unit_label}`;
|
|
278
|
+
}
|
|
279
|
+
if (price.recurring?.usage_type === 'metered' || item.quantity === 1) {
|
|
280
|
+
return alt;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return quantity ? `${unit} each` : '';
|
|
284
|
+
};
|
|
267
285
|
|
|
268
286
|
if (price.type === 'recurring' && price.recurring) {
|
|
269
287
|
if (trial > 0) {
|
|
270
|
-
const secondary = price.product.unit_label
|
|
271
|
-
? `${amount} ${currency.symbol} / ${price.product.unit_label}`
|
|
272
|
-
: `${amount} ${currency.symbol}`;
|
|
273
288
|
return {
|
|
274
289
|
primary: `Free for ${trial} days`,
|
|
275
|
-
secondary: `${
|
|
290
|
+
secondary: `${appendUnit(total, total)} ${formatRecurring(price.recurring, false, '/')}`,
|
|
291
|
+
quantity,
|
|
276
292
|
};
|
|
277
293
|
}
|
|
278
294
|
|
|
279
295
|
return {
|
|
280
|
-
primary:
|
|
281
|
-
secondary:
|
|
296
|
+
primary: total,
|
|
297
|
+
secondary: appendUnit(total, ''),
|
|
298
|
+
quantity,
|
|
282
299
|
};
|
|
283
300
|
}
|
|
284
301
|
|
|
285
302
|
return {
|
|
286
|
-
primary:
|
|
287
|
-
secondary:
|
|
303
|
+
primary: total,
|
|
304
|
+
secondary: appendUnit(total, ''),
|
|
305
|
+
quantity,
|
|
288
306
|
};
|
|
289
307
|
}
|
|
290
308
|
|