@easypayment/medusa-payment-paypal 1.1.2 → 1.2.1

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.
Files changed (68) hide show
  1. package/.medusa/server/src/admin/index.js +73 -73
  2. package/.medusa/server/src/admin/index.mjs +73 -73
  3. package/.medusa/server/src/api/middlewares.d.ts.map +1 -1
  4. package/.medusa/server/src/api/middlewares.js +16 -2
  5. package/.medusa/server/src/api/middlewares.js.map +1 -1
  6. package/.medusa/server/src/api/store/paypal/capture-order/route.d.ts.map +1 -1
  7. package/.medusa/server/src/api/store/paypal/capture-order/route.js +66 -13
  8. package/.medusa/server/src/api/store/paypal/capture-order/route.js.map +1 -1
  9. package/.medusa/server/src/api/store/paypal/create-order/route.d.ts.map +1 -1
  10. package/.medusa/server/src/api/store/paypal/create-order/route.js +11 -6
  11. package/.medusa/server/src/api/store/paypal/create-order/route.js.map +1 -1
  12. package/.medusa/server/src/api/utils/rate-limit.d.ts +13 -1
  13. package/.medusa/server/src/api/utils/rate-limit.d.ts.map +1 -1
  14. package/.medusa/server/src/api/utils/rate-limit.js +7 -5
  15. package/.medusa/server/src/api/utils/rate-limit.js.map +1 -1
  16. package/.medusa/server/src/jobs/paypal-webhook-retry.d.ts.map +1 -1
  17. package/.medusa/server/src/jobs/paypal-webhook-retry.js +4 -0
  18. package/.medusa/server/src/jobs/paypal-webhook-retry.js.map +1 -1
  19. package/.medusa/server/src/modules/paypal/payment-provider/base-provider.d.ts +15 -0
  20. package/.medusa/server/src/modules/paypal/payment-provider/base-provider.d.ts.map +1 -1
  21. package/.medusa/server/src/modules/paypal/payment-provider/base-provider.js +26 -0
  22. package/.medusa/server/src/modules/paypal/payment-provider/base-provider.js.map +1 -1
  23. package/.medusa/server/src/modules/paypal/payment-provider/card-service.d.ts.map +1 -1
  24. package/.medusa/server/src/modules/paypal/payment-provider/card-service.js +244 -169
  25. package/.medusa/server/src/modules/paypal/payment-provider/card-service.js.map +1 -1
  26. package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts +0 -4
  27. package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts.map +1 -1
  28. package/.medusa/server/src/modules/paypal/payment-provider/service.js +8 -25
  29. package/.medusa/server/src/modules/paypal/payment-provider/service.js.map +1 -1
  30. package/.medusa/server/src/modules/paypal/service.d.ts +2 -0
  31. package/.medusa/server/src/modules/paypal/service.d.ts.map +1 -1
  32. package/.medusa/server/src/modules/paypal/service.js +54 -13
  33. package/.medusa/server/src/modules/paypal/service.js.map +1 -1
  34. package/.medusa/server/src/modules/paypal/types/config.d.ts.map +1 -1
  35. package/.medusa/server/src/modules/paypal/types/config.js +13 -0
  36. package/.medusa/server/src/modules/paypal/types/config.js.map +1 -1
  37. package/.medusa/server/src/modules/paypal/utils/amounts.d.ts +1 -1
  38. package/.medusa/server/src/modules/paypal/utils/credential-resolver.d.ts.map +1 -1
  39. package/.medusa/server/src/modules/paypal/utils/credential-resolver.js +10 -34
  40. package/.medusa/server/src/modules/paypal/utils/credential-resolver.js.map +1 -1
  41. package/.medusa/server/src/modules/paypal/utils/metrics.d.ts +18 -0
  42. package/.medusa/server/src/modules/paypal/utils/metrics.d.ts.map +1 -0
  43. package/.medusa/server/src/modules/paypal/utils/metrics.js +45 -0
  44. package/.medusa/server/src/modules/paypal/utils/metrics.js.map +1 -0
  45. package/.medusa/server/src/modules/paypal/webhook-processor.d.ts +16 -0
  46. package/.medusa/server/src/modules/paypal/webhook-processor.d.ts.map +1 -1
  47. package/.medusa/server/src/modules/paypal/webhook-processor.js +85 -2
  48. package/.medusa/server/src/modules/paypal/webhook-processor.js.map +1 -1
  49. package/.medusa/server/src/subscribers/paypal-webhook-process.d.ts.map +1 -1
  50. package/.medusa/server/src/subscribers/paypal-webhook-process.js +4 -0
  51. package/.medusa/server/src/subscribers/paypal-webhook-process.js.map +1 -1
  52. package/CHANGELOG.md +208 -146
  53. package/README.md +175 -184
  54. package/package.json +91 -88
  55. package/src/api/middlewares.ts +16 -2
  56. package/src/api/store/paypal/capture-order/route.ts +83 -12
  57. package/src/api/store/paypal/create-order/route.ts +11 -7
  58. package/src/api/utils/rate-limit.ts +20 -5
  59. package/src/jobs/paypal-webhook-retry.ts +4 -0
  60. package/src/modules/paypal/payment-provider/base-provider.ts +31 -0
  61. package/src/modules/paypal/payment-provider/card-service.ts +84 -0
  62. package/src/modules/paypal/payment-provider/service.ts +12 -30
  63. package/src/modules/paypal/service.ts +1703 -1651
  64. package/src/modules/paypal/types/config.ts +16 -0
  65. package/src/modules/paypal/utils/credential-resolver.ts +9 -36
  66. package/src/modules/paypal/utils/metrics.ts +48 -0
  67. package/src/modules/paypal/webhook-processor.ts +101 -2
  68. 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
- enabled: true,
138
- title: "Credit or Debit Card",
139
- threeDS: "when_required"
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
- 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;
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.advanced_card_payments;
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
- const json = await adminFetch("/admin/paypal/settings", {
179
- method: "POST",
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.advanced_card_payments;
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: (e instanceof Error ? e.message : "") || "Failed to save settings." });
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,58 @@ function AdvancedCardPaymentsTab() {
196
192
  /* @__PURE__ */ jsxRuntime.jsx(
197
193
  SectionCard,
198
194
  {
199
- title: "Advanced Card Payments",
200
- description: "Control card checkout settings and 3D Secure behavior.",
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: "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" })
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: "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
- ] }) })
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
  }
227
+ function PayPalApplePayPage() {
228
+ return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
229
+ }
220
230
  const DEFAULT_FORM = {
221
- paymentAction: "capture",
222
- brandName: "PayPal",
223
- landingPage: "no_preference",
224
- requireInstantPayment: false,
225
- sendItemDetails: true,
226
- invoicePrefix: "PP-",
227
- creditCardStatementName: "PayPal"
231
+ enabled: true,
232
+ title: "Credit or Debit Card",
233
+ threeDS: "when_required"
228
234
  };
229
235
  function mergeWithDefaults(saved) {
230
236
  if (!saved) return { ...DEFAULT_FORM };
231
237
  const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
232
238
  return { ...DEFAULT_FORM, ...Object.fromEntries(entries) };
233
239
  }
234
- function AdditionalSettingsTab() {
240
+ const THREE_DS_OPTIONS = [
241
+ { value: "when_required", label: "3D Secure when required", hint: "Triggers 3DS only when the card / issuer requires it." },
242
+ { value: "sli", label: "3D Secure (SCA) / liability shift (recommended)", hint: "Attempts to optimize for liability shift while remaining compliant." },
243
+ { value: "always", label: "Always request 3D Secure", hint: "Forces 3DS challenge whenever possible (may reduce conversion)." }
244
+ ];
245
+ function AdvancedCardPaymentsTab() {
246
+ var _a, _b;
235
247
  const [form, setForm] = react.useState(() => ({ ...DEFAULT_FORM }));
236
248
  const [loading, setLoading] = react.useState(false);
237
249
  const [saving, setSaving] = react.useState(false);
@@ -246,7 +258,7 @@ function AdditionalSettingsTab() {
246
258
  setLoading(true);
247
259
  const json = await adminFetch("/admin/paypal/settings");
248
260
  const payload = (json == null ? void 0 : json.data) ?? json;
249
- const saved = payload == null ? void 0 : payload.additional_settings;
261
+ const saved = payload == null ? void 0 : payload.advanced_card_payments;
250
262
  if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
251
263
  } catch {
252
264
  } finally {
@@ -257,14 +269,16 @@ function AdditionalSettingsTab() {
257
269
  async function onSave() {
258
270
  try {
259
271
  setSaving(true);
260
- setToast(null);
261
- const json = await adminFetch("/admin/paypal/settings", { method: "POST", body: { additional_settings: form } });
272
+ const json = await adminFetch("/admin/paypal/settings", {
273
+ method: "POST",
274
+ body: { advanced_card_payments: form }
275
+ });
262
276
  const payload = (json == null ? void 0 : json.data) ?? json;
263
- const saved = payload == null ? void 0 : payload.additional_settings;
277
+ const saved = payload == null ? void 0 : payload.advanced_card_payments;
264
278
  if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
265
279
  setToast({ kind: "success", message: "Settings saved" });
266
280
  } catch (e) {
267
- setToast({ kind: "error", message: e instanceof Error ? e.message : "Failed to save settings" });
281
+ setToast({ kind: "error", message: (e instanceof Error ? e.message : "") || "Failed to save settings." });
268
282
  } finally {
269
283
  setSaving(false);
270
284
  }
@@ -276,44 +290,27 @@ function AdditionalSettingsTab() {
276
290
  /* @__PURE__ */ jsxRuntime.jsx(
277
291
  SectionCard,
278
292
  {
279
- title: "Additional Settings",
280
- description: "These settings control checkout behavior and PayPal experience.",
293
+ title: "Advanced Card Payments",
294
+ description: "Control card checkout settings and 3D Secure behavior.",
281
295
  right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
282
296
  /* @__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
297
  loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
284
298
  ] }),
285
299
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
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" })
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" })
300
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Enable/Disable", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
301
+ /* @__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" }),
302
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
303
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" }) })
304
+ /* @__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" }) }),
305
+ /* @__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: [
306
+ /* @__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)) }),
307
+ ((_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
308
+ ] }) })
306
309
  ] })
307
310
  }
308
311
  )
309
312
  ] }) });
310
313
  }
311
- function PayPalApplePayPage() {
312
- return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
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,10 +1248,6 @@ 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"
@@ -1261,13 +1257,17 @@ const routeModule = {
1261
1257
  path: "/settings/paypal/apple-pay"
1262
1258
  },
1263
1259
  {
1264
- Component: PayPalGooglePayPage,
1265
- path: "/settings/paypal/google-pay"
1260
+ Component: AdvancedCardPaymentsTab,
1261
+ path: "/settings/paypal/advanced-card-payments"
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
- enabled: true,
137
- title: "Credit or Debit Card",
138
- threeDS: "when_required"
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
- 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;
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.advanced_card_payments;
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
- const json = await adminFetch("/admin/paypal/settings", {
178
- method: "POST",
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.advanced_card_payments;
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: (e instanceof Error ? e.message : "") || "Failed to save settings." });
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,58 @@ function AdvancedCardPaymentsTab() {
195
191
  /* @__PURE__ */ jsx(
196
192
  SectionCard,
197
193
  {
198
- title: "Advanced Card Payments",
199
- description: "Control card checkout settings and 3D Secure behavior.",
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: "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" })
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: "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
- ] }) })
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
  }
226
+ function PayPalApplePayPage() {
227
+ return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
228
+ }
219
229
  const DEFAULT_FORM = {
220
- paymentAction: "capture",
221
- brandName: "PayPal",
222
- landingPage: "no_preference",
223
- requireInstantPayment: false,
224
- sendItemDetails: true,
225
- invoicePrefix: "PP-",
226
- creditCardStatementName: "PayPal"
230
+ enabled: true,
231
+ title: "Credit or Debit Card",
232
+ threeDS: "when_required"
227
233
  };
228
234
  function mergeWithDefaults(saved) {
229
235
  if (!saved) return { ...DEFAULT_FORM };
230
236
  const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
231
237
  return { ...DEFAULT_FORM, ...Object.fromEntries(entries) };
232
238
  }
233
- function AdditionalSettingsTab() {
239
+ const THREE_DS_OPTIONS = [
240
+ { value: "when_required", label: "3D Secure when required", hint: "Triggers 3DS only when the card / issuer requires it." },
241
+ { value: "sli", label: "3D Secure (SCA) / liability shift (recommended)", hint: "Attempts to optimize for liability shift while remaining compliant." },
242
+ { value: "always", label: "Always request 3D Secure", hint: "Forces 3DS challenge whenever possible (may reduce conversion)." }
243
+ ];
244
+ function AdvancedCardPaymentsTab() {
245
+ var _a, _b;
234
246
  const [form, setForm] = useState(() => ({ ...DEFAULT_FORM }));
235
247
  const [loading, setLoading] = useState(false);
236
248
  const [saving, setSaving] = useState(false);
@@ -245,7 +257,7 @@ function AdditionalSettingsTab() {
245
257
  setLoading(true);
246
258
  const json = await adminFetch("/admin/paypal/settings");
247
259
  const payload = (json == null ? void 0 : json.data) ?? json;
248
- const saved = payload == null ? void 0 : payload.additional_settings;
260
+ const saved = payload == null ? void 0 : payload.advanced_card_payments;
249
261
  if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
250
262
  } catch {
251
263
  } finally {
@@ -256,14 +268,16 @@ function AdditionalSettingsTab() {
256
268
  async function onSave() {
257
269
  try {
258
270
  setSaving(true);
259
- setToast(null);
260
- const json = await adminFetch("/admin/paypal/settings", { method: "POST", body: { additional_settings: form } });
271
+ const json = await adminFetch("/admin/paypal/settings", {
272
+ method: "POST",
273
+ body: { advanced_card_payments: form }
274
+ });
261
275
  const payload = (json == null ? void 0 : json.data) ?? json;
262
- const saved = payload == null ? void 0 : payload.additional_settings;
276
+ const saved = payload == null ? void 0 : payload.advanced_card_payments;
263
277
  if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
264
278
  setToast({ kind: "success", message: "Settings saved" });
265
279
  } catch (e) {
266
- setToast({ kind: "error", message: e instanceof Error ? e.message : "Failed to save settings" });
280
+ setToast({ kind: "error", message: (e instanceof Error ? e.message : "") || "Failed to save settings." });
267
281
  } finally {
268
282
  setSaving(false);
269
283
  }
@@ -275,44 +289,27 @@ function AdditionalSettingsTab() {
275
289
  /* @__PURE__ */ jsx(
276
290
  SectionCard,
277
291
  {
278
- title: "Additional Settings",
279
- description: "These settings control checkout behavior and PayPal experience.",
292
+ title: "Advanced Card Payments",
293
+ description: "Control card checkout settings and 3D Secure behavior.",
280
294
  right: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
281
295
  /* @__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
296
  loading ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
283
297
  ] }),
284
298
  children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-ui-border-base", children: [
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" })
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" })
299
+ /* @__PURE__ */ jsx(FieldRow, { label: "Enable/Disable", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
300
+ /* @__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" }),
301
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
302
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" }) })
303
+ /* @__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" }) }),
304
+ /* @__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: [
305
+ /* @__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)) }),
306
+ ((_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
307
+ ] }) })
305
308
  ] })
306
309
  }
307
310
  )
308
311
  ] }) });
309
312
  }
310
- function PayPalApplePayPage() {
311
- return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
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,10 +1247,6 @@ 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"
@@ -1260,13 +1256,17 @@ const routeModule = {
1260
1256
  path: "/settings/paypal/apple-pay"
1261
1257
  },
1262
1258
  {
1263
- Component: PayPalGooglePayPage,
1264
- path: "/settings/paypal/google-pay"
1259
+ Component: AdvancedCardPaymentsTab,
1260
+ path: "/settings/paypal/advanced-card-payments"
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,wBA2CE"}
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;SAChB;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,EAAE;SAChB;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
+ {"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;AAsI7E,wBAAsB,IAAI,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,2BAoKjE"}
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"}