@easypayment/medusa-payment-paypal 0.9.4 → 0.9.6
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.d.ts +2 -0
- package/.medusa/server/src/admin/index.d.ts.map +1 -0
- package/.medusa/server/src/admin/index.js +190 -233
- package/.medusa/server/src/admin/index.js.map +1 -0
- package/.medusa/server/src/admin/index.mjs +191 -234
- package/.medusa/server/src/admin/routes/settings/paypal/_components/FieldRow.d.ts +8 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_components/FieldRow.d.ts.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_components/FieldRow.js +8 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_components/FieldRow.js.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_components/SectionCard.d.ts +8 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_components/SectionCard.d.ts.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_components/SectionCard.js +8 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_components/SectionCard.js.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_components/Tabs.d.ts +2 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_components/Tabs.d.ts.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_components/Tabs.js +25 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_components/Tabs.js.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_components/Toast.d.ts +12 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_components/Toast.d.ts.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_components/Toast.js +22 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_components/Toast.js.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_utils/adminFetch.d.ts +7 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_utils/adminFetch.d.ts.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_utils/adminFetch.js +40 -0
- package/.medusa/server/src/admin/routes/settings/paypal/_utils/adminFetch.js.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/additional-settings/page.d.ts +2 -0
- package/.medusa/server/src/admin/routes/settings/paypal/additional-settings/page.d.ts.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/additional-settings/page.js +76 -0
- package/.medusa/server/src/admin/routes/settings/paypal/additional-settings/page.js.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/advanced-card-payments/page.d.ts +2 -0
- package/.medusa/server/src/admin/routes/settings/paypal/advanced-card-payments/page.d.ts.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/advanced-card-payments/page.js +81 -0
- package/.medusa/server/src/admin/routes/settings/paypal/advanced-card-payments/page.js.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/apple-pay/page.d.ts +2 -0
- package/.medusa/server/src/admin/routes/settings/paypal/apple-pay/page.d.ts.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/apple-pay/page.js +9 -0
- package/.medusa/server/src/admin/routes/settings/paypal/apple-pay/page.js.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/connection/page.d.ts +20 -0
- package/.medusa/server/src/admin/routes/settings/paypal/connection/page.d.ts.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/connection/page.js +440 -0
- package/.medusa/server/src/admin/routes/settings/paypal/connection/page.js.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/google-pay/page.d.ts +2 -0
- package/.medusa/server/src/admin/routes/settings/paypal/google-pay/page.d.ts.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/google-pay/page.js +9 -0
- package/.medusa/server/src/admin/routes/settings/paypal/google-pay/page.js.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/page.d.ts +4 -0
- package/.medusa/server/src/admin/routes/settings/paypal/page.d.ts.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/page.js +14 -0
- package/.medusa/server/src/admin/routes/settings/paypal/page.js.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/pay-later-messaging/page.d.ts +2 -0
- package/.medusa/server/src/admin/routes/settings/paypal/pay-later-messaging/page.d.ts.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/pay-later-messaging/page.js +9 -0
- package/.medusa/server/src/admin/routes/settings/paypal/pay-later-messaging/page.js.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/paypal-settings/page.d.ts +2 -0
- package/.medusa/server/src/admin/routes/settings/paypal/paypal-settings/page.d.ts.map +1 -0
- package/.medusa/server/src/admin/routes/settings/paypal/paypal-settings/page.js +109 -0
- package/.medusa/server/src/admin/routes/settings/paypal/paypal-settings/page.js.map +1 -0
- package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.d.ts +1 -1
- package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.js +24 -9
- package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/disconnect/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/paypal/disconnect/route.js +10 -3
- package/.medusa/server/src/api/admin/paypal/disconnect/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/environment/route.js +2 -2
- package/.medusa/server/src/api/admin/paypal/environment/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/onboard-complete/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/paypal/onboard-complete/route.js +3 -2
- package/.medusa/server/src/api/admin/paypal/onboard-complete/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/onboarding-link/route.js +1 -1
- package/.medusa/server/src/api/admin/paypal/onboarding-link/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/onboarding-status/route.js +4 -4
- package/.medusa/server/src/api/admin/paypal/onboarding-status/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/save-credentials/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/paypal/save-credentials/route.js +21 -8
- package/.medusa/server/src/api/admin/paypal/save-credentials/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/settings/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/paypal/settings/route.js +34 -4
- package/.medusa/server/src/api/admin/paypal/settings/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/status/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/paypal/status/route.js +11 -5
- package/.medusa/server/src/api/admin/paypal/status/route.js.map +1 -1
- package/.medusa/server/src/api/store/paypal/capture-order/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal/capture-order/route.js +21 -3
- package/.medusa/server/src/api/store/paypal/capture-order/route.js.map +1 -1
- package/.medusa/server/src/api/store/paypal/config/route.js +2 -2
- package/.medusa/server/src/api/store/paypal/config/route.js.map +1 -1
- package/.medusa/server/src/api/store/paypal/create-order/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal/create-order/route.js +13 -9
- package/.medusa/server/src/api/store/paypal/create-order/route.js.map +1 -1
- package/.medusa/server/src/api/store/paypal/settings/route.js +3 -3
- package/.medusa/server/src/api/store/paypal/settings/route.js.map +1 -1
- package/.medusa/server/src/api/store/paypal/webhook/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal/webhook/route.js +10 -3
- package/.medusa/server/src/api/store/paypal/webhook/route.js.map +1 -1
- package/.medusa/server/src/api/store/paypal-complete/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal-complete/route.js +7 -4
- package/.medusa/server/src/api/store/paypal-complete/route.js.map +1 -1
- package/.medusa/server/src/modules/paypal/clients/paypal-seller.client.js +3 -3
- package/.medusa/server/src/modules/paypal/clients/paypal-seller.client.js.map +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.d.ts +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.js +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.js.map +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270102090000_add_paypal_seller_email.d.ts +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270102090000_add_paypal_seller_email.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270102090000_add_paypal_seller_email.js +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270102090000_add_paypal_seller_email.js.map +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270103090000_add_paypal_seller_merchant_id.d.ts +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270103090000_add_paypal_seller_merchant_id.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270103090000_add_paypal_seller_merchant_id.js +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270103090000_add_paypal_seller_merchant_id.js.map +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270202000000_align_nullable_defaults.d.ts +6 -0
- package/.medusa/server/src/modules/paypal/migrations/20270202000000_align_nullable_defaults.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20270202000000_align_nullable_defaults.js +25 -0
- package/.medusa/server/src/modules/paypal/migrations/20270202000000_align_nullable_defaults.js.map +1 -0
- package/.medusa/server/src/modules/paypal/models/paypal_connection.d.ts +1 -1
- package/.medusa/server/src/modules/paypal/models/paypal_connection.js +3 -3
- package/.medusa/server/src/modules/paypal/models/paypal_connection.js.map +1 -1
- package/.medusa/server/src/modules/paypal/models/paypal_metric.d.ts +1 -1
- package/.medusa/server/src/modules/paypal/models/paypal_metric.js +1 -1
- package/.medusa/server/src/modules/paypal/models/paypal_metric.js.map +1 -1
- package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.d.ts +1 -1
- package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.js +1 -1
- package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.js.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/card-service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/card-service.js +95 -76
- package/.medusa/server/src/modules/paypal/payment-provider/card-service.js.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/service.js +39 -89
- package/.medusa/server/src/modules/paypal/payment-provider/service.js.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/webhook-utils.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/webhook-utils.js +7 -0
- package/.medusa/server/src/modules/paypal/payment-provider/webhook-utils.js.map +1 -1
- package/.medusa/server/src/modules/paypal/service.d.ts +10 -8
- package/.medusa/server/src/modules/paypal/service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/service.js +56 -51
- package/.medusa/server/src/modules/paypal/service.js.map +1 -1
- package/.medusa/server/src/modules/paypal/types/config.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/types/config.js +11 -2
- package/.medusa/server/src/modules/paypal/types/config.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/paypal-auth.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/paypal-auth.js +1 -0
- package/.medusa/server/src/modules/paypal/utils/paypal-auth.js.map +1 -1
- package/.medusa/server/src/modules/paypal/webhook-processor.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/webhook-processor.js +1 -1
- package/.medusa/server/src/modules/paypal/webhook-processor.js.map +1 -1
- package/.medusa/server/src/subscribers/paypal-order-invoice.js +4 -4
- package/.medusa/server/src/subscribers/paypal-order-invoice.js.map +1 -1
- package/package.json +1 -1
- package/src/admin/index.ts +1 -7
- package/src/admin/routes/settings/paypal/_components/FieldRow.tsx +29 -0
- package/src/admin/routes/settings/paypal/_components/SectionCard.tsx +26 -0
- package/src/admin/routes/settings/paypal/_components/Toast.tsx +4 -3
- package/src/admin/routes/settings/paypal/_utils/adminFetch.ts +32 -0
- package/src/admin/routes/settings/paypal/additional-settings/page.tsx +23 -83
- package/src/admin/routes/settings/paypal/advanced-card-payments/page.tsx +17 -77
- package/src/admin/routes/settings/paypal/connection/page.tsx +88 -45
- package/src/admin/routes/settings/paypal/paypal-settings/page.tsx +23 -101
- package/src/api/admin/payment-collections/[id]/payment-sessions/route.ts +26 -9
- package/src/api/admin/paypal/disconnect/route.ts +9 -3
- package/src/api/admin/paypal/environment/route.ts +2 -2
- package/src/api/admin/paypal/onboard-complete/route.ts +4 -3
- package/src/api/admin/paypal/onboarding-link/route.ts +1 -1
- package/src/api/admin/paypal/onboarding-status/route.ts +5 -5
- package/src/api/admin/paypal/save-credentials/route.ts +24 -9
- package/src/api/admin/paypal/settings/route.ts +35 -4
- package/src/api/admin/paypal/status/route.ts +10 -5
- package/src/api/store/paypal/capture-order/route.ts +27 -3
- package/src/api/store/paypal/config/route.ts +2 -2
- package/src/api/store/paypal/create-order/route.ts +16 -10
- package/src/api/store/paypal/settings/route.ts +3 -3
- package/src/api/store/paypal/webhook/route.ts +13 -3
- package/src/api/store/paypal-complete/route.ts +8 -4
- package/src/modules/paypal/clients/paypal-seller.client.ts +3 -3
- package/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.ts +1 -1
- package/src/modules/paypal/migrations/20270102090000_add_paypal_seller_email.ts +1 -1
- package/src/modules/paypal/migrations/20270103090000_add_paypal_seller_merchant_id.ts +1 -1
- package/src/modules/paypal/migrations/20270202000000_align_nullable_defaults.ts +44 -0
- package/src/modules/paypal/models/paypal_connection.ts +3 -3
- package/src/modules/paypal/models/paypal_metric.ts +1 -1
- package/src/modules/paypal/models/paypal_webhook_event.ts +1 -1
- package/src/modules/paypal/payment-provider/card-service.ts +120 -80
- package/src/modules/paypal/payment-provider/service.ts +44 -93
- package/src/modules/paypal/payment-provider/webhook-utils.ts +9 -0
- package/src/modules/paypal/service.ts +79 -66
- package/src/modules/paypal/types/config.ts +18 -2
- package/src/modules/paypal/utils/paypal-auth.ts +1 -0
- package/src/modules/paypal/webhook-processor.ts +8 -5
- package/src/subscribers/paypal-order-invoice.ts +4 -4
|
@@ -34,7 +34,73 @@ function PayPalTabs() {
|
|
|
34
34
|
);
|
|
35
35
|
}) }) });
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
function SectionCard({
|
|
38
|
+
title,
|
|
39
|
+
description,
|
|
40
|
+
children,
|
|
41
|
+
right
|
|
42
|
+
}) {
|
|
43
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
44
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-4 border-b border-ui-border-base p-4", children: [
|
|
45
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
46
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: title }),
|
|
47
|
+
description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-sm text-ui-fg-subtle", children: description }) : null
|
|
48
|
+
] }),
|
|
49
|
+
right
|
|
50
|
+
] }),
|
|
51
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children })
|
|
52
|
+
] });
|
|
53
|
+
}
|
|
54
|
+
function FieldRow({
|
|
55
|
+
label,
|
|
56
|
+
hint,
|
|
57
|
+
htmlFor,
|
|
58
|
+
children
|
|
59
|
+
}) {
|
|
60
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-12 items-start gap-4 py-3", children: [
|
|
61
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "col-span-12 md:col-span-4", children: [
|
|
62
|
+
htmlFor ? /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor, className: "text-sm font-medium text-ui-fg-base", children: label }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium text-ui-fg-base", children: label }),
|
|
63
|
+
hint ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: hint }) : null
|
|
64
|
+
] }),
|
|
65
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-12 md:col-span-8", children })
|
|
66
|
+
] });
|
|
67
|
+
}
|
|
68
|
+
function Toast({ toast, onClose }) {
|
|
69
|
+
react.useEffect(() => {
|
|
70
|
+
if (!toast) return;
|
|
71
|
+
const duration = toast.kind === "error" ? 5e3 : 2500;
|
|
72
|
+
const t = setTimeout(() => onClose(), duration);
|
|
73
|
+
return () => clearTimeout(t);
|
|
74
|
+
}, [toast, onClose]);
|
|
75
|
+
if (!toast) return null;
|
|
76
|
+
const isSuccess = toast.kind === "success";
|
|
77
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed right-6 top-6 z-[9999]", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
78
|
+
"div",
|
|
79
|
+
{
|
|
80
|
+
className: [
|
|
81
|
+
"min-w-[280px] max-w-[420px] rounded-lg border px-4 py-3 shadow-md",
|
|
82
|
+
isSuccess ? "border-emerald-500/30 bg-emerald-500/10" : "border-rose-500/30 bg-rose-500/10"
|
|
83
|
+
].join(" "),
|
|
84
|
+
role: isSuccess ? "status" : "alert",
|
|
85
|
+
"aria-live": isSuccess ? "polite" : "assertive",
|
|
86
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
|
|
87
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: ["mt-0.5 h-2.5 w-2.5 rounded-full", isSuccess ? "bg-emerald-500" : "bg-rose-500"].join(" ") }),
|
|
88
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 text-sm text-ui-fg-base", children: toast.message }),
|
|
89
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
90
|
+
"button",
|
|
91
|
+
{
|
|
92
|
+
type: "button",
|
|
93
|
+
onClick: onClose,
|
|
94
|
+
className: "text-ui-fg-subtle hover:text-ui-fg-base",
|
|
95
|
+
"aria-label": "Close",
|
|
96
|
+
children: "×"
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
] })
|
|
100
|
+
}
|
|
101
|
+
) });
|
|
102
|
+
}
|
|
103
|
+
async function adminFetch(path, opts = {}) {
|
|
38
104
|
var _a;
|
|
39
105
|
const { method = "GET", body, query } = opts;
|
|
40
106
|
let url = path;
|
|
@@ -73,7 +139,7 @@ const DEFAULT_FORM$1 = {
|
|
|
73
139
|
landingPage: "no_preference",
|
|
74
140
|
requireInstantPayment: false,
|
|
75
141
|
sendItemDetails: true,
|
|
76
|
-
invoicePrefix: "
|
|
142
|
+
invoicePrefix: "PP-",
|
|
77
143
|
creditCardStatementName: "PayPal"
|
|
78
144
|
};
|
|
79
145
|
function mergeWithDefaults$1(saved) {
|
|
@@ -81,40 +147,20 @@ function mergeWithDefaults$1(saved) {
|
|
|
81
147
|
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
82
148
|
return { ...DEFAULT_FORM$1, ...Object.fromEntries(entries) };
|
|
83
149
|
}
|
|
84
|
-
function SectionCard$2({ title, description, right, children }) {
|
|
85
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
86
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-4 border-b border-ui-border-base p-4", children: [
|
|
87
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
88
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: title }),
|
|
89
|
-
description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-sm text-ui-fg-subtle", children: description }) : null
|
|
90
|
-
] }),
|
|
91
|
-
right
|
|
92
|
-
] }),
|
|
93
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children })
|
|
94
|
-
] });
|
|
95
|
-
}
|
|
96
|
-
function FieldRow$2({ label, hint, children }) {
|
|
97
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-12 items-start gap-4 py-3", children: [
|
|
98
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "col-span-12 md:col-span-4", children: [
|
|
99
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium text-ui-fg-base", children: label }),
|
|
100
|
-
hint ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: hint }) : null
|
|
101
|
-
] }),
|
|
102
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-12 md:col-span-8", children })
|
|
103
|
-
] });
|
|
104
|
-
}
|
|
105
150
|
function AdditionalSettingsTab() {
|
|
106
151
|
const [form, setForm] = react.useState(() => ({ ...DEFAULT_FORM$1 }));
|
|
107
152
|
const [loading, setLoading] = react.useState(false);
|
|
108
153
|
const [saving, setSaving] = react.useState(false);
|
|
109
154
|
const [toast, setToast] = react.useState(null);
|
|
110
155
|
const didInit = react.useRef(false);
|
|
156
|
+
const dismissToast = react.useCallback(() => setToast(null), []);
|
|
111
157
|
react.useEffect(() => {
|
|
112
158
|
if (didInit.current) return;
|
|
113
159
|
didInit.current = true;
|
|
114
160
|
(async () => {
|
|
115
161
|
try {
|
|
116
162
|
setLoading(true);
|
|
117
|
-
const json = await adminFetch
|
|
163
|
+
const json = await adminFetch("/admin/paypal/settings");
|
|
118
164
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
119
165
|
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
120
166
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
@@ -128,15 +174,13 @@ function AdditionalSettingsTab() {
|
|
|
128
174
|
try {
|
|
129
175
|
setSaving(true);
|
|
130
176
|
setToast(null);
|
|
131
|
-
const json = await adminFetch
|
|
177
|
+
const json = await adminFetch("/admin/paypal/settings", { method: "POST", body: { additional_settings: form } });
|
|
132
178
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
133
179
|
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
134
180
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
135
|
-
setToast({
|
|
136
|
-
window.setTimeout(() => setToast(null), 2500);
|
|
181
|
+
setToast({ kind: "success", message: "Settings saved" });
|
|
137
182
|
} catch (e) {
|
|
138
|
-
setToast({
|
|
139
|
-
window.setTimeout(() => setToast(null), 3500);
|
|
183
|
+
setToast({ kind: "error", message: e instanceof Error ? e.message : "Failed to save settings" });
|
|
140
184
|
} finally {
|
|
141
185
|
setSaving(false);
|
|
142
186
|
}
|
|
@@ -144,75 +188,42 @@ function AdditionalSettingsTab() {
|
|
|
144
188
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
145
189
|
/* @__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" }) }) }),
|
|
146
190
|
/* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
|
|
147
|
-
|
|
191
|
+
/* @__PURE__ */ jsxRuntime.jsx(Toast, { toast, onClose: dismissToast }),
|
|
148
192
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
149
|
-
SectionCard
|
|
193
|
+
SectionCard,
|
|
150
194
|
{
|
|
151
195
|
title: "Additional Settings",
|
|
152
196
|
description: "These settings control checkout behavior and PayPal experience.",
|
|
153
197
|
right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
154
198
|
/* @__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" }),
|
|
155
|
-
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading
|
|
199
|
+
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
|
|
156
200
|
] }),
|
|
157
201
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
158
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow
|
|
202
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Payment action", htmlFor: "as-payment-action", children: /* @__PURE__ */ jsxRuntime.jsxs("select", { id: "as-payment-action", value: form.paymentAction, onChange: (e) => setForm((p) => ({ ...p, paymentAction: 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: [
|
|
159
203
|
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "capture", children: "Capture" }),
|
|
160
204
|
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "authorize", children: "Authorize" })
|
|
161
205
|
] }) }),
|
|
162
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow
|
|
163
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow
|
|
206
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Brand Name", htmlFor: "as-brand-name", children: /* @__PURE__ */ jsxRuntime.jsx("input", { id: "as-brand-name", value: form.brandName, onChange: (e) => setForm((p) => ({ ...p, brandName: 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: "PayPal" }) }),
|
|
207
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Landing Page", htmlFor: "as-landing-page", children: /* @__PURE__ */ jsxRuntime.jsxs("select", { id: "as-landing-page", value: form.landingPage, onChange: (e) => setForm((p) => ({ ...p, landingPage: 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: [
|
|
164
208
|
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "no_preference", children: "No Preference" }),
|
|
165
209
|
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "login", children: "Login" }),
|
|
166
210
|
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "billing", children: "Billing" })
|
|
167
211
|
] }) }),
|
|
168
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow
|
|
212
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Instant Payments", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
169
213
|
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.requireInstantPayment, onChange: (e) => setForm((p) => ({ ...p, requireInstantPayment: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
170
214
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Require Instant Payment" })
|
|
171
215
|
] }) }),
|
|
172
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow
|
|
216
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Send Item Details", hint: "Include all line item details in the payment request to PayPal so that they can be seen from the PayPal transaction details page.", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
173
217
|
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.sendItemDetails, onChange: (e) => setForm((p) => ({ ...p, sendItemDetails: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
174
218
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Send line item details to PayPal" })
|
|
175
219
|
] }) }),
|
|
176
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow
|
|
177
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow
|
|
220
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Invoice prefix", htmlFor: "as-invoice-prefix", children: /* @__PURE__ */ jsxRuntime.jsx("input", { id: "as-invoice-prefix", value: form.invoicePrefix, onChange: (e) => setForm((p) => ({ ...p, invoicePrefix: 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: "PP-" }) }),
|
|
221
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Credit Card Statement Name", htmlFor: "as-cc-statement", children: /* @__PURE__ */ jsxRuntime.jsx("input", { id: "as-cc-statement", value: form.creditCardStatementName, onChange: (e) => setForm((p) => ({ ...p, creditCardStatementName: 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: "PayPal" }) })
|
|
178
222
|
] })
|
|
179
223
|
}
|
|
180
224
|
)
|
|
181
225
|
] }) });
|
|
182
226
|
}
|
|
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
227
|
const DEFAULT_FORM = {
|
|
217
228
|
enabled: true,
|
|
218
229
|
title: "Credit or Debit Card",
|
|
@@ -228,27 +239,6 @@ const THREE_DS_OPTIONS = [
|
|
|
228
239
|
{ value: "sli", label: "3D Secure (SCA) / liability shift (recommended)", hint: "Attempts to optimize for liability shift while remaining compliant." },
|
|
229
240
|
{ value: "always", label: "Always request 3D Secure", hint: "Forces 3DS challenge whenever possible (may reduce conversion)." }
|
|
230
241
|
];
|
|
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
242
|
function AdvancedCardPaymentsTab() {
|
|
253
243
|
var _a, _b;
|
|
254
244
|
const [form, setForm] = react.useState(() => ({ ...DEFAULT_FORM }));
|
|
@@ -256,13 +246,14 @@ function AdvancedCardPaymentsTab() {
|
|
|
256
246
|
const [saving, setSaving] = react.useState(false);
|
|
257
247
|
const [toast, setToast] = react.useState(null);
|
|
258
248
|
const didInit = react.useRef(false);
|
|
249
|
+
const dismissToast = react.useCallback(() => setToast(null), []);
|
|
259
250
|
react.useEffect(() => {
|
|
260
251
|
if (didInit.current) return;
|
|
261
252
|
didInit.current = true;
|
|
262
253
|
(async () => {
|
|
263
254
|
try {
|
|
264
255
|
setLoading(true);
|
|
265
|
-
const json = await adminFetch
|
|
256
|
+
const json = await adminFetch("/admin/paypal/settings");
|
|
266
257
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
267
258
|
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
268
259
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
@@ -275,18 +266,16 @@ function AdvancedCardPaymentsTab() {
|
|
|
275
266
|
async function onSave() {
|
|
276
267
|
try {
|
|
277
268
|
setSaving(true);
|
|
278
|
-
const json = await adminFetch
|
|
269
|
+
const json = await adminFetch("/admin/paypal/settings", {
|
|
279
270
|
method: "POST",
|
|
280
271
|
body: { advanced_card_payments: form }
|
|
281
272
|
});
|
|
282
273
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
283
274
|
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
284
275
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
285
|
-
setToast({
|
|
286
|
-
window.setTimeout(() => setToast(null), 2500);
|
|
276
|
+
setToast({ kind: "success", message: "Settings saved" });
|
|
287
277
|
} catch (e) {
|
|
288
|
-
setToast({
|
|
289
|
-
window.setTimeout(() => setToast(null), 3500);
|
|
278
|
+
setToast({ kind: "error", message: (e instanceof Error ? e.message : "") || "Failed to save settings." });
|
|
290
279
|
} finally {
|
|
291
280
|
setSaving(false);
|
|
292
281
|
}
|
|
@@ -294,24 +283,24 @@ function AdvancedCardPaymentsTab() {
|
|
|
294
283
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
295
284
|
/* @__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
285
|
/* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
|
|
297
|
-
|
|
286
|
+
/* @__PURE__ */ jsxRuntime.jsx(Toast, { toast, onClose: dismissToast }),
|
|
298
287
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
299
|
-
SectionCard
|
|
288
|
+
SectionCard,
|
|
300
289
|
{
|
|
301
290
|
title: "Advanced Card Payments",
|
|
302
291
|
description: "Control card checkout settings and 3D Secure behavior.",
|
|
303
292
|
right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
304
293
|
/* @__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
|
|
294
|
+
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
|
|
306
295
|
] }),
|
|
307
296
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
308
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow
|
|
297
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Enable/Disable", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
309
298
|
/* @__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
299
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
|
|
311
300
|
] }) }),
|
|
312
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow
|
|
313
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow
|
|
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)) }),
|
|
301
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Title", htmlFor: "acp-title", children: /* @__PURE__ */ jsxRuntime.jsx("input", { id: "acp-title", 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" }) }),
|
|
302
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Contingency for 3D Secure", hint: "Choose when 3D Secure should be triggered during card payments.", htmlFor: "acp-threeds", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
303
|
+
/* @__PURE__ */ jsxRuntime.jsx("select", { id: "acp-threeds", 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
304
|
((_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
305
|
] }) })
|
|
317
306
|
] })
|
|
@@ -326,35 +315,11 @@ function PayPalGooglePayPage() {
|
|
|
326
315
|
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
327
316
|
}
|
|
328
317
|
const config = adminSdk.defineRouteConfig({
|
|
329
|
-
label: "PayPal Connection"
|
|
330
|
-
hide: true
|
|
318
|
+
label: "PayPal Connection"
|
|
331
319
|
});
|
|
332
|
-
|
|
333
|
-
const preloadHref = "https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js";
|
|
334
|
-
const existingPreload = document.head.querySelector(
|
|
335
|
-
`link[rel="preload"][href="${preloadHref}"]`
|
|
336
|
-
);
|
|
337
|
-
if (!existingPreload) {
|
|
338
|
-
const preloadLink = document.createElement("link");
|
|
339
|
-
preloadLink.rel = "preload";
|
|
340
|
-
preloadLink.href = preloadHref;
|
|
341
|
-
preloadLink.as = "script";
|
|
342
|
-
document.head.appendChild(preloadLink);
|
|
343
|
-
}
|
|
344
|
-
const existingScript = document.getElementById(
|
|
345
|
-
"paypal-partner-js"
|
|
346
|
-
);
|
|
347
|
-
if (!existingScript) {
|
|
348
|
-
const ppScript = document.createElement("script");
|
|
349
|
-
ppScript.id = "paypal-partner-js";
|
|
350
|
-
ppScript.src = preloadHref;
|
|
351
|
-
ppScript.async = true;
|
|
352
|
-
document.head.appendChild(ppScript);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
320
|
+
const PARTNER_JS_URL = "https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js";
|
|
355
321
|
const SERVICE_URL = "/admin/paypal/onboarding-link";
|
|
356
322
|
const CACHE_KEY = "pp_onboard_cache";
|
|
357
|
-
const RELOAD_KEY = "pp_onboard_reloaded_once";
|
|
358
323
|
const CACHE_EXPIRY = 10 * 60 * 1e3;
|
|
359
324
|
const ONBOARDING_COMPLETE_ENDPOINT = "/admin/paypal/onboard-complete";
|
|
360
325
|
const STATUS_ENDPOINT = "/admin/paypal/status";
|
|
@@ -377,12 +342,45 @@ if (typeof window !== "undefined") {
|
|
|
377
342
|
function PayPalConnectionPage() {
|
|
378
343
|
const [env, setEnv] = react.useState("live");
|
|
379
344
|
react.useEffect(() => {
|
|
380
|
-
fetch("/admin/paypal/environment", { method: "GET" }).then((r) => r.json()).then((d) => {
|
|
345
|
+
fetch("/admin/paypal/environment", { method: "GET", credentials: "include" }).then((r) => r.json()).then((d) => {
|
|
381
346
|
const v = (d == null ? void 0 : d.environment) === "sandbox" ? "sandbox" : "live";
|
|
382
347
|
setEnv(v);
|
|
383
348
|
}).catch(() => {
|
|
384
349
|
});
|
|
385
350
|
}, []);
|
|
351
|
+
react.useEffect(() => {
|
|
352
|
+
const preloadHref = PARTNER_JS_URL;
|
|
353
|
+
let preloadLink = null;
|
|
354
|
+
const existingPreload = document.head.querySelector(
|
|
355
|
+
`link[rel="preload"][href="${preloadHref}"]`
|
|
356
|
+
);
|
|
357
|
+
if (!existingPreload) {
|
|
358
|
+
preloadLink = document.createElement("link");
|
|
359
|
+
preloadLink.rel = "preload";
|
|
360
|
+
preloadLink.href = preloadHref;
|
|
361
|
+
preloadLink.as = "script";
|
|
362
|
+
document.head.appendChild(preloadLink);
|
|
363
|
+
}
|
|
364
|
+
let ppScript = null;
|
|
365
|
+
const existingScript = document.getElementById(
|
|
366
|
+
"paypal-partner-js"
|
|
367
|
+
);
|
|
368
|
+
if (!existingScript) {
|
|
369
|
+
ppScript = document.createElement("script");
|
|
370
|
+
ppScript.id = "paypal-partner-js";
|
|
371
|
+
ppScript.src = preloadHref;
|
|
372
|
+
ppScript.async = true;
|
|
373
|
+
document.head.appendChild(ppScript);
|
|
374
|
+
}
|
|
375
|
+
return () => {
|
|
376
|
+
if (preloadLink && preloadLink.parentNode) {
|
|
377
|
+
preloadLink.parentNode.removeChild(preloadLink);
|
|
378
|
+
}
|
|
379
|
+
if (ppScript && ppScript.parentNode) {
|
|
380
|
+
ppScript.parentNode.removeChild(ppScript);
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
}, []);
|
|
386
384
|
const [connState, setConnState] = react.useState("loading");
|
|
387
385
|
const [error, setError] = react.useState(null);
|
|
388
386
|
const [finalUrl, setFinalUrl] = react.useState("");
|
|
@@ -411,10 +409,14 @@ function PayPalConnectionPage() {
|
|
|
411
409
|
fetch(SERVICE_URL, {
|
|
412
410
|
method: "POST",
|
|
413
411
|
headers: { "content-type": "application/json" },
|
|
412
|
+
credentials: "include",
|
|
414
413
|
body: JSON.stringify({
|
|
415
414
|
products: ["PPCP"]
|
|
416
415
|
})
|
|
417
|
-
}).then((r) =>
|
|
416
|
+
}).then((r) => {
|
|
417
|
+
if (!r.ok) throw new Error(`Service returned ${r.status}`);
|
|
418
|
+
return r.json();
|
|
419
|
+
}).then((data) => {
|
|
418
420
|
if (runId !== currentRunId.current) return;
|
|
419
421
|
const href = data == null ? void 0 : data.onboarding_url;
|
|
420
422
|
if (!href) {
|
|
@@ -429,11 +431,6 @@ function PayPalConnectionPage() {
|
|
|
429
431
|
ts: Date.now()
|
|
430
432
|
})
|
|
431
433
|
);
|
|
432
|
-
if (!localStorage.getItem(RELOAD_KEY)) {
|
|
433
|
-
localStorage.setItem(RELOAD_KEY, "1");
|
|
434
|
-
window.location.reload();
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
434
|
activatePayPal(finalUrl2, runId);
|
|
438
435
|
}).catch(() => {
|
|
439
436
|
if (runId !== currentRunId.current) return;
|
|
@@ -460,6 +457,8 @@ function PayPalConnectionPage() {
|
|
|
460
457
|
paypalButtonRef.current.href = url;
|
|
461
458
|
}
|
|
462
459
|
setFinalUrl(url);
|
|
460
|
+
let attempts = 0;
|
|
461
|
+
const MAX_ATTEMPTS = 200;
|
|
463
462
|
const tryInit = () => {
|
|
464
463
|
var _a, _b;
|
|
465
464
|
if (runId !== currentRunId.current) return;
|
|
@@ -467,6 +466,11 @@ function PayPalConnectionPage() {
|
|
|
467
466
|
showUI();
|
|
468
467
|
return;
|
|
469
468
|
}
|
|
469
|
+
attempts++;
|
|
470
|
+
if (attempts >= MAX_ATTEMPTS) {
|
|
471
|
+
showError("PayPal partner script failed to load. Please refresh and try again.");
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
470
474
|
setTimeout(tryInit, 50);
|
|
471
475
|
};
|
|
472
476
|
tryInit();
|
|
@@ -483,7 +487,8 @@ function PayPalConnectionPage() {
|
|
|
483
487
|
setFinalUrl("");
|
|
484
488
|
try {
|
|
485
489
|
const r = await fetch(`${STATUS_ENDPOINT}?environment=${env}`, {
|
|
486
|
-
method: "GET"
|
|
490
|
+
method: "GET",
|
|
491
|
+
credentials: "include"
|
|
487
492
|
});
|
|
488
493
|
const st = await r.json().catch(() => ({}));
|
|
489
494
|
if (cancelled || runId !== currentRunId.current) return;
|
|
@@ -513,8 +518,7 @@ function PayPalConnectionPage() {
|
|
|
513
518
|
window.onboardingCallback = async function(authCode, sharedId) {
|
|
514
519
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
515
520
|
try {
|
|
516
|
-
;
|
|
517
|
-
window.onbeforeunload = "";
|
|
521
|
+
window.onbeforeunload = null;
|
|
518
522
|
} catch {
|
|
519
523
|
}
|
|
520
524
|
setOnboardingInProgress(true);
|
|
@@ -529,6 +533,7 @@ function PayPalConnectionPage() {
|
|
|
529
533
|
const res = await fetch(ONBOARDING_COMPLETE_ENDPOINT, {
|
|
530
534
|
method: "POST",
|
|
531
535
|
headers: { "content-type": "application/json" },
|
|
536
|
+
credentials: "include",
|
|
532
537
|
body: JSON.stringify(payload)
|
|
533
538
|
});
|
|
534
539
|
if (!res.ok) {
|
|
@@ -547,10 +552,22 @@ function PayPalConnectionPage() {
|
|
|
547
552
|
}
|
|
548
553
|
try {
|
|
549
554
|
localStorage.removeItem(CACHE_KEY);
|
|
550
|
-
localStorage.removeItem(RELOAD_KEY);
|
|
551
555
|
} catch {
|
|
552
556
|
}
|
|
553
|
-
|
|
557
|
+
try {
|
|
558
|
+
const statusRes = await fetch(`${STATUS_ENDPOINT}?environment=${env}`, {
|
|
559
|
+
method: "GET",
|
|
560
|
+
credentials: "include"
|
|
561
|
+
});
|
|
562
|
+
const refreshedStatus = await statusRes.json().catch(() => ({}));
|
|
563
|
+
setStatusInfo(refreshedStatus || null);
|
|
564
|
+
setConnState("connected");
|
|
565
|
+
setShowManual(false);
|
|
566
|
+
} catch {
|
|
567
|
+
setConnState("connected");
|
|
568
|
+
setShowManual(false);
|
|
569
|
+
}
|
|
570
|
+
setOnboardingInProgress(false);
|
|
554
571
|
} catch (e) {
|
|
555
572
|
console.error(e);
|
|
556
573
|
setConnState("error");
|
|
@@ -596,6 +613,7 @@ function PayPalConnectionPage() {
|
|
|
596
613
|
const res = await fetch(SAVE_CREDENTIALS_ENDPOINT, {
|
|
597
614
|
method: "POST",
|
|
598
615
|
headers: { "content-type": "application/json" },
|
|
616
|
+
credentials: "include",
|
|
599
617
|
body: JSON.stringify({
|
|
600
618
|
clientId: clientId.trim(),
|
|
601
619
|
clientSecret: secret.trim(),
|
|
@@ -607,7 +625,8 @@ function PayPalConnectionPage() {
|
|
|
607
625
|
throw new Error(txt || `Save credentials failed (${res.status})`);
|
|
608
626
|
}
|
|
609
627
|
const statusRes = await fetch(`${STATUS_ENDPOINT}?environment=${env}`, {
|
|
610
|
-
method: "GET"
|
|
628
|
+
method: "GET",
|
|
629
|
+
credentials: "include"
|
|
611
630
|
});
|
|
612
631
|
const refreshedStatus = await statusRes.json().catch(() => ({}));
|
|
613
632
|
setConnState("connected");
|
|
@@ -615,7 +634,6 @@ function PayPalConnectionPage() {
|
|
|
615
634
|
setShowManual(false);
|
|
616
635
|
try {
|
|
617
636
|
localStorage.removeItem(CACHE_KEY);
|
|
618
|
-
localStorage.removeItem(RELOAD_KEY);
|
|
619
637
|
} catch {
|
|
620
638
|
}
|
|
621
639
|
} catch (e) {
|
|
@@ -634,10 +652,12 @@ function PayPalConnectionPage() {
|
|
|
634
652
|
setError(null);
|
|
635
653
|
setFinalUrl("");
|
|
636
654
|
setShowManual(false);
|
|
655
|
+
setStatusInfo(null);
|
|
637
656
|
try {
|
|
638
657
|
const res = await fetch(DISCONNECT_ENDPOINT, {
|
|
639
658
|
method: "POST",
|
|
640
659
|
headers: { "content-type": "application/json" },
|
|
660
|
+
credentials: "include",
|
|
641
661
|
body: JSON.stringify({ environment: env })
|
|
642
662
|
});
|
|
643
663
|
if (!res.ok) {
|
|
@@ -646,7 +666,6 @@ function PayPalConnectionPage() {
|
|
|
646
666
|
}
|
|
647
667
|
try {
|
|
648
668
|
localStorage.removeItem(CACHE_KEY);
|
|
649
|
-
localStorage.removeItem(RELOAD_KEY);
|
|
650
669
|
} catch {
|
|
651
670
|
}
|
|
652
671
|
currentRunId.current = ++runIdRef.current;
|
|
@@ -668,19 +687,19 @@ function PayPalConnectionPage() {
|
|
|
668
687
|
await fetch("/admin/paypal/environment", {
|
|
669
688
|
method: "POST",
|
|
670
689
|
headers: { "content-type": "application/json" },
|
|
690
|
+
credentials: "include",
|
|
671
691
|
body: JSON.stringify({ environment: next })
|
|
672
692
|
});
|
|
673
693
|
} catch {
|
|
674
694
|
}
|
|
675
695
|
try {
|
|
676
696
|
localStorage.removeItem(CACHE_KEY);
|
|
677
|
-
localStorage.removeItem(RELOAD_KEY);
|
|
678
697
|
} catch {
|
|
679
698
|
}
|
|
680
699
|
};
|
|
681
700
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-6", children: [
|
|
682
701
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
683
|
-
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl font-semibold", children: "PayPal Gateway By Easy Payment" }),
|
|
702
|
+
/* @__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" }) }) }),
|
|
684
703
|
/* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
|
|
685
704
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-y-6 p-4 md:grid-cols-[260px_1fr] md:items-start", children: [
|
|
686
705
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium pt-2", children: "Environment" }),
|
|
@@ -704,6 +723,7 @@ function PayPalConnectionPage() {
|
|
|
704
723
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
705
724
|
"a",
|
|
706
725
|
{
|
|
726
|
+
target: "PPFrame",
|
|
707
727
|
"data-paypal-button": "true",
|
|
708
728
|
"data-paypal-onboard-complete": "onboardingCallback",
|
|
709
729
|
href: "#",
|
|
@@ -752,6 +772,7 @@ function PayPalConnectionPage() {
|
|
|
752
772
|
ppBtnMeasureRef.current = node;
|
|
753
773
|
},
|
|
754
774
|
id: "paypal-button",
|
|
775
|
+
target: "PPFrame",
|
|
755
776
|
"data-paypal-button": "true",
|
|
756
777
|
href: finalUrl || "#",
|
|
757
778
|
"data-paypal-onboard-complete": "onboardingCallback",
|
|
@@ -810,10 +831,11 @@ function PayPalConnectionPage() {
|
|
|
810
831
|
] }) }),
|
|
811
832
|
showManual && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "md:col-span-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-[260px] max-w-xl mt-4 grid grid-cols-1 gap-3 md:grid-cols-2", children: [
|
|
812
833
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
813
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Client ID" }),
|
|
834
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "pp-manual-client-id", className: "text-sm font-medium", children: "Client ID" }),
|
|
814
835
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
815
836
|
"input",
|
|
816
837
|
{
|
|
838
|
+
id: "pp-manual-client-id",
|
|
817
839
|
type: "text",
|
|
818
840
|
value: clientId,
|
|
819
841
|
onChange: (e) => setClientId(e.target.value),
|
|
@@ -824,10 +846,11 @@ function PayPalConnectionPage() {
|
|
|
824
846
|
)
|
|
825
847
|
] }),
|
|
826
848
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
827
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Secret" }),
|
|
849
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "pp-manual-secret", className: "text-sm font-medium", children: "Secret" }),
|
|
828
850
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
829
851
|
"input",
|
|
830
852
|
{
|
|
853
|
+
id: "pp-manual-secret",
|
|
831
854
|
type: "password",
|
|
832
855
|
value: secret,
|
|
833
856
|
onChange: (e) => setSecret(e.target.value),
|
|
@@ -921,39 +944,6 @@ function PayPalConnectionPage() {
|
|
|
921
944
|
function PayPalPayLaterMessagingPage() {
|
|
922
945
|
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
923
946
|
}
|
|
924
|
-
async function adminFetch(path, opts = {}) {
|
|
925
|
-
var _a;
|
|
926
|
-
const { method = "GET", body, query } = opts;
|
|
927
|
-
let url = path;
|
|
928
|
-
if (query && Object.keys(query).length > 0) {
|
|
929
|
-
const params = new URLSearchParams(query);
|
|
930
|
-
url = `${path}?${params.toString()}`;
|
|
931
|
-
}
|
|
932
|
-
const headers = { Accept: "application/json" };
|
|
933
|
-
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
934
|
-
if (typeof window !== "undefined") {
|
|
935
|
-
const token = (_a = window.__medusa__) == null ? void 0 : _a.token;
|
|
936
|
-
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
937
|
-
}
|
|
938
|
-
const res = await fetch(url, {
|
|
939
|
-
method,
|
|
940
|
-
headers,
|
|
941
|
-
credentials: "include",
|
|
942
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
943
|
-
});
|
|
944
|
-
const text = await res.text().catch(() => "");
|
|
945
|
-
if (!res.ok) {
|
|
946
|
-
if (res.status === 401) throw new Error("Unauthorized (401) - session may have expired. Please reload and log in again.");
|
|
947
|
-
if (res.status === 403) throw new Error("Forbidden (403) - you do not have permission to perform this action.");
|
|
948
|
-
throw new Error(text || `Request failed with status ${res.status}`);
|
|
949
|
-
}
|
|
950
|
-
if (!text) return {};
|
|
951
|
-
try {
|
|
952
|
-
return JSON.parse(text);
|
|
953
|
-
} catch {
|
|
954
|
-
return {};
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
947
|
const COLOR_OPTIONS = [
|
|
958
948
|
{ value: "gold", label: "Gold (Recommended)" },
|
|
959
949
|
{ value: "blue", label: "Blue" },
|
|
@@ -978,36 +968,6 @@ const LABEL_OPTIONS = [
|
|
|
978
968
|
{ value: "buynow", label: "Buy Now" },
|
|
979
969
|
{ value: "pay", label: "Pay" }
|
|
980
970
|
];
|
|
981
|
-
function SectionCard({
|
|
982
|
-
title,
|
|
983
|
-
description,
|
|
984
|
-
children,
|
|
985
|
-
right
|
|
986
|
-
}) {
|
|
987
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
988
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-4 border-b border-ui-border-base p-4", children: [
|
|
989
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
990
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: title }),
|
|
991
|
-
description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-sm text-ui-fg-subtle", children: description }) : null
|
|
992
|
-
] }),
|
|
993
|
-
right
|
|
994
|
-
] }),
|
|
995
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children })
|
|
996
|
-
] });
|
|
997
|
-
}
|
|
998
|
-
function FieldRow({
|
|
999
|
-
label,
|
|
1000
|
-
hint,
|
|
1001
|
-
children
|
|
1002
|
-
}) {
|
|
1003
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-12 items-start gap-4 py-3", children: [
|
|
1004
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "col-span-12 md:col-span-4", children: [
|
|
1005
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium text-ui-fg-base", children: label }),
|
|
1006
|
-
hint ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: hint }) : null
|
|
1007
|
-
] }),
|
|
1008
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-12 md:col-span-8", children })
|
|
1009
|
-
] });
|
|
1010
|
-
}
|
|
1011
971
|
function PayPalSettingsTab() {
|
|
1012
972
|
const [form, setForm] = react.useState({
|
|
1013
973
|
enabled: true,
|
|
@@ -1023,6 +983,7 @@ function PayPalSettingsTab() {
|
|
|
1023
983
|
const [saving, setSaving] = react.useState(false);
|
|
1024
984
|
const [toast, setToast] = react.useState(null);
|
|
1025
985
|
const didInit = react.useRef(false);
|
|
986
|
+
const dismissToast = react.useCallback(() => setToast(null), []);
|
|
1026
987
|
react.useEffect(() => {
|
|
1027
988
|
if (didInit.current) return;
|
|
1028
989
|
didInit.current = true;
|
|
@@ -1065,14 +1026,12 @@ function PayPalSettingsTab() {
|
|
|
1065
1026
|
...saved
|
|
1066
1027
|
}));
|
|
1067
1028
|
}
|
|
1068
|
-
setToast({
|
|
1069
|
-
window.setTimeout(() => setToast(null), 2500);
|
|
1029
|
+
setToast({ kind: "success", message: "Settings saved" });
|
|
1070
1030
|
} catch (e) {
|
|
1071
1031
|
setToast({
|
|
1072
|
-
|
|
1032
|
+
kind: "error",
|
|
1073
1033
|
message: (e instanceof Error ? e.message : "") || "Failed to save settings."
|
|
1074
1034
|
});
|
|
1075
|
-
window.setTimeout(() => setToast(null), 3500);
|
|
1076
1035
|
} finally {
|
|
1077
1036
|
setSaving(false);
|
|
1078
1037
|
}
|
|
@@ -1083,15 +1042,7 @@ function PayPalSettingsTab() {
|
|
|
1083
1042
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2" })
|
|
1084
1043
|
] }),
|
|
1085
1044
|
/* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
|
|
1086
|
-
|
|
1087
|
-
"div",
|
|
1088
|
-
{
|
|
1089
|
-
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",
|
|
1090
|
-
role: "status",
|
|
1091
|
-
"aria-live": "polite",
|
|
1092
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: toast.type === "success" ? "text-ui-fg-base" : "text-ui-fg-error", children: toast.message })
|
|
1093
|
-
}
|
|
1094
|
-
) : null,
|
|
1045
|
+
/* @__PURE__ */ jsxRuntime.jsx(Toast, { toast, onClose: dismissToast }),
|
|
1095
1046
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1096
1047
|
SectionCard,
|
|
1097
1048
|
{
|
|
@@ -1123,9 +1074,10 @@ function PayPalSettingsTab() {
|
|
|
1123
1074
|
),
|
|
1124
1075
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable PayPal" })
|
|
1125
1076
|
] }) }),
|
|
1126
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Title", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1077
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Title", htmlFor: "pp-title", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1127
1078
|
"input",
|
|
1128
1079
|
{
|
|
1080
|
+
id: "pp-title",
|
|
1129
1081
|
value: form.title,
|
|
1130
1082
|
onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })),
|
|
1131
1083
|
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",
|
|
@@ -1141,36 +1093,40 @@ function PayPalSettingsTab() {
|
|
|
1141
1093
|
title: "Button Appearance",
|
|
1142
1094
|
description: "Control PayPal Smart Button styling (color/shape/size/label).",
|
|
1143
1095
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
1144
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Button Color", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1096
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Button Color", htmlFor: "pp-btn-color", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1145
1097
|
"select",
|
|
1146
1098
|
{
|
|
1099
|
+
id: "pp-btn-color",
|
|
1147
1100
|
value: form.buttonColor,
|
|
1148
1101
|
onChange: (e) => setForm((p) => ({ ...p, buttonColor: e.target.value })),
|
|
1149
1102
|
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",
|
|
1150
1103
|
children: COLOR_OPTIONS.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value))
|
|
1151
1104
|
}
|
|
1152
1105
|
) }),
|
|
1153
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Button Shape", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1106
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Button Shape", htmlFor: "pp-btn-shape", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1154
1107
|
"select",
|
|
1155
1108
|
{
|
|
1109
|
+
id: "pp-btn-shape",
|
|
1156
1110
|
value: form.buttonShape,
|
|
1157
1111
|
onChange: (e) => setForm((p) => ({ ...p, buttonShape: e.target.value })),
|
|
1158
1112
|
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",
|
|
1159
1113
|
children: SHAPE_OPTIONS.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value))
|
|
1160
1114
|
}
|
|
1161
1115
|
) }),
|
|
1162
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Button Width", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1116
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Button Width", htmlFor: "pp-btn-width", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1163
1117
|
"select",
|
|
1164
1118
|
{
|
|
1119
|
+
id: "pp-btn-width",
|
|
1165
1120
|
value: form.buttonWidth,
|
|
1166
1121
|
onChange: (e) => setForm((p) => ({ ...p, buttonWidth: e.target.value })),
|
|
1167
1122
|
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",
|
|
1168
1123
|
children: WIDTH_OPTIONS.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value))
|
|
1169
1124
|
}
|
|
1170
1125
|
) }),
|
|
1171
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Button Height", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1126
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Button Height", htmlFor: "pp-btn-height", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1172
1127
|
"select",
|
|
1173
1128
|
{
|
|
1129
|
+
id: "pp-btn-height",
|
|
1174
1130
|
value: String(form.buttonHeight),
|
|
1175
1131
|
onChange: (e) => setForm((p) => ({ ...p, buttonHeight: Number(e.target.value) })),
|
|
1176
1132
|
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",
|
|
@@ -1180,9 +1136,10 @@ function PayPalSettingsTab() {
|
|
|
1180
1136
|
] }, h))
|
|
1181
1137
|
}
|
|
1182
1138
|
) }),
|
|
1183
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Button Label", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1139
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Button Label", htmlFor: "pp-btn-label", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1184
1140
|
"select",
|
|
1185
1141
|
{
|
|
1142
|
+
id: "pp-btn-label",
|
|
1186
1143
|
value: form.buttonLabel,
|
|
1187
1144
|
onChange: (e) => setForm((p) => ({ ...p, buttonLabel: e.target.value })),
|
|
1188
1145
|
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",
|