payment-kit 1.18.41 → 1.18.43

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.
@@ -60,17 +60,20 @@ export async function handleStripeSubscriptionSucceed(subscription: Subscription
60
60
  if (checkoutSession && checkoutSession.status === 'open') {
61
61
  await checkoutSession.increment('success_subscription_count', { by: 1 });
62
62
  await checkoutSession.reload();
63
- if (checkoutSession.success_subscription_count === subscriptionIds.length) {
63
+ if (
64
+ checkoutSession.success_subscription_count &&
65
+ checkoutSession.success_subscription_count >= subscriptionIds.length
66
+ ) {
64
67
  await checkoutSession.update({
65
68
  status: 'complete',
66
69
  payment_status: 'paid',
67
70
  payment_details: paymentIntent?.payment_details || null,
68
71
  });
72
+ logger.info('checkout session become complete on stripe event', {
73
+ id: checkoutSession.id,
74
+ subscriptionId: subscription.id,
75
+ });
69
76
  }
70
- logger.info('checkout session become complete on stripe event', {
71
- id: checkoutSession.id,
72
- subscriptionId: subscription.id,
73
- });
74
77
  }
75
78
  }
76
79
 
@@ -312,12 +312,18 @@ export const handlePaymentSucceed = async (
312
312
  await checkoutSession.increment('success_subscription_count', { by: 1 });
313
313
  await checkoutSession.reload();
314
314
  const subscriptionIds = getCheckoutSessionSubscriptionIds(checkoutSession);
315
- if (checkoutSession.success_subscription_count === subscriptionIds.length) {
315
+ if (
316
+ checkoutSession.success_subscription_count &&
317
+ checkoutSession.success_subscription_count >= subscriptionIds.length
318
+ ) {
316
319
  await checkoutSession.update({
317
320
  status: 'complete',
318
321
  payment_status: 'paid',
319
322
  payment_details: paymentIntent.payment_details,
320
323
  });
324
+ logger.info('checkout session become complete on payment done', {
325
+ id: checkoutSession.id,
326
+ });
321
327
  }
322
328
  } else {
323
329
  await checkoutSession.update({
@@ -325,6 +331,9 @@ export const handlePaymentSucceed = async (
325
331
  payment_status: 'paid',
326
332
  payment_details: paymentIntent.payment_details,
327
333
  });
334
+ logger.info('checkout session become complete on payment done', {
335
+ id: checkoutSession.id,
336
+ });
328
337
  }
329
338
  logger.info(`CheckoutSession ${checkoutSession.id} updated on payment done ${paymentIntent.id}`);
330
339
  }
@@ -923,7 +923,11 @@ router.get('/retrieve/:id', user, async (req, res) => {
923
923
  let subscriptions: Subscription[] = [];
924
924
  if (['subscription', 'setup'].includes(doc.mode)) {
925
925
  const subscriptionIds = getCheckoutSessionSubscriptionIds(doc);
926
- if (doc.success_subscription_count === subscriptionIds.length && doc.status === 'incomplete') {
926
+ if (
927
+ doc.success_subscription_count &&
928
+ doc.success_subscription_count >= subscriptionIds.length &&
929
+ doc.status === 'incomplete'
930
+ ) {
927
931
  await doc.update({
928
932
  status: 'complete',
929
933
  payment_status: 'paid',
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.18.41
17
+ version: 1.18.43
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.18.41",
3
+ "version": "1.18.43",
4
4
  "scripts": {
5
5
  "dev": "blocklet dev --open",
6
6
  "eject": "vite eject",
@@ -45,30 +45,30 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@abtnode/cron": "^1.16.43",
48
- "@arcblock/did": "^1.20.8",
48
+ "@arcblock/did": "^1.20.10",
49
49
  "@arcblock/did-auth-storage-nedb": "^1.7.1",
50
- "@arcblock/did-connect": "^2.13.29",
51
- "@arcblock/did-util": "^1.20.8",
52
- "@arcblock/jwt": "^1.20.8",
53
- "@arcblock/ux": "^2.13.29",
54
- "@arcblock/validator": "^1.20.8",
55
- "@blocklet/did-space-js": "^1.0.51",
50
+ "@arcblock/did-connect": "^2.13.32",
51
+ "@arcblock/did-util": "^1.20.10",
52
+ "@arcblock/jwt": "^1.20.10",
53
+ "@arcblock/ux": "^2.13.32",
54
+ "@arcblock/validator": "^1.20.10",
55
+ "@blocklet/did-space-js": "^1.0.53",
56
56
  "@blocklet/js-sdk": "^1.16.43",
57
57
  "@blocklet/logger": "^1.16.43",
58
- "@blocklet/payment-react": "1.18.41",
58
+ "@blocklet/payment-react": "1.18.43",
59
59
  "@blocklet/sdk": "^1.16.43",
60
- "@blocklet/ui-react": "^2.13.29",
60
+ "@blocklet/ui-react": "^2.13.32",
61
61
  "@blocklet/uploader": "^0.1.90",
62
62
  "@blocklet/xss": "^0.1.35",
63
63
  "@mui/icons-material": "^5.16.6",
64
64
  "@mui/lab": "^5.0.0-alpha.173",
65
65
  "@mui/material": "^5.16.6",
66
66
  "@mui/system": "^5.16.6",
67
- "@ocap/asset": "^1.20.8",
68
- "@ocap/client": "^1.20.8",
69
- "@ocap/mcrypto": "^1.20.8",
70
- "@ocap/util": "^1.20.8",
71
- "@ocap/wallet": "^1.20.8",
67
+ "@ocap/asset": "^1.20.10",
68
+ "@ocap/client": "^1.20.10",
69
+ "@ocap/mcrypto": "^1.20.10",
70
+ "@ocap/util": "^1.20.10",
71
+ "@ocap/wallet": "^1.20.10",
72
72
  "@stripe/react-stripe-js": "^2.7.3",
73
73
  "@stripe/stripe-js": "^2.4.0",
74
74
  "ahooks": "^3.8.0",
@@ -123,7 +123,7 @@
123
123
  "devDependencies": {
124
124
  "@abtnode/types": "^1.16.43",
125
125
  "@arcblock/eslint-config-ts": "^0.3.3",
126
- "@blocklet/payment-types": "1.18.41",
126
+ "@blocklet/payment-types": "1.18.43",
127
127
  "@types/cookie-parser": "^1.4.7",
128
128
  "@types/cors": "^2.8.17",
129
129
  "@types/debug": "^4.1.12",
@@ -169,5 +169,5 @@
169
169
  "parser": "typescript"
170
170
  }
171
171
  },
172
- "gitHead": "4232e09576dd8aa8dcfb0e4dd5a1bbbb50480b7f"
172
+ "gitHead": "278c503efd49cab6413b324a4b38bf37a3456468"
173
173
  }
@@ -34,6 +34,9 @@ export default function CustomerLink({
34
34
  avatarProps={{
35
35
  size: size === 'small' ? 24 : 40,
36
36
  }}
37
+ shortenLabelProps={{
38
+ maxLength: 20,
39
+ }}
37
40
  popupInfoType={InfoType.Minimal}
38
41
  showDid={size !== 'small'}
39
42
  {...(customer.metadata.anonymous === true
@@ -6,7 +6,7 @@ import { useRequest } from 'ahooks';
6
6
  import { Button, Stack, Typography, Tooltip, Avatar, Box, CircularProgress, Skeleton } from '@mui/material';
7
7
  import { BN } from '@ocap/util';
8
8
  import { useNavigate } from 'react-router-dom';
9
- import { AccountBalanceWalletOutlined, ArrowForward } from '@mui/icons-material';
9
+ import { AccountBalanceWalletOutlined, ArrowForward, InfoOutlined } from '@mui/icons-material';
10
10
  import InfoMetric from '../info-metric';
11
11
  import SubscriptionStatus from './status';
12
12
 
@@ -89,7 +89,14 @@ export default function SubscriptionMetrics({ subscription, showBalance = true }
89
89
  )}
90
90
  {['active', 'trialing'].includes(subscription.status) && upcoming?.amount && upcoming.amount !== '0' && (
91
91
  <InfoMetric
92
- label={t('admin.subscription.nextInvoiceAmount')}
92
+ label={
93
+ <Typography display="flex" alignItems="center" gap={0.5}>
94
+ {t('admin.subscription.nextInvoiceAmount')}
95
+ <Tooltip title={t('admin.subscription.nextInvoiceAmountTip')} placement="top" arrow>
96
+ <InfoOutlined fontSize="small" sx={{ color: 'text.secondary', cursor: 'pointer', fontSize: '16px' }} />
97
+ </Tooltip>
98
+ </Typography>
99
+ }
93
100
  value={`${formatBNStr(upcoming.amount, subscription.paymentCurrency.decimal)} ${
94
101
  subscription.paymentCurrency.symbol
95
102
  } (${t('common.estimated')})`}
@@ -384,17 +384,7 @@ export function SubscriptionActionsInner({
384
384
  const supportUnsubscribe = action?.action === 'cancel' && showUnsubscribe;
385
385
  const supportAction = action && (action?.action !== 'cancel' || supportUnsubscribe);
386
386
  const supportResume = isWillCanceled(subscription) && action?.action === 'recover';
387
- const serviceActions = subscription.service_actions?.filter((x: any) => x?.type !== 'notification') || [
388
- {
389
- name: 'notification',
390
- text: {
391
- en: 'Application Details',
392
- zh: '应用详情',
393
- },
394
- link: '/customer/notification',
395
- color: 'primary',
396
- },
397
- ];
387
+ const serviceActions = subscription.service_actions?.filter((x: any) => x?.type !== 'notification') || [];
398
388
  const actionConfigs: ActionConfig[] = [
399
389
  {
400
390
  key: 'delegation',
@@ -224,10 +224,12 @@ export default function CurrentSubscriptions({
224
224
  flexWrap: 'wrap',
225
225
  }}>
226
226
  <Typography variant={isMobile ? 'subtitle2' : 'subtitle1'} sx={{ whiteSpace: 'nowrap' }}>
227
- {
227
+ {formatPrice(
228
228
  // @ts-ignore
229
- formatPrice(subscription.items[0].price, subscription.paymentCurrency)
230
- }
229
+ subscription.items?.[0]?.price,
230
+ subscription.paymentCurrency,
231
+ subscription.items?.[0]?.price?.product?.unit_label
232
+ )}
231
233
  </Typography>
232
234
  {subscriptionTime && (
233
235
  <Typography variant="body2" color="text.secondary">
@@ -538,6 +538,8 @@ export default flat({
538
538
  startedAt: 'Started',
539
539
  nextInvoice: 'Next Invoice',
540
540
  nextInvoiceAmount: 'Next Invoice Amount',
541
+ nextInvoiceAmountTip:
542
+ 'The next invoice amount is estimated, the actual amount will be calculated based on actual usage.',
541
543
  itemId: 'Subscription Item ID',
542
544
  update: 'Update subscription',
543
545
  resume: 'Resume payment collection',
@@ -527,6 +527,7 @@ export default flat({
527
527
  startedAt: '开始于',
528
528
  nextInvoice: '下次账单时间',
529
529
  nextInvoiceAmount: '下次账单金额',
530
+ nextInvoiceAmountTip: '下次账单金额为预估,最终金额会根据实际使用情况结算。',
530
531
  itemId: '订阅项目ID',
531
532
  update: '更新订阅',
532
533
  resume: '恢复付款',
@@ -583,7 +583,11 @@ export default function BalanceRechargePage() {
583
583
 
584
584
  {subscription.items && subscription.items[0] && currency && (
585
585
  <Typography variant="body1" sx={{ color: 'text.secondary' }}>
586
- {formatPrice(subscription.items[0].price, currency)}
586
+ {formatPrice(
587
+ subscription.items[0].price,
588
+ currency,
589
+ subscription.items[0].price?.product?.unit_label
590
+ )}
587
591
  </Typography>
588
592
  )}
589
593
  </Stack>