@loczer/storefront-sdk 0.179.0 → 0.181.0
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/dist/lib/checkoutPaymentSession.d.ts +2 -2
- package/dist/lib/checkoutPaymentSession.js +6 -6
- package/dist/lib/securePaymentLink.d.ts +3 -3
- package/dist/lib/securePaymentLink.js +7 -7
- package/dist/pages/CheckoutPaymentPage.js +12 -12
- package/dist/pages/PaymentLinkPage.js +9 -9
- package/package.json +3 -3
|
@@ -40,10 +40,10 @@ export declare const responseSchema: z.ZodObject<{
|
|
|
40
40
|
testmode: z.ZodOptional<z.ZodBoolean>;
|
|
41
41
|
checkoutUrl: z.ZodOptional<z.ZodString>;
|
|
42
42
|
clientSecret: z.ZodOptional<z.ZodString>;
|
|
43
|
-
|
|
43
|
+
providerAccountId: z.ZodOptional<z.ZodString>;
|
|
44
44
|
stripePublishableKey: z.ZodOptional<z.ZodString>;
|
|
45
45
|
payment: z.ZodOptional<z.ZodObject<{
|
|
46
|
-
|
|
46
|
+
providerPaymentId: z.ZodString;
|
|
47
47
|
amount: z.ZodNumber;
|
|
48
48
|
currency: z.ZodString;
|
|
49
49
|
status: z.ZodString;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z as t } from "zod";
|
|
2
|
-
const
|
|
2
|
+
const r = "/api/public/storefront/checkout/payment-session", e = t.enum([
|
|
3
3
|
"stripe_connect_oauth",
|
|
4
4
|
"mollie_connect_oauth"
|
|
5
5
|
]), o = t.enum([
|
|
@@ -8,13 +8,13 @@ const s = "/api/public/storefront/checkout/payment-session", e = t.enum([
|
|
|
8
8
|
"succeeded",
|
|
9
9
|
"failed",
|
|
10
10
|
"cancelled"
|
|
11
|
-
]),
|
|
11
|
+
]), s = t.object({
|
|
12
12
|
storeSlug: t.string().trim().min(1).toLowerCase(),
|
|
13
13
|
checkoutSessionId: t.string().trim().min(1).max(256),
|
|
14
14
|
returnSearch: t.string().max(2e3).optional(),
|
|
15
15
|
cardToken: t.string().trim().min(1).optional()
|
|
16
16
|
}), n = t.object({
|
|
17
|
-
|
|
17
|
+
providerPaymentId: t.string(),
|
|
18
18
|
amount: t.number().int().positive(),
|
|
19
19
|
currency: t.string(),
|
|
20
20
|
status: t.string(),
|
|
@@ -32,14 +32,14 @@ const s = "/api/public/storefront/checkout/payment-session", e = t.enum([
|
|
|
32
32
|
testmode: t.boolean().optional(),
|
|
33
33
|
checkoutUrl: t.string().url().optional(),
|
|
34
34
|
clientSecret: t.string().optional(),
|
|
35
|
-
|
|
35
|
+
providerAccountId: t.string().optional(),
|
|
36
36
|
stripePublishableKey: t.string().optional(),
|
|
37
37
|
payment: n.optional()
|
|
38
38
|
});
|
|
39
39
|
export {
|
|
40
|
-
|
|
40
|
+
r as ROUTE,
|
|
41
41
|
e as checkoutPaymentSessionProviderTypeSchema,
|
|
42
42
|
o as checkoutPaymentSessionStatusSchema,
|
|
43
|
-
|
|
43
|
+
s as requestSchema,
|
|
44
44
|
a as responseSchema
|
|
45
45
|
};
|
|
@@ -59,10 +59,10 @@ export declare const getStripeSecurePaymentSessionResponseSchema: z.ZodObject<{
|
|
|
59
59
|
success: z.ZodBoolean;
|
|
60
60
|
message: z.ZodString;
|
|
61
61
|
clientSecret: z.ZodOptional<z.ZodString>;
|
|
62
|
-
|
|
62
|
+
providerAccountId: z.ZodOptional<z.ZodString>;
|
|
63
63
|
stripePublishableKey: z.ZodOptional<z.ZodString>;
|
|
64
64
|
payment: z.ZodOptional<z.ZodObject<{
|
|
65
|
-
|
|
65
|
+
providerPaymentId: z.ZodString;
|
|
66
66
|
amount: z.ZodNumber;
|
|
67
67
|
currency: z.ZodString;
|
|
68
68
|
status: z.ZodString;
|
|
@@ -93,7 +93,7 @@ export declare const getMollieSecurePaymentSessionResponseSchema: z.ZodObject<{
|
|
|
93
93
|
}>>;
|
|
94
94
|
checkoutUrl: z.ZodOptional<z.ZodString>;
|
|
95
95
|
payment: z.ZodOptional<z.ZodObject<{
|
|
96
|
-
|
|
96
|
+
providerPaymentId: z.ZodString;
|
|
97
97
|
amount: z.ZodNumber;
|
|
98
98
|
currency: z.ZodString;
|
|
99
99
|
status: z.ZodString;
|
|
@@ -29,14 +29,14 @@ const o = "/api/public/storefront/secure-payment-link/get", s = "/api/public/sto
|
|
|
29
29
|
}), m = e.object({
|
|
30
30
|
storeSlug: e.string().trim().min(1).toLowerCase(),
|
|
31
31
|
token: e.string().trim().min(1)
|
|
32
|
-
}),
|
|
32
|
+
}), p = e.object({
|
|
33
33
|
success: e.boolean(),
|
|
34
34
|
message: e.string(),
|
|
35
35
|
clientSecret: e.string().optional(),
|
|
36
|
-
|
|
36
|
+
providerAccountId: e.string().optional(),
|
|
37
37
|
stripePublishableKey: e.string().optional(),
|
|
38
38
|
payment: e.object({
|
|
39
|
-
|
|
39
|
+
providerPaymentId: e.string(),
|
|
40
40
|
amount: e.number().int().positive(),
|
|
41
41
|
currency: e.string(),
|
|
42
42
|
status: e.string(),
|
|
@@ -44,7 +44,7 @@ const o = "/api/public/storefront/secure-payment-link/get", s = "/api/public/sto
|
|
|
44
44
|
description: e.string().optional(),
|
|
45
45
|
livemode: e.boolean()
|
|
46
46
|
}).optional()
|
|
47
|
-
}),
|
|
47
|
+
}), l = e.object({
|
|
48
48
|
storeSlug: e.string().trim().min(1).toLowerCase(),
|
|
49
49
|
token: e.string().trim().min(1),
|
|
50
50
|
cardToken: e.string().trim().min(1).optional()
|
|
@@ -56,7 +56,7 @@ const o = "/api/public/storefront/secure-payment-link/get", s = "/api/public/sto
|
|
|
56
56
|
paymentStatus: t.optional(),
|
|
57
57
|
checkoutUrl: e.string().url().optional(),
|
|
58
58
|
payment: e.object({
|
|
59
|
-
|
|
59
|
+
providerPaymentId: e.string(),
|
|
60
60
|
amount: e.number().int().positive(),
|
|
61
61
|
currency: e.string(),
|
|
62
62
|
status: e.string(),
|
|
@@ -69,12 +69,12 @@ export {
|
|
|
69
69
|
r as GET_MOLLIE_SECURE_PAYMENT_SESSION_ROUTE,
|
|
70
70
|
o as GET_SECURE_PAYMENT_LINK_ROUTE,
|
|
71
71
|
s as GET_STRIPE_SECURE_PAYMENT_SESSION_ROUTE,
|
|
72
|
-
|
|
72
|
+
l as getMollieSecurePaymentSessionRequestSchema,
|
|
73
73
|
u as getMollieSecurePaymentSessionResponseSchema,
|
|
74
74
|
c as getSecurePaymentLinkRequestSchema,
|
|
75
75
|
a as getSecurePaymentLinkResponseSchema,
|
|
76
76
|
m as getStripeSecurePaymentSessionRequestSchema,
|
|
77
|
-
|
|
77
|
+
p as getStripeSecurePaymentSessionResponseSchema,
|
|
78
78
|
n as securePaymentLinkProviderTypeSchema,
|
|
79
79
|
t as securePaymentLinkStatusSchema
|
|
80
80
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as n } from "react/jsx-runtime";
|
|
2
2
|
import { useState as f, useRef as j, useEffect as L, useMemo as K } from "react";
|
|
3
3
|
import { toast as G } from "@rpcbase/client";
|
|
4
|
-
import { useParams as J, useNavigate as Q, useSearchParams as V, Link as
|
|
4
|
+
import { useParams as J, useNavigate as Q, useSearchParams as V, Link as v } from "@rpcbase/router";
|
|
5
5
|
import { loadStripe as W } from "@stripe/stripe-js";
|
|
6
6
|
import { Elements as Z, useStripe as ee } from "@stripe/react-stripe-js";
|
|
7
7
|
import { Spinner as te } from "../chunks/ui/dist/Spinner/index-SbbUxcsT.js";
|
|
@@ -13,7 +13,7 @@ import { pickBookingSearchParams as ue } from "../lib/booking.js";
|
|
|
13
13
|
import { useStorefrontCart as me } from "../lib/cart.js";
|
|
14
14
|
import { MollieCardFieldsForm as de } from "../components/payment/MollieCardFieldsForm.js";
|
|
15
15
|
import { StripeCardFieldsForm as pe } from "../components/payment/StripeCardFieldsForm.js";
|
|
16
|
-
import { Button as
|
|
16
|
+
import { Button as N } from "../ui/button.js";
|
|
17
17
|
import { Card as y } from "../ui/card.js";
|
|
18
18
|
const he = {}, _e = () => he?.RB_PUBLIC_STRIPE_PUBLISHABLE_KEY?.trim() ?? "", fe = _e(), ye = 20, xe = 2500, ge = (t, u, c) => {
|
|
19
19
|
try {
|
|
@@ -65,7 +65,7 @@ function be() {
|
|
|
65
65
|
function Fe() {
|
|
66
66
|
const { t, i18n: u } = E(), { storeSlug: c } = J(), _ = Q(), { clear: x } = me(), [m] = V(), [r, d] = f(null), [q, g] = f(!0), [I, k] = f(null), [D, X] = f(0), [A, U] = f(0), b = j(!1), l = j(null), p = m.get("checkout_session_id")?.trim() ?? "", $ = new URLSearchParams(m.toString());
|
|
67
67
|
$.delete("checkout_session_id");
|
|
68
|
-
const h = ue($).toString(),
|
|
68
|
+
const h = ue($).toString(), S = `/${c ?? ""}/checkout${h ? `?${h}` : ""}`, P = `/${c ?? ""}/checkout/success${h ? `?${h}` : ""}`, R = async (a) => {
|
|
69
69
|
if (!c || !p)
|
|
70
70
|
throw new Error(t("checkout_payment_return_missing_session"));
|
|
71
71
|
const s = await ie(
|
|
@@ -113,20 +113,20 @@ function Fe() {
|
|
|
113
113
|
}, [p, x, _, h, D, c, P, t]);
|
|
114
114
|
const o = r?.paymentStatus ?? "pending";
|
|
115
115
|
L(() => {
|
|
116
|
-
if (o !== "pending" || r?.providerType === "stripe_connect_oauth" || A >= ye || !r?.payment?.
|
|
116
|
+
if (o !== "pending" || r?.providerType === "stripe_connect_oauth" || A >= ye || !r?.payment?.providerPaymentId) return;
|
|
117
117
|
const a = window.setTimeout(() => {
|
|
118
118
|
U((s) => s + 1), X((s) => s + 1);
|
|
119
119
|
}, xe);
|
|
120
120
|
return () => {
|
|
121
121
|
window.clearTimeout(a);
|
|
122
122
|
};
|
|
123
|
-
}, [o, A, r?.payment?.
|
|
123
|
+
}, [o, A, r?.payment?.providerPaymentId, r?.providerType]);
|
|
124
124
|
const z = K(() => {
|
|
125
125
|
const a = r?.stripePublishableKey?.trim() || fe;
|
|
126
|
-
return !a || !r?.
|
|
127
|
-
stripeAccount: r.
|
|
126
|
+
return !a || !r?.providerAccountId ? null : W(a, {
|
|
127
|
+
stripeAccount: r.providerAccountId
|
|
128
128
|
});
|
|
129
|
-
}, [r?.
|
|
129
|
+
}, [r?.providerAccountId, r?.stripePublishableKey]), M = K(() => {
|
|
130
130
|
if (r?.clientSecret)
|
|
131
131
|
return {
|
|
132
132
|
clientSecret: r.clientSecret
|
|
@@ -138,7 +138,7 @@ function Fe() {
|
|
|
138
138
|
/* @__PURE__ */ e(O, { className: "mt-0.5 h-5 w-5 text-destructive", "aria-hidden": "true" }),
|
|
139
139
|
/* @__PURE__ */ e("p", { className: "text-sm text-slate-700", children: /* @__PURE__ */ e("span", { children: t("checkout_payment_return_missing_session") }) })
|
|
140
140
|
] }),
|
|
141
|
-
/* @__PURE__ */ e(
|
|
141
|
+
/* @__PURE__ */ e(v, { to: S, children: /* @__PURE__ */ e(N, { variant: "outline", children: /* @__PURE__ */ e("span", { children: t("checkout_payment_return_back_to_checkout") }) }) })
|
|
142
142
|
] }) }) });
|
|
143
143
|
if (q && !r)
|
|
144
144
|
return /* @__PURE__ */ e("div", { className: "mx-auto max-w-3xl px-4 py-14 sm:px-6", children: /* @__PURE__ */ e(y, { className: "border-slate-200 bg-white p-5 sm:p-6 shadow-sm", children: /* @__PURE__ */ e(be, {}) }) });
|
|
@@ -148,7 +148,7 @@ function Fe() {
|
|
|
148
148
|
/* @__PURE__ */ e(O, { className: "mt-0.5 h-5 w-5 text-destructive", "aria-hidden": "true" }),
|
|
149
149
|
/* @__PURE__ */ e("p", { className: "text-sm text-slate-700", children: /* @__PURE__ */ e("span", { children: I ?? t("checkout_payment_return_status_error") }) })
|
|
150
150
|
] }),
|
|
151
|
-
/* @__PURE__ */ e(
|
|
151
|
+
/* @__PURE__ */ e(v, { to: S, children: /* @__PURE__ */ e(N, { variant: "outline", children: /* @__PURE__ */ e("span", { children: t("checkout_payment_return_back_to_checkout") }) }) })
|
|
152
152
|
] }) }) });
|
|
153
153
|
const B = typeof r.amountMinor == "number" && r.currency ? ge(r.amountMinor, r.currency, u.language) : null, w = o === "authorized" || o === "succeeded", T = o === "failed" || o === "cancelled", Y = w ? se : T ? ne : ce, H = w ? "text-success" : T ? "text-destructive" : "text-warning";
|
|
154
154
|
return /* @__PURE__ */ e("div", { className: "mx-auto max-w-5xl px-4 py-10 sm:px-6", children: /* @__PURE__ */ n("div", { className: "grid gap-6 lg:grid-cols-[1fr_1fr]", children: [
|
|
@@ -178,10 +178,10 @@ function Fe() {
|
|
|
178
178
|
/* @__PURE__ */ e("h2", { className: "text-xl font-semibold text-slate-950", children: /* @__PURE__ */ e("span", { children: t(`secure_payment_link.success_titles.${o}`) }) }),
|
|
179
179
|
/* @__PURE__ */ e("p", { className: "text-sm text-slate-600", children: /* @__PURE__ */ e("span", { children: t(`secure_payment_link.statuses.${o}`) }) })
|
|
180
180
|
] }),
|
|
181
|
-
w ? /* @__PURE__ */ e(
|
|
181
|
+
w ? /* @__PURE__ */ e(v, { to: P, children: /* @__PURE__ */ n(N, { className: "gap-2", children: [
|
|
182
182
|
/* @__PURE__ */ e("span", { children: t("checkout_payment_return_go_to_success") }),
|
|
183
183
|
/* @__PURE__ */ e(ae, { className: "h-4 w-4", "aria-hidden": "true" })
|
|
184
|
-
] }) }) : /* @__PURE__ */ e(
|
|
184
|
+
] }) }) : /* @__PURE__ */ e(v, { to: S, children: /* @__PURE__ */ e(N, { children: /* @__PURE__ */ e("span", { children: t("checkout_payment_return_retry_checkout") }) }) })
|
|
185
185
|
] }) : r.providerType === "mollie_connect_oauth" ? /* @__PURE__ */ n("div", { className: "space-y-4", children: [
|
|
186
186
|
/* @__PURE__ */ e("h2", { className: "text-lg font-semibold text-slate-950", children: /* @__PURE__ */ e("span", { children: t("secure_payment_link.mollie.form_title") }) }),
|
|
187
187
|
/* @__PURE__ */ e("p", { className: "text-sm text-slate-600", children: /* @__PURE__ */ e("span", { children: t("checkout_payment_hold_form_description") }) }),
|
|
@@ -29,7 +29,7 @@ function C() {
|
|
|
29
29
|
/* @__PURE__ */ e("span", { children: r("secure_payment_link.form.loading_session") })
|
|
30
30
|
] });
|
|
31
31
|
}
|
|
32
|
-
const
|
|
32
|
+
const Ne = (async ({ ctx: r, params: d }) => {
|
|
33
33
|
const l = typeof d.storeSlug == "string" ? d.storeSlug.trim().toLowerCase() : "", o = typeof d.token == "string" ? d.token.trim() : "";
|
|
34
34
|
if (!l || !o)
|
|
35
35
|
return {
|
|
@@ -106,7 +106,7 @@ function ce({
|
|
|
106
106
|
);
|
|
107
107
|
}
|
|
108
108
|
function we() {
|
|
109
|
-
const { t: r, i18n: d } = k(), l = j(), o = G(), { storeSlug: n, token: t } = o, s = o.session, b = o.errorMessage ?? (o.errorKey ? r(`secure_payment_link.errors.${o.errorKey}`) : null), K = s?.providerType === "mollie_connect_oauth" && s.status === "pending" && !!(n && t), A = s?.providerType === "stripe_connect_oauth" && s.status === "pending" && !!(n && t), [y, h] = p(null), [F, f] = p(K), [
|
|
109
|
+
const { t: r, i18n: d } = k(), l = j(), o = G(), { storeSlug: n, token: t } = o, s = o.session, b = o.errorMessage ?? (o.errorKey ? r(`secure_payment_link.errors.${o.errorKey}`) : null), K = s?.providerType === "mollie_connect_oauth" && s.status === "pending" && !!(n && t), A = s?.providerType === "stripe_connect_oauth" && s.status === "pending" && !!(n && t), [y, h] = p(null), [F, f] = p(K), [v, _] = p(null), [m, N] = p(null), [$, w] = p(A), [E, S] = p(null), L = `/${n ?? ""}/secure-payment-link/${t ?? ""}/success`;
|
|
110
110
|
T(() => {
|
|
111
111
|
if (!s || !n || !t) {
|
|
112
112
|
h(null), _(null), f(!1);
|
|
@@ -144,7 +144,7 @@ function we() {
|
|
|
144
144
|
}, [s, n, r, t]), T(() => {
|
|
145
145
|
if (!s || s.providerType !== "stripe_connect_oauth" || s.status !== "pending" || !n || !t) return;
|
|
146
146
|
let a = !1;
|
|
147
|
-
return w(!0), S(null),
|
|
147
|
+
return w(!0), S(null), N(null), (async () => {
|
|
148
148
|
try {
|
|
149
149
|
const u = await g(
|
|
150
150
|
X,
|
|
@@ -158,7 +158,7 @@ function we() {
|
|
|
158
158
|
S(i.message || r("secure_payment_link.errors.session_failed"));
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
|
-
|
|
161
|
+
N(i);
|
|
162
162
|
} catch (u) {
|
|
163
163
|
if (a) return;
|
|
164
164
|
console.error("Failed to create stripe secure session", u), S(r("secure_payment_link.errors.session_failed"));
|
|
@@ -171,10 +171,10 @@ function we() {
|
|
|
171
171
|
}, [s, n, r, t]);
|
|
172
172
|
const P = M(() => {
|
|
173
173
|
const a = m?.stripePublishableKey?.trim() || oe;
|
|
174
|
-
return !a || !m?.
|
|
175
|
-
stripeAccount: m.
|
|
174
|
+
return !a || !m?.providerAccountId ? null : z(a, {
|
|
175
|
+
stripeAccount: m.providerAccountId
|
|
176
176
|
});
|
|
177
|
-
}, [m?.
|
|
177
|
+
}, [m?.providerAccountId, m?.stripePublishableKey]), I = M(() => {
|
|
178
178
|
if (m?.clientSecret)
|
|
179
179
|
return {
|
|
180
180
|
clientSecret: m.clientSecret
|
|
@@ -215,7 +215,7 @@ function we() {
|
|
|
215
215
|
/* @__PURE__ */ e(x, { className: "border-slate-200 bg-white p-5 shadow-sm", children: s.providerType === "mollie_connect_oauth" ? /* @__PURE__ */ c("div", { className: "space-y-4", children: [
|
|
216
216
|
/* @__PURE__ */ e("h2", { className: "text-lg font-semibold text-slate-950", children: /* @__PURE__ */ e("span", { children: r("secure_payment_link.mollie.form_title") }) }),
|
|
217
217
|
/* @__PURE__ */ e("p", { className: "text-sm text-slate-600", children: /* @__PURE__ */ e("span", { children: r("secure_payment_link.mollie.form_description") }) }),
|
|
218
|
-
F ? /* @__PURE__ */ e(C, {}) :
|
|
218
|
+
F ? /* @__PURE__ */ e(C, {}) : v ? /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: /* @__PURE__ */ e("span", { children: v }) }) : y?.profileId ? /* @__PURE__ */ e(
|
|
219
219
|
se,
|
|
220
220
|
{
|
|
221
221
|
profileId: y.profileId,
|
|
@@ -255,5 +255,5 @@ function we() {
|
|
|
255
255
|
}
|
|
256
256
|
export {
|
|
257
257
|
we as default,
|
|
258
|
-
|
|
258
|
+
Ne as loader
|
|
259
259
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loczer/storefront-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.181.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -164,8 +164,8 @@
|
|
|
164
164
|
"@types/qrcode": "1.5.6",
|
|
165
165
|
"@types/react-signature-canvas": "1.0.7",
|
|
166
166
|
"@vitejs/plugin-react": "5.1.2",
|
|
167
|
-
"react": "19.2.
|
|
168
|
-
"react-dom": "19.2.
|
|
167
|
+
"react": "19.2.7",
|
|
168
|
+
"react-dom": "19.2.7",
|
|
169
169
|
"tailwindcss": "4.1.18",
|
|
170
170
|
"tw-animate-css": "1.4.0",
|
|
171
171
|
"vite": "7.3.0",
|