payment-kit 1.15.7 → 1.15.8
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/crons/currency.ts +36 -0
- package/api/src/hooks/pre-start.ts +2 -0
- package/api/src/index.ts +2 -0
- package/api/src/libs/notification/template/customer-reward-succeeded.ts +10 -0
- package/api/src/libs/notification/template/subscription-will-renew.ts +22 -20
- package/blocklet.yml +1 -1
- package/package.json +10 -10
- package/src/components/product/create.tsx +2 -2
- package/src/contexts/products.tsx +1 -1
- package/src/pages/customer/subscription/change-payment.tsx +1 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Op } from 'sequelize';
|
|
2
|
+
import { getUrl } from '@blocklet/sdk';
|
|
3
|
+
import { PaymentMethod, PaymentCurrency } from '../store/models';
|
|
4
|
+
import logger from '../libs/logger';
|
|
5
|
+
|
|
6
|
+
export async function syncCurrencyLogo() {
|
|
7
|
+
const where = {
|
|
8
|
+
logo: {
|
|
9
|
+
[Op.like]: '%/methods/%.png',
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const [paymentMethods, paymentCurrencies] = await Promise.all([
|
|
14
|
+
PaymentMethod.findAll({ where }),
|
|
15
|
+
PaymentCurrency.findAll({ where }),
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
const promises: Promise<any>[] = [];
|
|
19
|
+
|
|
20
|
+
const updateLogo = (item: PaymentMethod | PaymentCurrency) => {
|
|
21
|
+
const { logo } = item;
|
|
22
|
+
if (/\/methods\/(stripe|arcblock|ethereum)\.png$/.test(logo)) {
|
|
23
|
+
const newLogo = getUrl(logo.replace(/^.*?(\/methods\/.*)$/, '$1'));
|
|
24
|
+
promises.push((item as any).update({ logo: newLogo }));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
paymentMethods.forEach(updateLogo);
|
|
29
|
+
paymentCurrencies.forEach(updateLogo);
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
await Promise.all(promises);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
logger.error('syncCurrency error', error);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -6,6 +6,7 @@ import { ensurePaymentStats } from '../crons/payment-stat';
|
|
|
6
6
|
import { initPaywallResources } from '../libs/resource';
|
|
7
7
|
import { initialize } from '../store/models';
|
|
8
8
|
import { sequelize } from '../store/sequelize';
|
|
9
|
+
import { syncCurrencyLogo } from '../crons/currency';
|
|
9
10
|
|
|
10
11
|
dotenv.config({ silent: true });
|
|
11
12
|
|
|
@@ -14,6 +15,7 @@ dotenv.config({ silent: true });
|
|
|
14
15
|
initialize(sequelize);
|
|
15
16
|
await initPaywallResources();
|
|
16
17
|
await ensurePaymentStats();
|
|
18
|
+
await syncCurrencyLogo();
|
|
17
19
|
process.exit(0);
|
|
18
20
|
} catch (err) {
|
|
19
21
|
console.error('pre-start error', err);
|
package/api/src/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import morgan from 'morgan';
|
|
|
11
11
|
|
|
12
12
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
13
13
|
import { xss } from '@blocklet/xss';
|
|
14
|
+
import { csrf } from '@blocklet/sdk/lib/middlewares';
|
|
14
15
|
|
|
15
16
|
import crons from './crons/index';
|
|
16
17
|
import { ensureStakedForGas } from './integrations/arcblock/stake';
|
|
@@ -57,6 +58,7 @@ app.use((req, res, next) => {
|
|
|
57
58
|
app.use(express.urlencoded({ extended: true, limit: '1 mb' }));
|
|
58
59
|
app.use(cors());
|
|
59
60
|
app.use(xss({ allowedKeys: [] }));
|
|
61
|
+
app.use(csrf());
|
|
60
62
|
app.use(ensureI18n());
|
|
61
63
|
|
|
62
64
|
const router = express.Router();
|
|
@@ -44,6 +44,7 @@ interface CustomerRewardSucceededEmailTemplateContext {
|
|
|
44
44
|
title: string;
|
|
45
45
|
appDID: string;
|
|
46
46
|
logo?: string;
|
|
47
|
+
desc?: string;
|
|
47
48
|
}[]
|
|
48
49
|
| null;
|
|
49
50
|
donationSettings: DonationSettings;
|
|
@@ -187,6 +188,7 @@ export class CustomerRewardSucceededEmailTemplate
|
|
|
187
188
|
title: string;
|
|
188
189
|
appDID: string;
|
|
189
190
|
logo?: string;
|
|
191
|
+
desc?: string;
|
|
190
192
|
}[]
|
|
191
193
|
| null
|
|
192
194
|
> {
|
|
@@ -215,6 +217,7 @@ export class CustomerRewardSucceededEmailTemplate
|
|
|
215
217
|
? joinURL(process.env.BLOCKLET_APP_URL, users[index]?.user?.avatar as string)
|
|
216
218
|
: '',
|
|
217
219
|
appDID: x.address,
|
|
220
|
+
desc: '',
|
|
218
221
|
};
|
|
219
222
|
});
|
|
220
223
|
|
|
@@ -296,6 +299,13 @@ export class CustomerRewardSucceededEmailTemplate
|
|
|
296
299
|
text: translate('notification.common.rewardDetail', locale),
|
|
297
300
|
},
|
|
298
301
|
},
|
|
302
|
+
{
|
|
303
|
+
type: 'text',
|
|
304
|
+
data: {
|
|
305
|
+
type: 'plain',
|
|
306
|
+
text: ' ', // TODO: ios bug fix, wait for next release
|
|
307
|
+
},
|
|
308
|
+
},
|
|
299
309
|
].filter(Boolean),
|
|
300
310
|
},
|
|
301
311
|
...(rewardDetail
|
|
@@ -326,25 +326,28 @@ export class SubscriptionWillRenewEmailTemplate
|
|
|
326
326
|
text: paymentInfo,
|
|
327
327
|
},
|
|
328
328
|
},
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
329
|
+
...(!isStripe
|
|
330
|
+
? [
|
|
331
|
+
{
|
|
332
|
+
type: 'text',
|
|
333
|
+
data: {
|
|
334
|
+
type: 'plain',
|
|
335
|
+
color: '#9397A1',
|
|
336
|
+
text: translate('notification.common.currentBalance', locale),
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
type: 'text',
|
|
341
|
+
data: {
|
|
342
|
+
type: 'plain',
|
|
343
|
+
...(!canPay && {
|
|
344
|
+
color: '#FF0000',
|
|
345
|
+
}),
|
|
346
|
+
text: `${paymentDetail.balance} ${paymentDetail.symbol}`,
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
]
|
|
350
|
+
: []),
|
|
348
351
|
...(!canPay && !isStripe
|
|
349
352
|
? [
|
|
350
353
|
{
|
|
@@ -368,7 +371,6 @@ export class SubscriptionWillRenewEmailTemplate
|
|
|
368
371
|
},
|
|
369
372
|
]
|
|
370
373
|
: []),
|
|
371
|
-
|
|
372
374
|
{
|
|
373
375
|
type: 'text',
|
|
374
376
|
data: {
|
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.8",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev --open",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
]
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@abtnode/cron": "1.16.
|
|
45
|
+
"@abtnode/cron": "^1.16.31",
|
|
46
46
|
"@arcblock/did": "^1.18.135",
|
|
47
47
|
"@arcblock/did-auth-storage-nedb": "^1.7.1",
|
|
48
48
|
"@arcblock/did-connect": "^2.10.33",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"@arcblock/jwt": "^1.18.135",
|
|
51
51
|
"@arcblock/ux": "^2.10.33",
|
|
52
52
|
"@arcblock/validator": "^1.18.135",
|
|
53
|
-
"@blocklet/js-sdk": "1.16.
|
|
54
|
-
"@blocklet/logger": "1.16.
|
|
55
|
-
"@blocklet/payment-react": "1.15.
|
|
56
|
-
"@blocklet/sdk": "1.16.
|
|
53
|
+
"@blocklet/js-sdk": "^1.16.31",
|
|
54
|
+
"@blocklet/logger": "^1.16.31",
|
|
55
|
+
"@blocklet/payment-react": "1.15.8",
|
|
56
|
+
"@blocklet/sdk": "^1.16.31",
|
|
57
57
|
"@blocklet/ui-react": "^2.10.33",
|
|
58
|
-
"@blocklet/uploader": "^0.1.
|
|
58
|
+
"@blocklet/uploader": "^0.1.36",
|
|
59
59
|
"@blocklet/xss": "^0.1.7",
|
|
60
60
|
"@mui/icons-material": "^5.16.6",
|
|
61
61
|
"@mui/lab": "^5.0.0-alpha.173",
|
|
@@ -116,9 +116,9 @@
|
|
|
116
116
|
"validator": "^13.12.0"
|
|
117
117
|
},
|
|
118
118
|
"devDependencies": {
|
|
119
|
-
"@abtnode/types": "1.16.
|
|
119
|
+
"@abtnode/types": "^1.16.31",
|
|
120
120
|
"@arcblock/eslint-config-ts": "^0.3.2",
|
|
121
|
-
"@blocklet/payment-types": "1.15.
|
|
121
|
+
"@blocklet/payment-types": "1.15.8",
|
|
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": "d0e3c23bed5a41a9b16554fc3b7458e8dee4fd60"
|
|
164
164
|
}
|
|
@@ -29,7 +29,7 @@ export default function CreateProduct({
|
|
|
29
29
|
name: '',
|
|
30
30
|
description: '',
|
|
31
31
|
images: [],
|
|
32
|
-
statement_descriptor:
|
|
32
|
+
statement_descriptor: '',
|
|
33
33
|
unit_label: '',
|
|
34
34
|
features: [],
|
|
35
35
|
prices: [{ ...DEFAULT_PRICE, currency_id: settings.baseCurrency.id }],
|
|
@@ -47,7 +47,7 @@ export default function CreateProduct({
|
|
|
47
47
|
|
|
48
48
|
const onCreate = (data: Product) => {
|
|
49
49
|
setState({ loading: true });
|
|
50
|
-
api
|
|
50
|
+
return api
|
|
51
51
|
.post('/api/products', data)
|
|
52
52
|
.then(() => {
|
|
53
53
|
Toast.success(t('admin.product.saved'));
|
|
@@ -15,7 +15,7 @@ const { Provider, Consumer } = ProductsContext;
|
|
|
15
15
|
|
|
16
16
|
const getProducts = async (): Promise<TProductExpanded[]> => {
|
|
17
17
|
// FIXME: pagination here
|
|
18
|
-
const { data } = await api.get('/api/products?active=true&page=1&pageSize=100');
|
|
18
|
+
const { data } = await api.get('/api/products?active=true&page=1&pageSize=100&donation=hide');
|
|
19
19
|
return data.list || [];
|
|
20
20
|
};
|
|
21
21
|
|