@easypayment/medusa-payment-paypal 1.1.1 → 1.1.2
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 +65 -65
- package/.medusa/server/src/admin/index.mjs +65 -65
- package/.medusa/server/src/api/hooks/paypal/onboard-return/route.d.ts +16 -0
- package/.medusa/server/src/api/hooks/paypal/onboard-return/route.d.ts.map +1 -0
- package/.medusa/server/src/api/hooks/paypal/onboard-return/route.js +20 -0
- package/.medusa/server/src/api/hooks/paypal/onboard-return/route.js.map +1 -0
- package/.medusa/server/src/api/hooks/paypal/webhook/route.d.ts +18 -0
- package/.medusa/server/src/api/hooks/paypal/webhook/route.d.ts.map +1 -0
- package/.medusa/server/src/api/hooks/paypal/webhook/route.js +22 -0
- package/.medusa/server/src/api/hooks/paypal/webhook/route.js.map +1 -0
- package/.medusa/server/src/api/middlewares.d.ts.map +1 -1
- package/.medusa/server/src/api/middlewares.js +9 -0
- package/.medusa/server/src/api/middlewares.js.map +1 -1
- package/.medusa/server/src/api/store/paypal/config/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal/config/route.js +8 -0
- package/.medusa/server/src/api/store/paypal/config/route.js.map +1 -1
- package/.medusa/server/src/api/store/paypal/create-order/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal/create-order/route.js +53 -4
- package/.medusa/server/src/api/store/paypal/create-order/route.js.map +1 -1
- package/.medusa/server/src/api/store/paypal-complete/route.js +1 -1
- package/.medusa/server/src/api/store/paypal-complete/route.js.map +1 -1
- package/.medusa/server/src/api/utils/rate-limit.d.ts.map +1 -1
- package/.medusa/server/src/api/utils/rate-limit.js +11 -2
- package/.medusa/server/src/api/utils/rate-limit.js.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/base-provider.d.ts +32 -3
- package/.medusa/server/src/modules/paypal/payment-provider/base-provider.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/base-provider.js +47 -0
- package/.medusa/server/src/modules/paypal/payment-provider/base-provider.js.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/card-service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/card-service.js +172 -117
- package/.medusa/server/src/modules/paypal/payment-provider/card-service.js.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/service.js +132 -126
- package/.medusa/server/src/modules/paypal/payment-provider/service.js.map +1 -1
- package/.medusa/server/src/modules/paypal/service.d.ts +5 -0
- package/.medusa/server/src/modules/paypal/service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/service.js +82 -1
- package/.medusa/server/src/modules/paypal/service.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/credential-resolver.d.ts +10 -0
- package/.medusa/server/src/modules/paypal/utils/credential-resolver.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/credential-resolver.js +39 -0
- package/.medusa/server/src/modules/paypal/utils/credential-resolver.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/paypal-fetch.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/paypal-fetch.js +45 -28
- package/.medusa/server/src/modules/paypal/utils/paypal-fetch.js.map +1 -1
- package/.medusa/server/src/modules/paypal/webhook-processor.d.ts +11 -0
- package/.medusa/server/src/modules/paypal/webhook-processor.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/webhook-processor.js +85 -7
- package/.medusa/server/src/modules/paypal/webhook-processor.js.map +1 -1
- package/CHANGELOG.md +73 -0
- package/package.json +2 -4
- package/src/api/hooks/paypal/onboard-return/route.ts +15 -0
- package/src/api/hooks/paypal/webhook/route.ts +17 -0
- package/src/api/middlewares.ts +9 -0
- package/src/api/store/paypal/config/route.ts +8 -0
- package/src/api/store/paypal/create-order/route.ts +64 -4
- package/src/api/store/paypal-complete/route.ts +1 -1
- package/src/api/utils/rate-limit.ts +11 -2
- package/src/modules/paypal/payment-provider/base-provider.ts +52 -0
- package/src/modules/paypal/payment-provider/card-service.ts +193 -136
- package/src/modules/paypal/payment-provider/service.ts +137 -156
- package/src/modules/paypal/service.ts +98 -1
- package/src/modules/paypal/utils/credential-resolver.ts +36 -0
- package/src/modules/paypal/utils/paypal-fetch.ts +58 -29
- package/src/modules/paypal/webhook-processor.ts +94 -8
|
@@ -134,20 +134,22 @@ async function adminFetch(path, opts = {}) {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
const DEFAULT_FORM$1 = {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
requireInstantPayment: false,
|
|
141
|
-
sendItemDetails: true,
|
|
142
|
-
invoicePrefix: "PP-",
|
|
143
|
-
creditCardStatementName: "PayPal"
|
|
137
|
+
enabled: true,
|
|
138
|
+
title: "Credit or Debit Card",
|
|
139
|
+
threeDS: "when_required"
|
|
144
140
|
};
|
|
145
141
|
function mergeWithDefaults$1(saved) {
|
|
146
142
|
if (!saved) return { ...DEFAULT_FORM$1 };
|
|
147
143
|
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
148
144
|
return { ...DEFAULT_FORM$1, ...Object.fromEntries(entries) };
|
|
149
145
|
}
|
|
150
|
-
|
|
146
|
+
const THREE_DS_OPTIONS = [
|
|
147
|
+
{ value: "when_required", label: "3D Secure when required", hint: "Triggers 3DS only when the card / issuer requires it." },
|
|
148
|
+
{ value: "sli", label: "3D Secure (SCA) / liability shift (recommended)", hint: "Attempts to optimize for liability shift while remaining compliant." },
|
|
149
|
+
{ value: "always", label: "Always request 3D Secure", hint: "Forces 3DS challenge whenever possible (may reduce conversion)." }
|
|
150
|
+
];
|
|
151
|
+
function AdvancedCardPaymentsTab() {
|
|
152
|
+
var _a, _b;
|
|
151
153
|
const [form, setForm] = react.useState(() => ({ ...DEFAULT_FORM$1 }));
|
|
152
154
|
const [loading, setLoading] = react.useState(false);
|
|
153
155
|
const [saving, setSaving] = react.useState(false);
|
|
@@ -162,7 +164,7 @@ function AdditionalSettingsTab() {
|
|
|
162
164
|
setLoading(true);
|
|
163
165
|
const json = await adminFetch("/admin/paypal/settings");
|
|
164
166
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
165
|
-
const saved = payload == null ? void 0 : payload.
|
|
167
|
+
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
166
168
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
167
169
|
} catch {
|
|
168
170
|
} finally {
|
|
@@ -173,14 +175,16 @@ function AdditionalSettingsTab() {
|
|
|
173
175
|
async function onSave() {
|
|
174
176
|
try {
|
|
175
177
|
setSaving(true);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
const json = await adminFetch("/admin/paypal/settings", {
|
|
179
|
+
method: "POST",
|
|
180
|
+
body: { advanced_card_payments: form }
|
|
181
|
+
});
|
|
178
182
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
179
|
-
const saved = payload == null ? void 0 : payload.
|
|
183
|
+
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
180
184
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
181
185
|
setToast({ kind: "success", message: "Settings saved" });
|
|
182
186
|
} catch (e) {
|
|
183
|
-
setToast({ kind: "error", message: e instanceof Error ? e.message : "Failed to save settings" });
|
|
187
|
+
setToast({ kind: "error", message: (e instanceof Error ? e.message : "") || "Failed to save settings." });
|
|
184
188
|
} finally {
|
|
185
189
|
setSaving(false);
|
|
186
190
|
}
|
|
@@ -192,55 +196,42 @@ function AdditionalSettingsTab() {
|
|
|
192
196
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
193
197
|
SectionCard,
|
|
194
198
|
{
|
|
195
|
-
title: "
|
|
196
|
-
description: "
|
|
199
|
+
title: "Advanced Card Payments",
|
|
200
|
+
description: "Control card checkout settings and 3D Secure behavior.",
|
|
197
201
|
right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
198
202
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onSave, disabled: saving || loading, className: "transition-fg relative inline-flex w-fit items-center justify-center overflow-hidden rounded-md outline-none shadow-buttons-neutral text-ui-fg-base bg-ui-button-neutral after:transition-fg after:absolute after:inset-0 after:content-[''] after:button-neutral-gradient hover:bg-ui-button-neutral-hover hover:after:button-neutral-hover-gradient active:bg-ui-button-neutral-pressed active:after:button-neutral-pressed-gradient focus-visible:shadow-buttons-neutral-focus disabled:bg-ui-bg-disabled disabled:border-ui-border-base disabled:text-ui-fg-disabled disabled:shadow-buttons-neutral disabled:after:hidden txt-compact-small-plus px-3 py-1.5", children: saving ? "Saving..." : "Save settings" }),
|
|
199
203
|
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
|
|
200
204
|
] }),
|
|
201
205
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
202
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "
|
|
203
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
204
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
205
|
-
] }) }),
|
|
206
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Brand Name", htmlFor: "as-brand-name", children: /* @__PURE__ */ jsxRuntime.jsx("input", { id: "as-brand-name", value: form.brandName, onChange: (e) => setForm((p) => ({ ...p, brandName: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "PayPal" }) }),
|
|
207
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Landing Page", htmlFor: "as-landing-page", children: /* @__PURE__ */ jsxRuntime.jsxs("select", { id: "as-landing-page", value: form.landingPage, onChange: (e) => setForm((p) => ({ ...p, landingPage: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", children: [
|
|
208
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "no_preference", children: "No Preference" }),
|
|
209
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "login", children: "Login" }),
|
|
210
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "billing", children: "Billing" })
|
|
211
|
-
] }) }),
|
|
212
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Instant Payments", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
213
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.requireInstantPayment, onChange: (e) => setForm((p) => ({ ...p, requireInstantPayment: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
214
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Require Instant Payment" })
|
|
215
|
-
] }) }),
|
|
216
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Send Item Details", hint: "Include all line item details in the payment request to PayPal so that they can be seen from the PayPal transaction details page.", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
217
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.sendItemDetails, onChange: (e) => setForm((p) => ({ ...p, sendItemDetails: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
218
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Send line item details to PayPal" })
|
|
206
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Enable/Disable", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
207
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.enabled, onChange: (e) => setForm((p) => ({ ...p, enabled: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
208
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
|
|
219
209
|
] }) }),
|
|
220
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "
|
|
221
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "
|
|
210
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Title", htmlFor: "acp-title", children: /* @__PURE__ */ jsxRuntime.jsx("input", { id: "acp-title", value: form.title, onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "Credit or Debit Card" }) }),
|
|
211
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Contingency for 3D Secure", hint: "Choose when 3D Secure should be triggered during card payments.", htmlFor: "acp-threeds", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
212
|
+
/* @__PURE__ */ jsxRuntime.jsx("select", { id: "acp-threeds", value: form.threeDS, onChange: (e) => setForm((p) => ({ ...p, threeDS: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", children: THREE_DS_OPTIONS.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value)) }),
|
|
213
|
+
((_a = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _a.hint) ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-ui-fg-subtle", children: (_b = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _b.hint }) : null
|
|
214
|
+
] }) })
|
|
222
215
|
] })
|
|
223
216
|
}
|
|
224
217
|
)
|
|
225
218
|
] }) });
|
|
226
219
|
}
|
|
227
220
|
const DEFAULT_FORM = {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
221
|
+
paymentAction: "capture",
|
|
222
|
+
brandName: "PayPal",
|
|
223
|
+
landingPage: "no_preference",
|
|
224
|
+
requireInstantPayment: false,
|
|
225
|
+
sendItemDetails: true,
|
|
226
|
+
invoicePrefix: "PP-",
|
|
227
|
+
creditCardStatementName: "PayPal"
|
|
231
228
|
};
|
|
232
229
|
function mergeWithDefaults(saved) {
|
|
233
230
|
if (!saved) return { ...DEFAULT_FORM };
|
|
234
231
|
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
235
232
|
return { ...DEFAULT_FORM, ...Object.fromEntries(entries) };
|
|
236
233
|
}
|
|
237
|
-
|
|
238
|
-
{ value: "when_required", label: "3D Secure when required", hint: "Triggers 3DS only when the card / issuer requires it." },
|
|
239
|
-
{ value: "sli", label: "3D Secure (SCA) / liability shift (recommended)", hint: "Attempts to optimize for liability shift while remaining compliant." },
|
|
240
|
-
{ value: "always", label: "Always request 3D Secure", hint: "Forces 3DS challenge whenever possible (may reduce conversion)." }
|
|
241
|
-
];
|
|
242
|
-
function AdvancedCardPaymentsTab() {
|
|
243
|
-
var _a, _b;
|
|
234
|
+
function AdditionalSettingsTab() {
|
|
244
235
|
const [form, setForm] = react.useState(() => ({ ...DEFAULT_FORM }));
|
|
245
236
|
const [loading, setLoading] = react.useState(false);
|
|
246
237
|
const [saving, setSaving] = react.useState(false);
|
|
@@ -255,7 +246,7 @@ function AdvancedCardPaymentsTab() {
|
|
|
255
246
|
setLoading(true);
|
|
256
247
|
const json = await adminFetch("/admin/paypal/settings");
|
|
257
248
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
258
|
-
const saved = payload == null ? void 0 : payload.
|
|
249
|
+
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
259
250
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
260
251
|
} catch {
|
|
261
252
|
} finally {
|
|
@@ -266,16 +257,14 @@ function AdvancedCardPaymentsTab() {
|
|
|
266
257
|
async function onSave() {
|
|
267
258
|
try {
|
|
268
259
|
setSaving(true);
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
body: { advanced_card_payments: form }
|
|
272
|
-
});
|
|
260
|
+
setToast(null);
|
|
261
|
+
const json = await adminFetch("/admin/paypal/settings", { method: "POST", body: { additional_settings: form } });
|
|
273
262
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
274
|
-
const saved = payload == null ? void 0 : payload.
|
|
263
|
+
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
275
264
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
276
265
|
setToast({ kind: "success", message: "Settings saved" });
|
|
277
266
|
} catch (e) {
|
|
278
|
-
setToast({ kind: "error", message:
|
|
267
|
+
setToast({ kind: "error", message: e instanceof Error ? e.message : "Failed to save settings" });
|
|
279
268
|
} finally {
|
|
280
269
|
setSaving(false);
|
|
281
270
|
}
|
|
@@ -287,22 +276,33 @@ function AdvancedCardPaymentsTab() {
|
|
|
287
276
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
288
277
|
SectionCard,
|
|
289
278
|
{
|
|
290
|
-
title: "
|
|
291
|
-
description: "
|
|
279
|
+
title: "Additional Settings",
|
|
280
|
+
description: "These settings control checkout behavior and PayPal experience.",
|
|
292
281
|
right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
293
282
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onSave, disabled: saving || loading, className: "transition-fg relative inline-flex w-fit items-center justify-center overflow-hidden rounded-md outline-none shadow-buttons-neutral text-ui-fg-base bg-ui-button-neutral after:transition-fg after:absolute after:inset-0 after:content-[''] after:button-neutral-gradient hover:bg-ui-button-neutral-hover hover:after:button-neutral-hover-gradient active:bg-ui-button-neutral-pressed active:after:button-neutral-pressed-gradient focus-visible:shadow-buttons-neutral-focus disabled:bg-ui-bg-disabled disabled:border-ui-border-base disabled:text-ui-fg-disabled disabled:shadow-buttons-neutral disabled:after:hidden txt-compact-small-plus px-3 py-1.5", children: saving ? "Saving..." : "Save settings" }),
|
|
294
283
|
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
|
|
295
284
|
] }),
|
|
296
285
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
297
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "
|
|
298
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
299
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
286
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Payment action", htmlFor: "as-payment-action", children: /* @__PURE__ */ jsxRuntime.jsxs("select", { id: "as-payment-action", value: form.paymentAction, onChange: (e) => setForm((p) => ({ ...p, paymentAction: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", children: [
|
|
287
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "capture", children: "Capture" }),
|
|
288
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "authorize", children: "Authorize" })
|
|
300
289
|
] }) }),
|
|
301
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "
|
|
302
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "
|
|
303
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
304
|
-
|
|
305
|
-
|
|
290
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Brand Name", htmlFor: "as-brand-name", children: /* @__PURE__ */ jsxRuntime.jsx("input", { id: "as-brand-name", value: form.brandName, onChange: (e) => setForm((p) => ({ ...p, brandName: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "PayPal" }) }),
|
|
291
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Landing Page", htmlFor: "as-landing-page", children: /* @__PURE__ */ jsxRuntime.jsxs("select", { id: "as-landing-page", value: form.landingPage, onChange: (e) => setForm((p) => ({ ...p, landingPage: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", children: [
|
|
292
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "no_preference", children: "No Preference" }),
|
|
293
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "login", children: "Login" }),
|
|
294
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "billing", children: "Billing" })
|
|
295
|
+
] }) }),
|
|
296
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Instant Payments", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
297
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.requireInstantPayment, onChange: (e) => setForm((p) => ({ ...p, requireInstantPayment: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
298
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Require Instant Payment" })
|
|
299
|
+
] }) }),
|
|
300
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Send Item Details", hint: "Include all line item details in the payment request to PayPal so that they can be seen from the PayPal transaction details page.", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
301
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.sendItemDetails, onChange: (e) => setForm((p) => ({ ...p, sendItemDetails: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
302
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Send line item details to PayPal" })
|
|
303
|
+
] }) }),
|
|
304
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Invoice prefix", htmlFor: "as-invoice-prefix", children: /* @__PURE__ */ jsxRuntime.jsx("input", { id: "as-invoice-prefix", value: form.invoicePrefix, onChange: (e) => setForm((p) => ({ ...p, invoicePrefix: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "PP-" }) }),
|
|
305
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Credit Card Statement Name", htmlFor: "as-cc-statement", children: /* @__PURE__ */ jsxRuntime.jsx("input", { id: "as-cc-statement", value: form.creditCardStatementName, onChange: (e) => setForm((p) => ({ ...p, creditCardStatementName: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "PayPal" }) })
|
|
306
306
|
] })
|
|
307
307
|
}
|
|
308
308
|
)
|
|
@@ -1248,14 +1248,14 @@ const routeModule = {
|
|
|
1248
1248
|
Component: PayPalSettingsIndexRoute,
|
|
1249
1249
|
path: "/settings/paypal"
|
|
1250
1250
|
},
|
|
1251
|
-
{
|
|
1252
|
-
Component: AdditionalSettingsTab,
|
|
1253
|
-
path: "/settings/paypal/additional-settings"
|
|
1254
|
-
},
|
|
1255
1251
|
{
|
|
1256
1252
|
Component: AdvancedCardPaymentsTab,
|
|
1257
1253
|
path: "/settings/paypal/advanced-card-payments"
|
|
1258
1254
|
},
|
|
1255
|
+
{
|
|
1256
|
+
Component: AdditionalSettingsTab,
|
|
1257
|
+
path: "/settings/paypal/additional-settings"
|
|
1258
|
+
},
|
|
1259
1259
|
{
|
|
1260
1260
|
Component: PayPalApplePayPage,
|
|
1261
1261
|
path: "/settings/paypal/apple-pay"
|
|
@@ -133,20 +133,22 @@ async function adminFetch(path, opts = {}) {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
const DEFAULT_FORM$1 = {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
requireInstantPayment: false,
|
|
140
|
-
sendItemDetails: true,
|
|
141
|
-
invoicePrefix: "PP-",
|
|
142
|
-
creditCardStatementName: "PayPal"
|
|
136
|
+
enabled: true,
|
|
137
|
+
title: "Credit or Debit Card",
|
|
138
|
+
threeDS: "when_required"
|
|
143
139
|
};
|
|
144
140
|
function mergeWithDefaults$1(saved) {
|
|
145
141
|
if (!saved) return { ...DEFAULT_FORM$1 };
|
|
146
142
|
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
147
143
|
return { ...DEFAULT_FORM$1, ...Object.fromEntries(entries) };
|
|
148
144
|
}
|
|
149
|
-
|
|
145
|
+
const THREE_DS_OPTIONS = [
|
|
146
|
+
{ value: "when_required", label: "3D Secure when required", hint: "Triggers 3DS only when the card / issuer requires it." },
|
|
147
|
+
{ value: "sli", label: "3D Secure (SCA) / liability shift (recommended)", hint: "Attempts to optimize for liability shift while remaining compliant." },
|
|
148
|
+
{ value: "always", label: "Always request 3D Secure", hint: "Forces 3DS challenge whenever possible (may reduce conversion)." }
|
|
149
|
+
];
|
|
150
|
+
function AdvancedCardPaymentsTab() {
|
|
151
|
+
var _a, _b;
|
|
150
152
|
const [form, setForm] = useState(() => ({ ...DEFAULT_FORM$1 }));
|
|
151
153
|
const [loading, setLoading] = useState(false);
|
|
152
154
|
const [saving, setSaving] = useState(false);
|
|
@@ -161,7 +163,7 @@ function AdditionalSettingsTab() {
|
|
|
161
163
|
setLoading(true);
|
|
162
164
|
const json = await adminFetch("/admin/paypal/settings");
|
|
163
165
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
164
|
-
const saved = payload == null ? void 0 : payload.
|
|
166
|
+
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
165
167
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
166
168
|
} catch {
|
|
167
169
|
} finally {
|
|
@@ -172,14 +174,16 @@ function AdditionalSettingsTab() {
|
|
|
172
174
|
async function onSave() {
|
|
173
175
|
try {
|
|
174
176
|
setSaving(true);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
+
const json = await adminFetch("/admin/paypal/settings", {
|
|
178
|
+
method: "POST",
|
|
179
|
+
body: { advanced_card_payments: form }
|
|
180
|
+
});
|
|
177
181
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
178
|
-
const saved = payload == null ? void 0 : payload.
|
|
182
|
+
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
179
183
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
180
184
|
setToast({ kind: "success", message: "Settings saved" });
|
|
181
185
|
} catch (e) {
|
|
182
|
-
setToast({ kind: "error", message: e instanceof Error ? e.message : "Failed to save settings" });
|
|
186
|
+
setToast({ kind: "error", message: (e instanceof Error ? e.message : "") || "Failed to save settings." });
|
|
183
187
|
} finally {
|
|
184
188
|
setSaving(false);
|
|
185
189
|
}
|
|
@@ -191,55 +195,42 @@ function AdditionalSettingsTab() {
|
|
|
191
195
|
/* @__PURE__ */ jsx(
|
|
192
196
|
SectionCard,
|
|
193
197
|
{
|
|
194
|
-
title: "
|
|
195
|
-
description: "
|
|
198
|
+
title: "Advanced Card Payments",
|
|
199
|
+
description: "Control card checkout settings and 3D Secure behavior.",
|
|
196
200
|
right: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
197
201
|
/* @__PURE__ */ jsx("button", { type: "button", onClick: onSave, disabled: saving || loading, className: "transition-fg relative inline-flex w-fit items-center justify-center overflow-hidden rounded-md outline-none shadow-buttons-neutral text-ui-fg-base bg-ui-button-neutral after:transition-fg after:absolute after:inset-0 after:content-[''] after:button-neutral-gradient hover:bg-ui-button-neutral-hover hover:after:button-neutral-hover-gradient active:bg-ui-button-neutral-pressed active:after:button-neutral-pressed-gradient focus-visible:shadow-buttons-neutral-focus disabled:bg-ui-bg-disabled disabled:border-ui-border-base disabled:text-ui-fg-disabled disabled:shadow-buttons-neutral disabled:after:hidden txt-compact-small-plus px-3 py-1.5", children: saving ? "Saving..." : "Save settings" }),
|
|
198
202
|
loading ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
|
|
199
203
|
] }),
|
|
200
204
|
children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
201
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "
|
|
202
|
-
/* @__PURE__ */ jsx("
|
|
203
|
-
/* @__PURE__ */ jsx("
|
|
204
|
-
] }) }),
|
|
205
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "Brand Name", htmlFor: "as-brand-name", children: /* @__PURE__ */ jsx("input", { id: "as-brand-name", value: form.brandName, onChange: (e) => setForm((p) => ({ ...p, brandName: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "PayPal" }) }),
|
|
206
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "Landing Page", htmlFor: "as-landing-page", children: /* @__PURE__ */ jsxs("select", { id: "as-landing-page", value: form.landingPage, onChange: (e) => setForm((p) => ({ ...p, landingPage: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", children: [
|
|
207
|
-
/* @__PURE__ */ jsx("option", { value: "no_preference", children: "No Preference" }),
|
|
208
|
-
/* @__PURE__ */ jsx("option", { value: "login", children: "Login" }),
|
|
209
|
-
/* @__PURE__ */ jsx("option", { value: "billing", children: "Billing" })
|
|
210
|
-
] }) }),
|
|
211
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "Instant Payments", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
212
|
-
/* @__PURE__ */ jsx("input", { type: "checkbox", checked: form.requireInstantPayment, onChange: (e) => setForm((p) => ({ ...p, requireInstantPayment: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
213
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Require Instant Payment" })
|
|
214
|
-
] }) }),
|
|
215
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "Send Item Details", hint: "Include all line item details in the payment request to PayPal so that they can be seen from the PayPal transaction details page.", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
216
|
-
/* @__PURE__ */ jsx("input", { type: "checkbox", checked: form.sendItemDetails, onChange: (e) => setForm((p) => ({ ...p, sendItemDetails: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
217
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Send line item details to PayPal" })
|
|
205
|
+
/* @__PURE__ */ jsx(FieldRow, { label: "Enable/Disable", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
206
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", checked: form.enabled, onChange: (e) => setForm((p) => ({ ...p, enabled: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
207
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
|
|
218
208
|
] }) }),
|
|
219
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "
|
|
220
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "
|
|
209
|
+
/* @__PURE__ */ jsx(FieldRow, { label: "Title", htmlFor: "acp-title", children: /* @__PURE__ */ jsx("input", { id: "acp-title", value: form.title, onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "Credit or Debit Card" }) }),
|
|
210
|
+
/* @__PURE__ */ jsx(FieldRow, { label: "Contingency for 3D Secure", hint: "Choose when 3D Secure should be triggered during card payments.", htmlFor: "acp-threeds", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
211
|
+
/* @__PURE__ */ jsx("select", { id: "acp-threeds", value: form.threeDS, onChange: (e) => setForm((p) => ({ ...p, threeDS: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", children: THREE_DS_OPTIONS.map((o) => /* @__PURE__ */ jsx("option", { value: o.value, children: o.label }, o.value)) }),
|
|
212
|
+
((_a = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _a.hint) ? /* @__PURE__ */ jsx("div", { className: "text-xs text-ui-fg-subtle", children: (_b = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _b.hint }) : null
|
|
213
|
+
] }) })
|
|
221
214
|
] })
|
|
222
215
|
}
|
|
223
216
|
)
|
|
224
217
|
] }) });
|
|
225
218
|
}
|
|
226
219
|
const DEFAULT_FORM = {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
220
|
+
paymentAction: "capture",
|
|
221
|
+
brandName: "PayPal",
|
|
222
|
+
landingPage: "no_preference",
|
|
223
|
+
requireInstantPayment: false,
|
|
224
|
+
sendItemDetails: true,
|
|
225
|
+
invoicePrefix: "PP-",
|
|
226
|
+
creditCardStatementName: "PayPal"
|
|
230
227
|
};
|
|
231
228
|
function mergeWithDefaults(saved) {
|
|
232
229
|
if (!saved) return { ...DEFAULT_FORM };
|
|
233
230
|
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
234
231
|
return { ...DEFAULT_FORM, ...Object.fromEntries(entries) };
|
|
235
232
|
}
|
|
236
|
-
|
|
237
|
-
{ value: "when_required", label: "3D Secure when required", hint: "Triggers 3DS only when the card / issuer requires it." },
|
|
238
|
-
{ value: "sli", label: "3D Secure (SCA) / liability shift (recommended)", hint: "Attempts to optimize for liability shift while remaining compliant." },
|
|
239
|
-
{ value: "always", label: "Always request 3D Secure", hint: "Forces 3DS challenge whenever possible (may reduce conversion)." }
|
|
240
|
-
];
|
|
241
|
-
function AdvancedCardPaymentsTab() {
|
|
242
|
-
var _a, _b;
|
|
233
|
+
function AdditionalSettingsTab() {
|
|
243
234
|
const [form, setForm] = useState(() => ({ ...DEFAULT_FORM }));
|
|
244
235
|
const [loading, setLoading] = useState(false);
|
|
245
236
|
const [saving, setSaving] = useState(false);
|
|
@@ -254,7 +245,7 @@ function AdvancedCardPaymentsTab() {
|
|
|
254
245
|
setLoading(true);
|
|
255
246
|
const json = await adminFetch("/admin/paypal/settings");
|
|
256
247
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
257
|
-
const saved = payload == null ? void 0 : payload.
|
|
248
|
+
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
258
249
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
259
250
|
} catch {
|
|
260
251
|
} finally {
|
|
@@ -265,16 +256,14 @@ function AdvancedCardPaymentsTab() {
|
|
|
265
256
|
async function onSave() {
|
|
266
257
|
try {
|
|
267
258
|
setSaving(true);
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
body: { advanced_card_payments: form }
|
|
271
|
-
});
|
|
259
|
+
setToast(null);
|
|
260
|
+
const json = await adminFetch("/admin/paypal/settings", { method: "POST", body: { additional_settings: form } });
|
|
272
261
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
273
|
-
const saved = payload == null ? void 0 : payload.
|
|
262
|
+
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
274
263
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
275
264
|
setToast({ kind: "success", message: "Settings saved" });
|
|
276
265
|
} catch (e) {
|
|
277
|
-
setToast({ kind: "error", message:
|
|
266
|
+
setToast({ kind: "error", message: e instanceof Error ? e.message : "Failed to save settings" });
|
|
278
267
|
} finally {
|
|
279
268
|
setSaving(false);
|
|
280
269
|
}
|
|
@@ -286,22 +275,33 @@ function AdvancedCardPaymentsTab() {
|
|
|
286
275
|
/* @__PURE__ */ jsx(
|
|
287
276
|
SectionCard,
|
|
288
277
|
{
|
|
289
|
-
title: "
|
|
290
|
-
description: "
|
|
278
|
+
title: "Additional Settings",
|
|
279
|
+
description: "These settings control checkout behavior and PayPal experience.",
|
|
291
280
|
right: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
292
281
|
/* @__PURE__ */ jsx("button", { type: "button", onClick: onSave, disabled: saving || loading, className: "transition-fg relative inline-flex w-fit items-center justify-center overflow-hidden rounded-md outline-none shadow-buttons-neutral text-ui-fg-base bg-ui-button-neutral after:transition-fg after:absolute after:inset-0 after:content-[''] after:button-neutral-gradient hover:bg-ui-button-neutral-hover hover:after:button-neutral-hover-gradient active:bg-ui-button-neutral-pressed active:after:button-neutral-pressed-gradient focus-visible:shadow-buttons-neutral-focus disabled:bg-ui-bg-disabled disabled:border-ui-border-base disabled:text-ui-fg-disabled disabled:shadow-buttons-neutral disabled:after:hidden txt-compact-small-plus px-3 py-1.5", children: saving ? "Saving..." : "Save settings" }),
|
|
293
282
|
loading ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
|
|
294
283
|
] }),
|
|
295
284
|
children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
296
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "
|
|
297
|
-
/* @__PURE__ */ jsx("
|
|
298
|
-
/* @__PURE__ */ jsx("
|
|
285
|
+
/* @__PURE__ */ jsx(FieldRow, { label: "Payment action", htmlFor: "as-payment-action", children: /* @__PURE__ */ jsxs("select", { id: "as-payment-action", value: form.paymentAction, onChange: (e) => setForm((p) => ({ ...p, paymentAction: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", children: [
|
|
286
|
+
/* @__PURE__ */ jsx("option", { value: "capture", children: "Capture" }),
|
|
287
|
+
/* @__PURE__ */ jsx("option", { value: "authorize", children: "Authorize" })
|
|
299
288
|
] }) }),
|
|
300
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "
|
|
301
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "
|
|
302
|
-
/* @__PURE__ */ jsx("
|
|
303
|
-
|
|
304
|
-
|
|
289
|
+
/* @__PURE__ */ jsx(FieldRow, { label: "Brand Name", htmlFor: "as-brand-name", children: /* @__PURE__ */ jsx("input", { id: "as-brand-name", value: form.brandName, onChange: (e) => setForm((p) => ({ ...p, brandName: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "PayPal" }) }),
|
|
290
|
+
/* @__PURE__ */ jsx(FieldRow, { label: "Landing Page", htmlFor: "as-landing-page", children: /* @__PURE__ */ jsxs("select", { id: "as-landing-page", value: form.landingPage, onChange: (e) => setForm((p) => ({ ...p, landingPage: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", children: [
|
|
291
|
+
/* @__PURE__ */ jsx("option", { value: "no_preference", children: "No Preference" }),
|
|
292
|
+
/* @__PURE__ */ jsx("option", { value: "login", children: "Login" }),
|
|
293
|
+
/* @__PURE__ */ jsx("option", { value: "billing", children: "Billing" })
|
|
294
|
+
] }) }),
|
|
295
|
+
/* @__PURE__ */ jsx(FieldRow, { label: "Instant Payments", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
296
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", checked: form.requireInstantPayment, onChange: (e) => setForm((p) => ({ ...p, requireInstantPayment: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
297
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Require Instant Payment" })
|
|
298
|
+
] }) }),
|
|
299
|
+
/* @__PURE__ */ jsx(FieldRow, { label: "Send Item Details", hint: "Include all line item details in the payment request to PayPal so that they can be seen from the PayPal transaction details page.", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
300
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", checked: form.sendItemDetails, onChange: (e) => setForm((p) => ({ ...p, sendItemDetails: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
301
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Send line item details to PayPal" })
|
|
302
|
+
] }) }),
|
|
303
|
+
/* @__PURE__ */ jsx(FieldRow, { label: "Invoice prefix", htmlFor: "as-invoice-prefix", children: /* @__PURE__ */ jsx("input", { id: "as-invoice-prefix", value: form.invoicePrefix, onChange: (e) => setForm((p) => ({ ...p, invoicePrefix: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "PP-" }) }),
|
|
304
|
+
/* @__PURE__ */ jsx(FieldRow, { label: "Credit Card Statement Name", htmlFor: "as-cc-statement", children: /* @__PURE__ */ jsx("input", { id: "as-cc-statement", value: form.creditCardStatementName, onChange: (e) => setForm((p) => ({ ...p, creditCardStatementName: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "PayPal" }) })
|
|
305
305
|
] })
|
|
306
306
|
}
|
|
307
307
|
)
|
|
@@ -1247,14 +1247,14 @@ const routeModule = {
|
|
|
1247
1247
|
Component: PayPalSettingsIndexRoute,
|
|
1248
1248
|
path: "/settings/paypal"
|
|
1249
1249
|
},
|
|
1250
|
-
{
|
|
1251
|
-
Component: AdditionalSettingsTab,
|
|
1252
|
-
path: "/settings/paypal/additional-settings"
|
|
1253
|
-
},
|
|
1254
1250
|
{
|
|
1255
1251
|
Component: AdvancedCardPaymentsTab,
|
|
1256
1252
|
path: "/settings/paypal/advanced-card-payments"
|
|
1257
1253
|
},
|
|
1254
|
+
{
|
|
1255
|
+
Component: AdditionalSettingsTab,
|
|
1256
|
+
path: "/settings/paypal/additional-settings"
|
|
1257
|
+
},
|
|
1258
1258
|
{
|
|
1259
1259
|
Component: PayPalApplePayPage,
|
|
1260
1260
|
path: "/settings/paypal/apple-pay"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PayPal onboarding `return_url` under the `/hooks` namespace.
|
|
3
|
+
*
|
|
4
|
+
* PayPal redirects the onboarding popup here as a plain top-level browser
|
|
5
|
+
* navigation, which carries no `x-publishable-api-key` header — and Medusa's
|
|
6
|
+
* store publishable-key middleware rejects every `/store/*` request without
|
|
7
|
+
* that header before the handler runs. Hosting the return bridge under
|
|
8
|
+
* `/hooks` (no publishable-key guard) lets the popup complete the credential
|
|
9
|
+
* exchange and close itself.
|
|
10
|
+
*
|
|
11
|
+
* The legacy `/store/paypal/onboard-return` route is kept for deployments
|
|
12
|
+
* whose edge injects the key; both paths share this exact handler. Newly
|
|
13
|
+
* generated onboarding links point at `/hooks/paypal/onboard-return`.
|
|
14
|
+
*/
|
|
15
|
+
export { GET } from "../../../store/paypal/onboard-return/route";
|
|
16
|
+
//# sourceMappingURL=route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/hooks/paypal/onboard-return/route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,4CAA4C,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GET = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* PayPal onboarding `return_url` under the `/hooks` namespace.
|
|
6
|
+
*
|
|
7
|
+
* PayPal redirects the onboarding popup here as a plain top-level browser
|
|
8
|
+
* navigation, which carries no `x-publishable-api-key` header — and Medusa's
|
|
9
|
+
* store publishable-key middleware rejects every `/store/*` request without
|
|
10
|
+
* that header before the handler runs. Hosting the return bridge under
|
|
11
|
+
* `/hooks` (no publishable-key guard) lets the popup complete the credential
|
|
12
|
+
* exchange and close itself.
|
|
13
|
+
*
|
|
14
|
+
* The legacy `/store/paypal/onboard-return` route is kept for deployments
|
|
15
|
+
* whose edge injects the key; both paths share this exact handler. Newly
|
|
16
|
+
* generated onboarding links point at `/hooks/paypal/onboard-return`.
|
|
17
|
+
*/
|
|
18
|
+
var route_1 = require("../../../store/paypal/onboard-return/route");
|
|
19
|
+
Object.defineProperty(exports, "GET", { enumerable: true, get: function () { return route_1.GET; } });
|
|
20
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../src/api/hooks/paypal/onboard-return/route.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH,oEAAgE;AAAvD,4FAAA,GAAG,OAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PayPal webhook endpoint under the `/hooks` namespace.
|
|
3
|
+
*
|
|
4
|
+
* Medusa applies its store publishable-key middleware to EVERY `/store/*`
|
|
5
|
+
* route, and PayPal's webhook delivery cannot send the
|
|
6
|
+
* `x-publishable-api-key` header — so the original
|
|
7
|
+
* `/store/paypal/webhook` endpoint is rejected with NOT_ALLOWED before the
|
|
8
|
+
* handler runs unless a reverse proxy injects the header. The `/hooks`
|
|
9
|
+
* namespace (the same one Medusa core uses for provider webhooks) has no such
|
|
10
|
+
* guard, so external callers can reach it directly.
|
|
11
|
+
*
|
|
12
|
+
* The `/store/paypal/webhook` route is kept for deployments that already
|
|
13
|
+
* inject the key at their edge; both paths share this exact handler. New
|
|
14
|
+
* webhook registrations (and migrated existing ones) point at
|
|
15
|
+
* `/hooks/paypal/webhook`.
|
|
16
|
+
*/
|
|
17
|
+
export { POST } from "../../../store/paypal/webhook/route";
|
|
18
|
+
//# sourceMappingURL=route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/hooks/paypal/webhook/route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.POST = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* PayPal webhook endpoint under the `/hooks` namespace.
|
|
6
|
+
*
|
|
7
|
+
* Medusa applies its store publishable-key middleware to EVERY `/store/*`
|
|
8
|
+
* route, and PayPal's webhook delivery cannot send the
|
|
9
|
+
* `x-publishable-api-key` header — so the original
|
|
10
|
+
* `/store/paypal/webhook` endpoint is rejected with NOT_ALLOWED before the
|
|
11
|
+
* handler runs unless a reverse proxy injects the header. The `/hooks`
|
|
12
|
+
* namespace (the same one Medusa core uses for provider webhooks) has no such
|
|
13
|
+
* guard, so external callers can reach it directly.
|
|
14
|
+
*
|
|
15
|
+
* The `/store/paypal/webhook` route is kept for deployments that already
|
|
16
|
+
* inject the key at their edge; both paths share this exact handler. New
|
|
17
|
+
* webhook registrations (and migrated existing ones) point at
|
|
18
|
+
* `/hooks/paypal/webhook`.
|
|
19
|
+
*/
|
|
20
|
+
var route_1 = require("../../../store/paypal/webhook/route");
|
|
21
|
+
Object.defineProperty(exports, "POST", { enumerable: true, get: function () { return route_1.POST; } });
|
|
22
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../src/api/hooks/paypal/webhook/route.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,6DAA0D;AAAjD,6FAAA,IAAI,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middlewares.d.ts","sourceRoot":"","sources":["../../../../src/api/middlewares.ts"],"names":[],"mappings":";AAGA,
|
|
1
|
+
{"version":3,"file":"middlewares.d.ts","sourceRoot":"","sources":["../../../../src/api/middlewares.ts"],"names":[],"mappings":";AAGA,wBA2CE"}
|
|
@@ -13,6 +13,15 @@ exports.default = (0, http_1.defineMiddlewares)({
|
|
|
13
13
|
bodyParser: { preserveRawBody: true },
|
|
14
14
|
middlewares: [],
|
|
15
15
|
},
|
|
16
|
+
{
|
|
17
|
+
// Same raw-body requirement for the /hooks mirror of the webhook route —
|
|
18
|
+
// the path external PayPal deliveries actually reach, since Medusa's
|
|
19
|
+
// publishable-key middleware blocks unauthenticated POSTs to /store/*.
|
|
20
|
+
matcher: "/hooks/paypal/webhook",
|
|
21
|
+
method: ["POST"],
|
|
22
|
+
bodyParser: { preserveRawBody: true },
|
|
23
|
+
middlewares: [],
|
|
24
|
+
},
|
|
16
25
|
{
|
|
17
26
|
// Rate-limit the order-creating route: unauthenticated by necessity, so
|
|
18
27
|
// cap how fast one client can spin up PayPal orders on the merchant
|