@easypayment/medusa-payment-paypal 1.3.8 → 1.3.10
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 +261 -94
- package/.medusa/server/src/admin/index.mjs +196 -31
- package/.medusa/server/src/api/admin/paypal/merchant-status/route.d.ts +11 -0
- package/.medusa/server/src/api/admin/paypal/merchant-status/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/paypal/merchant-status/route.js +32 -0
- package/.medusa/server/src/api/admin/paypal/merchant-status/route.js.map +1 -0
- package/.medusa/server/src/api/store/paypal/create-order/route.d.ts +4 -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 +113 -108
- package/.medusa/server/src/api/store/paypal/create-order/route.js.map +1 -1
- package/.medusa/server/src/api/utils/request-logger.d.ts.map +1 -1
- package/.medusa/server/src/api/utils/request-logger.js +4 -2
- package/.medusa/server/src/api/utils/request-logger.js.map +1 -1
- package/.medusa/server/src/modules/paypal/service.d.ts +33 -0
- package/.medusa/server/src/modules/paypal/service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/service.js +138 -34
- 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 +2 -1
- package/.medusa/server/src/modules/paypal/types/config.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/merchant-status.d.ts +48 -0
- package/.medusa/server/src/modules/paypal/utils/merchant-status.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/utils/merchant-status.js +106 -0
- package/.medusa/server/src/modules/paypal/utils/merchant-status.js.map +1 -0
- package/.medusa/server/src/modules/paypal/utils/order-context.d.ts +61 -0
- package/.medusa/server/src/modules/paypal/utils/order-context.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/utils/order-context.js +127 -0
- package/.medusa/server/src/modules/paypal/utils/order-context.js.map +1 -0
- package/.medusa/server/src/modules/paypal/utils/request-logger.d.ts +12 -0
- package/.medusa/server/src/modules/paypal/utils/request-logger.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/request-logger.js +26 -2
- package/.medusa/server/src/modules/paypal/utils/request-logger.js.map +1 -1
- package/CHANGELOG.md +102 -0
- package/README.md +4 -4
- package/package.json +1 -1
- package/src/admin/routes/settings/paypal/_components/MerchantStatusNotices.tsx +116 -0
- package/src/admin/routes/settings/paypal/additional-settings/page.tsx +54 -12
- package/src/admin/routes/settings/paypal/advanced-card-payments/page.tsx +2 -0
- package/src/admin/routes/settings/paypal/connection/page.tsx +73 -6
- package/src/api/admin/paypal/merchant-status/route.ts +36 -0
- package/src/api/store/paypal/create-order/route.ts +191 -165
- package/src/api/utils/request-logger.ts +7 -3
- package/src/modules/paypal/service.ts +192 -43
- package/src/modules/paypal/types/config.ts +3 -2
- package/src/modules/paypal/utils/merchant-status.ts +187 -0
- package/src/modules/paypal/utils/order-context.ts +163 -0
- package/src/modules/paypal/utils/request-logger.ts +30 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { defineRouteConfig } from "@medusajs/admin-sdk";
|
|
3
3
|
import { Navigate, useLocation, Link } from "react-router-dom";
|
|
4
|
-
import { useEffect, useState, useRef, useCallback, useMemo, useLayoutEffect } from "react";
|
|
4
|
+
import React, { useEffect, useState, useRef, useCallback, useMemo, useLayoutEffect } from "react";
|
|
5
5
|
const config$1 = defineRouteConfig({
|
|
6
6
|
label: "PayPal"
|
|
7
7
|
});
|
|
@@ -155,23 +155,33 @@ async function adminFetch(path, opts = {}) {
|
|
|
155
155
|
}
|
|
156
156
|
const DEFAULT_FORM$1 = {
|
|
157
157
|
paymentAction: "capture",
|
|
158
|
-
brandName: "
|
|
159
|
-
landingPage: "
|
|
158
|
+
brandName: "",
|
|
159
|
+
landingPage: "login",
|
|
160
160
|
requireInstantPayment: false,
|
|
161
161
|
sendItemDetails: true,
|
|
162
|
+
sendShippingAddress: true,
|
|
162
163
|
invoicePrefix: "PP-",
|
|
163
|
-
creditCardStatementName: "
|
|
164
|
+
creditCardStatementName: "",
|
|
164
165
|
debugLogging: false
|
|
165
166
|
};
|
|
167
|
+
function isPlaceholderName(value) {
|
|
168
|
+
return typeof value === "string" && value.trim().toLowerCase() === "paypal";
|
|
169
|
+
}
|
|
166
170
|
function mergeWithDefaults$1(saved) {
|
|
167
171
|
if (!saved) return { ...DEFAULT_FORM$1 };
|
|
168
172
|
const entries = Object.entries(saved).filter(
|
|
169
173
|
([, value]) => value !== void 0
|
|
170
174
|
);
|
|
171
|
-
|
|
175
|
+
const merged = {
|
|
172
176
|
...DEFAULT_FORM$1,
|
|
173
177
|
...Object.fromEntries(entries)
|
|
174
178
|
};
|
|
179
|
+
if (merged.landingPage !== "billing") merged.landingPage = "login";
|
|
180
|
+
if (isPlaceholderName(merged.brandName)) merged.brandName = "";
|
|
181
|
+
if (isPlaceholderName(merged.creditCardStatementName)) {
|
|
182
|
+
merged.creditCardStatementName = "";
|
|
183
|
+
}
|
|
184
|
+
return merged;
|
|
175
185
|
}
|
|
176
186
|
function AdditionalSettingsTab() {
|
|
177
187
|
const [form, setForm] = useState(() => ({
|
|
@@ -305,16 +315,24 @@ function AdditionalSettingsTab() {
|
|
|
305
315
|
]
|
|
306
316
|
}
|
|
307
317
|
) }),
|
|
308
|
-
/* @__PURE__ */ jsx(
|
|
309
|
-
|
|
318
|
+
/* @__PURE__ */ jsx(
|
|
319
|
+
FieldRow,
|
|
310
320
|
{
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
321
|
+
label: "Brand Name",
|
|
322
|
+
htmlFor: "as-brand-name",
|
|
323
|
+
hint: "The business name customers see in the PayPal checkout. Leave empty to use your store's name.",
|
|
324
|
+
children: /* @__PURE__ */ jsx(
|
|
325
|
+
"input",
|
|
326
|
+
{
|
|
327
|
+
id: "as-brand-name",
|
|
328
|
+
value: form.brandName,
|
|
329
|
+
onChange: (e) => setForm((p) => ({ ...p, brandName: e.target.value })),
|
|
330
|
+
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",
|
|
331
|
+
placeholder: "Your store name"
|
|
332
|
+
}
|
|
333
|
+
)
|
|
316
334
|
}
|
|
317
|
-
)
|
|
335
|
+
),
|
|
318
336
|
/* @__PURE__ */ jsx(FieldRow, { label: "Landing Page", htmlFor: "as-landing-page", children: /* @__PURE__ */ jsxs(
|
|
319
337
|
"select",
|
|
320
338
|
{
|
|
@@ -326,9 +344,8 @@ function AdditionalSettingsTab() {
|
|
|
326
344
|
})),
|
|
327
345
|
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",
|
|
328
346
|
children: [
|
|
329
|
-
/* @__PURE__ */ jsx("option", { value: "
|
|
330
|
-
/* @__PURE__ */ jsx("option", { value: "
|
|
331
|
-
/* @__PURE__ */ jsx("option", { value: "billing", children: "Billing" })
|
|
347
|
+
/* @__PURE__ */ jsx("option", { value: "login", children: "Login (PayPal account)" }),
|
|
348
|
+
/* @__PURE__ */ jsx("option", { value: "billing", children: "Guest checkout (card form)" })
|
|
332
349
|
]
|
|
333
350
|
}
|
|
334
351
|
) }),
|
|
@@ -369,6 +386,28 @@ function AdditionalSettingsTab() {
|
|
|
369
386
|
] })
|
|
370
387
|
}
|
|
371
388
|
),
|
|
389
|
+
/* @__PURE__ */ jsx(
|
|
390
|
+
FieldRow,
|
|
391
|
+
{
|
|
392
|
+
label: "Send Shipping Address",
|
|
393
|
+
hint: "Send the shipping address the customer entered at checkout to PayPal, so PayPal shows that address instead of the ones saved on the customer's PayPal account. Needed for PayPal Seller Protection.",
|
|
394
|
+
children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
395
|
+
/* @__PURE__ */ jsx(
|
|
396
|
+
"input",
|
|
397
|
+
{
|
|
398
|
+
type: "checkbox",
|
|
399
|
+
checked: form.sendShippingAddress,
|
|
400
|
+
onChange: (e) => setForm((p) => ({
|
|
401
|
+
...p,
|
|
402
|
+
sendShippingAddress: e.target.checked
|
|
403
|
+
})),
|
|
404
|
+
className: "h-4 w-4 rounded border-ui-border-base"
|
|
405
|
+
}
|
|
406
|
+
),
|
|
407
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Send the checkout shipping address to PayPal" })
|
|
408
|
+
] })
|
|
409
|
+
}
|
|
410
|
+
),
|
|
372
411
|
/* @__PURE__ */ jsx(FieldRow, { label: "Invoice prefix", htmlFor: "as-invoice-prefix", children: /* @__PURE__ */ jsx(
|
|
373
412
|
"input",
|
|
374
413
|
{
|
|
@@ -384,6 +423,7 @@ function AdditionalSettingsTab() {
|
|
|
384
423
|
{
|
|
385
424
|
label: "Credit Card Statement Name",
|
|
386
425
|
htmlFor: "as-cc-statement",
|
|
426
|
+
hint: "Shown on the customer's card statement (up to 22 characters). Leave empty to use the name on your PayPal account.",
|
|
387
427
|
children: /* @__PURE__ */ jsx(
|
|
388
428
|
"input",
|
|
389
429
|
{
|
|
@@ -394,7 +434,8 @@ function AdditionalSettingsTab() {
|
|
|
394
434
|
creditCardStatementName: e.target.value
|
|
395
435
|
})),
|
|
396
436
|
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",
|
|
397
|
-
placeholder: "
|
|
437
|
+
placeholder: "Your business name",
|
|
438
|
+
maxLength: 22
|
|
398
439
|
}
|
|
399
440
|
)
|
|
400
441
|
}
|
|
@@ -421,7 +462,7 @@ function AdditionalSettingsTab() {
|
|
|
421
462
|
FieldRow,
|
|
422
463
|
{
|
|
423
464
|
label: "Request/response logging",
|
|
424
|
-
hint: "When enabled, the plugin appends each request and response to logs/paypal-requests-YYYY-MM-DD.log (path configurable via PAYPAL_LOG_DIR). Remember to save after toggling.",
|
|
465
|
+
hint: "When enabled, the plugin appends each request and response to .medusa/paypal-logs/paypal-requests-YYYY-MM-DD.log in your project (path configurable via PAYPAL_LOG_DIR). Remember to save after toggling.",
|
|
425
466
|
children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
426
467
|
/* @__PURE__ */ jsx(
|
|
427
468
|
"input",
|
|
@@ -443,6 +484,71 @@ function AdditionalSettingsTab() {
|
|
|
443
484
|
)
|
|
444
485
|
] }) });
|
|
445
486
|
}
|
|
487
|
+
function PayPalApplePayPage() {
|
|
488
|
+
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
489
|
+
}
|
|
490
|
+
const URL_RE = /(https?:\/\/[^\s]+[^\s.,!?])/g;
|
|
491
|
+
function NoticeText({ message }) {
|
|
492
|
+
const parts = message.split(URL_RE);
|
|
493
|
+
return /* @__PURE__ */ jsx(Fragment, { children: parts.map(
|
|
494
|
+
(part, i) => /^https?:\/\//.test(part) ? /* @__PURE__ */ jsx(
|
|
495
|
+
"a",
|
|
496
|
+
{
|
|
497
|
+
href: part,
|
|
498
|
+
target: "_blank",
|
|
499
|
+
rel: "noopener noreferrer",
|
|
500
|
+
className: "underline",
|
|
501
|
+
children: part
|
|
502
|
+
},
|
|
503
|
+
i
|
|
504
|
+
) : /* @__PURE__ */ jsx(React.Fragment, { children: part }, i)
|
|
505
|
+
) });
|
|
506
|
+
}
|
|
507
|
+
function MerchantStatusNotices({
|
|
508
|
+
environment,
|
|
509
|
+
only,
|
|
510
|
+
reloadKey
|
|
511
|
+
}) {
|
|
512
|
+
const [notices, setNotices] = useState([]);
|
|
513
|
+
useEffect(() => {
|
|
514
|
+
let cancelled = false;
|
|
515
|
+
setNotices([]);
|
|
516
|
+
(async () => {
|
|
517
|
+
try {
|
|
518
|
+
const json = await adminFetch(
|
|
519
|
+
"/admin/paypal/merchant-status",
|
|
520
|
+
environment ? { query: { environment } } : {}
|
|
521
|
+
);
|
|
522
|
+
if (cancelled) return;
|
|
523
|
+
setNotices(Array.isArray(json == null ? void 0 : json.notices) ? json.notices : []);
|
|
524
|
+
} catch {
|
|
525
|
+
}
|
|
526
|
+
})();
|
|
527
|
+
return () => {
|
|
528
|
+
cancelled = true;
|
|
529
|
+
};
|
|
530
|
+
}, [environment, reloadKey]);
|
|
531
|
+
const visible = only ? notices.filter((notice) => only.includes(notice.code)) : notices;
|
|
532
|
+
if (visible.length === 0) return null;
|
|
533
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", "data-testid": "paypal-merchant-notices", children: visible.map((notice) => /* @__PURE__ */ jsx(
|
|
534
|
+
"div",
|
|
535
|
+
{
|
|
536
|
+
role: "alert",
|
|
537
|
+
className: "rounded border p-3 text-sm",
|
|
538
|
+
style: notice.level === "error" ? {
|
|
539
|
+
background: "#fef2f2",
|
|
540
|
+
borderColor: "#fecaca",
|
|
541
|
+
color: "#b91c1c"
|
|
542
|
+
} : {
|
|
543
|
+
background: "#fffbeb",
|
|
544
|
+
borderColor: "#fde68a",
|
|
545
|
+
color: "#92400e"
|
|
546
|
+
},
|
|
547
|
+
children: /* @__PURE__ */ jsx(NoticeText, { message: notice.message })
|
|
548
|
+
},
|
|
549
|
+
notice.code
|
|
550
|
+
)) });
|
|
551
|
+
}
|
|
446
552
|
const DEFAULT_FORM = {
|
|
447
553
|
enabled: true,
|
|
448
554
|
title: "Credit or Debit Card",
|
|
@@ -528,6 +634,7 @@ function AdvancedCardPaymentsTab() {
|
|
|
528
634
|
/* @__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" }) }) }),
|
|
529
635
|
/* @__PURE__ */ jsx(PayPalTabs, {}),
|
|
530
636
|
/* @__PURE__ */ jsx(Toast, { toast, onClose: dismissToast }),
|
|
637
|
+
/* @__PURE__ */ jsx(MerchantStatusNotices, { only: ["card_payments_not_enabled"] }),
|
|
531
638
|
/* @__PURE__ */ jsx(
|
|
532
639
|
SectionCard,
|
|
533
640
|
{
|
|
@@ -601,12 +708,21 @@ function AdvancedCardPaymentsTab() {
|
|
|
601
708
|
function PayPalGooglePayPage() {
|
|
602
709
|
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
603
710
|
}
|
|
604
|
-
function PayPalApplePayPage() {
|
|
605
|
-
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
606
|
-
}
|
|
607
711
|
const config = defineRouteConfig({
|
|
608
712
|
label: "PayPal Connection"
|
|
609
713
|
});
|
|
714
|
+
const SESSION_EXPIRED_MESSAGE = "Your admin session has expired. Reload this page and log in again.";
|
|
715
|
+
function describeFailure(status, body, fallback) {
|
|
716
|
+
var _a;
|
|
717
|
+
if (status === 401) return SESSION_EXPIRED_MESSAGE;
|
|
718
|
+
try {
|
|
719
|
+
const message = (_a = JSON.parse(body)) == null ? void 0 : _a.message;
|
|
720
|
+
if (typeof message === "string" && message.trim()) return message.trim();
|
|
721
|
+
} catch {
|
|
722
|
+
}
|
|
723
|
+
const text = body.trim();
|
|
724
|
+
return text && !text.startsWith("<") ? text.slice(0, 300) : fallback;
|
|
725
|
+
}
|
|
610
726
|
const PARTNER_JS_URL = "https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js";
|
|
611
727
|
const PARTNER_SCRIPT_ID = "paypal-partner-js";
|
|
612
728
|
const PARTNER_HELPER_SCRIPT_IDS = [
|
|
@@ -816,7 +932,13 @@ function PayPalConnectionPage() {
|
|
|
816
932
|
});
|
|
817
933
|
if (!res.ok) {
|
|
818
934
|
const txt = await res.text().catch(() => "");
|
|
819
|
-
throw new Error(
|
|
935
|
+
throw new Error(
|
|
936
|
+
describeFailure(
|
|
937
|
+
res.status,
|
|
938
|
+
txt,
|
|
939
|
+
`Onboarding exchange failed (${res.status})`
|
|
940
|
+
)
|
|
941
|
+
);
|
|
820
942
|
}
|
|
821
943
|
closeMiniBrowser();
|
|
822
944
|
clearCachedUrl(activeEnv);
|
|
@@ -1054,7 +1176,13 @@ function PayPalConnectionPage() {
|
|
|
1054
1176
|
});
|
|
1055
1177
|
if (!res.ok) {
|
|
1056
1178
|
const txt = await res.text().catch(() => "");
|
|
1057
|
-
throw new Error(
|
|
1179
|
+
throw new Error(
|
|
1180
|
+
describeFailure(
|
|
1181
|
+
res.status,
|
|
1182
|
+
txt,
|
|
1183
|
+
`Save credentials failed (${res.status})`
|
|
1184
|
+
)
|
|
1185
|
+
);
|
|
1058
1186
|
}
|
|
1059
1187
|
const statusRes = await fetch(`${STATUS_ENDPOINT}?environment=${env}`, {
|
|
1060
1188
|
method: "GET",
|
|
@@ -1092,7 +1220,9 @@ function PayPalConnectionPage() {
|
|
|
1092
1220
|
});
|
|
1093
1221
|
if (!res.ok) {
|
|
1094
1222
|
const t = await res.text().catch(() => "");
|
|
1095
|
-
throw new Error(
|
|
1223
|
+
throw new Error(
|
|
1224
|
+
describeFailure(res.status, t, `Disconnect failed (${res.status})`)
|
|
1225
|
+
);
|
|
1096
1226
|
}
|
|
1097
1227
|
clearCachedUrl(env);
|
|
1098
1228
|
completedRef.current = false;
|
|
@@ -1100,7 +1230,8 @@ function PayPalConnectionPage() {
|
|
|
1100
1230
|
await fetchFreshLink(env, currentRunId.current);
|
|
1101
1231
|
} catch (e) {
|
|
1102
1232
|
console.error(e);
|
|
1103
|
-
|
|
1233
|
+
const stillConnected = await refreshStatusAndMaybeConnect(env);
|
|
1234
|
+
if (!stillConnected) setConnState("error");
|
|
1104
1235
|
setError((e == null ? void 0 : e.message) || "Failed to disconnect.");
|
|
1105
1236
|
} finally {
|
|
1106
1237
|
setOnboardingInProgress(false);
|
|
@@ -1145,8 +1276,27 @@ function PayPalConnectionPage() {
|
|
|
1145
1276
|
) }),
|
|
1146
1277
|
/* @__PURE__ */ jsx("div", { className: "text-sm font-medium pt-2", children: env === "sandbox" ? "Connect to PayPal (Sandbox)" : "Connect to PayPal" }),
|
|
1147
1278
|
/* @__PURE__ */ jsx("div", { className: "max-w-xl", children: connState === "connected" ? /* @__PURE__ */ jsxs("div", { children: [
|
|
1148
|
-
/* @__PURE__ */ jsxs("div", { className: "text-sm text-green-600 bg-green-50 p-3 rounded border border-green-200", children: [
|
|
1149
|
-
|
|
1279
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm text-green-600 bg-green-50 p-3 rounded border border-green-200", children: [
|
|
1280
|
+
/* @__PURE__ */ jsxs(
|
|
1281
|
+
"svg",
|
|
1282
|
+
{
|
|
1283
|
+
width: "16",
|
|
1284
|
+
height: "16",
|
|
1285
|
+
viewBox: "0 0 24 24",
|
|
1286
|
+
fill: "none",
|
|
1287
|
+
stroke: "currentColor",
|
|
1288
|
+
strokeWidth: "2.5",
|
|
1289
|
+
strokeLinecap: "round",
|
|
1290
|
+
strokeLinejoin: "round",
|
|
1291
|
+
"aria-hidden": "true",
|
|
1292
|
+
style: { flexShrink: 0 },
|
|
1293
|
+
children: [
|
|
1294
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
1295
|
+
/* @__PURE__ */ jsx("path", { d: "m8 12 3 3 5-6" })
|
|
1296
|
+
]
|
|
1297
|
+
}
|
|
1298
|
+
),
|
|
1299
|
+
/* @__PURE__ */ jsx("span", { children: "Successfully connected to PayPal" }),
|
|
1150
1300
|
/* @__PURE__ */ jsx(
|
|
1151
1301
|
"a",
|
|
1152
1302
|
{
|
|
@@ -1158,6 +1308,13 @@ function PayPalConnectionPage() {
|
|
|
1158
1308
|
}
|
|
1159
1309
|
)
|
|
1160
1310
|
] }),
|
|
1311
|
+
/* @__PURE__ */ jsx("div", { className: "mt-3", children: /* @__PURE__ */ jsx(
|
|
1312
|
+
MerchantStatusNotices,
|
|
1313
|
+
{
|
|
1314
|
+
environment: env,
|
|
1315
|
+
reloadKey: (statusInfo == null ? void 0 : statusInfo.seller_client_id_masked) || ""
|
|
1316
|
+
}
|
|
1317
|
+
) }),
|
|
1161
1318
|
/* @__PURE__ */ jsxs("div", { className: "mt-3 rounded-md border border-ui-border-base bg-ui-bg-subtle p-3 text-xs text-ui-fg-subtle", children: [
|
|
1162
1319
|
/* @__PURE__ */ jsx("div", { className: "font-medium text-ui-fg-base", children: "Connected PayPal account" }),
|
|
1163
1320
|
/* @__PURE__ */ jsxs("div", { className: "mt-1", children: [
|
|
@@ -1166,6 +1323,14 @@ function PayPalConnectionPage() {
|
|
|
1166
1323
|
/* @__PURE__ */ jsx("span", { className: "font-mono text-ui-fg-base", children: (statusInfo == null ? void 0 : statusInfo.seller_email) || "Unavailable" })
|
|
1167
1324
|
] })
|
|
1168
1325
|
] }),
|
|
1326
|
+
error ? /* @__PURE__ */ jsx(
|
|
1327
|
+
"div",
|
|
1328
|
+
{
|
|
1329
|
+
role: "alert",
|
|
1330
|
+
className: "mt-3 text-left text-xs bg-red-50 text-red-600 p-3 border border-red-200 rounded",
|
|
1331
|
+
children: error
|
|
1332
|
+
}
|
|
1333
|
+
) : null,
|
|
1169
1334
|
/* @__PURE__ */ jsx("div", { className: "mt-3 flex items-center gap-2", children: /* @__PURE__ */ jsx(
|
|
1170
1335
|
"button",
|
|
1171
1336
|
{
|
|
@@ -1629,6 +1794,10 @@ const routeModule = {
|
|
|
1629
1794
|
Component: AdditionalSettingsTab,
|
|
1630
1795
|
path: "/settings/paypal/additional-settings"
|
|
1631
1796
|
},
|
|
1797
|
+
{
|
|
1798
|
+
Component: PayPalApplePayPage,
|
|
1799
|
+
path: "/settings/paypal/apple-pay"
|
|
1800
|
+
},
|
|
1632
1801
|
{
|
|
1633
1802
|
Component: AdvancedCardPaymentsTab,
|
|
1634
1803
|
path: "/settings/paypal/advanced-card-payments"
|
|
@@ -1637,10 +1806,6 @@ const routeModule = {
|
|
|
1637
1806
|
Component: PayPalGooglePayPage,
|
|
1638
1807
|
path: "/settings/paypal/google-pay"
|
|
1639
1808
|
},
|
|
1640
|
-
{
|
|
1641
|
-
Component: PayPalApplePayPage,
|
|
1642
|
-
path: "/settings/paypal/apple-pay"
|
|
1643
|
-
},
|
|
1644
1809
|
{
|
|
1645
1810
|
Component: PayPalConnectionPage,
|
|
1646
1811
|
path: "/settings/paypal/connection"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http";
|
|
2
|
+
/**
|
|
3
|
+
* GET /admin/paypal/merchant-status[?environment=sandbox|live][&refresh=1]
|
|
4
|
+
*
|
|
5
|
+
* Whether the connected seller can receive payments, per PayPal's seller
|
|
6
|
+
* onboarding status: confirmed email, payments receivable, PayPal payments and
|
|
7
|
+
* Advanced Card payments — plus the notices to show the merchant when a check
|
|
8
|
+
* fails. Cached for a few minutes; `refresh=1` forces a new lookup.
|
|
9
|
+
*/
|
|
10
|
+
export declare function GET(req: MedusaRequest, res: MedusaResponse): Promise<MedusaResponse>;
|
|
11
|
+
//# sourceMappingURL=route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/admin/paypal/merchant-status/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAG7E;;;;;;;GAOG;AACH,wBAAsB,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,2BAwBhE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GET = GET;
|
|
4
|
+
/**
|
|
5
|
+
* GET /admin/paypal/merchant-status[?environment=sandbox|live][&refresh=1]
|
|
6
|
+
*
|
|
7
|
+
* Whether the connected seller can receive payments, per PayPal's seller
|
|
8
|
+
* onboarding status: confirmed email, payments receivable, PayPal payments and
|
|
9
|
+
* Advanced Card payments — plus the notices to show the merchant when a check
|
|
10
|
+
* fails. Cached for a few minutes; `refresh=1` forces a new lookup.
|
|
11
|
+
*/
|
|
12
|
+
async function GET(req, res) {
|
|
13
|
+
try {
|
|
14
|
+
const paypal = req.scope.resolve("paypal_onboarding");
|
|
15
|
+
const q = (req.query || {});
|
|
16
|
+
const envParam = (q.environment || q.env);
|
|
17
|
+
const env = envParam === "live"
|
|
18
|
+
? "live"
|
|
19
|
+
: envParam === "sandbox"
|
|
20
|
+
? "sandbox"
|
|
21
|
+
: undefined;
|
|
22
|
+
const refresh = q.refresh === "1" || q.refresh === "true";
|
|
23
|
+
return res.json(await paypal.getMerchantStatus(env, { refresh }));
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
console.error("[PayPal] merchant-status GET failed:", e instanceof Error ? e.message : e);
|
|
27
|
+
return res
|
|
28
|
+
.status(500)
|
|
29
|
+
.json({ message: "Failed to retrieve PayPal seller status" });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../src/api/admin/paypal/merchant-status/route.ts"],"names":[],"mappings":";;AAWA,kBAwBC;AAhCD;;;;;;;GAOG;AACI,KAAK,UAAU,GAAG,CAAC,GAAkB,EAAE,GAAmB;IAC/D,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAsB,mBAAmB,CAAC,CAAA;QAE1E,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAwB,CAAA;QAClD,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,GAAG,CAAuB,CAAA;QAC/D,MAAM,GAAG,GACP,QAAQ,KAAK,MAAM;YACjB,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,QAAQ,KAAK,SAAS;gBACtB,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,SAAS,CAAA;QACjB,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,KAAK,MAAM,CAAA;QAEzD,OAAO,GAAG,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC,iBAAiB,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;IACnE,CAAC;IAAC,OAAO,CAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CACX,sCAAsC,EACtC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CACnC,CAAA;QACD,OAAO,GAAG;aACP,MAAM,CAAC,GAAG,CAAC;aACX,IAAI,CAAC,EAAE,OAAO,EAAE,yCAAyC,EAAE,CAAC,CAAA;IACjE,CAAC;AACH,CAAC"}
|
|
@@ -5,7 +5,10 @@ import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http";
|
|
|
5
5
|
*
|
|
6
6
|
* Returns `{ id }` — the PayPal order id the storefront hands to the JS SDK.
|
|
7
7
|
* Line items and an amount breakdown are sent when `sendItemDetails` is on,
|
|
8
|
-
* with rounding drift reconciled so PayPal's strict total checks pass.
|
|
8
|
+
* with rounding drift reconciled so PayPal's strict total checks pass. The
|
|
9
|
+
* shipping address the buyer entered at checkout is sent with
|
|
10
|
+
* `shipping_preference: SET_PROVIDED_ADDRESS` unless `sendShippingAddress` is
|
|
11
|
+
* turned off.
|
|
9
12
|
*/
|
|
10
13
|
export declare function POST(req: MedusaRequest, res: MedusaResponse): Promise<MedusaResponse>;
|
|
11
14
|
//# sourceMappingURL=route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/create-order/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/create-order/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAgG7E;;;;;;;;;;GAUG;AACH,wBAAsB,IAAI,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,2BAqmBjE"}
|