payment-kit 1.23.5 → 1.23.6

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.
@@ -19,6 +19,7 @@ import { checkDepositVaultAmount } from '../libs/payment';
19
19
  import { getTokenSummaryByDid } from '../integrations/arcblock/stake';
20
20
  import { MetadataSchema } from '../libs/api';
21
21
  import { getRechargePaymentUrl } from '../libs/currency';
22
+ import { checkCurrencySupportRecurring } from '../libs/product';
22
23
 
23
24
  const router = Router();
24
25
 
@@ -577,4 +578,29 @@ router.put('/:id/recharge-config', auth, async (req, res) => {
577
578
  });
578
579
  });
579
580
 
581
+ // check if currencies support recurring subscriptions
582
+ router.post('/check-recurring-support', async (req, res) => {
583
+ try {
584
+ const { currency_ids: currencyIds } = req.body;
585
+ if (!Array.isArray(currencyIds)) {
586
+ return res.status(400).json({ error: 'currency_ids must be an array' });
587
+ }
588
+ if (currencyIds.length === 0) {
589
+ return res.status(400).json({ error: 'currency_ids cannot be empty' });
590
+ }
591
+ const { notSupportCurrencies, validate } = await checkCurrencySupportRecurring(currencyIds, true);
592
+ return res.json({
593
+ supported: validate,
594
+ unsupported_currencies: notSupportCurrencies.map((c) => ({
595
+ id: c.id,
596
+ name: c.name,
597
+ symbol: c.symbol,
598
+ })),
599
+ });
600
+ } catch (err) {
601
+ logger.error('check recurring support error', err);
602
+ return res.status(400).json({ error: err.message });
603
+ }
604
+ });
605
+
580
606
  export default router;
package/blocklet.yml CHANGED
@@ -14,7 +14,7 @@ repository:
14
14
  type: git
15
15
  url: git+https://github.com/blocklet/payment-kit.git
16
16
  specVersion: 1.2.8
17
- version: 1.23.5
17
+ version: 1.23.6
18
18
  logo: logo.png
19
19
  files:
20
20
  - dist
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payment-kit",
3
- "version": "1.23.5",
3
+ "version": "1.23.6",
4
4
  "scripts": {
5
5
  "dev": "blocklet dev --open",
6
6
  "lint": "tsc --noEmit && eslint src api/src --ext .mjs,.js,.jsx,.ts,.tsx",
@@ -44,7 +44,7 @@
44
44
  ]
45
45
  },
46
46
  "dependencies": {
47
- "@abtnode/cron": "^1.17.5",
47
+ "@abtnode/cron": "^1.17.6",
48
48
  "@arcblock/did": "^1.27.15",
49
49
  "@arcblock/did-connect-react": "^3.2.19",
50
50
  "@arcblock/did-connect-storage-nedb": "^1.8.0",
@@ -56,15 +56,15 @@
56
56
  "@arcblock/vc": "^1.27.15",
57
57
  "@blocklet/did-space-js": "^1.2.11",
58
58
  "@blocklet/error": "^0.3.5",
59
- "@blocklet/js-sdk": "^1.17.5",
60
- "@blocklet/logger": "^1.17.5",
61
- "@blocklet/payment-broker-client": "1.23.5",
62
- "@blocklet/payment-react": "1.23.5",
63
- "@blocklet/payment-vendor": "1.23.5",
64
- "@blocklet/sdk": "^1.17.5",
59
+ "@blocklet/js-sdk": "^1.17.6",
60
+ "@blocklet/logger": "^1.17.6",
61
+ "@blocklet/payment-broker-client": "1.23.6",
62
+ "@blocklet/payment-react": "1.23.6",
63
+ "@blocklet/payment-vendor": "1.23.6",
64
+ "@blocklet/sdk": "^1.17.6",
65
65
  "@blocklet/ui-react": "^3.2.19",
66
- "@blocklet/uploader": "^0.3.16",
67
- "@blocklet/xss": "^0.3.14",
66
+ "@blocklet/uploader": "^0.3.17",
67
+ "@blocklet/xss": "^0.3.15",
68
68
  "@mui/icons-material": "^7.1.2",
69
69
  "@mui/lab": "7.0.0-beta.14",
70
70
  "@mui/material": "^7.1.2",
@@ -128,9 +128,9 @@
128
128
  "web3": "^4.16.0"
129
129
  },
130
130
  "devDependencies": {
131
- "@abtnode/types": "^1.17.5",
131
+ "@abtnode/types": "^1.17.6",
132
132
  "@arcblock/eslint-config-ts": "^0.3.3",
133
- "@blocklet/payment-types": "1.23.5",
133
+ "@blocklet/payment-types": "1.23.6",
134
134
  "@types/cookie-parser": "^1.4.9",
135
135
  "@types/cors": "^2.8.19",
136
136
  "@types/debug": "^4.1.12",
@@ -177,5 +177,5 @@
177
177
  "parser": "typescript"
178
178
  }
179
179
  },
180
- "gitHead": "486456ed522207cc4efa54cd14b1f65c6433d179"
180
+ "gitHead": "0026a41a10475159d72ade801561d6cbce0008fe"
181
181
  }
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable react/no-unstable-nested-components */
2
2
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
3
- import { formatBNStr, formatToDate, Table, usePaymentContext } from '@blocklet/payment-react';
3
+ import { formatBNStr, formatCreditAmount, formatToDate, Table, usePaymentContext } from '@blocklet/payment-react';
4
4
  import type { TCreditGrantExpanded } from '@blocklet/payment-types';
5
5
  import { Box, Chip, Divider, styled, Typography } from '@mui/material';
6
6
  import { useNavigate } from 'react-router-dom';
@@ -88,8 +88,10 @@ export default function RelatedCreditGrants({ grants, showDivider = true, mode =
88
88
  return (
89
89
  <Box onClick={() => handleShowGrantDetail(grant)}>
90
90
  <Typography variant="body2">
91
- {formatBNStr(grant.remaining_amount, grant.paymentCurrency?.decimal || 0)}{' '}
92
- {grant.paymentCurrency?.symbol}
91
+ {formatCreditAmount(
92
+ formatBNStr(grant.remaining_amount, grant.paymentCurrency?.decimal || 0),
93
+ grant.paymentCurrency?.symbol || ''
94
+ )}
93
95
  </Typography>
94
96
  </Box>
95
97
  );
@@ -1,6 +1,12 @@
1
1
  /* eslint-disable react/no-unstable-nested-components */
2
2
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
3
- import { formatAmount, Table, getPriceUintAmountByCurrency, formatNumber } from '@blocklet/payment-react';
3
+ import {
4
+ formatAmount,
5
+ Table,
6
+ getPriceUintAmountByCurrency,
7
+ formatNumber,
8
+ formatCreditForCheckout,
9
+ } from '@blocklet/payment-react';
4
10
  import type { TInvoiceExpanded, TInvoiceItem } from '@blocklet/payment-types';
5
11
  import { InfoOutlined } from '@mui/icons-material';
6
12
  import { Box, Stack, Tooltip, Typography } from '@mui/material';
@@ -77,7 +83,7 @@ export function getInvoiceRows(invoice: TInvoiceExpanded, t: (key: string) => st
77
83
  if (creditInfo?.amount) {
78
84
  credits = {
79
85
  total: creditInfo.amount,
80
- currency: creditInfo.currency?.name || 'Credits',
86
+ currency: creditInfo.currency?.symbol || 'Credits',
81
87
  };
82
88
  }
83
89
 
@@ -245,8 +251,7 @@ export default function InvoiceTable({ invoice, simple = false, emptyNodeText =
245
251
  },
246
252
  }}>
247
253
  {t('customer.invoice.creditsInfo', {
248
- amount: formatNumber(item.credits.total),
249
- currency: item.credits.currency,
254
+ amount: formatCreditForCheckout(formatNumber(item.credits.total), item.credits.currency, locale),
250
255
  })}
251
256
  </Typography>
252
257
  )}
@@ -1874,7 +1874,7 @@ export default flat({
1874
1874
  invoice: {
1875
1875
  relatedInvoice: 'Related Invoice',
1876
1876
  donation: 'Donation',
1877
- creditsInfo: 'Total {amount} {currency} included',
1877
+ creditsInfo: 'Total {amount} included',
1878
1878
  appliedDiscounts: 'Applied Discounts',
1879
1879
  },
1880
1880
  payout: {
@@ -1818,7 +1818,7 @@ export default flat({
1818
1818
  invoice: {
1819
1819
  relatedInvoice: '关联账单',
1820
1820
  donation: '打赏记录',
1821
- creditsInfo: '总共包含 {amount} {currency}',
1821
+ creditsInfo: '总共包含 {amount}',
1822
1822
  appliedDiscounts: '已应用优惠',
1823
1823
  },
1824
1824
  payout: {