@easypayment/medusa-payment-paypal 1.3.6 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.js +14 -14
- package/.medusa/server/src/admin/index.mjs +14 -14
- package/.medusa/server/src/api/admin/paypal/logs/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/paypal/logs/route.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/paypal-fetch.d.ts +16 -2
- package/.medusa/server/src/modules/paypal/utils/paypal-fetch.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/paypal-fetch.js +73 -2
- package/.medusa/server/src/modules/paypal/utils/paypal-fetch.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/request-logger.d.ts +2 -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 +9 -1
- package/.medusa/server/src/modules/paypal/utils/request-logger.js.map +1 -1
- package/CHANGELOG.md +45 -0
- package/README.md +107 -61
- package/package.json +2 -2
- package/src/api/admin/paypal/logs/route.ts +1 -4
- package/src/modules/paypal/utils/paypal-fetch.ts +78 -2
- package/src/modules/paypal/utils/request-logger.ts +43 -43
|
@@ -444,9 +444,6 @@ function AdditionalSettingsTab() {
|
|
|
444
444
|
)
|
|
445
445
|
] }) });
|
|
446
446
|
}
|
|
447
|
-
function PayPalApplePayPage() {
|
|
448
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
449
|
-
}
|
|
450
447
|
const DEFAULT_FORM = {
|
|
451
448
|
enabled: true,
|
|
452
449
|
title: "Credit or Debit Card",
|
|
@@ -602,6 +599,12 @@ function AdvancedCardPaymentsTab() {
|
|
|
602
599
|
)
|
|
603
600
|
] }) });
|
|
604
601
|
}
|
|
602
|
+
function PayPalGooglePayPage() {
|
|
603
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
604
|
+
}
|
|
605
|
+
function PayPalApplePayPage() {
|
|
606
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
607
|
+
}
|
|
605
608
|
const config = adminSdk.defineRouteConfig({
|
|
606
609
|
label: "PayPal Connection"
|
|
607
610
|
});
|
|
@@ -1397,9 +1400,6 @@ function PayPalConnectionPage() {
|
|
|
1397
1400
|
` })
|
|
1398
1401
|
] });
|
|
1399
1402
|
}
|
|
1400
|
-
function PayPalGooglePayPage() {
|
|
1401
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
1402
|
-
}
|
|
1403
1403
|
function PayPalPayLaterMessagingPage() {
|
|
1404
1404
|
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
1405
1405
|
}
|
|
@@ -1630,22 +1630,22 @@ const routeModule = {
|
|
|
1630
1630
|
Component: AdditionalSettingsTab,
|
|
1631
1631
|
path: "/settings/paypal/additional-settings"
|
|
1632
1632
|
},
|
|
1633
|
-
{
|
|
1634
|
-
Component: PayPalApplePayPage,
|
|
1635
|
-
path: "/settings/paypal/apple-pay"
|
|
1636
|
-
},
|
|
1637
1633
|
{
|
|
1638
1634
|
Component: AdvancedCardPaymentsTab,
|
|
1639
1635
|
path: "/settings/paypal/advanced-card-payments"
|
|
1640
1636
|
},
|
|
1641
|
-
{
|
|
1642
|
-
Component: PayPalConnectionPage,
|
|
1643
|
-
path: "/settings/paypal/connection"
|
|
1644
|
-
},
|
|
1645
1637
|
{
|
|
1646
1638
|
Component: PayPalGooglePayPage,
|
|
1647
1639
|
path: "/settings/paypal/google-pay"
|
|
1648
1640
|
},
|
|
1641
|
+
{
|
|
1642
|
+
Component: PayPalApplePayPage,
|
|
1643
|
+
path: "/settings/paypal/apple-pay"
|
|
1644
|
+
},
|
|
1645
|
+
{
|
|
1646
|
+
Component: PayPalConnectionPage,
|
|
1647
|
+
path: "/settings/paypal/connection"
|
|
1648
|
+
},
|
|
1649
1649
|
{
|
|
1650
1650
|
Component: PayPalPayLaterMessagingPage,
|
|
1651
1651
|
path: "/settings/paypal/pay-later-messaging"
|
|
@@ -443,9 +443,6 @@ function AdditionalSettingsTab() {
|
|
|
443
443
|
)
|
|
444
444
|
] }) });
|
|
445
445
|
}
|
|
446
|
-
function PayPalApplePayPage() {
|
|
447
|
-
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
448
|
-
}
|
|
449
446
|
const DEFAULT_FORM = {
|
|
450
447
|
enabled: true,
|
|
451
448
|
title: "Credit or Debit Card",
|
|
@@ -601,6 +598,12 @@ function AdvancedCardPaymentsTab() {
|
|
|
601
598
|
)
|
|
602
599
|
] }) });
|
|
603
600
|
}
|
|
601
|
+
function PayPalGooglePayPage() {
|
|
602
|
+
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
603
|
+
}
|
|
604
|
+
function PayPalApplePayPage() {
|
|
605
|
+
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
606
|
+
}
|
|
604
607
|
const config = defineRouteConfig({
|
|
605
608
|
label: "PayPal Connection"
|
|
606
609
|
});
|
|
@@ -1396,9 +1399,6 @@ function PayPalConnectionPage() {
|
|
|
1396
1399
|
` })
|
|
1397
1400
|
] });
|
|
1398
1401
|
}
|
|
1399
|
-
function PayPalGooglePayPage() {
|
|
1400
|
-
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
1401
|
-
}
|
|
1402
1402
|
function PayPalPayLaterMessagingPage() {
|
|
1403
1403
|
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
1404
1404
|
}
|
|
@@ -1629,22 +1629,22 @@ const routeModule = {
|
|
|
1629
1629
|
Component: AdditionalSettingsTab,
|
|
1630
1630
|
path: "/settings/paypal/additional-settings"
|
|
1631
1631
|
},
|
|
1632
|
-
{
|
|
1633
|
-
Component: PayPalApplePayPage,
|
|
1634
|
-
path: "/settings/paypal/apple-pay"
|
|
1635
|
-
},
|
|
1636
1632
|
{
|
|
1637
1633
|
Component: AdvancedCardPaymentsTab,
|
|
1638
1634
|
path: "/settings/paypal/advanced-card-payments"
|
|
1639
1635
|
},
|
|
1640
|
-
{
|
|
1641
|
-
Component: PayPalConnectionPage,
|
|
1642
|
-
path: "/settings/paypal/connection"
|
|
1643
|
-
},
|
|
1644
1636
|
{
|
|
1645
1637
|
Component: PayPalGooglePayPage,
|
|
1646
1638
|
path: "/settings/paypal/google-pay"
|
|
1647
1639
|
},
|
|
1640
|
+
{
|
|
1641
|
+
Component: PayPalApplePayPage,
|
|
1642
|
+
path: "/settings/paypal/apple-pay"
|
|
1643
|
+
},
|
|
1644
|
+
{
|
|
1645
|
+
Component: PayPalConnectionPage,
|
|
1646
|
+
path: "/settings/paypal/connection"
|
|
1647
|
+
},
|
|
1648
1648
|
{
|
|
1649
1649
|
Component: PayPalPayLaterMessagingPage,
|
|
1650
1650
|
path: "/settings/paypal/pay-later-messaging"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/admin/paypal/logs/route.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAO7E;;;;;;GAMG;AACH,wBAAsB,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/admin/paypal/logs/route.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAO7E;;;;;;GAMG;AACH,wBAAsB,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,2BA8BhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../src/api/admin/paypal/logs/route.ts"],"names":[],"mappings":";;;;;AAgBA,
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../src/api/admin/paypal/logs/route.ts"],"names":[],"mappings":";;;;;AAgBA,kBA8BC;AA9CD,4CAAmB;AACnB,gDAAuB;AAEvB,oFAIwD;AAExD;;;;;;GAMG;AACI,KAAK,UAAU,GAAG,CAAC,GAAkB,EAAE,GAAmB;IAC/D,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,GAAG,CAAC,KAA2C,CAAA;QAC7D,MAAM,aAAa,GACjB,KAAK,CAAC,QAAQ,KAAK,GAAG;YACtB,KAAK,CAAC,QAAQ,KAAK,MAAM;YACzB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAA;QAEhC,IAAI,aAAa,EAAE,CAAC;YAClB,MAAM,QAAQ,GAAG,IAAA,+BAAc,EAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAC3C,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAA;YAChE,CAAC;YACD,MAAM,IAAI,GAAG,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;YACpC,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,2BAA2B,CAAC,CAAA;YAC1D,GAAG,CAAC,SAAS,CAAC,qBAAqB,EAAE,yBAAyB,IAAI,GAAG,CAAC,CAAA;YACtE,OAAO,GAAG,CAAC,IAAI,CAAC,YAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAA;QACpD,CAAC;QAED,OAAO,GAAG,CAAC,IAAI,CAAC;YACd,OAAO,EAAE,IAAA,wCAAuB,GAAE;YAClC,KAAK,EAAE,IAAA,6BAAY,GAAE;SACtB,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,CAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CACX,2BAA2B,EAC3B,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CACnC,CAAA;QACD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC,CAAA;IACxE,CAAC;AACH,CAAC"}
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
* Outbound HTTP for PayPal API calls with timeout, circuit breaker, and
|
|
3
3
|
* optional retry for critical payment operations.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Guarantee the BN code on every request to PayPal.
|
|
7
|
+
*
|
|
8
|
+
* Call sites used to add the header themselves, and several (order lookups,
|
|
9
|
+
* webhook verification, the invoice subscriber) did not, so those calls went
|
|
10
|
+
* out unattributed. Enforcing it here means a new call site cannot forget.
|
|
11
|
+
* A header the caller already set is kept, and non-PayPal hosts (the partner
|
|
12
|
+
* onboarding service, alert webhooks) are left alone. The original shape of
|
|
13
|
+
* `headers` is preserved so the request log shows them as the caller wrote
|
|
14
|
+
* them.
|
|
15
|
+
*/
|
|
16
|
+
export declare function withPartnerAttribution(input: string | URL, init?: RequestInit): RequestInit;
|
|
5
17
|
export declare const PAYPAL_HTTP_TIMEOUT_MS: number;
|
|
6
18
|
export declare class CircuitOpenError extends Error {
|
|
7
19
|
constructor();
|
|
@@ -10,9 +22,11 @@ export declare class CircuitOpenError extends Error {
|
|
|
10
22
|
* `fetch` with a default timeout (`PAYPAL_HTTP_TIMEOUT_MS`) and a per-host
|
|
11
23
|
* circuit breaker. 5xx responses and network/timeout errors count as failures;
|
|
12
24
|
* once the breaker opens, calls to that host reject immediately with
|
|
13
|
-
* `CircuitOpenError` until the half-open probe succeeds.
|
|
25
|
+
* `CircuitOpenError` until the half-open probe succeeds. Requests to PayPal
|
|
26
|
+
* always carry the partner attribution (BN) header: see
|
|
27
|
+
* `withPartnerAttribution`.
|
|
14
28
|
*/
|
|
15
|
-
export declare function paypalFetch(input: string | URL,
|
|
29
|
+
export declare function paypalFetch(input: string | URL, requestInit?: RequestInit): Promise<Response>;
|
|
16
30
|
/**
|
|
17
31
|
* `paypalFetch` with bounded exponential-backoff retries on 5xx/429, timeouts,
|
|
18
32
|
* and an open circuit. Only use for calls that are idempotent on PayPal's side
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paypal-fetch.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/paypal/utils/paypal-fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"paypal-fetch.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/paypal/utils/paypal-fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqBH;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,GAAG,GAAG,EACnB,IAAI,GAAE,WAAgB,GACrB,WAAW,CAwCb;AAED,eAAO,MAAM,sBAAsB,QAG/B,CAAA;AAsFJ,qBAAa,gBAAiB,SAAQ,KAAK;;CAO1C;AAMD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,GAAG,GAAG,EACnB,WAAW,GAAE,WAAgB,GAC5B,OAAO,CAAC,QAAQ,CAAC,CAoEnB;AA2CD;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,MAAM,GAAG,GAAG,EACnB,IAAI,GAAE,WAAgB,GACrB,OAAO,CAAC,QAAQ,CAAC,CA0BnB"}
|
|
@@ -5,9 +5,77 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.CircuitOpenError = exports.PAYPAL_HTTP_TIMEOUT_MS = void 0;
|
|
8
|
+
exports.withPartnerAttribution = withPartnerAttribution;
|
|
8
9
|
exports.paypalFetch = paypalFetch;
|
|
9
10
|
exports.paypalFetchWithRetry = paypalFetchWithRetry;
|
|
11
|
+
const partner_1 = require("./partner");
|
|
10
12
|
const request_logger_1 = require("./request-logger");
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Partner attribution (BN code)
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
const ATTRIBUTION_HEADER = "PayPal-Partner-Attribution-Id";
|
|
17
|
+
/** True for PayPal's own API hosts (`api-m.paypal.com`, the sandbox, …). */
|
|
18
|
+
function isPayPalHost(input) {
|
|
19
|
+
try {
|
|
20
|
+
const hostname = new URL(String(input)).hostname.toLowerCase();
|
|
21
|
+
return hostname === "paypal.com" || hostname.endsWith(".paypal.com");
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Guarantee the BN code on every request to PayPal.
|
|
29
|
+
*
|
|
30
|
+
* Call sites used to add the header themselves, and several (order lookups,
|
|
31
|
+
* webhook verification, the invoice subscriber) did not, so those calls went
|
|
32
|
+
* out unattributed. Enforcing it here means a new call site cannot forget.
|
|
33
|
+
* A header the caller already set is kept, and non-PayPal hosts (the partner
|
|
34
|
+
* onboarding service, alert webhooks) are left alone. The original shape of
|
|
35
|
+
* `headers` is preserved so the request log shows them as the caller wrote
|
|
36
|
+
* them.
|
|
37
|
+
*/
|
|
38
|
+
function withPartnerAttribution(input, init = {}) {
|
|
39
|
+
if (!isPayPalHost(input))
|
|
40
|
+
return init;
|
|
41
|
+
const headers = init.headers;
|
|
42
|
+
const wanted = ATTRIBUTION_HEADER.toLowerCase();
|
|
43
|
+
if (!headers) {
|
|
44
|
+
return {
|
|
45
|
+
...init,
|
|
46
|
+
headers: { [ATTRIBUTION_HEADER]: partner_1.PAYPAL_PARTNER_ATTRIBUTION_ID },
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (typeof Headers !== "undefined" && headers instanceof Headers) {
|
|
50
|
+
if (headers.has(ATTRIBUTION_HEADER))
|
|
51
|
+
return init;
|
|
52
|
+
const next = new Headers(headers);
|
|
53
|
+
next.set(ATTRIBUTION_HEADER, partner_1.PAYPAL_PARTNER_ATTRIBUTION_ID);
|
|
54
|
+
return { ...init, headers: next };
|
|
55
|
+
}
|
|
56
|
+
if (Array.isArray(headers)) {
|
|
57
|
+
if (headers.some((pair) => String(pair?.[0]).toLowerCase() === wanted)) {
|
|
58
|
+
return init;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
...init,
|
|
62
|
+
headers: [
|
|
63
|
+
...headers,
|
|
64
|
+
[ATTRIBUTION_HEADER, partner_1.PAYPAL_PARTNER_ATTRIBUTION_ID],
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (Object.keys(headers).some((name) => name.toLowerCase() === wanted)) {
|
|
69
|
+
return init;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
...init,
|
|
73
|
+
headers: {
|
|
74
|
+
...headers,
|
|
75
|
+
[ATTRIBUTION_HEADER]: partner_1.PAYPAL_PARTNER_ATTRIBUTION_ID,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
11
79
|
exports.PAYPAL_HTTP_TIMEOUT_MS = (() => {
|
|
12
80
|
const v = Number(process.env.PAYPAL_HTTP_TIMEOUT_MS);
|
|
13
81
|
return Number.isFinite(v) && v > 0 ? v : 30_000;
|
|
@@ -90,9 +158,12 @@ exports.CircuitOpenError = CircuitOpenError;
|
|
|
90
158
|
* `fetch` with a default timeout (`PAYPAL_HTTP_TIMEOUT_MS`) and a per-host
|
|
91
159
|
* circuit breaker. 5xx responses and network/timeout errors count as failures;
|
|
92
160
|
* once the breaker opens, calls to that host reject immediately with
|
|
93
|
-
* `CircuitOpenError` until the half-open probe succeeds.
|
|
161
|
+
* `CircuitOpenError` until the half-open probe succeeds. Requests to PayPal
|
|
162
|
+
* always carry the partner attribution (BN) header: see
|
|
163
|
+
* `withPartnerAttribution`.
|
|
94
164
|
*/
|
|
95
|
-
function paypalFetch(input,
|
|
165
|
+
function paypalFetch(input, requestInit = {}) {
|
|
166
|
+
const init = withPartnerAttribution(input, requestInit);
|
|
96
167
|
const host = cbHostKey(input);
|
|
97
168
|
if (!cbAllowRequest(host)) {
|
|
98
169
|
return Promise.reject(new CircuitOpenError());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paypal-fetch.js","sourceRoot":"","sources":["../../../../../../src/modules/paypal/utils/paypal-fetch.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"paypal-fetch.js","sourceRoot":"","sources":["../../../../../../src/modules/paypal/utils/paypal-fetch.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgCH,wDA2CC;AAgHD,kCAuEC;AAgDD,oDA6BC;AA7UD,uCAAyD;AACzD,qDAAuE;AAEvE,8EAA8E;AAC9E,gCAAgC;AAChC,8EAA8E;AAE9E,MAAM,kBAAkB,GAAG,+BAA+B,CAAA;AAE1D,4EAA4E;AAC5E,SAAS,YAAY,CAAC,KAAmB;IACvC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAA;QAC9D,OAAO,QAAQ,KAAK,YAAY,IAAI,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;IACtE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,sBAAsB,CACpC,KAAmB,EACnB,OAAoB,EAAE;IAEtB,IA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ED;;;;GAIG;AACI,KAAK,UAAU,oBAAoB,CACxC,KAAmB,EACnB,OAAoB,EAAE;IAEtB,IAAI,SAAkB,CAAA;IACtB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC;QACxD,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YAC1C,IAAI,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,OAAO,GAAG,WAAW,EAAE,CAAC;gBAC3D,qEAAqE;gBACrE,iDAAiD;gBACjD,IAAI,CAAC;oBACH,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,CAAA;gBAC1B,CAAC;gBAAC,MAAM,CAAC;oBACP,2BAA2B;gBAC7B,CAAC;gBACD,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;gBACpC,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;gBAC9C,SAAQ;YACV,CAAC;YACD,OAAO,GAAG,CAAA;QACZ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,SAAS,GAAG,GAAG,CAAA;YACf,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,OAAO,IAAI,WAAW;gBAAE,MAAM,GAAG,CAAA;YAC1D,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;YACpC,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;IACD,MAAM,SAAS,CAAA;AACjB,CAAC"}
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
export declare function setRequestLoggingEnabled(enabled: boolean): void;
|
|
20
20
|
/** Whether request/response logging is currently active in this process. */
|
|
21
21
|
export declare function isRequestLoggingEnabled(): boolean;
|
|
22
|
+
/** Deep-copy `value` with the values of sensitive keys replaced. */
|
|
23
|
+
export declare function redactBody(value: unknown, depth?: number): unknown;
|
|
22
24
|
/** Absolute path of the log file for the current day. */
|
|
23
25
|
export declare function getCurrentLogFilePath(): string;
|
|
24
26
|
export type OutboundLog = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-logger.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/paypal/utils/request-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAoBH,mFAAmF;AACnF,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAE/D;AAED,4EAA4E;AAC5E,wBAAgB,uBAAuB,IAAI,OAAO,CAEjD;
|
|
1
|
+
{"version":3,"file":"request-logger.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/paypal/utils/request-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAoBH,mFAAmF;AACnF,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAE/D;AAED,4EAA4E;AAC5E,wBAAgB,uBAAuB,IAAI,OAAO,CAEjD;AAyBD,oEAAoE;AACpE,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,OAAO,CAY7D;AA2FD,yDAAyD;AACzD,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AA0CD,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CA+BpD;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,8DAA8D;AAC9D,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CA6BlD;AAMD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,wDAAwD;AACxD,wBAAgB,YAAY,IAAI,WAAW,EAAE,CAmB5C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAa3D"}
|
|
@@ -22,6 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.setRequestLoggingEnabled = setRequestLoggingEnabled;
|
|
24
24
|
exports.isRequestLoggingEnabled = isRequestLoggingEnabled;
|
|
25
|
+
exports.redactBody = redactBody;
|
|
25
26
|
exports.getCurrentLogFilePath = getCurrentLogFilePath;
|
|
26
27
|
exports.logOutbound = logOutbound;
|
|
27
28
|
exports.logInbound = logInbound;
|
|
@@ -53,11 +54,18 @@ function isRequestLoggingEnabled() {
|
|
|
53
54
|
// Body keys whose VALUES must never hit the exported file. Card fields are
|
|
54
55
|
// included even though they normally never reach the backend (the JS SDK sends
|
|
55
56
|
// them straight to PayPal) — defence in depth for the advanced-card flow.
|
|
56
|
-
|
|
57
|
+
//
|
|
58
|
+
// `authorization(?!s$)`: redact `authorization`, `authorization_code`, … but
|
|
59
|
+
// not PayPal's `payments.authorizations` collection, which holds the
|
|
60
|
+
// authorization id, status, amount and expiry a reviewer needs to see and no
|
|
61
|
+
// credential. `client_token` is the JS SDK token, which embeds a live access
|
|
62
|
+
// token.
|
|
63
|
+
const SENSITIVE_BODY_KEY_RE = /secret|password|client_secret|client_token|access_token|refresh_token|authorization(?!s$)|auth_code|code_verifier|api[_-]?key|private[_-]?key|security_code|\bcvv2?\b|card[_-]?number|(^|_)number$|expiry|exp_(month|year)/i;
|
|
57
64
|
// Request/response HEADER names to redact. The BN code header is deliberately
|
|
58
65
|
// NOT here — PayPal needs to see it in the log.
|
|
59
66
|
const SENSITIVE_HEADER_RE = /^(authorization|proxy-authorization|cookie|set-cookie|x-api-key)$/i;
|
|
60
67
|
const REDACTED = "[REDACTED]";
|
|
68
|
+
/** Deep-copy `value` with the values of sensitive keys replaced. */
|
|
61
69
|
function redactBody(value, depth = 0) {
|
|
62
70
|
if (depth > 8 || value === null || typeof value !== "object") {
|
|
63
71
|
return value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-logger.js","sourceRoot":"","sources":["../../../../../../src/modules/paypal/utils/request-logger.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;AAqBH,4DAEC;AAGD,0DAEC;
|
|
1
|
+
{"version":3,"file":"request-logger.js","sourceRoot":"","sources":["../../../../../../src/modules/paypal/utils/request-logger.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;AAqBH,4DAEC;AAGD,0DAEC;AA0BD,gCAYC;AA4FD,sDAEC;AAwDD,kCA+BC;AAcD,gCA6B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,cAAc,CAAC,IAAa;IAC1C,MAAM,GAAG,GAAG,SAAS,EAAE,CAAA;IACvB,MAAM,MAAM,GAAG,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;IACvD,MAAM,MAAM,GAAG,MAAM;QACnB,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;YACjB,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACxC,CAAC,CAAC,IAAI,CAAA;IACV,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IACxB,yEAAyE;IACzE,IAAI,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,cAAI,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAA;IAC3D,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAA;IACvC,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@easypayment/medusa-payment-paypal` are documented here.
|
|
4
4
|
|
|
5
|
+
## 1.3.8 — 2026-11-17
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **README rewritten for faster setup.** Added a contents list, a "Customize"
|
|
10
|
+
table that matches the admin tabs, a "Going live" table, and split the
|
|
11
|
+
advanced material into collapsible sections (environment variables, declined
|
|
12
|
+
cards, monitoring, integration log). The connect step now names the admin
|
|
13
|
+
page and the manual-credentials link as they appear in Medusa Admin, and
|
|
14
|
+
`STORE_URL` is documented as an alias of `STOREFRONT_URL`.
|
|
15
|
+
- No runtime changes.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **README:** removed the "Start a discussion" link, which returned 404, and
|
|
20
|
+
replaced emoji that render as plain glyphs or break heading anchors on npm
|
|
21
|
+
and GitHub.
|
|
22
|
+
- **package.json:** `repository.url` is now in the normalized `git+https://`
|
|
23
|
+
form, so `npm publish` no longer auto-corrects it with a warning.
|
|
24
|
+
- **Formatting:** `src/api/admin/paypal/logs/route.ts` now passes
|
|
25
|
+
`prettier --check`.
|
|
26
|
+
|
|
27
|
+
## 1.3.7 — 2026-11-16
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- **Every request to PayPal now carries the BN code.** The
|
|
32
|
+
`PayPal-Partner-Attribution-Id` header was added by each call site, and five
|
|
33
|
+
did not: the order lookups in the storefront create-order and capture-order
|
|
34
|
+
routes, webhook signature verification, and the order `GET` and `PATCH` in
|
|
35
|
+
the invoice subscriber. Those calls went out unattributed. The header is now
|
|
36
|
+
enforced in the shared `paypalFetch` helper for all PayPal hosts, so a call
|
|
37
|
+
site can no longer omit it. Non-PayPal hosts (the partner onboarding service,
|
|
38
|
+
alert webhooks) are unaffected.
|
|
39
|
+
- **Request log no longer hides authorization details.** The log redacted any
|
|
40
|
+
JSON key containing "authorization", which also blanked PayPal's
|
|
41
|
+
`payments.authorizations` block (authorization id, status, amount, expiry) in
|
|
42
|
+
authorize and order-details responses. Credentials such as `authorization`
|
|
43
|
+
and `authorization_code` are still redacted.
|
|
44
|
+
|
|
45
|
+
### Security
|
|
46
|
+
|
|
47
|
+
- **Request log now redacts the JS SDK `client_token`.** It embeds a live
|
|
48
|
+
PayPal access token and was written to the log file in full.
|
|
49
|
+
|
|
5
50
|
## 1.3.6 — 2026-11-16
|
|
6
51
|
|
|
7
52
|
### Fixed
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# PayPal for Medusa
|
|
2
2
|
|
|
3
|
-
**Accept PayPal and credit card payments in your Medusa v2 store
|
|
3
|
+
**Accept PayPal and credit card payments in your Medusa v2 store. Built by an official PayPal Partner.**
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@easypayment/medusa-payment-paypal)
|
|
6
6
|
[](https://www.npmjs.com/package/@easypayment/medusa-payment-paypal)
|
|
@@ -8,20 +8,31 @@
|
|
|
8
8
|
[](https://medusajs.com)
|
|
9
9
|
[](https://developer.paypal.com)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
This is the **backend plugin**. It adds PayPal to your Medusa server and Medusa Admin. The checkout components for your storefront are in the companion package, [@easypayment/medusa-paypal-ui](https://www.npmjs.com/package/@easypayment/medusa-paypal-ui).
|
|
12
|
+
|
|
13
|
+
## Contents
|
|
14
|
+
|
|
15
|
+
- [What you get](#-what-you-get)
|
|
16
|
+
- [Requirements](#-requirements)
|
|
17
|
+
- [Installation](#-installation)
|
|
18
|
+
- [Setup in 5 steps](#-setup-in-5-steps)
|
|
19
|
+
- [Customize](#-customize)
|
|
20
|
+
- [Going live](#-going-live)
|
|
21
|
+
- [Advanced options](#-advanced-options)
|
|
22
|
+
- [Support](#-support)
|
|
23
|
+
- [License](#-license)
|
|
12
24
|
|
|
13
25
|
## ✨ What you get
|
|
14
26
|
|
|
15
27
|
| Feature | Details |
|
|
16
|
-
|
|
28
|
+
| --- | --- |
|
|
17
29
|
| 🔵 **PayPal Buttons** | One-click PayPal checkout for your customers |
|
|
18
|
-
| 💳 **Card
|
|
19
|
-
|
|
|
20
|
-
| 🌍 **Test
|
|
30
|
+
| 💳 **Card payments** | Secure credit and debit card fields, hosted by PayPal (PCI compliant) |
|
|
31
|
+
| 🔧 **Admin dashboard** | Connect your PayPal account and manage everything from Medusa Admin |
|
|
32
|
+
| 🌍 **Test and Live modes** | Try everything safely in Sandbox before going live |
|
|
33
|
+
| 💰 **Capture or authorize** | Charge at checkout, or authorize first and capture from the order later |
|
|
21
34
|
| 🔐 **3D Secure** | Extra card security, configurable in one click |
|
|
22
|
-
| 🔄 **Reliable by design** | Payments are verified with PayPal at every step
|
|
23
|
-
|
|
24
|
-
---
|
|
35
|
+
| 🔄 **Reliable by design** | Payments are verified with PayPal at every step. Webhooks, retries and safety nets are handled for you |
|
|
25
36
|
|
|
26
37
|
## ✅ Requirements
|
|
27
38
|
|
|
@@ -29,8 +40,6 @@
|
|
|
29
40
|
- Node.js **20+**
|
|
30
41
|
- PostgreSQL
|
|
31
42
|
|
|
32
|
-
---
|
|
33
|
-
|
|
34
43
|
## 🚀 Installation
|
|
35
44
|
|
|
36
45
|
In your Medusa backend folder, run:
|
|
@@ -39,12 +48,12 @@ In your Medusa backend folder, run:
|
|
|
39
48
|
npm install @easypayment/medusa-payment-paypal
|
|
40
49
|
```
|
|
41
50
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
## ⚙️ Setup — 5 steps
|
|
51
|
+
## 🧩 Setup in 5 steps
|
|
45
52
|
|
|
46
53
|
### 1. Add the plugin to `medusa-config.ts`
|
|
47
54
|
|
|
55
|
+
Add the `plugins` entry and the two payment providers:
|
|
56
|
+
|
|
48
57
|
```ts
|
|
49
58
|
import { loadEnv, defineConfig } from "@medusajs/framework/utils"
|
|
50
59
|
|
|
@@ -103,92 +112,129 @@ npx medusa db:migrate
|
|
|
103
112
|
|
|
104
113
|
### 3. Connect your PayPal account
|
|
105
114
|
|
|
106
|
-
1. Start your Medusa server
|
|
107
|
-
2. Open **Medusa Admin → Settings → PayPal
|
|
108
|
-
3. Choose **Sandbox** (testing) or **Live** (real payments)
|
|
109
|
-
4. Click **Connect to PayPal** and follow the steps
|
|
115
|
+
1. Start your Medusa server.
|
|
116
|
+
2. Open **Medusa Admin → Settings → PayPal → PayPal Connection**.
|
|
117
|
+
3. Choose **Sandbox** (testing) or **Live** (real payments).
|
|
118
|
+
4. Click **Connect to PayPal** and follow the steps in the PayPal window.
|
|
110
119
|
|
|
111
|
-
|
|
120
|
+
Your credentials are saved automatically, and webhooks are registered for you.
|
|
112
121
|
|
|
113
|
-
> 💡 Prefer manual setup? Click **
|
|
122
|
+
> 💡 Prefer manual setup? Click **Click here to insert credentials manually** and paste your Client ID and Secret from [developer.paypal.com](https://developer.paypal.com/dashboard/).
|
|
114
123
|
|
|
115
124
|
### 4. Turn PayPal on in your region
|
|
116
125
|
|
|
117
126
|
Go to **Medusa Admin → Settings → Regions → your region** and enable:
|
|
118
127
|
|
|
119
128
|
| Payment provider | What it is |
|
|
120
|
-
|
|
129
|
+
| --- | --- |
|
|
121
130
|
| `pp_paypal_paypal` | PayPal Buttons |
|
|
122
131
|
| `pp_paypal_card_paypal_card` | Card payments |
|
|
123
132
|
|
|
124
133
|
### 5. Add PayPal to your storefront
|
|
125
134
|
|
|
126
|
-
The checkout UI
|
|
135
|
+
The checkout UI is a separate package. Install it in your **storefront** project and follow its step-by-step guide:
|
|
136
|
+
|
|
137
|
+
📦 **[@easypayment/medusa-paypal-ui](https://www.npmjs.com/package/@easypayment/medusa-paypal-ui)**: ready-made PayPal components for Next.js storefronts.
|
|
127
138
|
|
|
128
|
-
|
|
139
|
+
## 🎨 Customize
|
|
129
140
|
|
|
130
|
-
|
|
141
|
+
Everything is managed in **Medusa Admin → Settings → PayPal**. Changes apply right away, with no restart.
|
|
131
142
|
|
|
132
|
-
|
|
143
|
+
| Tab | What you can change |
|
|
144
|
+
| --- | --- |
|
|
145
|
+
| **PayPal Settings** | Turn PayPal on or off, checkout title, button color, shape, width, height and label |
|
|
146
|
+
| **Advanced Card Payments** | Turn card payments on or off, checkout title, 3D Secure mode |
|
|
147
|
+
| **Additional Settings** | Payment action (capture or authorize), brand name shown at PayPal, landing page, instant payments, item details, invoice prefix, card statement name |
|
|
133
148
|
|
|
134
|
-
|
|
149
|
+
## 🔐 Going live
|
|
135
150
|
|
|
136
|
-
|
|
137
|
-
- **Advanced Card Payments** — turn card payments on/off, 3D Secure mode
|
|
138
|
-
- **Additional Settings** — capture vs. authorize, brand name shown at PayPal, invoice prefix
|
|
151
|
+
Set these two environment variables on your server before taking real payments:
|
|
139
152
|
|
|
140
|
-
|
|
153
|
+
| Variable | Why |
|
|
154
|
+
| --- | --- |
|
|
155
|
+
| `PAYPAL_ENCRYPTION_KEY` | Any long random text. Your PayPal credentials are then stored encrypted in the database. Keep the key safe: if it is lost, reconnect PayPal |
|
|
156
|
+
| `MEDUSA_BACKEND_URL` | Your backend's public address, for example `https://api.mystore.com`, so PayPal can reach your store with payment notifications |
|
|
141
157
|
|
|
142
|
-
|
|
158
|
+
Then switch the environment to **Live** in **Settings → PayPal → PayPal Connection** and connect your live PayPal account.
|
|
143
159
|
|
|
144
|
-
|
|
145
|
-
|
|
160
|
+
## 🧰 Advanced options
|
|
161
|
+
|
|
162
|
+
Everything works without these. They are for developers who need to tune the plugin.
|
|
146
163
|
|
|
147
164
|
<details>
|
|
148
|
-
<summary><b>
|
|
165
|
+
<summary><b>Environment variables</b></summary>
|
|
149
166
|
|
|
150
167
|
<br>
|
|
151
168
|
|
|
152
169
|
| Variable | Default | What it does |
|
|
153
|
-
|
|
154
|
-
| `STOREFRONT_URL` |
|
|
155
|
-
| `PAYPAL_ENCRYPTION_STRICT` | `false` | `true`
|
|
156
|
-
| `
|
|
157
|
-
| `
|
|
170
|
+
| --- | --- | --- |
|
|
171
|
+
| `STOREFRONT_URL` (or `STORE_URL`) | Request origin, if listed in `STORE_CORS` | Storefront address used for PayPal return and cancel pages. Can also be set in Admin |
|
|
172
|
+
| `PAYPAL_ENCRYPTION_STRICT` | `false` | `true` refuses to save credentials unencrypted |
|
|
173
|
+
| `PAYPAL_ADMIN_ORIGIN` | First `ADMIN_CORS` entry | Restricts the onboarding popup to your admin URL |
|
|
174
|
+
| `PAYPAL_SEND_SHIPPING_ADDRESS` | `false` | `true` sends the cart's shipping address on PayPal orders (`SET_PROVIDED_ADDRESS`), which improves PayPal Seller Protection eligibility |
|
|
175
|
+
| `PAYPAL_CURRENCY` | `EUR` | Fallback currency if none is configured |
|
|
176
|
+
| `PAYPAL_HTTP_TIMEOUT_MS` | `30000` | Timeout for calls to PayPal |
|
|
177
|
+
| `PAYPAL_SETTINGS_CACHE_MS` | `15000` | In-process cache for plugin settings reads. `0` disables it |
|
|
158
178
|
| `PAYPAL_WEBHOOK_COMPLETE_CART` | `true` | Safety net that finishes an order when the payment succeeded but the buyer's browser closed. `false` disables it |
|
|
159
|
-
| `PAYPAL_RATE_LIMIT_MAX` / `PAYPAL_RATE_LIMIT_WINDOW_MS` | *(off)* / `60000` | Optional request limit for the public checkout routes |
|
|
160
|
-
| `PAYPAL_WEBHOOK_RATE_LIMIT_MAX` / `PAYPAL_WEBHOOK_RATE_LIMIT_WINDOW_MS` | *(off)* / `60000` | Optional request limit for the webhook endpoint (separate from the above) |
|
|
161
179
|
| `PAYPAL_WEBHOOK_REPLAY_WINDOW_MINUTES` | `60` | Rejects webhook deliveries older than this |
|
|
162
|
-
| `PAYPAL_WEBHOOK_STALE_PROCESSING_MS` | `300000` | When the retry job
|
|
163
|
-
| `PAYPAL_WEBHOOK_ID_LIVE` / `PAYPAL_WEBHOOK_ID_SANDBOX` |
|
|
164
|
-
| `
|
|
165
|
-
| `
|
|
166
|
-
| `PAYPAL_ALERT_WEBHOOK_URLS` |
|
|
167
|
-
| `
|
|
168
|
-
| `PAYPAL_REQUEST_LOG` | *(off)* | `1`/`true` force-enables the request/response log file regardless of the admin toggle (normally enabled from **Settings → PayPal → Additional Settings**) |
|
|
180
|
+
| `PAYPAL_WEBHOOK_STALE_PROCESSING_MS` | `300000` | When the retry job picks up interrupted webhook events again |
|
|
181
|
+
| `PAYPAL_WEBHOOK_ID_LIVE` / `PAYPAL_WEBHOOK_ID_SANDBOX` | Automatic | Manual webhook ID override |
|
|
182
|
+
| `PAYPAL_RATE_LIMIT_MAX` / `PAYPAL_RATE_LIMIT_WINDOW_MS` | Off / `60000` | Optional request limit for the public checkout routes |
|
|
183
|
+
| `PAYPAL_WEBHOOK_RATE_LIMIT_MAX` / `PAYPAL_WEBHOOK_RATE_LIMIT_WINDOW_MS` | Off / `60000` | Optional request limit for the webhook endpoint, separate from the one above |
|
|
184
|
+
| `PAYPAL_ALERT_WEBHOOK_URLS` | Unset | Comma-separated URLs that receive operational alerts, including dead-lettered webhook events |
|
|
185
|
+
| `PAYPAL_REQUEST_LOG` | Off | `1` or `true` forces the request/response log on, regardless of the admin toggle |
|
|
169
186
|
| `PAYPAL_LOG_DIR` | `./logs` | Directory for the `paypal-requests-YYYY-MM-DD.log` file written when logging is on |
|
|
170
|
-
| `
|
|
171
|
-
| `
|
|
172
|
-
| `PAYPAL_PARTNER_MERCHANT_ID_SANDBOX` / `PAYPAL_PARTNER_MERCHANT_ID_LIVE` |
|
|
187
|
+
| `PAYPAL_PARTNER_SERVICE_URL` | Built-in | Overrides the partner onboarding service used by the connect flow |
|
|
188
|
+
| `PAYPAL_SELLER_NONCE` | Partner service nonce | Only change this if you also run your own `PAYPAL_PARTNER_SERVICE_URL`. It must match the nonce that service puts in its onboarding links |
|
|
189
|
+
| `PAYPAL_PARTNER_MERCHANT_ID_SANDBOX` / `PAYPAL_PARTNER_MERCHANT_ID_LIVE` | Built-in | Overrides the partner merchant IDs used for onboarding |
|
|
173
190
|
|
|
174
|
-
|
|
191
|
+
</details>
|
|
175
192
|
|
|
176
|
-
|
|
193
|
+
<details>
|
|
194
|
+
<summary><b>Declined cards</b></summary>
|
|
177
195
|
|
|
178
|
-
|
|
196
|
+
<br>
|
|
197
|
+
|
|
198
|
+
When PayPal declines a capture, `/store/paypal/capture-order` responds `402` with a buyer-friendly `message` and a structured `decline` object:
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
{ code, message, retryable, avs_code?, cvv_code? }
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Storefronts can use it to show a message such as "insufficient funds, try another card" and to decide whether to offer a retry.
|
|
179
205
|
|
|
180
206
|
</details>
|
|
181
207
|
|
|
182
|
-
|
|
208
|
+
<details>
|
|
209
|
+
<summary><b>Monitoring</b></summary>
|
|
183
210
|
|
|
184
|
-
|
|
211
|
+
<br>
|
|
185
212
|
|
|
186
|
-
-
|
|
187
|
-
-
|
|
188
|
-
-
|
|
213
|
+
- Operational counters live in the `paypal_metric` table.
|
|
214
|
+
- Every webhook is recorded in `paypal_webhook_event` and retried automatically. Events that exhaust their retries are dead-lettered and pushed to `PAYPAL_ALERT_WEBHOOK_URLS`.
|
|
215
|
+
- Audit events are logged as JSON lines tagged `"log":"paypal_audit"`, with secrets redacted.
|
|
216
|
+
|
|
217
|
+
</details>
|
|
218
|
+
|
|
219
|
+
<details>
|
|
220
|
+
<summary><b>Integration log for PayPal review</b></summary>
|
|
221
|
+
|
|
222
|
+
<br>
|
|
223
|
+
|
|
224
|
+
Turn on **Settings → PayPal → Additional Settings → Request/response logging** (off by default) to append every PayPal API call, and every plugin API request and response, to `logs/paypal-requests-YYYY-MM-DD.log`.
|
|
225
|
+
|
|
226
|
+
- Credentials are redacted. The `PayPal-Partner-Attribution-Id` (BN code) is kept, so the file is safe to hand to PayPal's go-live review.
|
|
227
|
+
- Download it from the same settings page with **Download log**, or at `GET /admin/paypal/logs?download=1`.
|
|
228
|
+
- Turn logging off again once the review is complete.
|
|
229
|
+
|
|
230
|
+
</details>
|
|
231
|
+
|
|
232
|
+
## 💬 Support
|
|
189
233
|
|
|
190
|
-
|
|
234
|
+
- 🐛 **Found a bug, or have a question or feature request?** [Open an issue](https://github.com/easypaymentplugins/medusa-paypal/issues)
|
|
235
|
+
- 🛒 **Storefront UI package:** [@easypayment/medusa-paypal-ui](https://www.npmjs.com/package/@easypayment/medusa-paypal-ui)
|
|
236
|
+
- 📝 **Release notes:** see [CHANGELOG.md](CHANGELOG.md)
|
|
191
237
|
|
|
192
238
|
## 📄 License
|
|
193
239
|
|
|
194
|
-
MIT ©
|
|
240
|
+
[MIT](LICENSE) © Easy Payment
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easypayment/medusa-payment-paypal",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
4
4
|
"description": "PayPal & credit card payments for Medusa v2 — PayPal Buttons, hosted card fields, 3D Secure, and an admin dashboard. Built by a PayPal Partner.",
|
|
5
5
|
"author": "EasyPayment Plugins",
|
|
6
6
|
"license": "MIT",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
},
|
|
88
88
|
"repository": {
|
|
89
89
|
"type": "git",
|
|
90
|
-
"url": "https://github.com/easypaymentplugins/medusa-paypal.git"
|
|
90
|
+
"url": "git+https://github.com/easypaymentplugins/medusa-paypal.git"
|
|
91
91
|
},
|
|
92
92
|
"homepage": "https://github.com/easypaymentplugins/medusa-paypal#readme",
|
|
93
93
|
"bugs": {
|
|
@@ -29,10 +29,7 @@ export async function GET(req: MedusaRequest, res: MedusaResponse) {
|
|
|
29
29
|
}
|
|
30
30
|
const name = path.basename(filePath)
|
|
31
31
|
res.setHeader("Content-Type", "text/plain; charset=utf-8")
|
|
32
|
-
res.setHeader(
|
|
33
|
-
"Content-Disposition",
|
|
34
|
-
`attachment; filename="${name}"`
|
|
35
|
-
)
|
|
32
|
+
res.setHeader("Content-Disposition", `attachment; filename="${name}"`)
|
|
36
33
|
return res.send(fs.readFileSync(filePath, "utf8"))
|
|
37
34
|
}
|
|
38
35
|
|
|
@@ -3,8 +3,81 @@
|
|
|
3
3
|
* optional retry for critical payment operations.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { PAYPAL_PARTNER_ATTRIBUTION_ID } from "./partner"
|
|
6
7
|
import { isRequestLoggingEnabled, logOutbound } from "./request-logger"
|
|
7
8
|
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Partner attribution (BN code)
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
const ATTRIBUTION_HEADER = "PayPal-Partner-Attribution-Id"
|
|
14
|
+
|
|
15
|
+
/** True for PayPal's own API hosts (`api-m.paypal.com`, the sandbox, …). */
|
|
16
|
+
function isPayPalHost(input: string | URL): boolean {
|
|
17
|
+
try {
|
|
18
|
+
const hostname = new URL(String(input)).hostname.toLowerCase()
|
|
19
|
+
return hostname === "paypal.com" || hostname.endsWith(".paypal.com")
|
|
20
|
+
} catch {
|
|
21
|
+
return false
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Guarantee the BN code on every request to PayPal.
|
|
27
|
+
*
|
|
28
|
+
* Call sites used to add the header themselves, and several (order lookups,
|
|
29
|
+
* webhook verification, the invoice subscriber) did not, so those calls went
|
|
30
|
+
* out unattributed. Enforcing it here means a new call site cannot forget.
|
|
31
|
+
* A header the caller already set is kept, and non-PayPal hosts (the partner
|
|
32
|
+
* onboarding service, alert webhooks) are left alone. The original shape of
|
|
33
|
+
* `headers` is preserved so the request log shows them as the caller wrote
|
|
34
|
+
* them.
|
|
35
|
+
*/
|
|
36
|
+
export function withPartnerAttribution(
|
|
37
|
+
input: string | URL,
|
|
38
|
+
init: RequestInit = {}
|
|
39
|
+
): RequestInit {
|
|
40
|
+
if (!isPayPalHost(input)) return init
|
|
41
|
+
|
|
42
|
+
const headers = init.headers
|
|
43
|
+
const wanted = ATTRIBUTION_HEADER.toLowerCase()
|
|
44
|
+
|
|
45
|
+
if (!headers) {
|
|
46
|
+
return {
|
|
47
|
+
...init,
|
|
48
|
+
headers: { [ATTRIBUTION_HEADER]: PAYPAL_PARTNER_ATTRIBUTION_ID },
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (typeof Headers !== "undefined" && headers instanceof Headers) {
|
|
52
|
+
if (headers.has(ATTRIBUTION_HEADER)) return init
|
|
53
|
+
const next = new Headers(headers)
|
|
54
|
+
next.set(ATTRIBUTION_HEADER, PAYPAL_PARTNER_ATTRIBUTION_ID)
|
|
55
|
+
return { ...init, headers: next }
|
|
56
|
+
}
|
|
57
|
+
if (Array.isArray(headers)) {
|
|
58
|
+
if (headers.some((pair) => String(pair?.[0]).toLowerCase() === wanted)) {
|
|
59
|
+
return init
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
...init,
|
|
63
|
+
headers: [
|
|
64
|
+
...headers,
|
|
65
|
+
[ATTRIBUTION_HEADER, PAYPAL_PARTNER_ATTRIBUTION_ID],
|
|
66
|
+
],
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (Object.keys(headers).some((name) => name.toLowerCase() === wanted)) {
|
|
70
|
+
return init
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
...init,
|
|
74
|
+
headers: {
|
|
75
|
+
...(headers as Record<string, string>),
|
|
76
|
+
[ATTRIBUTION_HEADER]: PAYPAL_PARTNER_ATTRIBUTION_ID,
|
|
77
|
+
},
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
8
81
|
export const PAYPAL_HTTP_TIMEOUT_MS = (() => {
|
|
9
82
|
const v = Number(process.env.PAYPAL_HTTP_TIMEOUT_MS)
|
|
10
83
|
return Number.isFinite(v) && v > 0 ? v : 30_000
|
|
@@ -111,12 +184,15 @@ export class CircuitOpenError extends Error {
|
|
|
111
184
|
* `fetch` with a default timeout (`PAYPAL_HTTP_TIMEOUT_MS`) and a per-host
|
|
112
185
|
* circuit breaker. 5xx responses and network/timeout errors count as failures;
|
|
113
186
|
* once the breaker opens, calls to that host reject immediately with
|
|
114
|
-
* `CircuitOpenError` until the half-open probe succeeds.
|
|
187
|
+
* `CircuitOpenError` until the half-open probe succeeds. Requests to PayPal
|
|
188
|
+
* always carry the partner attribution (BN) header: see
|
|
189
|
+
* `withPartnerAttribution`.
|
|
115
190
|
*/
|
|
116
191
|
export function paypalFetch(
|
|
117
192
|
input: string | URL,
|
|
118
|
-
|
|
193
|
+
requestInit: RequestInit = {}
|
|
119
194
|
): Promise<Response> {
|
|
195
|
+
const init = withPartnerAttribution(input, requestInit)
|
|
120
196
|
const host = cbHostKey(input)
|
|
121
197
|
if (!cbAllowRequest(host)) {
|
|
122
198
|
return Promise.reject(new CircuitOpenError())
|
|
@@ -51,8 +51,14 @@ export function isRequestLoggingEnabled(): boolean {
|
|
|
51
51
|
// Body keys whose VALUES must never hit the exported file. Card fields are
|
|
52
52
|
// included even though they normally never reach the backend (the JS SDK sends
|
|
53
53
|
// them straight to PayPal) — defence in depth for the advanced-card flow.
|
|
54
|
+
//
|
|
55
|
+
// `authorization(?!s$)`: redact `authorization`, `authorization_code`, … but
|
|
56
|
+
// not PayPal's `payments.authorizations` collection, which holds the
|
|
57
|
+
// authorization id, status, amount and expiry a reviewer needs to see and no
|
|
58
|
+
// credential. `client_token` is the JS SDK token, which embeds a live access
|
|
59
|
+
// token.
|
|
54
60
|
const SENSITIVE_BODY_KEY_RE =
|
|
55
|
-
/secret|password|client_secret|access_token|refresh_token|authorization|auth_code|code_verifier|api[_-]?key|private[_-]?key|security_code|\bcvv2?\b|card[_-]?number|(^|_)number$|expiry|exp_(month|year)/i
|
|
61
|
+
/secret|password|client_secret|client_token|access_token|refresh_token|authorization(?!s$)|auth_code|code_verifier|api[_-]?key|private[_-]?key|security_code|\bcvv2?\b|card[_-]?number|(^|_)number$|expiry|exp_(month|year)/i
|
|
56
62
|
|
|
57
63
|
// Request/response HEADER names to redact. The BN code header is deliberately
|
|
58
64
|
// NOT here — PayPal needs to see it in the log.
|
|
@@ -61,7 +67,8 @@ const SENSITIVE_HEADER_RE =
|
|
|
61
67
|
|
|
62
68
|
const REDACTED = "[REDACTED]"
|
|
63
69
|
|
|
64
|
-
|
|
70
|
+
/** Deep-copy `value` with the values of sensitive keys replaced. */
|
|
71
|
+
export function redactBody(value: unknown, depth = 0): unknown {
|
|
65
72
|
if (depth > 8 || value === null || typeof value !== "object") {
|
|
66
73
|
return value
|
|
67
74
|
}
|
|
@@ -123,9 +130,7 @@ function redactSerializedBody(body: unknown): string {
|
|
|
123
130
|
return trimmed.slice(0, 20_000)
|
|
124
131
|
}
|
|
125
132
|
|
|
126
|
-
function normalizeHeaders(
|
|
127
|
-
headers: unknown
|
|
128
|
-
): Record<string, string> {
|
|
133
|
+
function normalizeHeaders(headers: unknown): Record<string, string> {
|
|
129
134
|
const out: Record<string, string> = {}
|
|
130
135
|
if (!headers) return out
|
|
131
136
|
try {
|
|
@@ -195,10 +200,7 @@ function write(block: string): void {
|
|
|
195
200
|
if (!ensureDir(dir)) return
|
|
196
201
|
fs.appendFileSync(getCurrentLogFilePath(), block)
|
|
197
202
|
} catch (e) {
|
|
198
|
-
console.warn(
|
|
199
|
-
"[paypal_request_log] write failed:",
|
|
200
|
-
(e as Error)?.message
|
|
201
|
-
)
|
|
203
|
+
console.warn("[paypal_request_log] write failed:", (e as Error)?.message)
|
|
202
204
|
}
|
|
203
205
|
}
|
|
204
206
|
|
|
@@ -240,24 +242,23 @@ export function logOutbound(entry: OutboundLog): void {
|
|
|
240
242
|
const duration =
|
|
241
243
|
typeof entry.durationMs === "number" ? ` (${entry.durationMs}ms)` : ""
|
|
242
244
|
|
|
243
|
-
const block =
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
entry.error
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
].join("\n")
|
|
245
|
+
const block = [
|
|
246
|
+
DIVIDER,
|
|
247
|
+
`[${new Date().toISOString()}] OUTBOUND ${entry.method} ${entry.url} ${outcome}${duration}`,
|
|
248
|
+
"Request Headers:",
|
|
249
|
+
renderHeaders(reqHeaders),
|
|
250
|
+
"Request Body:",
|
|
251
|
+
redactSerializedBody(entry.requestBody) || " (empty)",
|
|
252
|
+
"Response Headers:",
|
|
253
|
+
renderHeaders(resHeaders),
|
|
254
|
+
"Response Body:",
|
|
255
|
+
entry.error
|
|
256
|
+
? ` ${(entry.error as Error)?.stack || String(entry.error)}`
|
|
257
|
+
: redactSerializedBody(entry.responseBody) || " (empty)",
|
|
258
|
+
DIVIDER,
|
|
259
|
+
"",
|
|
260
|
+
"",
|
|
261
|
+
].join("\n")
|
|
261
262
|
|
|
262
263
|
write(block)
|
|
263
264
|
}
|
|
@@ -286,22 +287,21 @@ export function logInbound(entry: InboundLog): void {
|
|
|
286
287
|
).toString()}`
|
|
287
288
|
: ""
|
|
288
289
|
|
|
289
|
-
const block =
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
].join("\n")
|
|
290
|
+
const block = [
|
|
291
|
+
DIVIDER,
|
|
292
|
+
`[${new Date().toISOString()}] INBOUND ${entry.method} ${entry.path}${query} -> ${
|
|
293
|
+
entry.status ?? "?"
|
|
294
|
+
}${duration}`,
|
|
295
|
+
"Request Headers:",
|
|
296
|
+
renderHeaders(reqHeaders),
|
|
297
|
+
"Request Body:",
|
|
298
|
+
redactSerializedBody(entry.requestBody) || " (empty)",
|
|
299
|
+
"Response Body:",
|
|
300
|
+
redactSerializedBody(entry.responseBody) || " (empty)",
|
|
301
|
+
DIVIDER,
|
|
302
|
+
"",
|
|
303
|
+
"",
|
|
304
|
+
].join("\n")
|
|
305
305
|
|
|
306
306
|
write(block)
|
|
307
307
|
}
|