payment-kit 1.13.120 → 1.13.121
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/libs/resource.ts +21 -29
- package/blocklet.yml +1 -1
- package/package.json +4 -4
package/api/src/libs/resource.ts
CHANGED
|
@@ -54,19 +54,17 @@ export async function initPaywallResources() {
|
|
|
54
54
|
const config: any = JSON.parse(
|
|
55
55
|
replace(fs.readFileSync(path.join(configPath!, 'config.json'), 'utf8'), {
|
|
56
56
|
...env,
|
|
57
|
-
// @ts-ignore
|
|
58
57
|
monthPrice: resource.env?.MONTH_PRICE || '5',
|
|
59
|
-
// @ts-ignore
|
|
60
58
|
yearPrice: resource.env?.YEAR_PRICE || '30',
|
|
59
|
+
passport: resource.env?.PASSPORT_NAME || 'discussionSubscriber',
|
|
61
60
|
})
|
|
62
61
|
);
|
|
63
62
|
console.info('try import paywall config', config);
|
|
64
63
|
|
|
65
|
-
if (!
|
|
64
|
+
if (!config.passport) {
|
|
66
65
|
console.warn(`invalid paywall resource from ${configPath}: passport empty`);
|
|
67
66
|
continue;
|
|
68
67
|
}
|
|
69
|
-
|
|
70
68
|
if (!config.product) {
|
|
71
69
|
console.warn(`invalid paywall resource from ${configPath}: product empty`);
|
|
72
70
|
continue;
|
|
@@ -76,7 +74,7 @@ export async function initPaywallResources() {
|
|
|
76
74
|
continue;
|
|
77
75
|
}
|
|
78
76
|
|
|
79
|
-
const metadata = { source: resource.did };
|
|
77
|
+
const metadata = { source: resource.did, passport: config.passport };
|
|
80
78
|
const currency = await PaymentCurrency.findOne({
|
|
81
79
|
where: { is_base_currency: true, livemode: config.product.livemode },
|
|
82
80
|
});
|
|
@@ -92,6 +90,12 @@ export async function initPaywallResources() {
|
|
|
92
90
|
if (existProduct) {
|
|
93
91
|
console.warn(`paywall resource already imported from path: ${configPath}`);
|
|
94
92
|
|
|
93
|
+
await existProduct.update({
|
|
94
|
+
name: config.product.name,
|
|
95
|
+
description: config.product.description,
|
|
96
|
+
metadata,
|
|
97
|
+
});
|
|
98
|
+
|
|
95
99
|
// @ts-ignore
|
|
96
100
|
const monthPrice = existProduct.prices.find(
|
|
97
101
|
// @ts-ignore
|
|
@@ -174,26 +178,18 @@ export async function initPaywallResources() {
|
|
|
174
178
|
});
|
|
175
179
|
console.info('payment link recreated for paywall resource', { link: link.id });
|
|
176
180
|
|
|
177
|
-
await
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
acquire: { pay: link.id },
|
|
182
|
-
})
|
|
183
|
-
)
|
|
184
|
-
);
|
|
181
|
+
await updatePassportExtra(config.passport, {
|
|
182
|
+
payment: { product: existProduct.id },
|
|
183
|
+
acquire: { pay: link.id },
|
|
184
|
+
});
|
|
185
185
|
console.info('product and payment link reassociated with passport');
|
|
186
186
|
} else {
|
|
187
187
|
const existLink = await PaymentLink.findOne({ where: { 'metadata.source': resource.did } });
|
|
188
188
|
if (existLink) {
|
|
189
|
-
await
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
acquire: { pay: existLink.id },
|
|
194
|
-
})
|
|
195
|
-
)
|
|
196
|
-
);
|
|
189
|
+
await updatePassportExtra(config.passport, {
|
|
190
|
+
payment: { product: existProduct.id },
|
|
191
|
+
acquire: { pay: existLink.id },
|
|
192
|
+
});
|
|
197
193
|
}
|
|
198
194
|
console.info('product and payment link associated with passport again');
|
|
199
195
|
}
|
|
@@ -257,14 +253,10 @@ export async function initPaywallResources() {
|
|
|
257
253
|
});
|
|
258
254
|
console.info('payment link created for paywall resource', { link: link.id });
|
|
259
255
|
|
|
260
|
-
await
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
acquire: { pay: link.id },
|
|
265
|
-
})
|
|
266
|
-
)
|
|
267
|
-
);
|
|
256
|
+
await updatePassportExtra(config.passport, {
|
|
257
|
+
payment: { product: product.id },
|
|
258
|
+
acquire: { pay: link.id },
|
|
259
|
+
});
|
|
268
260
|
console.info('product and payment link associated with passport');
|
|
269
261
|
}
|
|
270
262
|
console.info(`paywall resource successfully imported from path: ${configPath}`);
|
package/blocklet.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.121",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "cross-env COMPONENT_STORE_URL=https://test.store.blocklet.dev blocklet dev",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@arcblock/jwt": "^1.18.108",
|
|
51
51
|
"@arcblock/ux": "^2.9.19",
|
|
52
52
|
"@blocklet/logger": "1.16.23-beta-aeb9f5bd",
|
|
53
|
-
"@blocklet/payment-react": "1.13.
|
|
53
|
+
"@blocklet/payment-react": "1.13.121",
|
|
54
54
|
"@blocklet/sdk": "1.16.23-beta-aeb9f5bd",
|
|
55
55
|
"@blocklet/ui-react": "^2.9.19",
|
|
56
56
|
"@blocklet/uploader": "^0.0.67",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"devDependencies": {
|
|
111
111
|
"@abtnode/types": "1.16.23-beta-aeb9f5bd",
|
|
112
112
|
"@arcblock/eslint-config-ts": "^0.2.4",
|
|
113
|
-
"@blocklet/payment-types": "1.13.
|
|
113
|
+
"@blocklet/payment-types": "1.13.121",
|
|
114
114
|
"@types/cookie-parser": "^1.4.6",
|
|
115
115
|
"@types/cors": "^2.8.17",
|
|
116
116
|
"@types/dotenv-flow": "^3.3.3",
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"parser": "typescript"
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "c02f337493cf7dac11324447534cf8684b763064"
|
|
153
153
|
}
|