@easypayment/medusa-payment-paypal 1.1.2 → 1.2.0
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 +72 -72
- package/.medusa/server/src/admin/index.mjs +72 -72
- package/.medusa/server/src/api/middlewares.d.ts.map +1 -1
- package/.medusa/server/src/api/middlewares.js +16 -2
- package/.medusa/server/src/api/middlewares.js.map +1 -1
- package/.medusa/server/src/api/store/paypal/capture-order/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal/capture-order/route.js +66 -13
- package/.medusa/server/src/api/store/paypal/capture-order/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 +11 -6
- package/.medusa/server/src/api/store/paypal/create-order/route.js.map +1 -1
- package/.medusa/server/src/api/utils/rate-limit.d.ts +13 -1
- package/.medusa/server/src/api/utils/rate-limit.d.ts.map +1 -1
- package/.medusa/server/src/api/utils/rate-limit.js +7 -5
- package/.medusa/server/src/api/utils/rate-limit.js.map +1 -1
- package/.medusa/server/src/jobs/paypal-webhook-retry.d.ts.map +1 -1
- package/.medusa/server/src/jobs/paypal-webhook-retry.js +4 -0
- package/.medusa/server/src/jobs/paypal-webhook-retry.js.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/base-provider.d.ts +15 -0
- 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 +26 -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 +244 -169
- 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 +0 -4
- package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/service.js +8 -25
- package/.medusa/server/src/modules/paypal/payment-provider/service.js.map +1 -1
- package/.medusa/server/src/modules/paypal/service.d.ts +2 -0
- package/.medusa/server/src/modules/paypal/service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/service.js +54 -13
- package/.medusa/server/src/modules/paypal/service.js.map +1 -1
- package/.medusa/server/src/modules/paypal/types/config.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/types/config.js +13 -0
- package/.medusa/server/src/modules/paypal/types/config.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/amounts.d.ts +1 -1
- package/.medusa/server/src/modules/paypal/utils/credential-resolver.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/credential-resolver.js +10 -34
- package/.medusa/server/src/modules/paypal/utils/credential-resolver.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/metrics.d.ts +18 -0
- package/.medusa/server/src/modules/paypal/utils/metrics.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/utils/metrics.js +45 -0
- package/.medusa/server/src/modules/paypal/utils/metrics.js.map +1 -0
- package/.medusa/server/src/modules/paypal/webhook-processor.d.ts +16 -0
- package/.medusa/server/src/modules/paypal/webhook-processor.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/webhook-processor.js +85 -2
- package/.medusa/server/src/modules/paypal/webhook-processor.js.map +1 -1
- package/.medusa/server/src/subscribers/paypal-webhook-process.d.ts.map +1 -1
- package/.medusa/server/src/subscribers/paypal-webhook-process.js +4 -0
- package/.medusa/server/src/subscribers/paypal-webhook-process.js.map +1 -1
- package/CHANGELOG.md +208 -146
- package/README.md +175 -184
- package/package.json +91 -88
- package/src/api/middlewares.ts +16 -2
- package/src/api/store/paypal/capture-order/route.ts +83 -12
- package/src/api/store/paypal/create-order/route.ts +11 -7
- package/src/api/utils/rate-limit.ts +20 -5
- package/src/jobs/paypal-webhook-retry.ts +4 -0
- package/src/modules/paypal/payment-provider/base-provider.ts +31 -0
- package/src/modules/paypal/payment-provider/card-service.ts +84 -0
- package/src/modules/paypal/payment-provider/service.ts +12 -30
- package/src/modules/paypal/service.ts +1703 -1651
- package/src/modules/paypal/types/config.ts +16 -0
- package/src/modules/paypal/utils/credential-resolver.ts +9 -36
- package/src/modules/paypal/utils/metrics.ts +48 -0
- package/src/modules/paypal/webhook-processor.ts +101 -2
- package/src/subscribers/paypal-webhook-process.ts +4 -0
|
@@ -134,22 +134,20 @@ async function adminFetch(path, opts = {}) {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
const DEFAULT_FORM$1 = {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
paymentAction: "capture",
|
|
138
|
+
brandName: "PayPal",
|
|
139
|
+
landingPage: "no_preference",
|
|
140
|
+
requireInstantPayment: false,
|
|
141
|
+
sendItemDetails: true,
|
|
142
|
+
invoicePrefix: "PP-",
|
|
143
|
+
creditCardStatementName: "PayPal"
|
|
140
144
|
};
|
|
141
145
|
function mergeWithDefaults$1(saved) {
|
|
142
146
|
if (!saved) return { ...DEFAULT_FORM$1 };
|
|
143
147
|
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
144
148
|
return { ...DEFAULT_FORM$1, ...Object.fromEntries(entries) };
|
|
145
149
|
}
|
|
146
|
-
|
|
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;
|
|
150
|
+
function AdditionalSettingsTab() {
|
|
153
151
|
const [form, setForm] = react.useState(() => ({ ...DEFAULT_FORM$1 }));
|
|
154
152
|
const [loading, setLoading] = react.useState(false);
|
|
155
153
|
const [saving, setSaving] = react.useState(false);
|
|
@@ -164,7 +162,7 @@ function AdvancedCardPaymentsTab() {
|
|
|
164
162
|
setLoading(true);
|
|
165
163
|
const json = await adminFetch("/admin/paypal/settings");
|
|
166
164
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
167
|
-
const saved = payload == null ? void 0 : payload.
|
|
165
|
+
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
168
166
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
169
167
|
} catch {
|
|
170
168
|
} finally {
|
|
@@ -175,16 +173,14 @@ function AdvancedCardPaymentsTab() {
|
|
|
175
173
|
async function onSave() {
|
|
176
174
|
try {
|
|
177
175
|
setSaving(true);
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
body: { advanced_card_payments: form }
|
|
181
|
-
});
|
|
176
|
+
setToast(null);
|
|
177
|
+
const json = await adminFetch("/admin/paypal/settings", { method: "POST", body: { additional_settings: form } });
|
|
182
178
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
183
|
-
const saved = payload == null ? void 0 : payload.
|
|
179
|
+
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
184
180
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
185
181
|
setToast({ kind: "success", message: "Settings saved" });
|
|
186
182
|
} catch (e) {
|
|
187
|
-
setToast({ kind: "error", message:
|
|
183
|
+
setToast({ kind: "error", message: e instanceof Error ? e.message : "Failed to save settings" });
|
|
188
184
|
} finally {
|
|
189
185
|
setSaving(false);
|
|
190
186
|
}
|
|
@@ -196,42 +192,55 @@ function AdvancedCardPaymentsTab() {
|
|
|
196
192
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
197
193
|
SectionCard,
|
|
198
194
|
{
|
|
199
|
-
title: "
|
|
200
|
-
description: "
|
|
195
|
+
title: "Additional Settings",
|
|
196
|
+
description: "These settings control checkout behavior and PayPal experience.",
|
|
201
197
|
right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
202
198
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onSave, disabled: saving || loading, className: "transition-fg relative inline-flex w-fit items-center justify-center overflow-hidden rounded-md outline-none shadow-buttons-neutral text-ui-fg-base bg-ui-button-neutral after:transition-fg after:absolute after:inset-0 after:content-[''] after:button-neutral-gradient hover:bg-ui-button-neutral-hover hover:after:button-neutral-hover-gradient active:bg-ui-button-neutral-pressed active:after:button-neutral-pressed-gradient focus-visible:shadow-buttons-neutral-focus disabled:bg-ui-bg-disabled disabled:border-ui-border-base disabled:text-ui-fg-disabled disabled:shadow-buttons-neutral disabled:after:hidden txt-compact-small-plus px-3 py-1.5", children: saving ? "Saving..." : "Save settings" }),
|
|
203
199
|
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
|
|
204
200
|
] }),
|
|
205
201
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
206
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "
|
|
207
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
208
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
202
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Payment action", htmlFor: "as-payment-action", children: /* @__PURE__ */ jsxRuntime.jsxs("select", { id: "as-payment-action", value: form.paymentAction, onChange: (e) => setForm((p) => ({ ...p, paymentAction: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", children: [
|
|
203
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "capture", children: "Capture" }),
|
|
204
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "authorize", children: "Authorize" })
|
|
209
205
|
] }) }),
|
|
210
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "
|
|
211
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "
|
|
212
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
213
|
-
|
|
214
|
-
|
|
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" })
|
|
219
|
+
] }) }),
|
|
220
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Invoice prefix", htmlFor: "as-invoice-prefix", children: /* @__PURE__ */ jsxRuntime.jsx("input", { id: "as-invoice-prefix", value: form.invoicePrefix, onChange: (e) => setForm((p) => ({ ...p, invoicePrefix: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "PP-" }) }),
|
|
221
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Credit Card Statement Name", htmlFor: "as-cc-statement", children: /* @__PURE__ */ jsxRuntime.jsx("input", { id: "as-cc-statement", value: form.creditCardStatementName, onChange: (e) => setForm((p) => ({ ...p, creditCardStatementName: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "PayPal" }) })
|
|
215
222
|
] })
|
|
216
223
|
}
|
|
217
224
|
)
|
|
218
225
|
] }) });
|
|
219
226
|
}
|
|
220
227
|
const DEFAULT_FORM = {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
requireInstantPayment: false,
|
|
225
|
-
sendItemDetails: true,
|
|
226
|
-
invoicePrefix: "PP-",
|
|
227
|
-
creditCardStatementName: "PayPal"
|
|
228
|
+
enabled: true,
|
|
229
|
+
title: "Credit or Debit Card",
|
|
230
|
+
threeDS: "when_required"
|
|
228
231
|
};
|
|
229
232
|
function mergeWithDefaults(saved) {
|
|
230
233
|
if (!saved) return { ...DEFAULT_FORM };
|
|
231
234
|
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
232
235
|
return { ...DEFAULT_FORM, ...Object.fromEntries(entries) };
|
|
233
236
|
}
|
|
234
|
-
|
|
237
|
+
const THREE_DS_OPTIONS = [
|
|
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;
|
|
235
244
|
const [form, setForm] = react.useState(() => ({ ...DEFAULT_FORM }));
|
|
236
245
|
const [loading, setLoading] = react.useState(false);
|
|
237
246
|
const [saving, setSaving] = react.useState(false);
|
|
@@ -246,7 +255,7 @@ function AdditionalSettingsTab() {
|
|
|
246
255
|
setLoading(true);
|
|
247
256
|
const json = await adminFetch("/admin/paypal/settings");
|
|
248
257
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
249
|
-
const saved = payload == null ? void 0 : payload.
|
|
258
|
+
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
250
259
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
251
260
|
} catch {
|
|
252
261
|
} finally {
|
|
@@ -257,14 +266,16 @@ function AdditionalSettingsTab() {
|
|
|
257
266
|
async function onSave() {
|
|
258
267
|
try {
|
|
259
268
|
setSaving(true);
|
|
260
|
-
|
|
261
|
-
|
|
269
|
+
const json = await adminFetch("/admin/paypal/settings", {
|
|
270
|
+
method: "POST",
|
|
271
|
+
body: { advanced_card_payments: form }
|
|
272
|
+
});
|
|
262
273
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
263
|
-
const saved = payload == null ? void 0 : payload.
|
|
274
|
+
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
264
275
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
265
276
|
setToast({ kind: "success", message: "Settings saved" });
|
|
266
277
|
} catch (e) {
|
|
267
|
-
setToast({ kind: "error", message: e instanceof Error ? e.message : "Failed to save settings" });
|
|
278
|
+
setToast({ kind: "error", message: (e instanceof Error ? e.message : "") || "Failed to save settings." });
|
|
268
279
|
} finally {
|
|
269
280
|
setSaving(false);
|
|
270
281
|
}
|
|
@@ -276,33 +287,22 @@ function AdditionalSettingsTab() {
|
|
|
276
287
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
277
288
|
SectionCard,
|
|
278
289
|
{
|
|
279
|
-
title: "
|
|
280
|
-
description: "
|
|
290
|
+
title: "Advanced Card Payments",
|
|
291
|
+
description: "Control card checkout settings and 3D Secure behavior.",
|
|
281
292
|
right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
282
293
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onSave, disabled: saving || loading, className: "transition-fg relative inline-flex w-fit items-center justify-center overflow-hidden rounded-md outline-none shadow-buttons-neutral text-ui-fg-base bg-ui-button-neutral after:transition-fg after:absolute after:inset-0 after:content-[''] after:button-neutral-gradient hover:bg-ui-button-neutral-hover hover:after:button-neutral-hover-gradient active:bg-ui-button-neutral-pressed active:after:button-neutral-pressed-gradient focus-visible:shadow-buttons-neutral-focus disabled:bg-ui-bg-disabled disabled:border-ui-border-base disabled:text-ui-fg-disabled disabled:shadow-buttons-neutral disabled:after:hidden txt-compact-small-plus px-3 py-1.5", children: saving ? "Saving..." : "Save settings" }),
|
|
283
294
|
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
|
|
284
295
|
] }),
|
|
285
296
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
286
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "
|
|
287
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
288
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
289
|
-
] }) }),
|
|
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" })
|
|
297
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Enable/Disable", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
298
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.enabled, onChange: (e) => setForm((p) => ({ ...p, enabled: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
299
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
|
|
303
300
|
] }) }),
|
|
304
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "
|
|
305
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "
|
|
301
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Title", htmlFor: "acp-title", children: /* @__PURE__ */ jsxRuntime.jsx("input", { id: "acp-title", value: form.title, onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "Credit or Debit Card" }) }),
|
|
302
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Contingency for 3D Secure", hint: "Choose when 3D Secure should be triggered during card payments.", htmlFor: "acp-threeds", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
303
|
+
/* @__PURE__ */ jsxRuntime.jsx("select", { id: "acp-threeds", value: form.threeDS, onChange: (e) => setForm((p) => ({ ...p, threeDS: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", children: THREE_DS_OPTIONS.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value)) }),
|
|
304
|
+
((_a = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _a.hint) ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-ui-fg-subtle", children: (_b = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _b.hint }) : null
|
|
305
|
+
] }) })
|
|
306
306
|
] })
|
|
307
307
|
}
|
|
308
308
|
)
|
|
@@ -311,9 +311,6 @@ function AdditionalSettingsTab() {
|
|
|
311
311
|
function PayPalApplePayPage() {
|
|
312
312
|
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
313
313
|
}
|
|
314
|
-
function PayPalGooglePayPage() {
|
|
315
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
316
|
-
}
|
|
317
314
|
const config = adminSdk.defineRouteConfig({
|
|
318
315
|
label: "PayPal Connection"
|
|
319
316
|
});
|
|
@@ -1031,6 +1028,9 @@ function PayPalConnectionPage() {
|
|
|
1031
1028
|
` })
|
|
1032
1029
|
] });
|
|
1033
1030
|
}
|
|
1031
|
+
function PayPalGooglePayPage() {
|
|
1032
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
1033
|
+
}
|
|
1034
1034
|
function PayPalPayLaterMessagingPage() {
|
|
1035
1035
|
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
1036
1036
|
}
|
|
@@ -1248,26 +1248,26 @@ const routeModule = {
|
|
|
1248
1248
|
Component: PayPalSettingsIndexRoute,
|
|
1249
1249
|
path: "/settings/paypal"
|
|
1250
1250
|
},
|
|
1251
|
-
{
|
|
1252
|
-
Component: AdvancedCardPaymentsTab,
|
|
1253
|
-
path: "/settings/paypal/advanced-card-payments"
|
|
1254
|
-
},
|
|
1255
1251
|
{
|
|
1256
1252
|
Component: AdditionalSettingsTab,
|
|
1257
1253
|
path: "/settings/paypal/additional-settings"
|
|
1258
1254
|
},
|
|
1259
1255
|
{
|
|
1260
|
-
Component:
|
|
1261
|
-
path: "/settings/paypal/
|
|
1256
|
+
Component: AdvancedCardPaymentsTab,
|
|
1257
|
+
path: "/settings/paypal/advanced-card-payments"
|
|
1262
1258
|
},
|
|
1263
1259
|
{
|
|
1264
|
-
Component:
|
|
1265
|
-
path: "/settings/paypal/
|
|
1260
|
+
Component: PayPalApplePayPage,
|
|
1261
|
+
path: "/settings/paypal/apple-pay"
|
|
1266
1262
|
},
|
|
1267
1263
|
{
|
|
1268
1264
|
Component: PayPalConnectionPage,
|
|
1269
1265
|
path: "/settings/paypal/connection"
|
|
1270
1266
|
},
|
|
1267
|
+
{
|
|
1268
|
+
Component: PayPalGooglePayPage,
|
|
1269
|
+
path: "/settings/paypal/google-pay"
|
|
1270
|
+
},
|
|
1271
1271
|
{
|
|
1272
1272
|
Component: PayPalPayLaterMessagingPage,
|
|
1273
1273
|
path: "/settings/paypal/pay-later-messaging"
|
|
@@ -133,22 +133,20 @@ async function adminFetch(path, opts = {}) {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
const DEFAULT_FORM$1 = {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
paymentAction: "capture",
|
|
137
|
+
brandName: "PayPal",
|
|
138
|
+
landingPage: "no_preference",
|
|
139
|
+
requireInstantPayment: false,
|
|
140
|
+
sendItemDetails: true,
|
|
141
|
+
invoicePrefix: "PP-",
|
|
142
|
+
creditCardStatementName: "PayPal"
|
|
139
143
|
};
|
|
140
144
|
function mergeWithDefaults$1(saved) {
|
|
141
145
|
if (!saved) return { ...DEFAULT_FORM$1 };
|
|
142
146
|
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
143
147
|
return { ...DEFAULT_FORM$1, ...Object.fromEntries(entries) };
|
|
144
148
|
}
|
|
145
|
-
|
|
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;
|
|
149
|
+
function AdditionalSettingsTab() {
|
|
152
150
|
const [form, setForm] = useState(() => ({ ...DEFAULT_FORM$1 }));
|
|
153
151
|
const [loading, setLoading] = useState(false);
|
|
154
152
|
const [saving, setSaving] = useState(false);
|
|
@@ -163,7 +161,7 @@ function AdvancedCardPaymentsTab() {
|
|
|
163
161
|
setLoading(true);
|
|
164
162
|
const json = await adminFetch("/admin/paypal/settings");
|
|
165
163
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
166
|
-
const saved = payload == null ? void 0 : payload.
|
|
164
|
+
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
167
165
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
168
166
|
} catch {
|
|
169
167
|
} finally {
|
|
@@ -174,16 +172,14 @@ function AdvancedCardPaymentsTab() {
|
|
|
174
172
|
async function onSave() {
|
|
175
173
|
try {
|
|
176
174
|
setSaving(true);
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
body: { advanced_card_payments: form }
|
|
180
|
-
});
|
|
175
|
+
setToast(null);
|
|
176
|
+
const json = await adminFetch("/admin/paypal/settings", { method: "POST", body: { additional_settings: form } });
|
|
181
177
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
182
|
-
const saved = payload == null ? void 0 : payload.
|
|
178
|
+
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
183
179
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
184
180
|
setToast({ kind: "success", message: "Settings saved" });
|
|
185
181
|
} catch (e) {
|
|
186
|
-
setToast({ kind: "error", message:
|
|
182
|
+
setToast({ kind: "error", message: e instanceof Error ? e.message : "Failed to save settings" });
|
|
187
183
|
} finally {
|
|
188
184
|
setSaving(false);
|
|
189
185
|
}
|
|
@@ -195,42 +191,55 @@ function AdvancedCardPaymentsTab() {
|
|
|
195
191
|
/* @__PURE__ */ jsx(
|
|
196
192
|
SectionCard,
|
|
197
193
|
{
|
|
198
|
-
title: "
|
|
199
|
-
description: "
|
|
194
|
+
title: "Additional Settings",
|
|
195
|
+
description: "These settings control checkout behavior and PayPal experience.",
|
|
200
196
|
right: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
201
197
|
/* @__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" }),
|
|
202
198
|
loading ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
|
|
203
199
|
] }),
|
|
204
200
|
children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
205
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "
|
|
206
|
-
/* @__PURE__ */ jsx("
|
|
207
|
-
/* @__PURE__ */ jsx("
|
|
201
|
+
/* @__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: [
|
|
202
|
+
/* @__PURE__ */ jsx("option", { value: "capture", children: "Capture" }),
|
|
203
|
+
/* @__PURE__ */ jsx("option", { value: "authorize", children: "Authorize" })
|
|
208
204
|
] }) }),
|
|
209
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "
|
|
210
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "
|
|
211
|
-
/* @__PURE__ */ jsx("
|
|
212
|
-
|
|
213
|
-
|
|
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" })
|
|
218
|
+
] }) }),
|
|
219
|
+
/* @__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-" }) }),
|
|
220
|
+
/* @__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" }) })
|
|
214
221
|
] })
|
|
215
222
|
}
|
|
216
223
|
)
|
|
217
224
|
] }) });
|
|
218
225
|
}
|
|
219
226
|
const DEFAULT_FORM = {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
requireInstantPayment: false,
|
|
224
|
-
sendItemDetails: true,
|
|
225
|
-
invoicePrefix: "PP-",
|
|
226
|
-
creditCardStatementName: "PayPal"
|
|
227
|
+
enabled: true,
|
|
228
|
+
title: "Credit or Debit Card",
|
|
229
|
+
threeDS: "when_required"
|
|
227
230
|
};
|
|
228
231
|
function mergeWithDefaults(saved) {
|
|
229
232
|
if (!saved) return { ...DEFAULT_FORM };
|
|
230
233
|
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
231
234
|
return { ...DEFAULT_FORM, ...Object.fromEntries(entries) };
|
|
232
235
|
}
|
|
233
|
-
|
|
236
|
+
const THREE_DS_OPTIONS = [
|
|
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;
|
|
234
243
|
const [form, setForm] = useState(() => ({ ...DEFAULT_FORM }));
|
|
235
244
|
const [loading, setLoading] = useState(false);
|
|
236
245
|
const [saving, setSaving] = useState(false);
|
|
@@ -245,7 +254,7 @@ function AdditionalSettingsTab() {
|
|
|
245
254
|
setLoading(true);
|
|
246
255
|
const json = await adminFetch("/admin/paypal/settings");
|
|
247
256
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
248
|
-
const saved = payload == null ? void 0 : payload.
|
|
257
|
+
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
249
258
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
250
259
|
} catch {
|
|
251
260
|
} finally {
|
|
@@ -256,14 +265,16 @@ function AdditionalSettingsTab() {
|
|
|
256
265
|
async function onSave() {
|
|
257
266
|
try {
|
|
258
267
|
setSaving(true);
|
|
259
|
-
|
|
260
|
-
|
|
268
|
+
const json = await adminFetch("/admin/paypal/settings", {
|
|
269
|
+
method: "POST",
|
|
270
|
+
body: { advanced_card_payments: form }
|
|
271
|
+
});
|
|
261
272
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
262
|
-
const saved = payload == null ? void 0 : payload.
|
|
273
|
+
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
263
274
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
264
275
|
setToast({ kind: "success", message: "Settings saved" });
|
|
265
276
|
} catch (e) {
|
|
266
|
-
setToast({ kind: "error", message: e instanceof Error ? e.message : "Failed to save settings" });
|
|
277
|
+
setToast({ kind: "error", message: (e instanceof Error ? e.message : "") || "Failed to save settings." });
|
|
267
278
|
} finally {
|
|
268
279
|
setSaving(false);
|
|
269
280
|
}
|
|
@@ -275,33 +286,22 @@ function AdditionalSettingsTab() {
|
|
|
275
286
|
/* @__PURE__ */ jsx(
|
|
276
287
|
SectionCard,
|
|
277
288
|
{
|
|
278
|
-
title: "
|
|
279
|
-
description: "
|
|
289
|
+
title: "Advanced Card Payments",
|
|
290
|
+
description: "Control card checkout settings and 3D Secure behavior.",
|
|
280
291
|
right: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
281
292
|
/* @__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" }),
|
|
282
293
|
loading ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
|
|
283
294
|
] }),
|
|
284
295
|
children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
285
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "
|
|
286
|
-
/* @__PURE__ */ jsx("
|
|
287
|
-
/* @__PURE__ */ jsx("
|
|
288
|
-
] }) }),
|
|
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" })
|
|
296
|
+
/* @__PURE__ */ jsx(FieldRow, { label: "Enable/Disable", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
297
|
+
/* @__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" }),
|
|
298
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
|
|
302
299
|
] }) }),
|
|
303
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "
|
|
304
|
-
/* @__PURE__ */ jsx(FieldRow, { label: "
|
|
300
|
+
/* @__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" }) }),
|
|
301
|
+
/* @__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: [
|
|
302
|
+
/* @__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)) }),
|
|
303
|
+
((_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
|
|
304
|
+
] }) })
|
|
305
305
|
] })
|
|
306
306
|
}
|
|
307
307
|
)
|
|
@@ -310,9 +310,6 @@ function AdditionalSettingsTab() {
|
|
|
310
310
|
function PayPalApplePayPage() {
|
|
311
311
|
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
312
312
|
}
|
|
313
|
-
function PayPalGooglePayPage() {
|
|
314
|
-
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
315
|
-
}
|
|
316
313
|
const config = defineRouteConfig({
|
|
317
314
|
label: "PayPal Connection"
|
|
318
315
|
});
|
|
@@ -1030,6 +1027,9 @@ function PayPalConnectionPage() {
|
|
|
1030
1027
|
` })
|
|
1031
1028
|
] });
|
|
1032
1029
|
}
|
|
1030
|
+
function PayPalGooglePayPage() {
|
|
1031
|
+
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
1032
|
+
}
|
|
1033
1033
|
function PayPalPayLaterMessagingPage() {
|
|
1034
1034
|
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
1035
1035
|
}
|
|
@@ -1247,26 +1247,26 @@ const routeModule = {
|
|
|
1247
1247
|
Component: PayPalSettingsIndexRoute,
|
|
1248
1248
|
path: "/settings/paypal"
|
|
1249
1249
|
},
|
|
1250
|
-
{
|
|
1251
|
-
Component: AdvancedCardPaymentsTab,
|
|
1252
|
-
path: "/settings/paypal/advanced-card-payments"
|
|
1253
|
-
},
|
|
1254
1250
|
{
|
|
1255
1251
|
Component: AdditionalSettingsTab,
|
|
1256
1252
|
path: "/settings/paypal/additional-settings"
|
|
1257
1253
|
},
|
|
1258
1254
|
{
|
|
1259
|
-
Component:
|
|
1260
|
-
path: "/settings/paypal/
|
|
1255
|
+
Component: AdvancedCardPaymentsTab,
|
|
1256
|
+
path: "/settings/paypal/advanced-card-payments"
|
|
1261
1257
|
},
|
|
1262
1258
|
{
|
|
1263
|
-
Component:
|
|
1264
|
-
path: "/settings/paypal/
|
|
1259
|
+
Component: PayPalApplePayPage,
|
|
1260
|
+
path: "/settings/paypal/apple-pay"
|
|
1265
1261
|
},
|
|
1266
1262
|
{
|
|
1267
1263
|
Component: PayPalConnectionPage,
|
|
1268
1264
|
path: "/settings/paypal/connection"
|
|
1269
1265
|
},
|
|
1266
|
+
{
|
|
1267
|
+
Component: PayPalGooglePayPage,
|
|
1268
|
+
path: "/settings/paypal/google-pay"
|
|
1269
|
+
},
|
|
1270
1270
|
{
|
|
1271
1271
|
Component: PayPalPayLaterMessagingPage,
|
|
1272
1272
|
path: "/settings/paypal/pay-later-messaging"
|
|
@@ -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,wBAyDE"}
|
|
@@ -8,10 +8,19 @@ exports.default = (0, http_1.defineMiddlewares)({
|
|
|
8
8
|
// Keep the exact bytes PayPal signed (`req.rawBody`) so webhook signature
|
|
9
9
|
// verification hashes the original payload, not a re-serialized copy. This
|
|
10
10
|
// entry must precede the "/store/paypal/:path*" catch-all below.
|
|
11
|
+
// Rate-limited (opt-in, like the store routes): every unauthenticated
|
|
12
|
+
// POST here costs a DB dedup read plus an outbound PayPal
|
|
13
|
+
// verify-webhook-signature call, and a flood of garbage requests could
|
|
14
|
+
// trip the shared circuit breaker for legitimate verifications.
|
|
11
15
|
matcher: "/store/paypal/webhook",
|
|
12
16
|
method: ["POST"],
|
|
13
17
|
bodyParser: { preserveRawBody: true },
|
|
14
|
-
middlewares: [
|
|
18
|
+
middlewares: [
|
|
19
|
+
(0, rate_limit_1.createRateLimiter)("webhook", {
|
|
20
|
+
maxEnvVar: "PAYPAL_WEBHOOK_RATE_LIMIT_MAX",
|
|
21
|
+
windowEnvVar: "PAYPAL_WEBHOOK_RATE_LIMIT_WINDOW_MS",
|
|
22
|
+
}),
|
|
23
|
+
],
|
|
15
24
|
},
|
|
16
25
|
{
|
|
17
26
|
// Same raw-body requirement for the /hooks mirror of the webhook route —
|
|
@@ -20,7 +29,12 @@ exports.default = (0, http_1.defineMiddlewares)({
|
|
|
20
29
|
matcher: "/hooks/paypal/webhook",
|
|
21
30
|
method: ["POST"],
|
|
22
31
|
bodyParser: { preserveRawBody: true },
|
|
23
|
-
middlewares: [
|
|
32
|
+
middlewares: [
|
|
33
|
+
(0, rate_limit_1.createRateLimiter)("webhook-hooks", {
|
|
34
|
+
maxEnvVar: "PAYPAL_WEBHOOK_RATE_LIMIT_MAX",
|
|
35
|
+
windowEnvVar: "PAYPAL_WEBHOOK_RATE_LIMIT_WINDOW_MS",
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
24
38
|
},
|
|
25
39
|
{
|
|
26
40
|
// Rate-limit the order-creating route: unauthenticated by necessity, so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middlewares.js","sourceRoot":"","sources":["../../../../src/api/middlewares.ts"],"names":[],"mappings":";;AAAA,mDAA4D;AAC5D,mDAAsD;AAEtD,kBAAe,IAAA,wBAAiB,EAAC;IAC/B,MAAM,EAAE;QACN;YACE,0EAA0E;YAC1E,2EAA2E;YAC3E,iEAAiE;YACjE,OAAO,EAAE,uBAAuB;YAChC,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,UAAU,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE;YACrC,WAAW,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"middlewares.js","sourceRoot":"","sources":["../../../../src/api/middlewares.ts"],"names":[],"mappings":";;AAAA,mDAA4D;AAC5D,mDAAsD;AAEtD,kBAAe,IAAA,wBAAiB,EAAC;IAC/B,MAAM,EAAE;QACN;YACE,0EAA0E;YAC1E,2EAA2E;YAC3E,iEAAiE;YACjE,sEAAsE;YACtE,0DAA0D;YAC1D,uEAAuE;YACvE,gEAAgE;YAChE,OAAO,EAAE,uBAAuB;YAChC,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,UAAU,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE;YACrC,WAAW,EAAE;gBACX,IAAA,8BAAiB,EAAC,SAAS,EAAE;oBAC3B,SAAS,EAAE,+BAA+B;oBAC1C,YAAY,EAAE,qCAAqC;iBACpD,CAAC;aACH;SACF;QACD;YACE,yEAAyE;YACzE,qEAAqE;YACrE,uEAAuE;YACvE,OAAO,EAAE,uBAAuB;YAChC,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,UAAU,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE;YACrC,WAAW,EAAE;gBACX,IAAA,8BAAiB,EAAC,eAAe,EAAE;oBACjC,SAAS,EAAE,+BAA+B;oBAC1C,YAAY,EAAE,qCAAqC;iBACpD,CAAC;aACH;SACF;QACD;YACE,wEAAwE;YACxE,oEAAoE;YACpE,yEAAyE;YACzE,OAAO,EAAE,4BAA4B;YACrC,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,WAAW,EAAE,CAAC,IAAA,8BAAiB,EAAC,cAAc,CAAC,CAAC;SACjD;QACD;YACE,OAAO,EAAE,6BAA6B;YACtC,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,WAAW,EAAE,CAAC,IAAA,8BAAiB,EAAC,eAAe,CAAC,CAAC;SAClD;QACD;YACE,OAAO,EAAE,wBAAwB;YACjC,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,WAAW,EAAE,CAAC,IAAA,8BAAiB,EAAC,iBAAiB,CAAC,CAAC;SACpD;QACD;YACE,OAAO,EAAE,sBAAsB;YAC/B,WAAW,EAAE,EAAE;SAChB;KACF;CACF,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/capture-order/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/capture-order/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AA6K7E,wBAAsB,IAAI,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,2BAoMjE"}
|