payment-kit 1.15.28 → 1.15.29
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.
|
@@ -462,12 +462,14 @@ export async function getUpcomingInvoiceAmount(subscriptionId: string) {
|
|
|
462
462
|
const expanded = await Price.expand(items.map((x) => x.toJSON()));
|
|
463
463
|
|
|
464
464
|
let amount = new BN(0);
|
|
465
|
+
let minExpectedAmount = new BN(0);
|
|
465
466
|
for (const item of expanded) {
|
|
466
467
|
const price = getSubscriptionItemPrice(item);
|
|
467
468
|
if (price.type === 'recurring') {
|
|
468
469
|
const unit = getPriceUintAmountByCurrency(price, subscription.currency_id);
|
|
469
470
|
if (price.recurring?.usage_type === 'licensed') {
|
|
470
471
|
amount = amount.add(new BN(unit).mul(new BN(item.quantity)));
|
|
472
|
+
minExpectedAmount = minExpectedAmount.add(new BN(unit).mul(new BN(item.quantity)));
|
|
471
473
|
}
|
|
472
474
|
if (price.recurring?.usage_type === 'metered') {
|
|
473
475
|
const rawQuantity = await UsageRecord.getSummary({
|
|
@@ -481,12 +483,14 @@ export async function getUpcomingInvoiceAmount(subscriptionId: string) {
|
|
|
481
483
|
// @ts-ignore
|
|
482
484
|
const quantity = price.transformQuantity(rawQuantity);
|
|
483
485
|
amount = amount.add(new BN(unit).mul(new BN(quantity)));
|
|
486
|
+
minExpectedAmount = minExpectedAmount.add(new BN(unit).mul(new BN(item.quantity)));
|
|
484
487
|
}
|
|
485
488
|
}
|
|
486
489
|
}
|
|
487
490
|
|
|
488
491
|
return {
|
|
489
492
|
amount: amount.toString(),
|
|
493
|
+
minExpectedAmount: minExpectedAmount.toString(),
|
|
490
494
|
start: subscription.current_period_start,
|
|
491
495
|
end: subscription.current_period_end,
|
|
492
496
|
currency,
|
package/blocklet.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.29",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev --open",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@arcblock/validator": "^1.18.137",
|
|
54
54
|
"@blocklet/js-sdk": "1.16.33-beta-20241031-073543-49b1ff9b",
|
|
55
55
|
"@blocklet/logger": "1.16.33-beta-20241031-073543-49b1ff9b",
|
|
56
|
-
"@blocklet/payment-react": "1.15.
|
|
56
|
+
"@blocklet/payment-react": "1.15.29",
|
|
57
57
|
"@blocklet/sdk": "1.16.33-beta-20241031-073543-49b1ff9b",
|
|
58
58
|
"@blocklet/ui-react": "^2.10.55",
|
|
59
59
|
"@blocklet/uploader": "^0.1.51",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@abtnode/types": "1.16.33-beta-20241031-073543-49b1ff9b",
|
|
122
122
|
"@arcblock/eslint-config-ts": "^0.3.3",
|
|
123
|
-
"@blocklet/payment-types": "1.15.
|
|
123
|
+
"@blocklet/payment-types": "1.15.29",
|
|
124
124
|
"@types/cookie-parser": "^1.4.7",
|
|
125
125
|
"@types/cors": "^2.8.17",
|
|
126
126
|
"@types/debug": "^4.1.12",
|
|
@@ -165,5 +165,5 @@
|
|
|
165
165
|
"parser": "typescript"
|
|
166
166
|
}
|
|
167
167
|
},
|
|
168
|
-
"gitHead": "
|
|
168
|
+
"gitHead": "74c394cd2a81792ea30fdf019aafb7b4e2400373"
|
|
169
169
|
}
|
|
@@ -100,7 +100,9 @@ export default function RechargePage() {
|
|
|
100
100
|
// Calculate preset amounts
|
|
101
101
|
const getCycleAmount = (cycles: number) =>
|
|
102
102
|
fromUnitToToken(
|
|
103
|
-
new BN(upcomingRes.data.amount
|
|
103
|
+
new BN(upcomingRes.data.amount === '0' ? upcomingRes.data.minExpectedAmount : upcomingRes.data.amount)
|
|
104
|
+
.mul(new BN(cycles))
|
|
105
|
+
.toString(),
|
|
104
106
|
upcomingRes.data?.currency?.decimal
|
|
105
107
|
);
|
|
106
108
|
setPresetAmounts([
|