payment-kit 1.22.10 → 1.22.11
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.
|
@@ -1470,7 +1470,10 @@ router.put('/:id/submit', user, ensureCheckoutSessionOpen, async (req, res) => {
|
|
|
1470
1470
|
req.body.payment_method,
|
|
1471
1471
|
req.body.payment_currency
|
|
1472
1472
|
);
|
|
1473
|
-
await checkoutSession.update({
|
|
1473
|
+
await checkoutSession.update({
|
|
1474
|
+
currency_id: paymentCurrency.id,
|
|
1475
|
+
metadata: { ...checkoutSession.metadata, preferred_locale: req.locale },
|
|
1476
|
+
});
|
|
1474
1477
|
|
|
1475
1478
|
let customer = await Customer.findOne({ where: { did: req.user.did } });
|
|
1476
1479
|
if (!customer) {
|
package/api/src/routes/index.ts
CHANGED
|
@@ -34,6 +34,7 @@ import usageRecords from './usage-records';
|
|
|
34
34
|
import webhookAttempts from './webhook-attempts';
|
|
35
35
|
import webhookEndpoints from './webhook-endpoints';
|
|
36
36
|
import vendor from './vendor';
|
|
37
|
+
import tool from './tool';
|
|
37
38
|
|
|
38
39
|
const router = Router();
|
|
39
40
|
|
|
@@ -89,5 +90,6 @@ router.use('/usage-records', usageRecords);
|
|
|
89
90
|
router.use('/webhook-attempts', webhookAttempts);
|
|
90
91
|
router.use('/webhook-endpoints', webhookEndpoints);
|
|
91
92
|
router.use('/vendors', vendor);
|
|
93
|
+
router.use('/tool', tool);
|
|
92
94
|
|
|
93
95
|
export default router;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import { Router } from 'express';
|
|
3
|
+
import Joi from 'joi';
|
|
4
|
+
|
|
5
|
+
import { authenticate } from '../libs/security';
|
|
6
|
+
import { formatToShortUrl } from '../libs/url';
|
|
7
|
+
import { CheckoutSession } from '../store/models';
|
|
8
|
+
|
|
9
|
+
const loginAuth = authenticate<CheckoutSession>({ component: false, ensureLogin: true, mine: true });
|
|
10
|
+
|
|
11
|
+
const router = Router();
|
|
12
|
+
|
|
13
|
+
const shortUrlSchema = Joi.object({
|
|
14
|
+
url: Joi.string().uri().required(),
|
|
15
|
+
timeoutMin: Joi.number().optional(),
|
|
16
|
+
maxVisits: Joi.number().optional(),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
router.get('/short-url', loginAuth, async (req, res) => {
|
|
20
|
+
const { error } = shortUrlSchema.validate(req.query);
|
|
21
|
+
if (error) {
|
|
22
|
+
return res.status(400).json({ error: 'Invalid parameters', message: error.message });
|
|
23
|
+
}
|
|
24
|
+
const { url, timeoutMin = 60, maxVisits = 5 } = req.query;
|
|
25
|
+
const timeoutMinNumber = Number(timeoutMin);
|
|
26
|
+
const validUntil = dayjs()
|
|
27
|
+
.add(timeoutMinNumber > 60 ? 60 : timeoutMinNumber, 'minutes')
|
|
28
|
+
.format('YYYY-MM-DDTHH:mm:ss+00:00');
|
|
29
|
+
|
|
30
|
+
const shortUrl = await formatToShortUrl({ url: url as string, validUntil, maxVisits: Number(maxVisits) });
|
|
31
|
+
|
|
32
|
+
return res.json({ url: shortUrl });
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export default router;
|
package/api/src/routes/vendor.ts
CHANGED
|
@@ -476,8 +476,12 @@ async function processVendorOrders(
|
|
|
476
476
|
return {
|
|
477
477
|
payment_status: doc.payment_status,
|
|
478
478
|
session_status: doc.status,
|
|
479
|
+
preferred_locale: doc.metadata?.preferred_locale,
|
|
479
480
|
vendors: await Promise.all(vendors),
|
|
480
481
|
subscriptionId: doc.subscription_id,
|
|
482
|
+
data: {
|
|
483
|
+
preferredLocale: doc.metadata?.preferred_locale,
|
|
484
|
+
},
|
|
481
485
|
error: null,
|
|
482
486
|
};
|
|
483
487
|
}
|
package/blocklet.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.11",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev --open",
|
|
6
6
|
"lint": "tsc --noEmit && eslint src api/src --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"@blocklet/error": "^0.3.2",
|
|
58
58
|
"@blocklet/js-sdk": "^1.17.1",
|
|
59
59
|
"@blocklet/logger": "^1.17.1",
|
|
60
|
-
"@blocklet/payment-broker-client": "1.22.
|
|
61
|
-
"@blocklet/payment-react": "1.22.
|
|
62
|
-
"@blocklet/payment-vendor": "1.22.
|
|
60
|
+
"@blocklet/payment-broker-client": "1.22.11",
|
|
61
|
+
"@blocklet/payment-react": "1.22.11",
|
|
62
|
+
"@blocklet/payment-vendor": "1.22.11",
|
|
63
63
|
"@blocklet/sdk": "^1.17.1",
|
|
64
64
|
"@blocklet/ui-react": "^3.2.1",
|
|
65
65
|
"@blocklet/uploader": "^0.3.8",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"devDependencies": {
|
|
130
130
|
"@abtnode/types": "^1.17.1",
|
|
131
131
|
"@arcblock/eslint-config-ts": "^0.3.3",
|
|
132
|
-
"@blocklet/payment-types": "1.22.
|
|
132
|
+
"@blocklet/payment-types": "1.22.11",
|
|
133
133
|
"@types/cookie-parser": "^1.4.9",
|
|
134
134
|
"@types/cors": "^2.8.19",
|
|
135
135
|
"@types/debug": "^4.1.12",
|
|
@@ -176,5 +176,5 @@
|
|
|
176
176
|
"parser": "typescript"
|
|
177
177
|
}
|
|
178
178
|
},
|
|
179
|
-
"gitHead": "
|
|
179
|
+
"gitHead": "d90e964e8aba2c288fe2960365df20f4159a56a1"
|
|
180
180
|
}
|