@blocklet/payment-react 1.21.17 → 1.22.1

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/es/libs/util.d.ts CHANGED
@@ -40,7 +40,7 @@ export declare function getWebhookStatusColor(status: string): "default" | "succ
40
40
  export declare function getCheckoutAmount(items: TLineItemExpanded[], currency: TPaymentCurrency, trialing?: boolean, upsell?: boolean): {
41
41
  subtotal: any;
42
42
  total: any;
43
- renew: any;
43
+ renew: string;
44
44
  discount: string;
45
45
  shipping: string;
46
46
  tax: string;
package/es/libs/util.js CHANGED
@@ -829,8 +829,8 @@ export function formatTotalPrice({
829
829
  totalAmount: "0"
830
830
  };
831
831
  }
832
- const unitValue = new BN(price.custom_unit_amount || price.unit_amount);
833
832
  const currency = price?.currency ?? {};
833
+ const unitValue = new BN(getPriceUintAmountByCurrency(price, currency));
834
834
  const total = `${fromUnitToToken(unitValue.mul(new BN(quantity)), currency.decimal)} ${currency.symbol} `;
835
835
  const unit = `${fromUnitToToken(unitValue, currency.decimal)} ${currency.symbol} `;
836
836
  const appendUnit = (v, alt) => {
@@ -195,7 +195,7 @@ export default function ProductItem({
195
195
  return t(getLocaleKey("normal", type2), buildBaseParams());
196
196
  }
197
197
  const pendingAmountBN = new BN(pendingAmount || "0");
198
- const creditAmountBN = fromTokenToUnit(new BN(creditAmount), creditCurrency?.decimal || 2);
198
+ const creditAmountBN = fromTokenToUnit(creditAmount, creditCurrency?.decimal || 2);
199
199
  const minQuantityNeeded = Math.ceil(pendingAmountBN.mul(new BN(100)).div(creditAmountBN).toNumber() / 100);
200
200
  const currentPurchaseCreditBN = creditAmountBN.mul(new BN(localQuantity || 0));
201
201
  const actualAvailable = currentPurchaseCreditBN.sub(pendingAmountBN).toString();
@@ -424,7 +424,7 @@ export default function PaymentSummary({
424
424
  sx: {
425
425
  justifyContent: "space-between",
426
426
  alignItems: "center",
427
- ...staking > 0 && {
427
+ ...+staking > 0 && {
428
428
  borderTop: "1px solid",
429
429
  borderColor: "divider",
430
430
  pt: 1,
@@ -40,7 +40,7 @@ export declare function getWebhookStatusColor(status: string): "default" | "succ
40
40
  export declare function getCheckoutAmount(items: TLineItemExpanded[], currency: TPaymentCurrency, trialing?: boolean, upsell?: boolean): {
41
41
  subtotal: any;
42
42
  total: any;
43
- renew: any;
43
+ renew: string;
44
44
  discount: string;
45
45
  shipping: string;
46
46
  tax: string;
package/lib/libs/util.js CHANGED
@@ -1060,8 +1060,8 @@ function formatTotalPrice({
1060
1060
  totalAmount: "0"
1061
1061
  };
1062
1062
  }
1063
- const unitValue = new _util.BN(price.custom_unit_amount || price.unit_amount);
1064
1063
  const currency = price?.currency ?? {};
1064
+ const unitValue = new _util.BN(getPriceUintAmountByCurrency(price, currency));
1065
1065
  const total = `${(0, _util.fromUnitToToken)(unitValue.mul(new _util.BN(quantity)), currency.decimal)} ${currency.symbol} `;
1066
1066
  const unit = `${(0, _util.fromUnitToToken)(unitValue, currency.decimal)} ${currency.symbol} `;
1067
1067
  const appendUnit = (v, alt) => {
@@ -204,7 +204,7 @@ function ProductItem({
204
204
  return t(getLocaleKey("normal", type2), buildBaseParams());
205
205
  }
206
206
  const pendingAmountBN = new _util.BN(pendingAmount || "0");
207
- const creditAmountBN = (0, _util.fromTokenToUnit)(new _util.BN(creditAmount), creditCurrency?.decimal || 2);
207
+ const creditAmountBN = (0, _util.fromTokenToUnit)(creditAmount, creditCurrency?.decimal || 2);
208
208
  const minQuantityNeeded = Math.ceil(pendingAmountBN.mul(new _util.BN(100)).div(creditAmountBN).toNumber() / 100);
209
209
  const currentPurchaseCreditBN = creditAmountBN.mul(new _util.BN(localQuantity || 0));
210
210
  const actualAvailable = currentPurchaseCreditBN.sub(pendingAmountBN).toString();
@@ -446,7 +446,7 @@ function PaymentSummary({
446
446
  sx: {
447
447
  justifyContent: "space-between",
448
448
  alignItems: "center",
449
- ...(staking > 0 && {
449
+ ...(+staking > 0 && {
450
450
  borderTop: "1px solid",
451
451
  borderColor: "divider",
452
452
  pt: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/payment-react",
3
- "version": "1.21.17",
3
+ "version": "1.22.1",
4
4
  "description": "Reusable react components for payment kit v2",
5
5
  "keywords": [
6
6
  "react",
@@ -54,16 +54,16 @@
54
54
  }
55
55
  },
56
56
  "dependencies": {
57
- "@arcblock/did-connect-react": "^3.1.46",
58
- "@arcblock/ux": "^3.1.46",
59
- "@arcblock/ws": "^1.25.6",
60
- "@blocklet/theme": "^3.1.46",
61
- "@blocklet/ui-react": "^3.1.46",
57
+ "@arcblock/did-connect-react": "^3.1.53",
58
+ "@arcblock/ux": "^3.1.53",
59
+ "@arcblock/ws": "^1.26.3",
60
+ "@blocklet/theme": "^3.1.53",
61
+ "@blocklet/ui-react": "^3.1.53",
62
62
  "@mui/icons-material": "^7.1.2",
63
63
  "@mui/lab": "7.0.0-beta.14",
64
64
  "@mui/material": "^7.1.2",
65
65
  "@mui/system": "^7.1.1",
66
- "@ocap/util": "^1.25.6",
66
+ "@ocap/util": "^1.26.3",
67
67
  "@stripe/react-stripe-js": "^2.9.0",
68
68
  "@stripe/stripe-js": "^2.4.0",
69
69
  "@vitejs/plugin-legacy": "^7.0.0",
@@ -94,7 +94,7 @@
94
94
  "@babel/core": "^7.27.4",
95
95
  "@babel/preset-env": "^7.27.2",
96
96
  "@babel/preset-react": "^7.27.1",
97
- "@blocklet/payment-types": "1.21.17",
97
+ "@blocklet/payment-types": "1.22.1",
98
98
  "@storybook/addon-essentials": "^7.6.20",
99
99
  "@storybook/addon-interactions": "^7.6.20",
100
100
  "@storybook/addon-links": "^7.6.20",
@@ -125,5 +125,5 @@
125
125
  "vite-plugin-babel": "^1.3.1",
126
126
  "vite-plugin-node-polyfills": "^0.23.0"
127
127
  },
128
- "gitHead": "a823bc05e706681ee70451437b0460aba909c253"
128
+ "gitHead": "8db720c3902e307a6d869ff706ae4857f88cf867"
129
129
  }
package/src/libs/util.ts CHANGED
@@ -1085,8 +1085,8 @@ export function formatTotalPrice({
1085
1085
  };
1086
1086
  }
1087
1087
 
1088
- const unitValue = new BN(price.custom_unit_amount || price.unit_amount);
1089
1088
  const currency: TPaymentCurrency = price?.currency ?? {};
1089
+ const unitValue = new BN(getPriceUintAmountByCurrency(price, currency));
1090
1090
 
1091
1091
  const total = `${fromUnitToToken(unitValue.mul(new BN(quantity)), currency.decimal)} ${currency.symbol} `;
1092
1092
 
@@ -249,7 +249,7 @@ export default function ProductItem({
249
249
  }
250
250
 
251
251
  const pendingAmountBN = new BN(pendingAmount || '0');
252
- const creditAmountBN = fromTokenToUnit(new BN(creditAmount), creditCurrency?.decimal || 2);
252
+ const creditAmountBN = fromTokenToUnit(creditAmount, creditCurrency?.decimal || 2);
253
253
  const minQuantityNeeded = Math.ceil(pendingAmountBN.mul(new BN(100)).div(creditAmountBN).toNumber() / 100);
254
254
  const currentPurchaseCreditBN = creditAmountBN.mul(new BN(localQuantity || 0));
255
255
  const actualAvailable = currentPurchaseCreditBN.sub(pendingAmountBN).toString();
@@ -475,7 +475,7 @@ export default function PaymentSummary({
475
475
  sx={{
476
476
  justifyContent: 'space-between',
477
477
  alignItems: 'center',
478
- ...(staking > 0 && {
478
+ ...(+staking > 0 && {
479
479
  borderTop: '1px solid',
480
480
  borderColor: 'divider',
481
481
  pt: 1,