payment-kit 1.15.5 → 1.15.7
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/api/src/integrations/blocklet/user.ts +2 -1
- package/api/src/libs/invoice.ts +1 -1
- package/api/src/libs/notification/template/subscription-renewed.ts +1 -1
- package/api/src/libs/notification/template/subscription-succeeded.ts +3 -3
- package/api/src/libs/notification/template/subscription-trial-will-end.ts +2 -3
- package/api/src/libs/notification/template/subscription-will-renew.ts +10 -3
- package/api/src/libs/payment.ts +13 -1
- package/api/src/routes/checkout-sessions.ts +1 -1
- package/blocklet.yml +1 -1
- package/package.json +4 -4
- package/src/components/filter-toolbar.tsx +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Customer } from '@api/store/models';
|
|
2
1
|
import notification from '@blocklet/sdk/service/notification';
|
|
3
2
|
|
|
3
|
+
import { Customer } from '../../store/models';
|
|
4
|
+
|
|
4
5
|
import logger from '../../libs/logger';
|
|
5
6
|
|
|
6
7
|
const handleUserUpdate = async ({ user }: { user: any }) => {
|
package/api/src/libs/invoice.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { component } from '@blocklet/sdk';
|
|
|
2
2
|
import type { LiteralUnion } from 'type-fest';
|
|
3
3
|
import { withQuery } from 'ufo';
|
|
4
4
|
|
|
5
|
-
import { Invoice, InvoiceItem, PaymentCurrency, Price, Product } from '@api/store/models';
|
|
6
5
|
import { fromUnitToToken } from '@ocap/util';
|
|
6
|
+
import { Invoice, InvoiceItem, PaymentCurrency, Price, Product } from '../store/models';
|
|
7
7
|
import { getConnectQueryParam } from './util';
|
|
8
8
|
import { expandLineItems } from './session';
|
|
9
9
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/indent */
|
|
3
3
|
import { fromUnitToToken, toDid } from '@ocap/util';
|
|
4
4
|
import prettyMsI18n from 'pretty-ms-i18n';
|
|
5
|
-
import logger from '
|
|
5
|
+
import logger from '../../logger';
|
|
6
6
|
import { getUserLocale } from '../../../integrations/blocklet/notification';
|
|
7
7
|
import { translate } from '../../../locales';
|
|
8
8
|
import {
|
|
@@ -4,7 +4,7 @@ import pWaitFor from 'p-wait-for';
|
|
|
4
4
|
import prettyMsI18n from 'pretty-ms-i18n';
|
|
5
5
|
import isEmpty from 'lodash/isEmpty';
|
|
6
6
|
|
|
7
|
-
import { getPaymentAmountForCycleSubscription } from '
|
|
7
|
+
import { getPaymentAmountForCycleSubscription } from '../../payment';
|
|
8
8
|
import { getUserLocale } from '../../../integrations/blocklet/notification';
|
|
9
9
|
import { translate } from '../../../locales';
|
|
10
10
|
import {
|
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
PaymentIntent,
|
|
15
15
|
PaymentMethod,
|
|
16
16
|
Subscription,
|
|
17
|
+
PaymentCurrency,
|
|
18
|
+
Invoice,
|
|
17
19
|
} from '../../../store/models';
|
|
18
|
-
import { Invoice } from '../../../store/models/invoice';
|
|
19
|
-
import { PaymentCurrency } from '../../../store/models/payment-currency';
|
|
20
20
|
import { getCustomerInvoicePageUrl, getOneTimeProductInfo } from '../../invoice';
|
|
21
21
|
import { getMainProductName } from '../../product';
|
|
22
22
|
import { getCustomerSubscriptionPageUrl } from '../../subscription';
|
|
@@ -4,11 +4,10 @@ import { fromUnitToToken } from '@ocap/util';
|
|
|
4
4
|
import type { ManipulateType } from 'dayjs';
|
|
5
5
|
import prettyMsI18n from 'pretty-ms-i18n';
|
|
6
6
|
|
|
7
|
-
import { getTokenSummaryByDid } from '
|
|
7
|
+
import { getTokenSummaryByDid } from '../../../integrations/arcblock/stake';
|
|
8
8
|
import { getUserLocale } from '../../../integrations/blocklet/notification';
|
|
9
9
|
import { translate } from '../../../locales';
|
|
10
|
-
import { Customer, PaymentMethod, Subscription } from '../../../store/models';
|
|
11
|
-
import { PaymentCurrency } from '../../../store/models/payment-currency';
|
|
10
|
+
import { Customer, PaymentMethod, Subscription, PaymentCurrency } from '../../../store/models';
|
|
12
11
|
import { PaymentDetail, getPaymentAmountForCycleSubscription } from '../../payment';
|
|
13
12
|
import { getMainProductName } from '../../product';
|
|
14
13
|
import { getCustomerSubscriptionPageUrl } from '../../subscription';
|
|
@@ -5,12 +5,19 @@ import dayjs from 'dayjs';
|
|
|
5
5
|
import prettyMsI18n from 'pretty-ms-i18n';
|
|
6
6
|
import type { LiteralUnion } from 'type-fest';
|
|
7
7
|
|
|
8
|
-
import { getTokenSummaryByDid } from '@api/integrations/arcblock/stake';
|
|
9
8
|
import { fromUnitToToken } from '@ocap/util';
|
|
9
|
+
import { getTokenSummaryByDid } from '../../../integrations/arcblock/stake';
|
|
10
10
|
import { getUserLocale } from '../../../integrations/blocklet/notification';
|
|
11
11
|
import { translate } from '../../../locales';
|
|
12
|
-
import {
|
|
13
|
-
|
|
12
|
+
import {
|
|
13
|
+
Customer,
|
|
14
|
+
Invoice,
|
|
15
|
+
PaymentMethod,
|
|
16
|
+
Price,
|
|
17
|
+
Subscription,
|
|
18
|
+
SubscriptionItem,
|
|
19
|
+
PaymentCurrency,
|
|
20
|
+
} from '../../../store/models';
|
|
14
21
|
import { getPaymentAmountForCycleSubscription, type PaymentDetail } from '../../payment';
|
|
15
22
|
import { getMainProductName } from '../../product';
|
|
16
23
|
import { getCustomerSubscriptionPageUrl } from '../../subscription';
|
package/api/src/libs/payment.ts
CHANGED
|
@@ -357,10 +357,22 @@ export async function getPaymentAmountForCycleSubscription(
|
|
|
357
357
|
paymentCurrency: PaymentCurrency
|
|
358
358
|
) {
|
|
359
359
|
const subscriptionItems = await SubscriptionItem.findAll({ where: { subscription_id: subscription.id } });
|
|
360
|
+
if (subscriptionItems.length === 0) {
|
|
361
|
+
logger.info('subscription items not found in getPaymentAmountForCycleSubscription', {
|
|
362
|
+
subscription: subscription.id,
|
|
363
|
+
});
|
|
364
|
+
return 0;
|
|
365
|
+
}
|
|
360
366
|
let expandedItems = await Price.expand(
|
|
361
367
|
subscriptionItems.map((x) => ({ id: x.id, price_id: x.price_id, quantity: x.quantity })),
|
|
362
368
|
{ product: true }
|
|
363
369
|
);
|
|
370
|
+
if (expandedItems.length === 0) {
|
|
371
|
+
logger.info('expanded items not found in getPaymentAmountForCycleSubscription', {
|
|
372
|
+
subscription: subscription.id,
|
|
373
|
+
});
|
|
374
|
+
return 0;
|
|
375
|
+
}
|
|
364
376
|
const previousPeriodEnd =
|
|
365
377
|
subscription.status === 'trialing' ? subscription.trial_end : subscription.current_period_end;
|
|
366
378
|
const setup = getSubscriptionCycleSetup(subscription.pending_invoice_item_interval, previousPeriodEnd as number);
|
|
@@ -375,7 +387,7 @@ export async function getPaymentAmountForCycleSubscription(
|
|
|
375
387
|
start: setup.period.start - setup.cycle / 1000,
|
|
376
388
|
end: setup.period.end - setup.cycle / 1000,
|
|
377
389
|
method: x.price.recurring?.aggregate_usage,
|
|
378
|
-
dryRun:
|
|
390
|
+
dryRun: true,
|
|
379
391
|
});
|
|
380
392
|
x.quantity = x.price.transformQuantity(rawQuantity);
|
|
381
393
|
// record raw quantity in metadata
|
|
@@ -13,7 +13,7 @@ import sortBy from 'lodash/sortBy';
|
|
|
13
13
|
import uniq from 'lodash/uniq';
|
|
14
14
|
import type { WhereOptions } from 'sequelize';
|
|
15
15
|
|
|
16
|
-
import { MetadataSchema } from '
|
|
16
|
+
import { MetadataSchema } from '../libs/api';
|
|
17
17
|
import { checkPassportForPaymentLink } from '../integrations/blocklet/passport';
|
|
18
18
|
import { handleStripePaymentSucceed } from '../integrations/stripe/handlers/payment-intent';
|
|
19
19
|
import { handleStripeSubscriptionSucceed } from '../integrations/stripe/handlers/subscription';
|
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.7",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev --open",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@arcblock/validator": "^1.18.135",
|
|
53
53
|
"@blocklet/js-sdk": "1.16.30",
|
|
54
54
|
"@blocklet/logger": "1.16.30",
|
|
55
|
-
"@blocklet/payment-react": "1.15.
|
|
55
|
+
"@blocklet/payment-react": "1.15.7",
|
|
56
56
|
"@blocklet/sdk": "1.16.30",
|
|
57
57
|
"@blocklet/ui-react": "^2.10.33",
|
|
58
58
|
"@blocklet/uploader": "^0.1.35",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"devDependencies": {
|
|
119
119
|
"@abtnode/types": "1.16.30",
|
|
120
120
|
"@arcblock/eslint-config-ts": "^0.3.2",
|
|
121
|
-
"@blocklet/payment-types": "1.15.
|
|
121
|
+
"@blocklet/payment-types": "1.15.7",
|
|
122
122
|
"@types/cookie-parser": "^1.4.7",
|
|
123
123
|
"@types/cors": "^2.8.17",
|
|
124
124
|
"@types/debug": "^4.1.12",
|
|
@@ -160,5 +160,5 @@
|
|
|
160
160
|
"parser": "typescript"
|
|
161
161
|
}
|
|
162
162
|
},
|
|
163
|
-
"gitHead": "
|
|
163
|
+
"gitHead": "9aae61000ca85dc8199f750e3989d756a8747307"
|
|
164
164
|
}
|
|
@@ -128,7 +128,7 @@ function SearchStatus({
|
|
|
128
128
|
<Add sx={{ color: 'text.secondary', cursor: 'pointer', fontSize: '1.2rem' }} />
|
|
129
129
|
)}
|
|
130
130
|
{t('common.status')}
|
|
131
|
-
<span>{search!.status}</span>
|
|
131
|
+
<span>{formatStatus ? formatStatus(search!.status) : search!.status}</span>
|
|
132
132
|
</Button>
|
|
133
133
|
<Menu
|
|
134
134
|
anchorEl={show}
|