@blocklet/payment-react 1.14.14 → 1.14.15
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/es/checkout/table.js +7 -1
- package/es/libs/util.js +3 -0
- package/lib/checkout/table.js +7 -1
- package/lib/libs/util.js +3 -0
- package/package.json +3 -3
- package/src/checkout/table.tsx +8 -1
- package/src/libs/util.ts +4 -0
package/es/checkout/table.js
CHANGED
|
@@ -14,6 +14,12 @@ const fetchData = async (id) => {
|
|
|
14
14
|
const { data } = await api.get(`/api/pricing-tables/${id}`);
|
|
15
15
|
return data;
|
|
16
16
|
};
|
|
17
|
+
const ensureProtocol = (url) => {
|
|
18
|
+
if (!/^https?:\/\//i.test(url)) {
|
|
19
|
+
return `https://${url}`;
|
|
20
|
+
}
|
|
21
|
+
return url;
|
|
22
|
+
};
|
|
17
23
|
export default function CheckoutTable({ id, mode, onPaid, onError, onChange, extraParams, goBack }) {
|
|
18
24
|
if (!id.startsWith("prctbl_")) {
|
|
19
25
|
throw new Error("A valid pricing table id is required.");
|
|
@@ -36,7 +42,7 @@ export default function CheckoutTable({ id, mode, onPaid, onError, onChange, ext
|
|
|
36
42
|
if (mode === "standalone") {
|
|
37
43
|
let { url } = res.data;
|
|
38
44
|
url = url.indexOf("?") > -1 ? `${url}¤cyId=${currencyId}` : `${url}?currencyId=${currencyId}`;
|
|
39
|
-
window.location.replace(url);
|
|
45
|
+
window.location.replace(ensureProtocol(url));
|
|
40
46
|
} else {
|
|
41
47
|
window.location.hash = res.data.id;
|
|
42
48
|
setSessionId(res.data.id);
|
package/es/libs/util.js
CHANGED
|
@@ -151,6 +151,9 @@ export function formatRecurring(recurring, translate = true, separator = "per",
|
|
|
151
151
|
month: "monthly",
|
|
152
152
|
year: "yearly"
|
|
153
153
|
};
|
|
154
|
+
if (!recurring) {
|
|
155
|
+
return "";
|
|
156
|
+
}
|
|
154
157
|
if (+recurring.interval_count === 1) {
|
|
155
158
|
const interval = t(`common.${recurring.interval}`, locale);
|
|
156
159
|
return translate ? t(`common.${intervals[recurring.interval]}`, locale) : separator ? t(`common.${separator}`, locale, { interval }) : interval;
|
package/lib/checkout/table.js
CHANGED
|
@@ -23,6 +23,12 @@ const fetchData = async id => {
|
|
|
23
23
|
} = await _api.default.get(`/api/pricing-tables/${id}`);
|
|
24
24
|
return data;
|
|
25
25
|
};
|
|
26
|
+
const ensureProtocol = url => {
|
|
27
|
+
if (!/^https?:\/\//i.test(url)) {
|
|
28
|
+
return `https://${url}`;
|
|
29
|
+
}
|
|
30
|
+
return url;
|
|
31
|
+
};
|
|
26
32
|
function CheckoutTable({
|
|
27
33
|
id,
|
|
28
34
|
mode,
|
|
@@ -67,7 +73,7 @@ function CheckoutTable({
|
|
|
67
73
|
url
|
|
68
74
|
} = res.data;
|
|
69
75
|
url = url.indexOf("?") > -1 ? `${url}¤cyId=${currencyId}` : `${url}?currencyId=${currencyId}`;
|
|
70
|
-
window.location.replace(url);
|
|
76
|
+
window.location.replace(ensureProtocol(url));
|
|
71
77
|
} else {
|
|
72
78
|
window.location.hash = res.data.id;
|
|
73
79
|
setSessionId(res.data.id);
|
package/lib/libs/util.js
CHANGED
|
@@ -212,6 +212,9 @@ function formatRecurring(recurring, translate = true, separator = "per", locale
|
|
|
212
212
|
month: "monthly",
|
|
213
213
|
year: "yearly"
|
|
214
214
|
};
|
|
215
|
+
if (!recurring) {
|
|
216
|
+
return "";
|
|
217
|
+
}
|
|
215
218
|
if (+recurring.interval_count === 1) {
|
|
216
219
|
const interval = (0, _locales.t)(`common.${recurring.interval}`, locale);
|
|
217
220
|
return translate ? (0, _locales.t)(`common.${intervals[recurring.interval]}`, locale) : separator ? (0, _locales.t)(`common.${separator}`, locale, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.15",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"@babel/core": "^7.25.2",
|
|
92
92
|
"@babel/preset-env": "^7.25.2",
|
|
93
93
|
"@babel/preset-react": "^7.24.7",
|
|
94
|
-
"@blocklet/payment-types": "1.14.
|
|
94
|
+
"@blocklet/payment-types": "1.14.15",
|
|
95
95
|
"@storybook/addon-essentials": "^7.6.20",
|
|
96
96
|
"@storybook/addon-interactions": "^7.6.20",
|
|
97
97
|
"@storybook/addon-links": "^7.6.20",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"vite-plugin-babel": "^1.2.0",
|
|
121
121
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
122
122
|
},
|
|
123
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "a2bc07ca48172f040a2874ee1b4bb751cc41e873"
|
|
124
124
|
}
|
package/src/checkout/table.tsx
CHANGED
|
@@ -18,6 +18,13 @@ const fetchData = async (id: string): Promise<TPricingTableExpanded> => {
|
|
|
18
18
|
return data;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
const ensureProtocol = (url: string): string => {
|
|
22
|
+
if (!/^https?:\/\//i.test(url)) {
|
|
23
|
+
return `https://${url}`;
|
|
24
|
+
}
|
|
25
|
+
return url;
|
|
26
|
+
};
|
|
27
|
+
|
|
21
28
|
export default function CheckoutTable({ id, mode, onPaid, onError, onChange, extraParams, goBack }: CheckoutProps) {
|
|
22
29
|
if (!id.startsWith('prctbl_')) {
|
|
23
30
|
throw new Error('A valid pricing table id is required.');
|
|
@@ -48,7 +55,7 @@ export default function CheckoutTable({ id, mode, onPaid, onError, onChange, ext
|
|
|
48
55
|
if (mode === 'standalone') {
|
|
49
56
|
let { url } = res.data;
|
|
50
57
|
url = url.indexOf('?') > -1 ? `${url}¤cyId=${currencyId}` : `${url}?currencyId=${currencyId}`;
|
|
51
|
-
window.location.replace(url);
|
|
58
|
+
window.location.replace(ensureProtocol(url));
|
|
52
59
|
} else {
|
|
53
60
|
window.location.hash = res.data.id;
|
|
54
61
|
setSessionId(res.data.id);
|
package/src/libs/util.ts
CHANGED