@easypayment/medusa-paypal 0.3.1 → 0.3.3
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 +9 -18
- package/.medusa/server/src/admin/index.mjs +9 -18
- package/.medusa/server/src/api/store/paypal/config/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal/config/route.js +20 -3
- package/.medusa/server/src/api/store/paypal/config/route.js.map +1 -1
- package/package.json +1 -1
- package/src/admin/routes/settings/paypal/advanced-card-payments/page.tsx +1 -1
- package/src/admin/routes/settings/paypal/paypal-settings/page.tsx +1 -10
- package/src/api/store/paypal/config/route.ts +26 -3
|
@@ -321,7 +321,7 @@ function AdvancedCardPaymentsTab() {
|
|
|
321
321
|
SectionCard$1,
|
|
322
322
|
{
|
|
323
323
|
title: "Advanced Card Payments",
|
|
324
|
-
description: "Control card checkout settings
|
|
324
|
+
description: "Control card checkout settings and 3D Secure behavior.",
|
|
325
325
|
right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
326
326
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onSave, disabled: saving || loading, className: "rounded-md bg-ui-button-neutral px-4 py-2 text-sm font-medium text-ui-fg-on-color shadow-sm hover:opacity-90 disabled:opacity-60", children: saving ? "Saving..." : "Save settings" }),
|
|
327
327
|
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading..." }) : null
|
|
@@ -354,6 +354,9 @@ function AdvancedCardPaymentsTab() {
|
|
|
354
354
|
function PayPalApplePayPage() {
|
|
355
355
|
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
356
356
|
}
|
|
357
|
+
function PayPalGooglePayPage() {
|
|
358
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
359
|
+
}
|
|
357
360
|
const config = adminSdk.defineRouteConfig({
|
|
358
361
|
label: "PayPal Connection",
|
|
359
362
|
hide: true
|
|
@@ -938,9 +941,6 @@ function PayPalConnectionPage() {
|
|
|
938
941
|
` })
|
|
939
942
|
] });
|
|
940
943
|
}
|
|
941
|
-
function PayPalGooglePayPage() {
|
|
942
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
943
|
-
}
|
|
944
944
|
function PayPalPayLaterMessagingPage() {
|
|
945
945
|
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
946
946
|
}
|
|
@@ -1185,7 +1185,7 @@ function PayPalSettingsTab() {
|
|
|
1185
1185
|
SectionCard,
|
|
1186
1186
|
{
|
|
1187
1187
|
title: "PayPal Settings",
|
|
1188
|
-
description: "Enable PayPal and configure checkout title
|
|
1188
|
+
description: "Enable PayPal and configure checkout title.",
|
|
1189
1189
|
right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
1190
1190
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1191
1191
|
"button",
|
|
@@ -1220,15 +1220,6 @@ function PayPalSettingsTab() {
|
|
|
1220
1220
|
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",
|
|
1221
1221
|
placeholder: "PayPal"
|
|
1222
1222
|
}
|
|
1223
|
-
) }),
|
|
1224
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Description", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1225
|
-
"textarea",
|
|
1226
|
-
{
|
|
1227
|
-
value: form.description,
|
|
1228
|
-
onChange: (e) => setForm((p) => ({ ...p, description: e.target.value })),
|
|
1229
|
-
className: "min-h-[84px] w-full resize-y 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",
|
|
1230
|
-
placeholder: "Pay via PayPal..."
|
|
1231
|
-
}
|
|
1232
1223
|
) })
|
|
1233
1224
|
] })
|
|
1234
1225
|
}
|
|
@@ -1364,14 +1355,14 @@ const routeModule = {
|
|
|
1364
1355
|
Component: PayPalApplePayPage,
|
|
1365
1356
|
path: "/settings/paypal/apple-pay"
|
|
1366
1357
|
},
|
|
1367
|
-
{
|
|
1368
|
-
Component: PayPalConnectionPage,
|
|
1369
|
-
path: "/settings/paypal/connection"
|
|
1370
|
-
},
|
|
1371
1358
|
{
|
|
1372
1359
|
Component: PayPalGooglePayPage,
|
|
1373
1360
|
path: "/settings/paypal/google-pay"
|
|
1374
1361
|
},
|
|
1362
|
+
{
|
|
1363
|
+
Component: PayPalConnectionPage,
|
|
1364
|
+
path: "/settings/paypal/connection"
|
|
1365
|
+
},
|
|
1375
1366
|
{
|
|
1376
1367
|
Component: PayPalPayLaterMessagingPage,
|
|
1377
1368
|
path: "/settings/paypal/pay-later-messaging"
|
|
@@ -320,7 +320,7 @@ function AdvancedCardPaymentsTab() {
|
|
|
320
320
|
SectionCard$1,
|
|
321
321
|
{
|
|
322
322
|
title: "Advanced Card Payments",
|
|
323
|
-
description: "Control card checkout settings
|
|
323
|
+
description: "Control card checkout settings and 3D Secure behavior.",
|
|
324
324
|
right: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
325
325
|
/* @__PURE__ */ jsx("button", { type: "button", onClick: onSave, disabled: saving || loading, className: "rounded-md bg-ui-button-neutral px-4 py-2 text-sm font-medium text-ui-fg-on-color shadow-sm hover:opacity-90 disabled:opacity-60", children: saving ? "Saving..." : "Save settings" }),
|
|
326
326
|
loading ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading..." }) : null
|
|
@@ -353,6 +353,9 @@ function AdvancedCardPaymentsTab() {
|
|
|
353
353
|
function PayPalApplePayPage() {
|
|
354
354
|
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
355
355
|
}
|
|
356
|
+
function PayPalGooglePayPage() {
|
|
357
|
+
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
358
|
+
}
|
|
356
359
|
const config = defineRouteConfig({
|
|
357
360
|
label: "PayPal Connection",
|
|
358
361
|
hide: true
|
|
@@ -937,9 +940,6 @@ function PayPalConnectionPage() {
|
|
|
937
940
|
` })
|
|
938
941
|
] });
|
|
939
942
|
}
|
|
940
|
-
function PayPalGooglePayPage() {
|
|
941
|
-
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
942
|
-
}
|
|
943
943
|
function PayPalPayLaterMessagingPage() {
|
|
944
944
|
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
945
945
|
}
|
|
@@ -1184,7 +1184,7 @@ function PayPalSettingsTab() {
|
|
|
1184
1184
|
SectionCard,
|
|
1185
1185
|
{
|
|
1186
1186
|
title: "PayPal Settings",
|
|
1187
|
-
description: "Enable PayPal and configure checkout title
|
|
1187
|
+
description: "Enable PayPal and configure checkout title.",
|
|
1188
1188
|
right: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
1189
1189
|
/* @__PURE__ */ jsx(
|
|
1190
1190
|
"button",
|
|
@@ -1219,15 +1219,6 @@ function PayPalSettingsTab() {
|
|
|
1219
1219
|
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",
|
|
1220
1220
|
placeholder: "PayPal"
|
|
1221
1221
|
}
|
|
1222
|
-
) }),
|
|
1223
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "Description", children: /* @__PURE__ */ jsx(
|
|
1224
|
-
"textarea",
|
|
1225
|
-
{
|
|
1226
|
-
value: form.description,
|
|
1227
|
-
onChange: (e) => setForm((p) => ({ ...p, description: e.target.value })),
|
|
1228
|
-
className: "min-h-[84px] w-full resize-y 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",
|
|
1229
|
-
placeholder: "Pay via PayPal..."
|
|
1230
|
-
}
|
|
1231
1222
|
) })
|
|
1232
1223
|
] })
|
|
1233
1224
|
}
|
|
@@ -1363,14 +1354,14 @@ const routeModule = {
|
|
|
1363
1354
|
Component: PayPalApplePayPage,
|
|
1364
1355
|
path: "/settings/paypal/apple-pay"
|
|
1365
1356
|
},
|
|
1366
|
-
{
|
|
1367
|
-
Component: PayPalConnectionPage,
|
|
1368
|
-
path: "/settings/paypal/connection"
|
|
1369
|
-
},
|
|
1370
1357
|
{
|
|
1371
1358
|
Component: PayPalGooglePayPage,
|
|
1372
1359
|
path: "/settings/paypal/google-pay"
|
|
1373
1360
|
},
|
|
1361
|
+
{
|
|
1362
|
+
Component: PayPalConnectionPage,
|
|
1363
|
+
path: "/settings/paypal/connection"
|
|
1364
|
+
},
|
|
1374
1365
|
{
|
|
1375
1366
|
Component: PayPalPayLaterMessagingPage,
|
|
1376
1367
|
path: "/settings/paypal/pay-later-messaging"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/config/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAQ7E,wBAAsB,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/config/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAQ7E,wBAAsB,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,2BA6EhE"}
|
|
@@ -26,14 +26,23 @@ async function GET(req, res) {
|
|
|
26
26
|
currencyCode: currency,
|
|
27
27
|
paypalCurrencyOverride: apiDetails?.apiDetails?.currency_code || process.env.PAYPAL_CURRENCY,
|
|
28
28
|
});
|
|
29
|
-
// Read
|
|
29
|
+
// Read settings so frontend SDK mirrors admin controls.
|
|
30
30
|
const settings = await paypal.getSettings().catch(() => ({}));
|
|
31
|
-
const
|
|
32
|
-
? (settings.data
|
|
31
|
+
const data = settings && typeof settings === "object" && "data" in settings
|
|
32
|
+
? (settings.data || {})
|
|
33
|
+
: {};
|
|
34
|
+
const additionalSettings = data && typeof data === "object"
|
|
35
|
+
? (data.additional_settings || {})
|
|
36
|
+
: {};
|
|
37
|
+
const paypalSettings = data && typeof data === "object"
|
|
38
|
+
? (data.paypal_settings || {})
|
|
33
39
|
: {};
|
|
34
40
|
const paymentAction = typeof additionalSettings.paymentAction === "string"
|
|
35
41
|
? additionalSettings.paymentAction
|
|
36
42
|
: "capture";
|
|
43
|
+
const disableButtons = Array.isArray(paypalSettings.disableButtons)
|
|
44
|
+
? paypalSettings.disableButtons.filter((value) => typeof value === "string")
|
|
45
|
+
: [];
|
|
37
46
|
return res.json({
|
|
38
47
|
environment: creds.environment,
|
|
39
48
|
client_id: creds.client_id,
|
|
@@ -43,6 +52,14 @@ async function GET(req, res) {
|
|
|
43
52
|
supported_currencies: (0, currencies_1.getPayPalSupportedCurrencies)(),
|
|
44
53
|
client_token,
|
|
45
54
|
intent: paymentAction, // "capture" or "authorize"
|
|
55
|
+
paypal_enabled: paypalSettings.enabled ?? true,
|
|
56
|
+
paypal_title: paypalSettings.title || "PayPal",
|
|
57
|
+
button_color: paypalSettings.buttonColor || "gold",
|
|
58
|
+
button_shape: paypalSettings.buttonShape || "rect",
|
|
59
|
+
button_width: paypalSettings.buttonWidth || "auto",
|
|
60
|
+
button_height: paypalSettings.buttonHeight ?? 45,
|
|
61
|
+
button_label: paypalSettings.buttonLabel || "paypal",
|
|
62
|
+
disable_buttons: disableButtons,
|
|
46
63
|
});
|
|
47
64
|
}
|
|
48
65
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/config/route.ts"],"names":[],"mappings":";;AAQA,
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/config/route.ts"],"names":[],"mappings":";;AAQA,kBA6EC;AAnFD,4EAIoD;AAE7C,KAAK,UAAU,GAAG,CAAC,GAAkB,EAAE,GAAmB;IAC/D,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAsB,mBAAmB,CAAC,CAAA;IAC1E,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,oBAAoB,EAAE,CAAA;QACjD,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;QACjE,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;QAC1F,MAAM,MAAM,GAAI,GAAG,CAAC,KAAK,EAAE,OAAkB,IAAI,EAAE,CAAA;QACnD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QACxC,IAAI,QAAQ,GAAG,IAAA,kCAAqB,EAClC,UAAU,EAAE,UAAU,EAAE,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,KAAK,CAC9E,CAAA;QACD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC;gBACxC,MAAM,EAAE,MA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vancedCardPaymentsTab() {
|
|
|
167
167
|
<span className={toast.type === "success" ? "text-ui-fg-base" : "text-ui-fg-error"}>{toast.message}</span>
|
|
168
168
|
</div>
|
|
169
169
|
) : null}
|
|
170
|
-
<SectionCard title="Advanced Card Payments" description="Control card checkout settings
|
|
170
|
+
<SectionCard title="Advanced Card Payments" description="Control card checkout settings and 3D Secure behavior."
|
|
171
171
|
right={(
|
|
172
172
|
<div className="flex items-center gap-3">
|
|
173
173
|
<button type="button" onClick={onSave} disabled={saving || loading} className="rounded-md bg-ui-button-neutral px-4 py-2 text-sm font-medium text-ui-fg-on-color shadow-sm hover:opacity-90 disabled:opacity-60">
|
|
@@ -335,7 +335,7 @@ export default function PayPalSettingsTab() {
|
|
|
335
335
|
{/* PayPal Settings */}
|
|
336
336
|
<SectionCard
|
|
337
337
|
title="PayPal Settings"
|
|
338
|
-
description="Enable PayPal and configure checkout title
|
|
338
|
+
description="Enable PayPal and configure checkout title."
|
|
339
339
|
right={(
|
|
340
340
|
<div className="flex items-center gap-3">
|
|
341
341
|
<button
|
|
@@ -372,15 +372,6 @@ export default function PayPalSettingsTab() {
|
|
|
372
372
|
/>
|
|
373
373
|
</FieldRow>
|
|
374
374
|
|
|
375
|
-
<FieldRow label="Description">
|
|
376
|
-
<textarea
|
|
377
|
-
value={form.description}
|
|
378
|
-
onChange={(e) => setForm((p) => ({ ...p, description: e.target.value }))}
|
|
379
|
-
className="min-h-[84px] w-full resize-y 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"
|
|
380
|
-
placeholder="Pay via PayPal..."
|
|
381
|
-
/>
|
|
382
|
-
</FieldRow>
|
|
383
|
-
|
|
384
375
|
</div>
|
|
385
376
|
</SectionCard>
|
|
386
377
|
|
|
@@ -36,17 +36,32 @@ export async function GET(req: MedusaRequest, res: MedusaResponse) {
|
|
|
36
36
|
apiDetails?.apiDetails?.currency_code || process.env.PAYPAL_CURRENCY,
|
|
37
37
|
})
|
|
38
38
|
|
|
39
|
-
// Read
|
|
39
|
+
// Read settings so frontend SDK mirrors admin controls.
|
|
40
40
|
const settings = await paypal.getSettings().catch(() => ({}))
|
|
41
|
-
const
|
|
41
|
+
const data =
|
|
42
42
|
settings && typeof settings === "object" && "data" in settings
|
|
43
|
-
? ((settings as any).data
|
|
43
|
+
? ((settings as any).data || {})
|
|
44
|
+
: {}
|
|
45
|
+
|
|
46
|
+
const additionalSettings =
|
|
47
|
+
data && typeof data === "object"
|
|
48
|
+
? ((data as Record<string, any>).additional_settings || {})
|
|
44
49
|
: {}
|
|
50
|
+
|
|
51
|
+
const paypalSettings =
|
|
52
|
+
data && typeof data === "object"
|
|
53
|
+
? ((data as Record<string, any>).paypal_settings || {})
|
|
54
|
+
: {}
|
|
55
|
+
|
|
45
56
|
const paymentAction =
|
|
46
57
|
typeof additionalSettings.paymentAction === "string"
|
|
47
58
|
? additionalSettings.paymentAction
|
|
48
59
|
: "capture"
|
|
49
60
|
|
|
61
|
+
const disableButtons = Array.isArray(paypalSettings.disableButtons)
|
|
62
|
+
? paypalSettings.disableButtons.filter((value: unknown): value is string => typeof value === "string")
|
|
63
|
+
: []
|
|
64
|
+
|
|
50
65
|
return res.json({
|
|
51
66
|
environment: creds.environment,
|
|
52
67
|
client_id: creds.client_id,
|
|
@@ -56,6 +71,14 @@ export async function GET(req: MedusaRequest, res: MedusaResponse) {
|
|
|
56
71
|
supported_currencies: getPayPalSupportedCurrencies(),
|
|
57
72
|
client_token,
|
|
58
73
|
intent: paymentAction, // "capture" or "authorize"
|
|
74
|
+
paypal_enabled: paypalSettings.enabled ?? true,
|
|
75
|
+
paypal_title: paypalSettings.title || "PayPal",
|
|
76
|
+
button_color: paypalSettings.buttonColor || "gold",
|
|
77
|
+
button_shape: paypalSettings.buttonShape || "rect",
|
|
78
|
+
button_width: paypalSettings.buttonWidth || "auto",
|
|
79
|
+
button_height: paypalSettings.buttonHeight ?? 45,
|
|
80
|
+
button_label: paypalSettings.buttonLabel || "paypal",
|
|
81
|
+
disable_buttons: disableButtons,
|
|
59
82
|
})
|
|
60
83
|
} catch (e: any) {
|
|
61
84
|
return res.status(500).json({ message: e?.message || "Failed to load PayPal config" })
|