@loczer/storefront-sdk 0.180.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.
@@ -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
- stripeAccountId: z.ZodOptional<z.ZodString>;
43
+ providerAccountId: z.ZodOptional<z.ZodString>;
44
44
  stripePublishableKey: z.ZodOptional<z.ZodString>;
45
45
  payment: z.ZodOptional<z.ZodObject<{
46
- id: z.ZodString;
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 s = "/api/public/storefront/checkout/payment-session", e = t.enum([
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
- ]), r = t.object({
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
- id: t.string(),
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
- stripeAccountId: t.string().optional(),
35
+ providerAccountId: t.string().optional(),
36
36
  stripePublishableKey: t.string().optional(),
37
37
  payment: n.optional()
38
38
  });
39
39
  export {
40
- s as ROUTE,
40
+ r as ROUTE,
41
41
  e as checkoutPaymentSessionProviderTypeSchema,
42
42
  o as checkoutPaymentSessionStatusSchema,
43
- r as requestSchema,
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
- stripeAccountId: z.ZodOptional<z.ZodString>;
62
+ providerAccountId: z.ZodOptional<z.ZodString>;
63
63
  stripePublishableKey: z.ZodOptional<z.ZodString>;
64
64
  payment: z.ZodOptional<z.ZodObject<{
65
- id: z.ZodString;
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
- id: z.ZodString;
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
- }), l = e.object({
32
+ }), p = e.object({
33
33
  success: e.boolean(),
34
34
  message: e.string(),
35
35
  clientSecret: e.string().optional(),
36
- stripeAccountId: e.string().optional(),
36
+ providerAccountId: e.string().optional(),
37
37
  stripePublishableKey: e.string().optional(),
38
38
  payment: e.object({
39
- id: e.string(),
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
- }), p = e.object({
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
- id: e.string(),
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
- p as getMollieSecurePaymentSessionRequestSchema,
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
- l as getStripeSecurePaymentSessionResponseSchema,
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 N } from "@rpcbase/router";
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 S } from "../ui/button.js";
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(), v = `/${c ?? ""}/checkout${h ? `?${h}` : ""}`, P = `/${c ?? ""}/checkout/success${h ? `?${h}` : ""}`, R = async (a) => {
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?.id) return;
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?.id, r?.providerType]);
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?.stripeAccountId ? null : W(a, {
127
- stripeAccount: r.stripeAccountId
126
+ return !a || !r?.providerAccountId ? null : W(a, {
127
+ stripeAccount: r.providerAccountId
128
128
  });
129
- }, [r?.stripeAccountId, r?.stripePublishableKey]), M = K(() => {
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(N, { to: v, children: /* @__PURE__ */ e(S, { variant: "outline", children: /* @__PURE__ */ e("span", { children: t("checkout_payment_return_back_to_checkout") }) }) })
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(N, { to: v, children: /* @__PURE__ */ e(S, { variant: "outline", children: /* @__PURE__ */ e("span", { children: t("checkout_payment_return_back_to_checkout") }) }) })
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(N, { to: P, children: /* @__PURE__ */ n(S, { className: "gap-2", children: [
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(N, { to: v, children: /* @__PURE__ */ e(S, { children: /* @__PURE__ */ e("span", { children: t("checkout_payment_return_retry_checkout") }) }) })
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 ve = (async ({ ctx: r, params: d }) => {
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), [N, _] = p(null), [m, v] = p(null), [$, w] = p(A), [E, S] = p(null), L = `/${n ?? ""}/secure-payment-link/${t ?? ""}/success`;
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), v(null), (async () => {
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
- v(i);
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?.stripeAccountId ? null : z(a, {
175
- stripeAccount: m.stripeAccountId
174
+ return !a || !m?.providerAccountId ? null : z(a, {
175
+ stripeAccount: m.providerAccountId
176
176
  });
177
- }, [m?.stripeAccountId, m?.stripePublishableKey]), I = 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, {}) : N ? /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: /* @__PURE__ */ e("span", { children: N }) }) : y?.profileId ? /* @__PURE__ */ e(
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
- ve as loader
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.180.0",
3
+ "version": "0.181.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"