@easypayment/medusa-payment-paypal 0.7.6 → 0.7.8
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/.medusa/server/src/admin/index.js +149 -149
- package/.medusa/server/src/admin/index.mjs +149 -149
- package/package.json +1 -1
|
@@ -180,151 +180,6 @@ function AdditionalSettingsTab() {
|
|
|
180
180
|
)
|
|
181
181
|
] }) });
|
|
182
182
|
}
|
|
183
|
-
async function adminFetch$1(path, opts = {}) {
|
|
184
|
-
var _a;
|
|
185
|
-
const { method = "GET", body, query } = opts;
|
|
186
|
-
let url = path;
|
|
187
|
-
if (query && Object.keys(query).length > 0) {
|
|
188
|
-
const params = new URLSearchParams(query);
|
|
189
|
-
url = `${path}?${params.toString()}`;
|
|
190
|
-
}
|
|
191
|
-
const headers = { Accept: "application/json" };
|
|
192
|
-
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
193
|
-
if (typeof window !== "undefined") {
|
|
194
|
-
const token = (_a = window.__medusa__) == null ? void 0 : _a.token;
|
|
195
|
-
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
196
|
-
}
|
|
197
|
-
const res = await fetch(url, {
|
|
198
|
-
method,
|
|
199
|
-
headers,
|
|
200
|
-
credentials: "include",
|
|
201
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
202
|
-
});
|
|
203
|
-
const text = await res.text().catch(() => "");
|
|
204
|
-
if (!res.ok) {
|
|
205
|
-
if (res.status === 401) throw new Error("Unauthorized (401) - session may have expired. Please reload and log in again.");
|
|
206
|
-
if (res.status === 403) throw new Error("Forbidden (403) - you do not have permission to perform this action.");
|
|
207
|
-
throw new Error(text || `Request failed with status ${res.status}`);
|
|
208
|
-
}
|
|
209
|
-
if (!text) return {};
|
|
210
|
-
try {
|
|
211
|
-
return JSON.parse(text);
|
|
212
|
-
} catch {
|
|
213
|
-
return {};
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
const DEFAULT_FORM = {
|
|
217
|
-
enabled: true,
|
|
218
|
-
title: "Credit or Debit Card",
|
|
219
|
-
threeDS: "when_required"
|
|
220
|
-
};
|
|
221
|
-
function mergeWithDefaults(saved) {
|
|
222
|
-
if (!saved) return { ...DEFAULT_FORM };
|
|
223
|
-
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
224
|
-
return { ...DEFAULT_FORM, ...Object.fromEntries(entries) };
|
|
225
|
-
}
|
|
226
|
-
const THREE_DS_OPTIONS = [
|
|
227
|
-
{ value: "when_required", label: "3D Secure when required", hint: "Triggers 3DS only when the card / issuer requires it." },
|
|
228
|
-
{ value: "sli", label: "3D Secure (SCA) / liability shift (recommended)", hint: "Attempts to optimize for liability shift while remaining compliant." },
|
|
229
|
-
{ value: "always", label: "Always request 3D Secure", hint: "Forces 3DS challenge whenever possible (may reduce conversion)." }
|
|
230
|
-
];
|
|
231
|
-
function SectionCard$1({ title, description, right, children }) {
|
|
232
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
233
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-4 border-b border-ui-border-base p-4", children: [
|
|
234
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
235
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: title }),
|
|
236
|
-
description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-sm text-ui-fg-subtle", children: description }) : null
|
|
237
|
-
] }),
|
|
238
|
-
right
|
|
239
|
-
] }),
|
|
240
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children })
|
|
241
|
-
] });
|
|
242
|
-
}
|
|
243
|
-
function FieldRow$1({ label, hint, children }) {
|
|
244
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-12 items-start gap-4 py-3", children: [
|
|
245
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "col-span-12 md:col-span-4", children: [
|
|
246
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium text-ui-fg-base", children: label }),
|
|
247
|
-
hint ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: hint }) : null
|
|
248
|
-
] }),
|
|
249
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-12 md:col-span-8", children })
|
|
250
|
-
] });
|
|
251
|
-
}
|
|
252
|
-
function AdvancedCardPaymentsTab() {
|
|
253
|
-
var _a, _b;
|
|
254
|
-
const [form, setForm] = react.useState(() => ({ ...DEFAULT_FORM }));
|
|
255
|
-
const [loading, setLoading] = react.useState(false);
|
|
256
|
-
const [saving, setSaving] = react.useState(false);
|
|
257
|
-
const [toast, setToast] = react.useState(null);
|
|
258
|
-
const didInit = react.useRef(false);
|
|
259
|
-
react.useEffect(() => {
|
|
260
|
-
if (didInit.current) return;
|
|
261
|
-
didInit.current = true;
|
|
262
|
-
(async () => {
|
|
263
|
-
try {
|
|
264
|
-
setLoading(true);
|
|
265
|
-
const json = await adminFetch$1("/admin/paypal/settings");
|
|
266
|
-
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
267
|
-
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
268
|
-
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
269
|
-
} catch {
|
|
270
|
-
} finally {
|
|
271
|
-
setLoading(false);
|
|
272
|
-
}
|
|
273
|
-
})();
|
|
274
|
-
}, []);
|
|
275
|
-
async function onSave() {
|
|
276
|
-
try {
|
|
277
|
-
setSaving(true);
|
|
278
|
-
const json = await adminFetch$1("/admin/paypal/settings", {
|
|
279
|
-
method: "POST",
|
|
280
|
-
body: { advanced_card_payments: form }
|
|
281
|
-
});
|
|
282
|
-
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
283
|
-
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
284
|
-
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
285
|
-
setToast({ type: "success", message: "Settings saved" });
|
|
286
|
-
window.setTimeout(() => setToast(null), 2500);
|
|
287
|
-
} catch (e) {
|
|
288
|
-
setToast({ type: "error", message: (e instanceof Error ? e.message : "") || "Failed to save settings." });
|
|
289
|
-
window.setTimeout(() => setToast(null), 3500);
|
|
290
|
-
} finally {
|
|
291
|
-
setSaving(false);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
295
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-start justify-between gap-4", children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Gateway By Easy Payment" }) }) }),
|
|
296
|
-
/* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
|
|
297
|
-
toast ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed right-6 top-6 z-50 rounded-md border border-ui-border-base bg-ui-bg-base px-4 py-3 text-sm shadow-lg", role: "status", "aria-live": "polite", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: toast.type === "success" ? "text-ui-fg-base" : "text-ui-fg-error", children: toast.message }) }) : null,
|
|
298
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
299
|
-
SectionCard$1,
|
|
300
|
-
{
|
|
301
|
-
title: "Advanced Card Payments",
|
|
302
|
-
description: "Control card checkout settings and 3D Secure behavior.",
|
|
303
|
-
right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
304
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onSave, disabled: saving || loading, className: "transition-fg relative inline-flex w-fit items-center justify-center overflow-hidden rounded-md outline-none shadow-buttons-neutral text-ui-fg-base bg-ui-button-neutral after:transition-fg after:absolute after:inset-0 after:content-[''] after:button-neutral-gradient hover:bg-ui-button-neutral-hover hover:after:button-neutral-hover-gradient active:bg-ui-button-neutral-pressed active:after:button-neutral-pressed-gradient focus-visible:shadow-buttons-neutral-focus disabled:bg-ui-bg-disabled disabled:border-ui-border-base disabled:text-ui-fg-disabled disabled:shadow-buttons-neutral disabled:after:hidden txt-compact-small-plus px-3 py-1.5", children: saving ? "Saving..." : "Save settings" }),
|
|
305
|
-
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading..." }) : null
|
|
306
|
-
] }),
|
|
307
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
308
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Enable/Disable", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
309
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.enabled, onChange: (e) => setForm((p) => ({ ...p, enabled: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
310
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
|
|
311
|
-
] }) }),
|
|
312
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Title", children: /* @__PURE__ */ jsxRuntime.jsx("input", { value: form.title, onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "Credit or Debit Card" }) }),
|
|
313
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Contingency for 3D Secure", hint: "Choose when 3D Secure should be triggered during card payments.", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
314
|
-
/* @__PURE__ */ jsxRuntime.jsx("select", { value: form.threeDS, onChange: (e) => setForm((p) => ({ ...p, threeDS: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", children: THREE_DS_OPTIONS.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value)) }),
|
|
315
|
-
((_a = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _a.hint) ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-ui-fg-subtle", children: (_b = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _b.hint }) : null
|
|
316
|
-
] }) })
|
|
317
|
-
] })
|
|
318
|
-
}
|
|
319
|
-
)
|
|
320
|
-
] }) });
|
|
321
|
-
}
|
|
322
|
-
function PayPalApplePayPage() {
|
|
323
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
324
|
-
}
|
|
325
|
-
function PayPalGooglePayPage() {
|
|
326
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
327
|
-
}
|
|
328
183
|
const config = adminSdk.defineRouteConfig({
|
|
329
184
|
label: "PayPal Connection",
|
|
330
185
|
hide: true
|
|
@@ -918,6 +773,151 @@ function PayPalConnectionPage() {
|
|
|
918
773
|
` })
|
|
919
774
|
] });
|
|
920
775
|
}
|
|
776
|
+
async function adminFetch$1(path, opts = {}) {
|
|
777
|
+
var _a;
|
|
778
|
+
const { method = "GET", body, query } = opts;
|
|
779
|
+
let url = path;
|
|
780
|
+
if (query && Object.keys(query).length > 0) {
|
|
781
|
+
const params = new URLSearchParams(query);
|
|
782
|
+
url = `${path}?${params.toString()}`;
|
|
783
|
+
}
|
|
784
|
+
const headers = { Accept: "application/json" };
|
|
785
|
+
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
786
|
+
if (typeof window !== "undefined") {
|
|
787
|
+
const token = (_a = window.__medusa__) == null ? void 0 : _a.token;
|
|
788
|
+
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
789
|
+
}
|
|
790
|
+
const res = await fetch(url, {
|
|
791
|
+
method,
|
|
792
|
+
headers,
|
|
793
|
+
credentials: "include",
|
|
794
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
795
|
+
});
|
|
796
|
+
const text = await res.text().catch(() => "");
|
|
797
|
+
if (!res.ok) {
|
|
798
|
+
if (res.status === 401) throw new Error("Unauthorized (401) - session may have expired. Please reload and log in again.");
|
|
799
|
+
if (res.status === 403) throw new Error("Forbidden (403) - you do not have permission to perform this action.");
|
|
800
|
+
throw new Error(text || `Request failed with status ${res.status}`);
|
|
801
|
+
}
|
|
802
|
+
if (!text) return {};
|
|
803
|
+
try {
|
|
804
|
+
return JSON.parse(text);
|
|
805
|
+
} catch {
|
|
806
|
+
return {};
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
const DEFAULT_FORM = {
|
|
810
|
+
enabled: true,
|
|
811
|
+
title: "Credit or Debit Card",
|
|
812
|
+
threeDS: "when_required"
|
|
813
|
+
};
|
|
814
|
+
function mergeWithDefaults(saved) {
|
|
815
|
+
if (!saved) return { ...DEFAULT_FORM };
|
|
816
|
+
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
817
|
+
return { ...DEFAULT_FORM, ...Object.fromEntries(entries) };
|
|
818
|
+
}
|
|
819
|
+
const THREE_DS_OPTIONS = [
|
|
820
|
+
{ value: "when_required", label: "3D Secure when required", hint: "Triggers 3DS only when the card / issuer requires it." },
|
|
821
|
+
{ value: "sli", label: "3D Secure (SCA) / liability shift (recommended)", hint: "Attempts to optimize for liability shift while remaining compliant." },
|
|
822
|
+
{ value: "always", label: "Always request 3D Secure", hint: "Forces 3DS challenge whenever possible (may reduce conversion)." }
|
|
823
|
+
];
|
|
824
|
+
function SectionCard$1({ title, description, right, children }) {
|
|
825
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
826
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-4 border-b border-ui-border-base p-4", children: [
|
|
827
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
828
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: title }),
|
|
829
|
+
description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-sm text-ui-fg-subtle", children: description }) : null
|
|
830
|
+
] }),
|
|
831
|
+
right
|
|
832
|
+
] }),
|
|
833
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children })
|
|
834
|
+
] });
|
|
835
|
+
}
|
|
836
|
+
function FieldRow$1({ label, hint, children }) {
|
|
837
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-12 items-start gap-4 py-3", children: [
|
|
838
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "col-span-12 md:col-span-4", children: [
|
|
839
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium text-ui-fg-base", children: label }),
|
|
840
|
+
hint ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: hint }) : null
|
|
841
|
+
] }),
|
|
842
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-12 md:col-span-8", children })
|
|
843
|
+
] });
|
|
844
|
+
}
|
|
845
|
+
function AdvancedCardPaymentsTab() {
|
|
846
|
+
var _a, _b;
|
|
847
|
+
const [form, setForm] = react.useState(() => ({ ...DEFAULT_FORM }));
|
|
848
|
+
const [loading, setLoading] = react.useState(false);
|
|
849
|
+
const [saving, setSaving] = react.useState(false);
|
|
850
|
+
const [toast, setToast] = react.useState(null);
|
|
851
|
+
const didInit = react.useRef(false);
|
|
852
|
+
react.useEffect(() => {
|
|
853
|
+
if (didInit.current) return;
|
|
854
|
+
didInit.current = true;
|
|
855
|
+
(async () => {
|
|
856
|
+
try {
|
|
857
|
+
setLoading(true);
|
|
858
|
+
const json = await adminFetch$1("/admin/paypal/settings");
|
|
859
|
+
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
860
|
+
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
861
|
+
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
862
|
+
} catch {
|
|
863
|
+
} finally {
|
|
864
|
+
setLoading(false);
|
|
865
|
+
}
|
|
866
|
+
})();
|
|
867
|
+
}, []);
|
|
868
|
+
async function onSave() {
|
|
869
|
+
try {
|
|
870
|
+
setSaving(true);
|
|
871
|
+
const json = await adminFetch$1("/admin/paypal/settings", {
|
|
872
|
+
method: "POST",
|
|
873
|
+
body: { advanced_card_payments: form }
|
|
874
|
+
});
|
|
875
|
+
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
876
|
+
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
877
|
+
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
878
|
+
setToast({ type: "success", message: "Settings saved" });
|
|
879
|
+
window.setTimeout(() => setToast(null), 2500);
|
|
880
|
+
} catch (e) {
|
|
881
|
+
setToast({ type: "error", message: (e instanceof Error ? e.message : "") || "Failed to save settings." });
|
|
882
|
+
window.setTimeout(() => setToast(null), 3500);
|
|
883
|
+
} finally {
|
|
884
|
+
setSaving(false);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
888
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-start justify-between gap-4", children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Gateway By Easy Payment" }) }) }),
|
|
889
|
+
/* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
|
|
890
|
+
toast ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed right-6 top-6 z-50 rounded-md border border-ui-border-base bg-ui-bg-base px-4 py-3 text-sm shadow-lg", role: "status", "aria-live": "polite", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: toast.type === "success" ? "text-ui-fg-base" : "text-ui-fg-error", children: toast.message }) }) : null,
|
|
891
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
892
|
+
SectionCard$1,
|
|
893
|
+
{
|
|
894
|
+
title: "Advanced Card Payments",
|
|
895
|
+
description: "Control card checkout settings and 3D Secure behavior.",
|
|
896
|
+
right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
897
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onSave, disabled: saving || loading, className: "transition-fg relative inline-flex w-fit items-center justify-center overflow-hidden rounded-md outline-none shadow-buttons-neutral text-ui-fg-base bg-ui-button-neutral after:transition-fg after:absolute after:inset-0 after:content-[''] after:button-neutral-gradient hover:bg-ui-button-neutral-hover hover:after:button-neutral-hover-gradient active:bg-ui-button-neutral-pressed active:after:button-neutral-pressed-gradient focus-visible:shadow-buttons-neutral-focus disabled:bg-ui-bg-disabled disabled:border-ui-border-base disabled:text-ui-fg-disabled disabled:shadow-buttons-neutral disabled:after:hidden txt-compact-small-plus px-3 py-1.5", children: saving ? "Saving..." : "Save settings" }),
|
|
898
|
+
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading..." }) : null
|
|
899
|
+
] }),
|
|
900
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
901
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Enable/Disable", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
902
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.enabled, onChange: (e) => setForm((p) => ({ ...p, enabled: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
903
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
|
|
904
|
+
] }) }),
|
|
905
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Title", children: /* @__PURE__ */ jsxRuntime.jsx("input", { value: form.title, onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "Credit or Debit Card" }) }),
|
|
906
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Contingency for 3D Secure", hint: "Choose when 3D Secure should be triggered during card payments.", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
907
|
+
/* @__PURE__ */ jsxRuntime.jsx("select", { value: form.threeDS, onChange: (e) => setForm((p) => ({ ...p, threeDS: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", children: THREE_DS_OPTIONS.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value)) }),
|
|
908
|
+
((_a = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _a.hint) ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-ui-fg-subtle", children: (_b = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _b.hint }) : null
|
|
909
|
+
] }) })
|
|
910
|
+
] })
|
|
911
|
+
}
|
|
912
|
+
)
|
|
913
|
+
] }) });
|
|
914
|
+
}
|
|
915
|
+
function PayPalApplePayPage() {
|
|
916
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
917
|
+
}
|
|
918
|
+
function PayPalGooglePayPage() {
|
|
919
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
920
|
+
}
|
|
921
921
|
function PayPalPayLaterMessagingPage() {
|
|
922
922
|
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
923
923
|
}
|
|
@@ -1205,6 +1205,10 @@ const routeModule = {
|
|
|
1205
1205
|
Component: AdditionalSettingsTab,
|
|
1206
1206
|
path: "/settings/paypal/additional-settings"
|
|
1207
1207
|
},
|
|
1208
|
+
{
|
|
1209
|
+
Component: PayPalConnectionPage,
|
|
1210
|
+
path: "/settings/paypal/connection"
|
|
1211
|
+
},
|
|
1208
1212
|
{
|
|
1209
1213
|
Component: AdvancedCardPaymentsTab,
|
|
1210
1214
|
path: "/settings/paypal/advanced-card-payments"
|
|
@@ -1217,10 +1221,6 @@ const routeModule = {
|
|
|
1217
1221
|
Component: PayPalGooglePayPage,
|
|
1218
1222
|
path: "/settings/paypal/google-pay"
|
|
1219
1223
|
},
|
|
1220
|
-
{
|
|
1221
|
-
Component: PayPalConnectionPage,
|
|
1222
|
-
path: "/settings/paypal/connection"
|
|
1223
|
-
},
|
|
1224
1224
|
{
|
|
1225
1225
|
Component: PayPalPayLaterMessagingPage,
|
|
1226
1226
|
path: "/settings/paypal/pay-later-messaging"
|
|
@@ -179,151 +179,6 @@ function AdditionalSettingsTab() {
|
|
|
179
179
|
)
|
|
180
180
|
] }) });
|
|
181
181
|
}
|
|
182
|
-
async function adminFetch$1(path, opts = {}) {
|
|
183
|
-
var _a;
|
|
184
|
-
const { method = "GET", body, query } = opts;
|
|
185
|
-
let url = path;
|
|
186
|
-
if (query && Object.keys(query).length > 0) {
|
|
187
|
-
const params = new URLSearchParams(query);
|
|
188
|
-
url = `${path}?${params.toString()}`;
|
|
189
|
-
}
|
|
190
|
-
const headers = { Accept: "application/json" };
|
|
191
|
-
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
192
|
-
if (typeof window !== "undefined") {
|
|
193
|
-
const token = (_a = window.__medusa__) == null ? void 0 : _a.token;
|
|
194
|
-
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
195
|
-
}
|
|
196
|
-
const res = await fetch(url, {
|
|
197
|
-
method,
|
|
198
|
-
headers,
|
|
199
|
-
credentials: "include",
|
|
200
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
201
|
-
});
|
|
202
|
-
const text = await res.text().catch(() => "");
|
|
203
|
-
if (!res.ok) {
|
|
204
|
-
if (res.status === 401) throw new Error("Unauthorized (401) - session may have expired. Please reload and log in again.");
|
|
205
|
-
if (res.status === 403) throw new Error("Forbidden (403) - you do not have permission to perform this action.");
|
|
206
|
-
throw new Error(text || `Request failed with status ${res.status}`);
|
|
207
|
-
}
|
|
208
|
-
if (!text) return {};
|
|
209
|
-
try {
|
|
210
|
-
return JSON.parse(text);
|
|
211
|
-
} catch {
|
|
212
|
-
return {};
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
const DEFAULT_FORM = {
|
|
216
|
-
enabled: true,
|
|
217
|
-
title: "Credit or Debit Card",
|
|
218
|
-
threeDS: "when_required"
|
|
219
|
-
};
|
|
220
|
-
function mergeWithDefaults(saved) {
|
|
221
|
-
if (!saved) return { ...DEFAULT_FORM };
|
|
222
|
-
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
223
|
-
return { ...DEFAULT_FORM, ...Object.fromEntries(entries) };
|
|
224
|
-
}
|
|
225
|
-
const THREE_DS_OPTIONS = [
|
|
226
|
-
{ value: "when_required", label: "3D Secure when required", hint: "Triggers 3DS only when the card / issuer requires it." },
|
|
227
|
-
{ value: "sli", label: "3D Secure (SCA) / liability shift (recommended)", hint: "Attempts to optimize for liability shift while remaining compliant." },
|
|
228
|
-
{ value: "always", label: "Always request 3D Secure", hint: "Forces 3DS challenge whenever possible (may reduce conversion)." }
|
|
229
|
-
];
|
|
230
|
-
function SectionCard$1({ title, description, right, children }) {
|
|
231
|
-
return /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
232
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4 border-b border-ui-border-base p-4", children: [
|
|
233
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
234
|
-
/* @__PURE__ */ jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: title }),
|
|
235
|
-
description ? /* @__PURE__ */ jsx("div", { className: "mt-1 text-sm text-ui-fg-subtle", children: description }) : null
|
|
236
|
-
] }),
|
|
237
|
-
right
|
|
238
|
-
] }),
|
|
239
|
-
/* @__PURE__ */ jsx("div", { className: "p-4", children })
|
|
240
|
-
] });
|
|
241
|
-
}
|
|
242
|
-
function FieldRow$1({ label, hint, children }) {
|
|
243
|
-
return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-12 items-start gap-4 py-3", children: [
|
|
244
|
-
/* @__PURE__ */ jsxs("div", { className: "col-span-12 md:col-span-4", children: [
|
|
245
|
-
/* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-ui-fg-base", children: label }),
|
|
246
|
-
hint ? /* @__PURE__ */ jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: hint }) : null
|
|
247
|
-
] }),
|
|
248
|
-
/* @__PURE__ */ jsx("div", { className: "col-span-12 md:col-span-8", children })
|
|
249
|
-
] });
|
|
250
|
-
}
|
|
251
|
-
function AdvancedCardPaymentsTab() {
|
|
252
|
-
var _a, _b;
|
|
253
|
-
const [form, setForm] = useState(() => ({ ...DEFAULT_FORM }));
|
|
254
|
-
const [loading, setLoading] = useState(false);
|
|
255
|
-
const [saving, setSaving] = useState(false);
|
|
256
|
-
const [toast, setToast] = useState(null);
|
|
257
|
-
const didInit = useRef(false);
|
|
258
|
-
useEffect(() => {
|
|
259
|
-
if (didInit.current) return;
|
|
260
|
-
didInit.current = true;
|
|
261
|
-
(async () => {
|
|
262
|
-
try {
|
|
263
|
-
setLoading(true);
|
|
264
|
-
const json = await adminFetch$1("/admin/paypal/settings");
|
|
265
|
-
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
266
|
-
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
267
|
-
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
268
|
-
} catch {
|
|
269
|
-
} finally {
|
|
270
|
-
setLoading(false);
|
|
271
|
-
}
|
|
272
|
-
})();
|
|
273
|
-
}, []);
|
|
274
|
-
async function onSave() {
|
|
275
|
-
try {
|
|
276
|
-
setSaving(true);
|
|
277
|
-
const json = await adminFetch$1("/admin/paypal/settings", {
|
|
278
|
-
method: "POST",
|
|
279
|
-
body: { advanced_card_payments: form }
|
|
280
|
-
});
|
|
281
|
-
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
282
|
-
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
283
|
-
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
284
|
-
setToast({ type: "success", message: "Settings saved" });
|
|
285
|
-
window.setTimeout(() => setToast(null), 2500);
|
|
286
|
-
} catch (e) {
|
|
287
|
-
setToast({ type: "error", message: (e instanceof Error ? e.message : "") || "Failed to save settings." });
|
|
288
|
-
window.setTimeout(() => setToast(null), 3500);
|
|
289
|
-
} finally {
|
|
290
|
-
setSaving(false);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return /* @__PURE__ */ jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
294
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-start justify-between gap-4", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Gateway By Easy Payment" }) }) }),
|
|
295
|
-
/* @__PURE__ */ jsx(PayPalTabs, {}),
|
|
296
|
-
toast ? /* @__PURE__ */ jsx("div", { className: "fixed right-6 top-6 z-50 rounded-md border border-ui-border-base bg-ui-bg-base px-4 py-3 text-sm shadow-lg", role: "status", "aria-live": "polite", children: /* @__PURE__ */ jsx("span", { className: toast.type === "success" ? "text-ui-fg-base" : "text-ui-fg-error", children: toast.message }) }) : null,
|
|
297
|
-
/* @__PURE__ */ jsx(
|
|
298
|
-
SectionCard$1,
|
|
299
|
-
{
|
|
300
|
-
title: "Advanced Card Payments",
|
|
301
|
-
description: "Control card checkout settings and 3D Secure behavior.",
|
|
302
|
-
right: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
303
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: onSave, disabled: saving || loading, className: "transition-fg relative inline-flex w-fit items-center justify-center overflow-hidden rounded-md outline-none shadow-buttons-neutral text-ui-fg-base bg-ui-button-neutral after:transition-fg after:absolute after:inset-0 after:content-[''] after:button-neutral-gradient hover:bg-ui-button-neutral-hover hover:after:button-neutral-hover-gradient active:bg-ui-button-neutral-pressed active:after:button-neutral-pressed-gradient focus-visible:shadow-buttons-neutral-focus disabled:bg-ui-bg-disabled disabled:border-ui-border-base disabled:text-ui-fg-disabled disabled:shadow-buttons-neutral disabled:after:hidden txt-compact-small-plus px-3 py-1.5", children: saving ? "Saving..." : "Save settings" }),
|
|
304
|
-
loading ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading..." }) : null
|
|
305
|
-
] }),
|
|
306
|
-
children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
307
|
-
/* @__PURE__ */ jsx(FieldRow$1, { label: "Enable/Disable", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
308
|
-
/* @__PURE__ */ jsx("input", { type: "checkbox", checked: form.enabled, onChange: (e) => setForm((p) => ({ ...p, enabled: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
309
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
|
|
310
|
-
] }) }),
|
|
311
|
-
/* @__PURE__ */ jsx(FieldRow$1, { label: "Title", children: /* @__PURE__ */ jsx("input", { value: form.title, onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "Credit or Debit Card" }) }),
|
|
312
|
-
/* @__PURE__ */ jsx(FieldRow$1, { label: "Contingency for 3D Secure", hint: "Choose when 3D Secure should be triggered during card payments.", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
313
|
-
/* @__PURE__ */ jsx("select", { value: form.threeDS, onChange: (e) => setForm((p) => ({ ...p, threeDS: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", children: THREE_DS_OPTIONS.map((o) => /* @__PURE__ */ jsx("option", { value: o.value, children: o.label }, o.value)) }),
|
|
314
|
-
((_a = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _a.hint) ? /* @__PURE__ */ jsx("div", { className: "text-xs text-ui-fg-subtle", children: (_b = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _b.hint }) : null
|
|
315
|
-
] }) })
|
|
316
|
-
] })
|
|
317
|
-
}
|
|
318
|
-
)
|
|
319
|
-
] }) });
|
|
320
|
-
}
|
|
321
|
-
function PayPalApplePayPage() {
|
|
322
|
-
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
323
|
-
}
|
|
324
|
-
function PayPalGooglePayPage() {
|
|
325
|
-
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
326
|
-
}
|
|
327
182
|
const config = defineRouteConfig({
|
|
328
183
|
label: "PayPal Connection",
|
|
329
184
|
hide: true
|
|
@@ -917,6 +772,151 @@ function PayPalConnectionPage() {
|
|
|
917
772
|
` })
|
|
918
773
|
] });
|
|
919
774
|
}
|
|
775
|
+
async function adminFetch$1(path, opts = {}) {
|
|
776
|
+
var _a;
|
|
777
|
+
const { method = "GET", body, query } = opts;
|
|
778
|
+
let url = path;
|
|
779
|
+
if (query && Object.keys(query).length > 0) {
|
|
780
|
+
const params = new URLSearchParams(query);
|
|
781
|
+
url = `${path}?${params.toString()}`;
|
|
782
|
+
}
|
|
783
|
+
const headers = { Accept: "application/json" };
|
|
784
|
+
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
785
|
+
if (typeof window !== "undefined") {
|
|
786
|
+
const token = (_a = window.__medusa__) == null ? void 0 : _a.token;
|
|
787
|
+
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
788
|
+
}
|
|
789
|
+
const res = await fetch(url, {
|
|
790
|
+
method,
|
|
791
|
+
headers,
|
|
792
|
+
credentials: "include",
|
|
793
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
794
|
+
});
|
|
795
|
+
const text = await res.text().catch(() => "");
|
|
796
|
+
if (!res.ok) {
|
|
797
|
+
if (res.status === 401) throw new Error("Unauthorized (401) - session may have expired. Please reload and log in again.");
|
|
798
|
+
if (res.status === 403) throw new Error("Forbidden (403) - you do not have permission to perform this action.");
|
|
799
|
+
throw new Error(text || `Request failed with status ${res.status}`);
|
|
800
|
+
}
|
|
801
|
+
if (!text) return {};
|
|
802
|
+
try {
|
|
803
|
+
return JSON.parse(text);
|
|
804
|
+
} catch {
|
|
805
|
+
return {};
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
const DEFAULT_FORM = {
|
|
809
|
+
enabled: true,
|
|
810
|
+
title: "Credit or Debit Card",
|
|
811
|
+
threeDS: "when_required"
|
|
812
|
+
};
|
|
813
|
+
function mergeWithDefaults(saved) {
|
|
814
|
+
if (!saved) return { ...DEFAULT_FORM };
|
|
815
|
+
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
816
|
+
return { ...DEFAULT_FORM, ...Object.fromEntries(entries) };
|
|
817
|
+
}
|
|
818
|
+
const THREE_DS_OPTIONS = [
|
|
819
|
+
{ value: "when_required", label: "3D Secure when required", hint: "Triggers 3DS only when the card / issuer requires it." },
|
|
820
|
+
{ value: "sli", label: "3D Secure (SCA) / liability shift (recommended)", hint: "Attempts to optimize for liability shift while remaining compliant." },
|
|
821
|
+
{ value: "always", label: "Always request 3D Secure", hint: "Forces 3DS challenge whenever possible (may reduce conversion)." }
|
|
822
|
+
];
|
|
823
|
+
function SectionCard$1({ title, description, right, children }) {
|
|
824
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
825
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4 border-b border-ui-border-base p-4", children: [
|
|
826
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
827
|
+
/* @__PURE__ */ jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: title }),
|
|
828
|
+
description ? /* @__PURE__ */ jsx("div", { className: "mt-1 text-sm text-ui-fg-subtle", children: description }) : null
|
|
829
|
+
] }),
|
|
830
|
+
right
|
|
831
|
+
] }),
|
|
832
|
+
/* @__PURE__ */ jsx("div", { className: "p-4", children })
|
|
833
|
+
] });
|
|
834
|
+
}
|
|
835
|
+
function FieldRow$1({ label, hint, children }) {
|
|
836
|
+
return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-12 items-start gap-4 py-3", children: [
|
|
837
|
+
/* @__PURE__ */ jsxs("div", { className: "col-span-12 md:col-span-4", children: [
|
|
838
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-ui-fg-base", children: label }),
|
|
839
|
+
hint ? /* @__PURE__ */ jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: hint }) : null
|
|
840
|
+
] }),
|
|
841
|
+
/* @__PURE__ */ jsx("div", { className: "col-span-12 md:col-span-8", children })
|
|
842
|
+
] });
|
|
843
|
+
}
|
|
844
|
+
function AdvancedCardPaymentsTab() {
|
|
845
|
+
var _a, _b;
|
|
846
|
+
const [form, setForm] = useState(() => ({ ...DEFAULT_FORM }));
|
|
847
|
+
const [loading, setLoading] = useState(false);
|
|
848
|
+
const [saving, setSaving] = useState(false);
|
|
849
|
+
const [toast, setToast] = useState(null);
|
|
850
|
+
const didInit = useRef(false);
|
|
851
|
+
useEffect(() => {
|
|
852
|
+
if (didInit.current) return;
|
|
853
|
+
didInit.current = true;
|
|
854
|
+
(async () => {
|
|
855
|
+
try {
|
|
856
|
+
setLoading(true);
|
|
857
|
+
const json = await adminFetch$1("/admin/paypal/settings");
|
|
858
|
+
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
859
|
+
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
860
|
+
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
861
|
+
} catch {
|
|
862
|
+
} finally {
|
|
863
|
+
setLoading(false);
|
|
864
|
+
}
|
|
865
|
+
})();
|
|
866
|
+
}, []);
|
|
867
|
+
async function onSave() {
|
|
868
|
+
try {
|
|
869
|
+
setSaving(true);
|
|
870
|
+
const json = await adminFetch$1("/admin/paypal/settings", {
|
|
871
|
+
method: "POST",
|
|
872
|
+
body: { advanced_card_payments: form }
|
|
873
|
+
});
|
|
874
|
+
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
875
|
+
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
876
|
+
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
877
|
+
setToast({ type: "success", message: "Settings saved" });
|
|
878
|
+
window.setTimeout(() => setToast(null), 2500);
|
|
879
|
+
} catch (e) {
|
|
880
|
+
setToast({ type: "error", message: (e instanceof Error ? e.message : "") || "Failed to save settings." });
|
|
881
|
+
window.setTimeout(() => setToast(null), 3500);
|
|
882
|
+
} finally {
|
|
883
|
+
setSaving(false);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
return /* @__PURE__ */ jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
887
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-start justify-between gap-4", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Gateway By Easy Payment" }) }) }),
|
|
888
|
+
/* @__PURE__ */ jsx(PayPalTabs, {}),
|
|
889
|
+
toast ? /* @__PURE__ */ jsx("div", { className: "fixed right-6 top-6 z-50 rounded-md border border-ui-border-base bg-ui-bg-base px-4 py-3 text-sm shadow-lg", role: "status", "aria-live": "polite", children: /* @__PURE__ */ jsx("span", { className: toast.type === "success" ? "text-ui-fg-base" : "text-ui-fg-error", children: toast.message }) }) : null,
|
|
890
|
+
/* @__PURE__ */ jsx(
|
|
891
|
+
SectionCard$1,
|
|
892
|
+
{
|
|
893
|
+
title: "Advanced Card Payments",
|
|
894
|
+
description: "Control card checkout settings and 3D Secure behavior.",
|
|
895
|
+
right: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
896
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: onSave, disabled: saving || loading, className: "transition-fg relative inline-flex w-fit items-center justify-center overflow-hidden rounded-md outline-none shadow-buttons-neutral text-ui-fg-base bg-ui-button-neutral after:transition-fg after:absolute after:inset-0 after:content-[''] after:button-neutral-gradient hover:bg-ui-button-neutral-hover hover:after:button-neutral-hover-gradient active:bg-ui-button-neutral-pressed active:after:button-neutral-pressed-gradient focus-visible:shadow-buttons-neutral-focus disabled:bg-ui-bg-disabled disabled:border-ui-border-base disabled:text-ui-fg-disabled disabled:shadow-buttons-neutral disabled:after:hidden txt-compact-small-plus px-3 py-1.5", children: saving ? "Saving..." : "Save settings" }),
|
|
897
|
+
loading ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading..." }) : null
|
|
898
|
+
] }),
|
|
899
|
+
children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
900
|
+
/* @__PURE__ */ jsx(FieldRow$1, { label: "Enable/Disable", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
901
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", checked: form.enabled, onChange: (e) => setForm((p) => ({ ...p, enabled: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
902
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
|
|
903
|
+
] }) }),
|
|
904
|
+
/* @__PURE__ */ jsx(FieldRow$1, { label: "Title", children: /* @__PURE__ */ jsx("input", { value: form.title, onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "Credit or Debit Card" }) }),
|
|
905
|
+
/* @__PURE__ */ jsx(FieldRow$1, { label: "Contingency for 3D Secure", hint: "Choose when 3D Secure should be triggered during card payments.", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
906
|
+
/* @__PURE__ */ jsx("select", { value: form.threeDS, onChange: (e) => setForm((p) => ({ ...p, threeDS: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", children: THREE_DS_OPTIONS.map((o) => /* @__PURE__ */ jsx("option", { value: o.value, children: o.label }, o.value)) }),
|
|
907
|
+
((_a = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _a.hint) ? /* @__PURE__ */ jsx("div", { className: "text-xs text-ui-fg-subtle", children: (_b = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _b.hint }) : null
|
|
908
|
+
] }) })
|
|
909
|
+
] })
|
|
910
|
+
}
|
|
911
|
+
)
|
|
912
|
+
] }) });
|
|
913
|
+
}
|
|
914
|
+
function PayPalApplePayPage() {
|
|
915
|
+
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
916
|
+
}
|
|
917
|
+
function PayPalGooglePayPage() {
|
|
918
|
+
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
919
|
+
}
|
|
920
920
|
function PayPalPayLaterMessagingPage() {
|
|
921
921
|
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
922
922
|
}
|
|
@@ -1204,6 +1204,10 @@ const routeModule = {
|
|
|
1204
1204
|
Component: AdditionalSettingsTab,
|
|
1205
1205
|
path: "/settings/paypal/additional-settings"
|
|
1206
1206
|
},
|
|
1207
|
+
{
|
|
1208
|
+
Component: PayPalConnectionPage,
|
|
1209
|
+
path: "/settings/paypal/connection"
|
|
1210
|
+
},
|
|
1207
1211
|
{
|
|
1208
1212
|
Component: AdvancedCardPaymentsTab,
|
|
1209
1213
|
path: "/settings/paypal/advanced-card-payments"
|
|
@@ -1216,10 +1220,6 @@ const routeModule = {
|
|
|
1216
1220
|
Component: PayPalGooglePayPage,
|
|
1217
1221
|
path: "/settings/paypal/google-pay"
|
|
1218
1222
|
},
|
|
1219
|
-
{
|
|
1220
|
-
Component: PayPalConnectionPage,
|
|
1221
|
-
path: "/settings/paypal/connection"
|
|
1222
|
-
},
|
|
1223
1223
|
{
|
|
1224
1224
|
Component: PayPalPayLaterMessagingPage,
|
|
1225
1225
|
path: "/settings/paypal/pay-later-messaging"
|