payment-kit 1.13.136 → 1.13.138

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.
Files changed (39) hide show
  1. package/api/src/crons/base.ts +7 -33
  2. package/api/src/crons/index.ts +7 -0
  3. package/api/src/crons/interface/base.ts +17 -0
  4. package/api/src/crons/subscription-trail-will-end.ts +29 -1
  5. package/api/src/crons/subscription-will-canceled.ts +48 -0
  6. package/api/src/crons/subscription-will-renew.ts +29 -2
  7. package/api/src/libs/invoice.ts +20 -6
  8. package/api/src/libs/notification/template/one-time-payment-succeeded.ts +245 -0
  9. package/api/src/libs/notification/template/subscription-cacceled.ts +241 -0
  10. package/api/src/libs/notification/template/subscription-refund-succeeded.ts +286 -0
  11. package/api/src/libs/notification/template/subscription-renew-failed.ts +17 -6
  12. package/api/src/libs/notification/template/subscription-renewed.ts +27 -6
  13. package/api/src/libs/notification/template/subscription-succeeded.ts +14 -5
  14. package/api/src/libs/notification/template/subscription-trial-start.ts +13 -4
  15. package/api/src/libs/notification/template/subscription-trial-will-end.ts +7 -3
  16. package/api/src/libs/notification/template/subscription-upgraded.ts +261 -0
  17. package/api/src/libs/notification/template/subscription-will-canceled.ts +225 -0
  18. package/api/src/libs/notification/template/subscription-will-renew.ts +30 -3
  19. package/api/src/libs/product.ts +24 -0
  20. package/api/src/libs/queue/index.ts +2 -0
  21. package/api/src/libs/queue/store.ts +1 -1
  22. package/api/src/libs/security.ts +1 -1
  23. package/api/src/libs/subscription.ts +19 -3
  24. package/api/src/libs/util.ts +33 -0
  25. package/api/src/locales/en.ts +38 -4
  26. package/api/src/locales/zh.ts +36 -2
  27. package/api/src/queues/notification.ts +91 -2
  28. package/api/src/routes/connect/setup.ts +2 -2
  29. package/api/src/routes/connect/shared.ts +2 -2
  30. package/api/src/store/models/subscription.ts +5 -0
  31. package/api/src/store/models/types.ts +3 -0
  32. package/blocklet.yml +1 -1
  33. package/package.json +44 -44
  34. package/src/contexts/session.ts +2 -2
  35. package/src/pages/admin/payments/links/create.tsx +1 -1
  36. package/src/pages/admin/products/pricing-tables/create.tsx +1 -1
  37. package/src/pages/customer/invoice.tsx +12 -3
  38. package/src/pages/customer/subscription/update.tsx +1 -1
  39. package/api/src/crons/interface/diff.ts +0 -9
@@ -37,11 +37,12 @@ export default function CustomerHome() {
37
37
  setState({ paying: true });
38
38
  connectApi.open({
39
39
  action: 'collect',
40
- timeout: 5 * 60 * 1000,
41
40
  messages: {
41
+ scan: '',
42
42
  title: t('payment.customer.invoice.pay'),
43
43
  success: t('payment.customer.invoice.paySuccess'),
44
44
  error: t('payment.customer.invoice.payError'),
45
+ confirm: '',
45
46
  },
46
47
  extraParams: { invoiceId: params.id },
47
48
  onSuccess: async () => {
@@ -64,12 +65,20 @@ export default function CustomerHome() {
64
65
  }
65
66
  };
66
67
 
68
+ const closePay = () => {
69
+ setState({ paying: true });
70
+ connectApi.close();
71
+ };
72
+
67
73
  useEffect(() => {
68
- if (searchParams.get('action') === 'pay') {
74
+ // @ts-expect-error
75
+ if (error?.response?.status === 403) {
76
+ closePay();
77
+ } else if (searchParams.get('action') === 'pay') {
69
78
  onPay();
70
79
  }
71
80
  // eslint-disable-next-line react-hooks/exhaustive-deps
72
- }, []);
81
+ }, [error]);
73
82
 
74
83
  if (error) {
75
84
  return <Alert severity="error">{formatError(error)}</Alert>;
@@ -145,12 +145,12 @@ export default function CustomerSubscriptionUpdate() {
145
145
  setState({ paying: true });
146
146
  connectApi.open({
147
147
  action: result.data.connectAction,
148
- timeout: 5 * 60 * 1000,
149
148
  messages: {
150
149
  title: t('payment.customer.upgrade.pay'),
151
150
  scan: t('payment.customer.upgrade.scan'),
152
151
  success: t('payment.customer.upgrade.success'),
153
152
  error: t('payment.customer.upgrade.error'),
153
+ confirm: '',
154
154
  },
155
155
  extraParams: { invoiceId: result.data.latest_invoice_id, subscriptionId: result.data.id },
156
156
  onSuccess: () => {
@@ -1,9 +0,0 @@
1
- import type { ManipulateType } from 'dayjs';
2
-
3
- export interface Diff {
4
- value: number;
5
- unit: ManipulateType;
6
-
7
- // 这个 job 必须跑吗?
8
- required?: false | true;
9
- }