@easypayment/medusa-payment-paypal 0.9.3 → 0.9.5

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 (190) hide show
  1. package/.medusa/server/src/admin/index.d.ts +2 -0
  2. package/.medusa/server/src/admin/index.d.ts.map +1 -0
  3. package/.medusa/server/src/admin/index.js +242 -287
  4. package/.medusa/server/src/admin/index.js.map +1 -0
  5. package/.medusa/server/src/admin/index.mjs +243 -288
  6. package/.medusa/server/src/admin/routes/settings/paypal/_components/FieldRow.d.ts +8 -0
  7. package/.medusa/server/src/admin/routes/settings/paypal/_components/FieldRow.d.ts.map +1 -0
  8. package/.medusa/server/src/admin/routes/settings/paypal/_components/FieldRow.js +8 -0
  9. package/.medusa/server/src/admin/routes/settings/paypal/_components/FieldRow.js.map +1 -0
  10. package/.medusa/server/src/admin/routes/settings/paypal/_components/SectionCard.d.ts +8 -0
  11. package/.medusa/server/src/admin/routes/settings/paypal/_components/SectionCard.d.ts.map +1 -0
  12. package/.medusa/server/src/admin/routes/settings/paypal/_components/SectionCard.js +8 -0
  13. package/.medusa/server/src/admin/routes/settings/paypal/_components/SectionCard.js.map +1 -0
  14. package/.medusa/server/src/admin/routes/settings/paypal/_components/Tabs.d.ts +2 -0
  15. package/.medusa/server/src/admin/routes/settings/paypal/_components/Tabs.d.ts.map +1 -0
  16. package/.medusa/server/src/admin/routes/settings/paypal/_components/Tabs.js +25 -0
  17. package/.medusa/server/src/admin/routes/settings/paypal/_components/Tabs.js.map +1 -0
  18. package/.medusa/server/src/admin/routes/settings/paypal/_components/Toast.d.ts +12 -0
  19. package/.medusa/server/src/admin/routes/settings/paypal/_components/Toast.d.ts.map +1 -0
  20. package/.medusa/server/src/admin/routes/settings/paypal/_components/Toast.js +22 -0
  21. package/.medusa/server/src/admin/routes/settings/paypal/_components/Toast.js.map +1 -0
  22. package/.medusa/server/src/admin/routes/settings/paypal/_utils/adminFetch.d.ts +7 -0
  23. package/.medusa/server/src/admin/routes/settings/paypal/_utils/adminFetch.d.ts.map +1 -0
  24. package/.medusa/server/src/admin/routes/settings/paypal/_utils/adminFetch.js +40 -0
  25. package/.medusa/server/src/admin/routes/settings/paypal/_utils/adminFetch.js.map +1 -0
  26. package/.medusa/server/src/admin/routes/settings/paypal/additional-settings/page.d.ts +2 -0
  27. package/.medusa/server/src/admin/routes/settings/paypal/additional-settings/page.d.ts.map +1 -0
  28. package/.medusa/server/src/admin/routes/settings/paypal/additional-settings/page.js +76 -0
  29. package/.medusa/server/src/admin/routes/settings/paypal/additional-settings/page.js.map +1 -0
  30. package/.medusa/server/src/admin/routes/settings/paypal/advanced-card-payments/page.d.ts +2 -0
  31. package/.medusa/server/src/admin/routes/settings/paypal/advanced-card-payments/page.d.ts.map +1 -0
  32. package/.medusa/server/src/admin/routes/settings/paypal/advanced-card-payments/page.js +81 -0
  33. package/.medusa/server/src/admin/routes/settings/paypal/advanced-card-payments/page.js.map +1 -0
  34. package/.medusa/server/src/admin/routes/settings/paypal/apple-pay/page.d.ts +2 -0
  35. package/.medusa/server/src/admin/routes/settings/paypal/apple-pay/page.d.ts.map +1 -0
  36. package/.medusa/server/src/admin/routes/settings/paypal/apple-pay/page.js +9 -0
  37. package/.medusa/server/src/admin/routes/settings/paypal/apple-pay/page.js.map +1 -0
  38. package/.medusa/server/src/admin/routes/settings/paypal/connection/page.d.ts +20 -0
  39. package/.medusa/server/src/admin/routes/settings/paypal/connection/page.d.ts.map +1 -0
  40. package/.medusa/server/src/admin/routes/settings/paypal/connection/page.js +440 -0
  41. package/.medusa/server/src/admin/routes/settings/paypal/connection/page.js.map +1 -0
  42. package/.medusa/server/src/admin/routes/settings/paypal/google-pay/page.d.ts +2 -0
  43. package/.medusa/server/src/admin/routes/settings/paypal/google-pay/page.d.ts.map +1 -0
  44. package/.medusa/server/src/admin/routes/settings/paypal/google-pay/page.js +9 -0
  45. package/.medusa/server/src/admin/routes/settings/paypal/google-pay/page.js.map +1 -0
  46. package/.medusa/server/src/admin/routes/settings/paypal/page.d.ts +4 -0
  47. package/.medusa/server/src/admin/routes/settings/paypal/page.d.ts.map +1 -0
  48. package/.medusa/server/src/admin/routes/settings/paypal/page.js +14 -0
  49. package/.medusa/server/src/admin/routes/settings/paypal/page.js.map +1 -0
  50. package/.medusa/server/src/admin/routes/settings/paypal/pay-later-messaging/page.d.ts +2 -0
  51. package/.medusa/server/src/admin/routes/settings/paypal/pay-later-messaging/page.d.ts.map +1 -0
  52. package/.medusa/server/src/admin/routes/settings/paypal/pay-later-messaging/page.js +9 -0
  53. package/.medusa/server/src/admin/routes/settings/paypal/pay-later-messaging/page.js.map +1 -0
  54. package/.medusa/server/src/admin/routes/settings/paypal/paypal-settings/page.d.ts +2 -0
  55. package/.medusa/server/src/admin/routes/settings/paypal/paypal-settings/page.d.ts.map +1 -0
  56. package/.medusa/server/src/admin/routes/settings/paypal/paypal-settings/page.js +109 -0
  57. package/.medusa/server/src/admin/routes/settings/paypal/paypal-settings/page.js.map +1 -0
  58. package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.d.ts +1 -1
  59. package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.d.ts.map +1 -1
  60. package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.js +24 -9
  61. package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.js.map +1 -1
  62. package/.medusa/server/src/api/admin/paypal/disconnect/route.d.ts.map +1 -1
  63. package/.medusa/server/src/api/admin/paypal/disconnect/route.js +10 -3
  64. package/.medusa/server/src/api/admin/paypal/disconnect/route.js.map +1 -1
  65. package/.medusa/server/src/api/admin/paypal/environment/route.js +2 -2
  66. package/.medusa/server/src/api/admin/paypal/environment/route.js.map +1 -1
  67. package/.medusa/server/src/api/admin/paypal/onboard-complete/route.d.ts.map +1 -1
  68. package/.medusa/server/src/api/admin/paypal/onboard-complete/route.js +3 -2
  69. package/.medusa/server/src/api/admin/paypal/onboard-complete/route.js.map +1 -1
  70. package/.medusa/server/src/api/admin/paypal/onboarding-link/route.js +1 -1
  71. package/.medusa/server/src/api/admin/paypal/onboarding-link/route.js.map +1 -1
  72. package/.medusa/server/src/api/admin/paypal/onboarding-status/route.js +4 -4
  73. package/.medusa/server/src/api/admin/paypal/onboarding-status/route.js.map +1 -1
  74. package/.medusa/server/src/api/admin/paypal/save-credentials/route.d.ts.map +1 -1
  75. package/.medusa/server/src/api/admin/paypal/save-credentials/route.js +21 -8
  76. package/.medusa/server/src/api/admin/paypal/save-credentials/route.js.map +1 -1
  77. package/.medusa/server/src/api/admin/paypal/settings/route.d.ts.map +1 -1
  78. package/.medusa/server/src/api/admin/paypal/settings/route.js +34 -4
  79. package/.medusa/server/src/api/admin/paypal/settings/route.js.map +1 -1
  80. package/.medusa/server/src/api/admin/paypal/status/route.d.ts.map +1 -1
  81. package/.medusa/server/src/api/admin/paypal/status/route.js +11 -5
  82. package/.medusa/server/src/api/admin/paypal/status/route.js.map +1 -1
  83. package/.medusa/server/src/api/store/paypal/capture-order/route.d.ts.map +1 -1
  84. package/.medusa/server/src/api/store/paypal/capture-order/route.js +21 -3
  85. package/.medusa/server/src/api/store/paypal/capture-order/route.js.map +1 -1
  86. package/.medusa/server/src/api/store/paypal/config/route.js +2 -2
  87. package/.medusa/server/src/api/store/paypal/config/route.js.map +1 -1
  88. package/.medusa/server/src/api/store/paypal/create-order/route.d.ts.map +1 -1
  89. package/.medusa/server/src/api/store/paypal/create-order/route.js +13 -9
  90. package/.medusa/server/src/api/store/paypal/create-order/route.js.map +1 -1
  91. package/.medusa/server/src/api/store/paypal/settings/route.js +3 -3
  92. package/.medusa/server/src/api/store/paypal/settings/route.js.map +1 -1
  93. package/.medusa/server/src/api/store/paypal/webhook/route.d.ts.map +1 -1
  94. package/.medusa/server/src/api/store/paypal/webhook/route.js +10 -3
  95. package/.medusa/server/src/api/store/paypal/webhook/route.js.map +1 -1
  96. package/.medusa/server/src/api/store/paypal-complete/route.d.ts.map +1 -1
  97. package/.medusa/server/src/api/store/paypal-complete/route.js +7 -4
  98. package/.medusa/server/src/api/store/paypal-complete/route.js.map +1 -1
  99. package/.medusa/server/src/modules/paypal/clients/paypal-seller.client.js +3 -3
  100. package/.medusa/server/src/modules/paypal/clients/paypal-seller.client.js.map +1 -1
  101. package/.medusa/server/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.d.ts +1 -1
  102. package/.medusa/server/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.d.ts.map +1 -1
  103. package/.medusa/server/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.js +1 -1
  104. package/.medusa/server/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.js.map +1 -1
  105. package/.medusa/server/src/modules/paypal/migrations/20270102090000_add_paypal_seller_email.d.ts +1 -1
  106. package/.medusa/server/src/modules/paypal/migrations/20270102090000_add_paypal_seller_email.d.ts.map +1 -1
  107. package/.medusa/server/src/modules/paypal/migrations/20270102090000_add_paypal_seller_email.js +1 -1
  108. package/.medusa/server/src/modules/paypal/migrations/20270102090000_add_paypal_seller_email.js.map +1 -1
  109. package/.medusa/server/src/modules/paypal/migrations/20270103090000_add_paypal_seller_merchant_id.d.ts +1 -1
  110. package/.medusa/server/src/modules/paypal/migrations/20270103090000_add_paypal_seller_merchant_id.d.ts.map +1 -1
  111. package/.medusa/server/src/modules/paypal/migrations/20270103090000_add_paypal_seller_merchant_id.js +1 -1
  112. package/.medusa/server/src/modules/paypal/migrations/20270103090000_add_paypal_seller_merchant_id.js.map +1 -1
  113. package/.medusa/server/src/modules/paypal/migrations/20270202000000_align_nullable_defaults.d.ts +6 -0
  114. package/.medusa/server/src/modules/paypal/migrations/20270202000000_align_nullable_defaults.d.ts.map +1 -0
  115. package/.medusa/server/src/modules/paypal/migrations/20270202000000_align_nullable_defaults.js +25 -0
  116. package/.medusa/server/src/modules/paypal/migrations/20270202000000_align_nullable_defaults.js.map +1 -0
  117. package/.medusa/server/src/modules/paypal/models/paypal_connection.d.ts +1 -1
  118. package/.medusa/server/src/modules/paypal/models/paypal_connection.js +3 -3
  119. package/.medusa/server/src/modules/paypal/models/paypal_connection.js.map +1 -1
  120. package/.medusa/server/src/modules/paypal/models/paypal_metric.d.ts +1 -1
  121. package/.medusa/server/src/modules/paypal/models/paypal_metric.js +1 -1
  122. package/.medusa/server/src/modules/paypal/models/paypal_metric.js.map +1 -1
  123. package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.d.ts +1 -1
  124. package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.js +1 -1
  125. package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.js.map +1 -1
  126. package/.medusa/server/src/modules/paypal/payment-provider/card-service.d.ts.map +1 -1
  127. package/.medusa/server/src/modules/paypal/payment-provider/card-service.js +95 -76
  128. package/.medusa/server/src/modules/paypal/payment-provider/card-service.js.map +1 -1
  129. package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts.map +1 -1
  130. package/.medusa/server/src/modules/paypal/payment-provider/service.js +39 -89
  131. package/.medusa/server/src/modules/paypal/payment-provider/service.js.map +1 -1
  132. package/.medusa/server/src/modules/paypal/payment-provider/webhook-utils.d.ts.map +1 -1
  133. package/.medusa/server/src/modules/paypal/payment-provider/webhook-utils.js +7 -0
  134. package/.medusa/server/src/modules/paypal/payment-provider/webhook-utils.js.map +1 -1
  135. package/.medusa/server/src/modules/paypal/service.d.ts +10 -8
  136. package/.medusa/server/src/modules/paypal/service.d.ts.map +1 -1
  137. package/.medusa/server/src/modules/paypal/service.js +56 -51
  138. package/.medusa/server/src/modules/paypal/service.js.map +1 -1
  139. package/.medusa/server/src/modules/paypal/types/config.d.ts.map +1 -1
  140. package/.medusa/server/src/modules/paypal/types/config.js +11 -2
  141. package/.medusa/server/src/modules/paypal/types/config.js.map +1 -1
  142. package/.medusa/server/src/modules/paypal/utils/paypal-auth.d.ts.map +1 -1
  143. package/.medusa/server/src/modules/paypal/utils/paypal-auth.js +1 -0
  144. package/.medusa/server/src/modules/paypal/utils/paypal-auth.js.map +1 -1
  145. package/.medusa/server/src/modules/paypal/webhook-processor.d.ts.map +1 -1
  146. package/.medusa/server/src/modules/paypal/webhook-processor.js +1 -1
  147. package/.medusa/server/src/modules/paypal/webhook-processor.js.map +1 -1
  148. package/.medusa/server/src/subscribers/paypal-order-invoice.js +4 -4
  149. package/.medusa/server/src/subscribers/paypal-order-invoice.js.map +1 -1
  150. package/package.json +1 -1
  151. package/src/admin/index.ts +1 -7
  152. package/src/admin/routes/settings/paypal/_components/FieldRow.tsx +29 -0
  153. package/src/admin/routes/settings/paypal/_components/SectionCard.tsx +26 -0
  154. package/src/admin/routes/settings/paypal/_components/Toast.tsx +4 -3
  155. package/src/admin/routes/settings/paypal/_utils/adminFetch.ts +32 -0
  156. package/src/admin/routes/settings/paypal/additional-settings/page.tsx +23 -83
  157. package/src/admin/routes/settings/paypal/advanced-card-payments/page.tsx +17 -77
  158. package/src/admin/routes/settings/paypal/connection/page.tsx +86 -45
  159. package/src/admin/routes/settings/paypal/paypal-settings/page.tsx +23 -101
  160. package/src/api/admin/payment-collections/[id]/payment-sessions/route.ts +26 -9
  161. package/src/api/admin/paypal/disconnect/route.ts +9 -3
  162. package/src/api/admin/paypal/environment/route.ts +2 -2
  163. package/src/api/admin/paypal/onboard-complete/route.ts +4 -3
  164. package/src/api/admin/paypal/onboarding-link/route.ts +1 -1
  165. package/src/api/admin/paypal/onboarding-status/route.ts +5 -5
  166. package/src/api/admin/paypal/save-credentials/route.ts +24 -9
  167. package/src/api/admin/paypal/settings/route.ts +35 -4
  168. package/src/api/admin/paypal/status/route.ts +10 -5
  169. package/src/api/store/paypal/capture-order/route.ts +27 -3
  170. package/src/api/store/paypal/config/route.ts +2 -2
  171. package/src/api/store/paypal/create-order/route.ts +16 -10
  172. package/src/api/store/paypal/settings/route.ts +3 -3
  173. package/src/api/store/paypal/webhook/route.ts +13 -3
  174. package/src/api/store/paypal-complete/route.ts +8 -4
  175. package/src/modules/paypal/clients/paypal-seller.client.ts +3 -3
  176. package/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.ts +1 -1
  177. package/src/modules/paypal/migrations/20270102090000_add_paypal_seller_email.ts +1 -1
  178. package/src/modules/paypal/migrations/20270103090000_add_paypal_seller_merchant_id.ts +1 -1
  179. package/src/modules/paypal/migrations/20270202000000_align_nullable_defaults.ts +44 -0
  180. package/src/modules/paypal/models/paypal_connection.ts +3 -3
  181. package/src/modules/paypal/models/paypal_metric.ts +1 -1
  182. package/src/modules/paypal/models/paypal_webhook_event.ts +1 -1
  183. package/src/modules/paypal/payment-provider/card-service.ts +120 -80
  184. package/src/modules/paypal/payment-provider/service.ts +44 -93
  185. package/src/modules/paypal/payment-provider/webhook-utils.ts +9 -0
  186. package/src/modules/paypal/service.ts +79 -66
  187. package/src/modules/paypal/types/config.ts +18 -2
  188. package/src/modules/paypal/utils/paypal-auth.ts +1 -0
  189. package/src/modules/paypal/webhook-processor.ts +8 -5
  190. package/src/subscribers/paypal-order-invoice.ts +4 -4
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { defineRouteConfig } from "@medusajs/admin-sdk";
3
3
  import { Navigate, useLocation, Link } from "react-router-dom";
4
- import { useState, useRef, useEffect, useMemo, useCallback, useLayoutEffect } from "react";
4
+ import { useEffect, useState, useRef, useCallback, useMemo, useLayoutEffect } from "react";
5
5
  const config$1 = defineRouteConfig({
6
6
  label: "PayPal"
7
7
  });
@@ -33,7 +33,73 @@ function PayPalTabs() {
33
33
  );
34
34
  }) }) });
35
35
  }
36
- async function adminFetch$2(path, opts = {}) {
36
+ function SectionCard({
37
+ title,
38
+ description,
39
+ children,
40
+ right
41
+ }) {
42
+ return /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
43
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4 border-b border-ui-border-base p-4", children: [
44
+ /* @__PURE__ */ jsxs("div", { children: [
45
+ /* @__PURE__ */ jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: title }),
46
+ description ? /* @__PURE__ */ jsx("div", { className: "mt-1 text-sm text-ui-fg-subtle", children: description }) : null
47
+ ] }),
48
+ right
49
+ ] }),
50
+ /* @__PURE__ */ jsx("div", { className: "p-4", children })
51
+ ] });
52
+ }
53
+ function FieldRow({
54
+ label,
55
+ hint,
56
+ htmlFor,
57
+ children
58
+ }) {
59
+ return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-12 items-start gap-4 py-3", children: [
60
+ /* @__PURE__ */ jsxs("div", { className: "col-span-12 md:col-span-4", children: [
61
+ htmlFor ? /* @__PURE__ */ jsx("label", { htmlFor, className: "text-sm font-medium text-ui-fg-base", children: label }) : /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-ui-fg-base", children: label }),
62
+ hint ? /* @__PURE__ */ jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: hint }) : null
63
+ ] }),
64
+ /* @__PURE__ */ jsx("div", { className: "col-span-12 md:col-span-8", children })
65
+ ] });
66
+ }
67
+ function Toast({ toast, onClose }) {
68
+ useEffect(() => {
69
+ if (!toast) return;
70
+ const duration = toast.kind === "error" ? 5e3 : 2500;
71
+ const t = setTimeout(() => onClose(), duration);
72
+ return () => clearTimeout(t);
73
+ }, [toast, onClose]);
74
+ if (!toast) return null;
75
+ const isSuccess = toast.kind === "success";
76
+ return /* @__PURE__ */ jsx("div", { className: "fixed right-6 top-6 z-[9999]", children: /* @__PURE__ */ jsx(
77
+ "div",
78
+ {
79
+ className: [
80
+ "min-w-[280px] max-w-[420px] rounded-lg border px-4 py-3 shadow-md",
81
+ isSuccess ? "border-emerald-500/30 bg-emerald-500/10" : "border-rose-500/30 bg-rose-500/10"
82
+ ].join(" "),
83
+ role: isSuccess ? "status" : "alert",
84
+ "aria-live": isSuccess ? "polite" : "assertive",
85
+ children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
86
+ /* @__PURE__ */ jsx("div", { className: ["mt-0.5 h-2.5 w-2.5 rounded-full", isSuccess ? "bg-emerald-500" : "bg-rose-500"].join(" ") }),
87
+ /* @__PURE__ */ jsx("div", { className: "flex-1 text-sm text-ui-fg-base", children: toast.message }),
88
+ /* @__PURE__ */ jsx(
89
+ "button",
90
+ {
91
+ type: "button",
92
+ onClick: onClose,
93
+ className: "text-ui-fg-subtle hover:text-ui-fg-base",
94
+ "aria-label": "Close",
95
+ children: "×"
96
+ }
97
+ )
98
+ ] })
99
+ }
100
+ ) });
101
+ }
102
+ async function adminFetch(path, opts = {}) {
37
103
  var _a;
38
104
  const { method = "GET", body, query } = opts;
39
105
  let url = path;
@@ -67,57 +133,35 @@ async function adminFetch$2(path, opts = {}) {
67
133
  }
68
134
  }
69
135
  const DEFAULT_FORM$1 = {
70
- enabled: true,
71
- title: "Credit or Debit Card",
72
- 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"
73
143
  };
74
144
  function mergeWithDefaults$1(saved) {
75
145
  if (!saved) return { ...DEFAULT_FORM$1 };
76
146
  const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
77
147
  return { ...DEFAULT_FORM$1, ...Object.fromEntries(entries) };
78
148
  }
79
- const THREE_DS_OPTIONS = [
80
- { value: "when_required", label: "3D Secure when required", hint: "Triggers 3DS only when the card / issuer requires it." },
81
- { value: "sli", label: "3D Secure (SCA) / liability shift (recommended)", hint: "Attempts to optimize for liability shift while remaining compliant." },
82
- { value: "always", label: "Always request 3D Secure", hint: "Forces 3DS challenge whenever possible (may reduce conversion)." }
83
- ];
84
- function SectionCard$2({ title, description, right, children }) {
85
- return /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
86
- /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4 border-b border-ui-border-base p-4", children: [
87
- /* @__PURE__ */ jsxs("div", { children: [
88
- /* @__PURE__ */ jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: title }),
89
- description ? /* @__PURE__ */ jsx("div", { className: "mt-1 text-sm text-ui-fg-subtle", children: description }) : null
90
- ] }),
91
- right
92
- ] }),
93
- /* @__PURE__ */ jsx("div", { className: "p-4", children })
94
- ] });
95
- }
96
- function FieldRow$2({ label, hint, children }) {
97
- return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-12 items-start gap-4 py-3", children: [
98
- /* @__PURE__ */ jsxs("div", { className: "col-span-12 md:col-span-4", children: [
99
- /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-ui-fg-base", children: label }),
100
- hint ? /* @__PURE__ */ jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: hint }) : null
101
- ] }),
102
- /* @__PURE__ */ jsx("div", { className: "col-span-12 md:col-span-8", children })
103
- ] });
104
- }
105
- function AdvancedCardPaymentsTab() {
106
- var _a, _b;
149
+ function AdditionalSettingsTab() {
107
150
  const [form, setForm] = useState(() => ({ ...DEFAULT_FORM$1 }));
108
151
  const [loading, setLoading] = useState(false);
109
152
  const [saving, setSaving] = useState(false);
110
153
  const [toast, setToast] = useState(null);
111
154
  const didInit = useRef(false);
155
+ const dismissToast = useCallback(() => setToast(null), []);
112
156
  useEffect(() => {
113
157
  if (didInit.current) return;
114
158
  didInit.current = true;
115
159
  (async () => {
116
160
  try {
117
161
  setLoading(true);
118
- const json = await adminFetch$2("/admin/paypal/settings");
162
+ const json = await adminFetch("/admin/paypal/settings");
119
163
  const payload = (json == null ? void 0 : json.data) ?? json;
120
- const saved = payload == null ? void 0 : payload.advanced_card_payments;
164
+ const saved = payload == null ? void 0 : payload.additional_settings;
121
165
  if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
122
166
  } catch {
123
167
  } finally {
@@ -128,18 +172,14 @@ function AdvancedCardPaymentsTab() {
128
172
  async function onSave() {
129
173
  try {
130
174
  setSaving(true);
131
- const json = await adminFetch$2("/admin/paypal/settings", {
132
- method: "POST",
133
- body: { advanced_card_payments: form }
134
- });
175
+ setToast(null);
176
+ const json = await adminFetch("/admin/paypal/settings", { method: "POST", body: { additional_settings: form } });
135
177
  const payload = (json == null ? void 0 : json.data) ?? json;
136
- const saved = payload == null ? void 0 : payload.advanced_card_payments;
178
+ const saved = payload == null ? void 0 : payload.additional_settings;
137
179
  if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
138
- setToast({ type: "success", message: "Settings saved" });
139
- window.setTimeout(() => setToast(null), 2500);
180
+ setToast({ kind: "success", message: "Settings saved" });
140
181
  } catch (e) {
141
- setToast({ type: "error", message: (e instanceof Error ? e.message : "") || "Failed to save settings." });
142
- window.setTimeout(() => setToast(null), 3500);
182
+ setToast({ kind: "error", message: e instanceof Error ? e.message : "Failed to save settings" });
143
183
  } finally {
144
184
  setSaving(false);
145
185
  }
@@ -147,114 +187,77 @@ function AdvancedCardPaymentsTab() {
147
187
  return /* @__PURE__ */ jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
148
188
  /* @__PURE__ */ jsx("div", { className: "flex items-start justify-between gap-4", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Gateway By Easy Payment" }) }) }),
149
189
  /* @__PURE__ */ jsx(PayPalTabs, {}),
150
- toast ? /* @__PURE__ */ jsx("div", { className: "fixed right-6 top-6 z-50 rounded-md border border-ui-border-base bg-ui-bg-base px-4 py-3 text-sm shadow-lg", role: "status", "aria-live": "polite", children: /* @__PURE__ */ jsx("span", { className: toast.type === "success" ? "text-ui-fg-base" : "text-ui-fg-error", children: toast.message }) }) : null,
190
+ /* @__PURE__ */ jsx(Toast, { toast, onClose: dismissToast }),
151
191
  /* @__PURE__ */ jsx(
152
- SectionCard$2,
192
+ SectionCard,
153
193
  {
154
- title: "Advanced Card Payments",
155
- description: "Control card checkout settings and 3D Secure behavior.",
194
+ title: "Additional Settings",
195
+ description: "These settings control checkout behavior and PayPal experience.",
156
196
  right: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
157
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" }),
158
- loading ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading..." }) : null
198
+ loading ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading" }) : null
159
199
  ] }),
160
200
  children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-ui-border-base", children: [
161
- /* @__PURE__ */ jsx(FieldRow$2, { label: "Enable/Disable", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
162
- /* @__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" }),
163
- /* @__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" })
164
204
  ] }) }),
165
- /* @__PURE__ */ jsx(FieldRow$2, { label: "Title", children: /* @__PURE__ */ jsx("input", { 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" }) }),
166
- /* @__PURE__ */ jsx(FieldRow$2, { label: "Contingency for 3D Secure", hint: "Choose when 3D Secure should be triggered during card payments.", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
167
- /* @__PURE__ */ jsx("select", { 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)) }),
168
- ((_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
169
- ] }) })
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" }) })
170
221
  ] })
171
222
  }
172
223
  )
173
224
  ] }) });
174
225
  }
175
- async function adminFetch$1(path, opts = {}) {
176
- var _a;
177
- const { method = "GET", body, query } = opts;
178
- let url = path;
179
- if (query && Object.keys(query).length > 0) {
180
- const params = new URLSearchParams(query);
181
- url = `${path}?${params.toString()}`;
182
- }
183
- const headers = { Accept: "application/json" };
184
- if (body !== void 0) headers["Content-Type"] = "application/json";
185
- if (typeof window !== "undefined") {
186
- const token = (_a = window.__medusa__) == null ? void 0 : _a.token;
187
- if (token) headers["Authorization"] = `Bearer ${token}`;
188
- }
189
- const res = await fetch(url, {
190
- method,
191
- headers,
192
- credentials: "include",
193
- body: body !== void 0 ? JSON.stringify(body) : void 0
194
- });
195
- const text = await res.text().catch(() => "");
196
- if (!res.ok) {
197
- if (res.status === 401) throw new Error("Unauthorized (401) - session may have expired. Please reload and log in again.");
198
- if (res.status === 403) throw new Error("Forbidden (403) - you do not have permission to perform this action.");
199
- throw new Error(text || `Request failed with status ${res.status}`);
200
- }
201
- if (!text) return {};
202
- try {
203
- return JSON.parse(text);
204
- } catch {
205
- return {};
206
- }
226
+ function PayPalApplePayPage() {
227
+ return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
207
228
  }
208
229
  const DEFAULT_FORM = {
209
- paymentAction: "capture",
210
- brandName: "PayPal",
211
- landingPage: "no_preference",
212
- requireInstantPayment: false,
213
- sendItemDetails: true,
214
- invoicePrefix: "WC-",
215
- creditCardStatementName: "PayPal"
230
+ enabled: true,
231
+ title: "Credit or Debit Card",
232
+ threeDS: "when_required"
216
233
  };
217
234
  function mergeWithDefaults(saved) {
218
235
  if (!saved) return { ...DEFAULT_FORM };
219
236
  const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
220
237
  return { ...DEFAULT_FORM, ...Object.fromEntries(entries) };
221
238
  }
222
- function SectionCard$1({ title, description, right, children }) {
223
- return /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
224
- /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4 border-b border-ui-border-base p-4", children: [
225
- /* @__PURE__ */ jsxs("div", { children: [
226
- /* @__PURE__ */ jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: title }),
227
- description ? /* @__PURE__ */ jsx("div", { className: "mt-1 text-sm text-ui-fg-subtle", children: description }) : null
228
- ] }),
229
- right
230
- ] }),
231
- /* @__PURE__ */ jsx("div", { className: "p-4", children })
232
- ] });
233
- }
234
- function FieldRow$1({ label, hint, children }) {
235
- return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-12 items-start gap-4 py-3", children: [
236
- /* @__PURE__ */ jsxs("div", { className: "col-span-12 md:col-span-4", children: [
237
- /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-ui-fg-base", children: label }),
238
- hint ? /* @__PURE__ */ jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: hint }) : null
239
- ] }),
240
- /* @__PURE__ */ jsx("div", { className: "col-span-12 md:col-span-8", children })
241
- ] });
242
- }
243
- 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;
244
246
  const [form, setForm] = useState(() => ({ ...DEFAULT_FORM }));
245
247
  const [loading, setLoading] = useState(false);
246
248
  const [saving, setSaving] = useState(false);
247
249
  const [toast, setToast] = useState(null);
248
250
  const didInit = useRef(false);
251
+ const dismissToast = useCallback(() => setToast(null), []);
249
252
  useEffect(() => {
250
253
  if (didInit.current) return;
251
254
  didInit.current = true;
252
255
  (async () => {
253
256
  try {
254
257
  setLoading(true);
255
- const json = await adminFetch$1("/admin/paypal/settings");
258
+ const json = await adminFetch("/admin/paypal/settings");
256
259
  const payload = (json == null ? void 0 : json.data) ?? json;
257
- const saved = payload == null ? void 0 : payload.additional_settings;
260
+ const saved = payload == null ? void 0 : payload.advanced_card_payments;
258
261
  if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
259
262
  } catch {
260
263
  } finally {
@@ -265,16 +268,16 @@ function AdditionalSettingsTab() {
265
268
  async function onSave() {
266
269
  try {
267
270
  setSaving(true);
268
- setToast(null);
269
- const json = await adminFetch$1("/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
+ });
270
275
  const payload = (json == null ? void 0 : json.data) ?? json;
271
- const saved = payload == null ? void 0 : payload.additional_settings;
276
+ const saved = payload == null ? void 0 : payload.advanced_card_payments;
272
277
  if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
273
- setToast({ type: "success", message: "Settings saved" });
274
- window.setTimeout(() => setToast(null), 2500);
278
+ setToast({ kind: "success", message: "Settings saved" });
275
279
  } catch (e) {
276
- setToast({ type: "error", message: e instanceof Error ? e.message : "Failed to save settings" });
277
- window.setTimeout(() => setToast(null), 3500);
280
+ setToast({ kind: "error", message: (e instanceof Error ? e.message : "") || "Failed to save settings." });
278
281
  } finally {
279
282
  setSaving(false);
280
283
  }
@@ -282,75 +285,40 @@ function AdditionalSettingsTab() {
282
285
  return /* @__PURE__ */ jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
283
286
  /* @__PURE__ */ jsx("div", { className: "flex items-start justify-between gap-4", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Gateway By Easy Payment" }) }) }),
284
287
  /* @__PURE__ */ jsx(PayPalTabs, {}),
285
- toast ? /* @__PURE__ */ jsx("div", { className: "fixed right-6 top-6 z-50 rounded-md border border-ui-border-base bg-ui-bg-base px-4 py-3 text-sm shadow-lg", role: "status", "aria-live": "polite", children: /* @__PURE__ */ jsx("span", { className: toast.type === "success" ? "text-ui-fg-base" : "text-ui-fg-error", children: toast.message }) }) : null,
288
+ /* @__PURE__ */ jsx(Toast, { toast, onClose: dismissToast }),
286
289
  /* @__PURE__ */ jsx(
287
- SectionCard$1,
290
+ SectionCard,
288
291
  {
289
- title: "Additional Settings",
290
- description: "These settings control checkout behavior and PayPal experience.",
292
+ title: "Advanced Card Payments",
293
+ description: "Control card checkout settings and 3D Secure behavior.",
291
294
  right: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
292
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" }),
293
- loading ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading..." }) : null
296
+ loading ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading" }) : null
294
297
  ] }),
295
298
  children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-ui-border-base", children: [
296
- /* @__PURE__ */ jsx(FieldRow$1, { label: "Payment action", children: /* @__PURE__ */ jsxs("select", { 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: [
297
- /* @__PURE__ */ jsx("option", { value: "capture", children: "Capture" }),
298
- /* @__PURE__ */ jsx("option", { value: "authorize", children: "Authorize" })
299
- ] }) }),
300
- /* @__PURE__ */ jsx(FieldRow$1, { label: "Brand Name", children: /* @__PURE__ */ jsx("input", { 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" }) }),
301
- /* @__PURE__ */ jsx(FieldRow$1, { label: "Landing Page", children: /* @__PURE__ */ jsxs("select", { 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: [
302
- /* @__PURE__ */ jsx("option", { value: "no_preference", children: "No Preference" }),
303
- /* @__PURE__ */ jsx("option", { value: "login", children: "Login" }),
304
- /* @__PURE__ */ jsx("option", { value: "billing", children: "Billing" })
305
- ] }) }),
306
- /* @__PURE__ */ jsx(FieldRow$1, { label: "Instant Payments", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
307
- /* @__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" }),
308
- /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Require Instant Payment" })
309
- ] }) }),
310
- /* @__PURE__ */ jsx(FieldRow$1, { 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: [
311
- /* @__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" }),
312
- /* @__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" })
313
302
  ] }) }),
314
- /* @__PURE__ */ jsx(FieldRow$1, { label: "Invoice prefix", children: /* @__PURE__ */ jsx("input", { 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: "WC-" }) }),
315
- /* @__PURE__ */ jsx(FieldRow$1, { label: "Credit Card Statement Name", children: /* @__PURE__ */ jsx("input", { 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
+ ] }) })
316
308
  ] })
317
309
  }
318
310
  )
319
311
  ] }) });
320
312
  }
321
- function PayPalApplePayPage() {
313
+ function PayPalGooglePayPage() {
322
314
  return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
323
315
  }
324
316
  const config = defineRouteConfig({
325
- label: "PayPal Connection",
326
- hide: true
317
+ label: "PayPal Connection"
327
318
  });
328
- if (typeof window !== "undefined") {
329
- const preloadHref = "https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js";
330
- const existingPreload = document.head.querySelector(
331
- `link[rel="preload"][href="${preloadHref}"]`
332
- );
333
- if (!existingPreload) {
334
- const preloadLink = document.createElement("link");
335
- preloadLink.rel = "preload";
336
- preloadLink.href = preloadHref;
337
- preloadLink.as = "script";
338
- document.head.appendChild(preloadLink);
339
- }
340
- const existingScript = document.getElementById(
341
- "paypal-partner-js"
342
- );
343
- if (!existingScript) {
344
- const ppScript = document.createElement("script");
345
- ppScript.id = "paypal-partner-js";
346
- ppScript.src = preloadHref;
347
- ppScript.async = true;
348
- document.head.appendChild(ppScript);
349
- }
350
- }
319
+ const PARTNER_JS_URL = "https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js";
351
320
  const SERVICE_URL = "/admin/paypal/onboarding-link";
352
321
  const CACHE_KEY = "pp_onboard_cache";
353
- const RELOAD_KEY = "pp_onboard_reloaded_once";
354
322
  const CACHE_EXPIRY = 10 * 60 * 1e3;
355
323
  const ONBOARDING_COMPLETE_ENDPOINT = "/admin/paypal/onboard-complete";
356
324
  const STATUS_ENDPOINT = "/admin/paypal/status";
@@ -373,12 +341,45 @@ if (typeof window !== "undefined") {
373
341
  function PayPalConnectionPage() {
374
342
  const [env, setEnv] = useState("live");
375
343
  useEffect(() => {
376
- fetch("/admin/paypal/environment", { method: "GET" }).then((r) => r.json()).then((d) => {
344
+ fetch("/admin/paypal/environment", { method: "GET", credentials: "include" }).then((r) => r.json()).then((d) => {
377
345
  const v = (d == null ? void 0 : d.environment) === "sandbox" ? "sandbox" : "live";
378
346
  setEnv(v);
379
347
  }).catch(() => {
380
348
  });
381
349
  }, []);
350
+ useEffect(() => {
351
+ const preloadHref = PARTNER_JS_URL;
352
+ let preloadLink = null;
353
+ const existingPreload = document.head.querySelector(
354
+ `link[rel="preload"][href="${preloadHref}"]`
355
+ );
356
+ if (!existingPreload) {
357
+ preloadLink = document.createElement("link");
358
+ preloadLink.rel = "preload";
359
+ preloadLink.href = preloadHref;
360
+ preloadLink.as = "script";
361
+ document.head.appendChild(preloadLink);
362
+ }
363
+ let ppScript = null;
364
+ const existingScript = document.getElementById(
365
+ "paypal-partner-js"
366
+ );
367
+ if (!existingScript) {
368
+ ppScript = document.createElement("script");
369
+ ppScript.id = "paypal-partner-js";
370
+ ppScript.src = preloadHref;
371
+ ppScript.async = true;
372
+ document.head.appendChild(ppScript);
373
+ }
374
+ return () => {
375
+ if (preloadLink && preloadLink.parentNode) {
376
+ preloadLink.parentNode.removeChild(preloadLink);
377
+ }
378
+ if (ppScript && ppScript.parentNode) {
379
+ ppScript.parentNode.removeChild(ppScript);
380
+ }
381
+ };
382
+ }, []);
382
383
  const [connState, setConnState] = useState("loading");
383
384
  const [error, setError] = useState(null);
384
385
  const [finalUrl, setFinalUrl] = useState("");
@@ -407,10 +408,14 @@ function PayPalConnectionPage() {
407
408
  fetch(SERVICE_URL, {
408
409
  method: "POST",
409
410
  headers: { "content-type": "application/json" },
411
+ credentials: "include",
410
412
  body: JSON.stringify({
411
413
  products: ["PPCP"]
412
414
  })
413
- }).then((r) => r.json()).then((data) => {
415
+ }).then((r) => {
416
+ if (!r.ok) throw new Error(`Service returned ${r.status}`);
417
+ return r.json();
418
+ }).then((data) => {
414
419
  if (runId !== currentRunId.current) return;
415
420
  const href = data == null ? void 0 : data.onboarding_url;
416
421
  if (!href) {
@@ -425,11 +430,6 @@ function PayPalConnectionPage() {
425
430
  ts: Date.now()
426
431
  })
427
432
  );
428
- if (!localStorage.getItem(RELOAD_KEY)) {
429
- localStorage.setItem(RELOAD_KEY, "1");
430
- window.location.reload();
431
- return;
432
- }
433
433
  activatePayPal(finalUrl2, runId);
434
434
  }).catch(() => {
435
435
  if (runId !== currentRunId.current) return;
@@ -456,6 +456,8 @@ function PayPalConnectionPage() {
456
456
  paypalButtonRef.current.href = url;
457
457
  }
458
458
  setFinalUrl(url);
459
+ let attempts = 0;
460
+ const MAX_ATTEMPTS = 200;
459
461
  const tryInit = () => {
460
462
  var _a, _b;
461
463
  if (runId !== currentRunId.current) return;
@@ -463,6 +465,11 @@ function PayPalConnectionPage() {
463
465
  showUI();
464
466
  return;
465
467
  }
468
+ attempts++;
469
+ if (attempts >= MAX_ATTEMPTS) {
470
+ showError("PayPal partner script failed to load. Please refresh and try again.");
471
+ return;
472
+ }
466
473
  setTimeout(tryInit, 50);
467
474
  };
468
475
  tryInit();
@@ -479,7 +486,8 @@ function PayPalConnectionPage() {
479
486
  setFinalUrl("");
480
487
  try {
481
488
  const r = await fetch(`${STATUS_ENDPOINT}?environment=${env}`, {
482
- method: "GET"
489
+ method: "GET",
490
+ credentials: "include"
483
491
  });
484
492
  const st = await r.json().catch(() => ({}));
485
493
  if (cancelled || runId !== currentRunId.current) return;
@@ -509,8 +517,7 @@ function PayPalConnectionPage() {
509
517
  window.onboardingCallback = async function(authCode, sharedId) {
510
518
  var _a, _b, _c, _d, _e, _f, _g;
511
519
  try {
512
- ;
513
- window.onbeforeunload = "";
520
+ window.onbeforeunload = null;
514
521
  } catch {
515
522
  }
516
523
  setOnboardingInProgress(true);
@@ -525,6 +532,7 @@ function PayPalConnectionPage() {
525
532
  const res = await fetch(ONBOARDING_COMPLETE_ENDPOINT, {
526
533
  method: "POST",
527
534
  headers: { "content-type": "application/json" },
535
+ credentials: "include",
528
536
  body: JSON.stringify(payload)
529
537
  });
530
538
  if (!res.ok) {
@@ -543,10 +551,22 @@ function PayPalConnectionPage() {
543
551
  }
544
552
  try {
545
553
  localStorage.removeItem(CACHE_KEY);
546
- localStorage.removeItem(RELOAD_KEY);
547
554
  } catch {
548
555
  }
549
- window.location.href = window.location.href;
556
+ try {
557
+ const statusRes = await fetch(`${STATUS_ENDPOINT}?environment=${env}`, {
558
+ method: "GET",
559
+ credentials: "include"
560
+ });
561
+ const refreshedStatus = await statusRes.json().catch(() => ({}));
562
+ setStatusInfo(refreshedStatus || null);
563
+ setConnState("connected");
564
+ setShowManual(false);
565
+ } catch {
566
+ setConnState("connected");
567
+ setShowManual(false);
568
+ }
569
+ setOnboardingInProgress(false);
550
570
  } catch (e) {
551
571
  console.error(e);
552
572
  setConnState("error");
@@ -592,6 +612,7 @@ function PayPalConnectionPage() {
592
612
  const res = await fetch(SAVE_CREDENTIALS_ENDPOINT, {
593
613
  method: "POST",
594
614
  headers: { "content-type": "application/json" },
615
+ credentials: "include",
595
616
  body: JSON.stringify({
596
617
  clientId: clientId.trim(),
597
618
  clientSecret: secret.trim(),
@@ -603,7 +624,8 @@ function PayPalConnectionPage() {
603
624
  throw new Error(txt || `Save credentials failed (${res.status})`);
604
625
  }
605
626
  const statusRes = await fetch(`${STATUS_ENDPOINT}?environment=${env}`, {
606
- method: "GET"
627
+ method: "GET",
628
+ credentials: "include"
607
629
  });
608
630
  const refreshedStatus = await statusRes.json().catch(() => ({}));
609
631
  setConnState("connected");
@@ -611,7 +633,6 @@ function PayPalConnectionPage() {
611
633
  setShowManual(false);
612
634
  try {
613
635
  localStorage.removeItem(CACHE_KEY);
614
- localStorage.removeItem(RELOAD_KEY);
615
636
  } catch {
616
637
  }
617
638
  } catch (e) {
@@ -630,10 +651,12 @@ function PayPalConnectionPage() {
630
651
  setError(null);
631
652
  setFinalUrl("");
632
653
  setShowManual(false);
654
+ setStatusInfo(null);
633
655
  try {
634
656
  const res = await fetch(DISCONNECT_ENDPOINT, {
635
657
  method: "POST",
636
658
  headers: { "content-type": "application/json" },
659
+ credentials: "include",
637
660
  body: JSON.stringify({ environment: env })
638
661
  });
639
662
  if (!res.ok) {
@@ -642,7 +665,6 @@ function PayPalConnectionPage() {
642
665
  }
643
666
  try {
644
667
  localStorage.removeItem(CACHE_KEY);
645
- localStorage.removeItem(RELOAD_KEY);
646
668
  } catch {
647
669
  }
648
670
  currentRunId.current = ++runIdRef.current;
@@ -664,19 +686,19 @@ function PayPalConnectionPage() {
664
686
  await fetch("/admin/paypal/environment", {
665
687
  method: "POST",
666
688
  headers: { "content-type": "application/json" },
689
+ credentials: "include",
667
690
  body: JSON.stringify({ environment: next })
668
691
  });
669
692
  } catch {
670
693
  }
671
694
  try {
672
695
  localStorage.removeItem(CACHE_KEY);
673
- localStorage.removeItem(RELOAD_KEY);
674
696
  } catch {
675
697
  }
676
698
  };
677
699
  return /* @__PURE__ */ jsxs("div", { className: "p-6", children: [
678
700
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
679
- /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold", children: "PayPal Gateway By Easy Payment" }),
701
+ /* @__PURE__ */ jsx("div", { className: "flex items-start justify-between gap-4", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Gateway By Easy Payment" }) }) }),
680
702
  /* @__PURE__ */ jsx(PayPalTabs, {}),
681
703
  /* @__PURE__ */ jsx("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-y-6 p-4 md:grid-cols-[260px_1fr] md:items-start", children: [
682
704
  /* @__PURE__ */ jsx("div", { className: "text-sm font-medium pt-2", children: "Environment" }),
@@ -806,10 +828,11 @@ function PayPalConnectionPage() {
806
828
  ] }) }),
807
829
  showManual && /* @__PURE__ */ jsx("div", { className: "md:col-span-2", children: /* @__PURE__ */ jsxs("div", { className: "ml-[260px] max-w-xl mt-4 grid grid-cols-1 gap-3 md:grid-cols-2", children: [
808
830
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
809
- /* @__PURE__ */ jsx("label", { className: "text-sm font-medium", children: "Client ID" }),
831
+ /* @__PURE__ */ jsx("label", { htmlFor: "pp-manual-client-id", className: "text-sm font-medium", children: "Client ID" }),
810
832
  /* @__PURE__ */ jsx(
811
833
  "input",
812
834
  {
835
+ id: "pp-manual-client-id",
813
836
  type: "text",
814
837
  value: clientId,
815
838
  onChange: (e) => setClientId(e.target.value),
@@ -820,10 +843,11 @@ function PayPalConnectionPage() {
820
843
  )
821
844
  ] }),
822
845
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
823
- /* @__PURE__ */ jsx("label", { className: "text-sm font-medium", children: "Secret" }),
846
+ /* @__PURE__ */ jsx("label", { htmlFor: "pp-manual-secret", className: "text-sm font-medium", children: "Secret" }),
824
847
  /* @__PURE__ */ jsx(
825
848
  "input",
826
849
  {
850
+ id: "pp-manual-secret",
827
851
  type: "password",
828
852
  value: secret,
829
853
  onChange: (e) => setSecret(e.target.value),
@@ -914,45 +938,9 @@ function PayPalConnectionPage() {
914
938
  ` })
915
939
  ] });
916
940
  }
917
- function PayPalGooglePayPage() {
918
- return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
919
- }
920
941
  function PayPalPayLaterMessagingPage() {
921
942
  return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
922
943
  }
923
- async function adminFetch(path, opts = {}) {
924
- var _a;
925
- const { method = "GET", body, query } = opts;
926
- let url = path;
927
- if (query && Object.keys(query).length > 0) {
928
- const params = new URLSearchParams(query);
929
- url = `${path}?${params.toString()}`;
930
- }
931
- const headers = { Accept: "application/json" };
932
- if (body !== void 0) headers["Content-Type"] = "application/json";
933
- if (typeof window !== "undefined") {
934
- const token = (_a = window.__medusa__) == null ? void 0 : _a.token;
935
- if (token) headers["Authorization"] = `Bearer ${token}`;
936
- }
937
- const res = await fetch(url, {
938
- method,
939
- headers,
940
- credentials: "include",
941
- body: body !== void 0 ? JSON.stringify(body) : void 0
942
- });
943
- const text = await res.text().catch(() => "");
944
- if (!res.ok) {
945
- if (res.status === 401) throw new Error("Unauthorized (401) - session may have expired. Please reload and log in again.");
946
- if (res.status === 403) throw new Error("Forbidden (403) - you do not have permission to perform this action.");
947
- throw new Error(text || `Request failed with status ${res.status}`);
948
- }
949
- if (!text) return {};
950
- try {
951
- return JSON.parse(text);
952
- } catch {
953
- return {};
954
- }
955
- }
956
944
  const COLOR_OPTIONS = [
957
945
  { value: "gold", label: "Gold (Recommended)" },
958
946
  { value: "blue", label: "Blue" },
@@ -977,36 +965,6 @@ const LABEL_OPTIONS = [
977
965
  { value: "buynow", label: "Buy Now" },
978
966
  { value: "pay", label: "Pay" }
979
967
  ];
980
- function SectionCard({
981
- title,
982
- description,
983
- children,
984
- right
985
- }) {
986
- return /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
987
- /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4 border-b border-ui-border-base p-4", children: [
988
- /* @__PURE__ */ jsxs("div", { children: [
989
- /* @__PURE__ */ jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: title }),
990
- description ? /* @__PURE__ */ jsx("div", { className: "mt-1 text-sm text-ui-fg-subtle", children: description }) : null
991
- ] }),
992
- right
993
- ] }),
994
- /* @__PURE__ */ jsx("div", { className: "p-4", children })
995
- ] });
996
- }
997
- function FieldRow({
998
- label,
999
- hint,
1000
- children
1001
- }) {
1002
- return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-12 items-start gap-4 py-3", children: [
1003
- /* @__PURE__ */ jsxs("div", { className: "col-span-12 md:col-span-4", children: [
1004
- /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-ui-fg-base", children: label }),
1005
- hint ? /* @__PURE__ */ jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: hint }) : null
1006
- ] }),
1007
- /* @__PURE__ */ jsx("div", { className: "col-span-12 md:col-span-8", children })
1008
- ] });
1009
- }
1010
968
  function PayPalSettingsTab() {
1011
969
  const [form, setForm] = useState({
1012
970
  enabled: true,
@@ -1022,6 +980,7 @@ function PayPalSettingsTab() {
1022
980
  const [saving, setSaving] = useState(false);
1023
981
  const [toast, setToast] = useState(null);
1024
982
  const didInit = useRef(false);
983
+ const dismissToast = useCallback(() => setToast(null), []);
1025
984
  useEffect(() => {
1026
985
  if (didInit.current) return;
1027
986
  didInit.current = true;
@@ -1064,14 +1023,12 @@ function PayPalSettingsTab() {
1064
1023
  ...saved
1065
1024
  }));
1066
1025
  }
1067
- setToast({ type: "success", message: "Settings saved" });
1068
- window.setTimeout(() => setToast(null), 2500);
1026
+ setToast({ kind: "success", message: "Settings saved" });
1069
1027
  } catch (e) {
1070
1028
  setToast({
1071
- type: "error",
1029
+ kind: "error",
1072
1030
  message: (e instanceof Error ? e.message : "") || "Failed to save settings."
1073
1031
  });
1074
- window.setTimeout(() => setToast(null), 3500);
1075
1032
  } finally {
1076
1033
  setSaving(false);
1077
1034
  }
@@ -1082,15 +1039,7 @@ function PayPalSettingsTab() {
1082
1039
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2" })
1083
1040
  ] }),
1084
1041
  /* @__PURE__ */ jsx(PayPalTabs, {}),
1085
- toast ? /* @__PURE__ */ jsx(
1086
- "div",
1087
- {
1088
- className: "fixed right-6 top-6 z-50 rounded-md border border-ui-border-base bg-ui-bg-base px-4 py-3 text-sm shadow-lg",
1089
- role: "status",
1090
- "aria-live": "polite",
1091
- children: /* @__PURE__ */ jsx("span", { className: toast.type === "success" ? "text-ui-fg-base" : "text-ui-fg-error", children: toast.message })
1092
- }
1093
- ) : null,
1042
+ /* @__PURE__ */ jsx(Toast, { toast, onClose: dismissToast }),
1094
1043
  /* @__PURE__ */ jsx(
1095
1044
  SectionCard,
1096
1045
  {
@@ -1122,9 +1071,10 @@ function PayPalSettingsTab() {
1122
1071
  ),
1123
1072
  /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable PayPal" })
1124
1073
  ] }) }),
1125
- /* @__PURE__ */ jsx(FieldRow, { label: "Title", children: /* @__PURE__ */ jsx(
1074
+ /* @__PURE__ */ jsx(FieldRow, { label: "Title", htmlFor: "pp-title", children: /* @__PURE__ */ jsx(
1126
1075
  "input",
1127
1076
  {
1077
+ id: "pp-title",
1128
1078
  value: form.title,
1129
1079
  onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })),
1130
1080
  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",
@@ -1140,36 +1090,40 @@ function PayPalSettingsTab() {
1140
1090
  title: "Button Appearance",
1141
1091
  description: "Control PayPal Smart Button styling (color/shape/size/label).",
1142
1092
  children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-ui-border-base", children: [
1143
- /* @__PURE__ */ jsx(FieldRow, { label: "Button Color", children: /* @__PURE__ */ jsx(
1093
+ /* @__PURE__ */ jsx(FieldRow, { label: "Button Color", htmlFor: "pp-btn-color", children: /* @__PURE__ */ jsx(
1144
1094
  "select",
1145
1095
  {
1096
+ id: "pp-btn-color",
1146
1097
  value: form.buttonColor,
1147
1098
  onChange: (e) => setForm((p) => ({ ...p, buttonColor: e.target.value })),
1148
1099
  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",
1149
1100
  children: COLOR_OPTIONS.map((o) => /* @__PURE__ */ jsx("option", { value: o.value, children: o.label }, o.value))
1150
1101
  }
1151
1102
  ) }),
1152
- /* @__PURE__ */ jsx(FieldRow, { label: "Button Shape", children: /* @__PURE__ */ jsx(
1103
+ /* @__PURE__ */ jsx(FieldRow, { label: "Button Shape", htmlFor: "pp-btn-shape", children: /* @__PURE__ */ jsx(
1153
1104
  "select",
1154
1105
  {
1106
+ id: "pp-btn-shape",
1155
1107
  value: form.buttonShape,
1156
1108
  onChange: (e) => setForm((p) => ({ ...p, buttonShape: e.target.value })),
1157
1109
  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",
1158
1110
  children: SHAPE_OPTIONS.map((o) => /* @__PURE__ */ jsx("option", { value: o.value, children: o.label }, o.value))
1159
1111
  }
1160
1112
  ) }),
1161
- /* @__PURE__ */ jsx(FieldRow, { label: "Button Width", children: /* @__PURE__ */ jsx(
1113
+ /* @__PURE__ */ jsx(FieldRow, { label: "Button Width", htmlFor: "pp-btn-width", children: /* @__PURE__ */ jsx(
1162
1114
  "select",
1163
1115
  {
1116
+ id: "pp-btn-width",
1164
1117
  value: form.buttonWidth,
1165
1118
  onChange: (e) => setForm((p) => ({ ...p, buttonWidth: e.target.value })),
1166
1119
  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",
1167
1120
  children: WIDTH_OPTIONS.map((o) => /* @__PURE__ */ jsx("option", { value: o.value, children: o.label }, o.value))
1168
1121
  }
1169
1122
  ) }),
1170
- /* @__PURE__ */ jsx(FieldRow, { label: "Button Height", children: /* @__PURE__ */ jsx(
1123
+ /* @__PURE__ */ jsx(FieldRow, { label: "Button Height", htmlFor: "pp-btn-height", children: /* @__PURE__ */ jsx(
1171
1124
  "select",
1172
1125
  {
1126
+ id: "pp-btn-height",
1173
1127
  value: String(form.buttonHeight),
1174
1128
  onChange: (e) => setForm((p) => ({ ...p, buttonHeight: Number(e.target.value) })),
1175
1129
  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",
@@ -1179,9 +1133,10 @@ function PayPalSettingsTab() {
1179
1133
  ] }, h))
1180
1134
  }
1181
1135
  ) }),
1182
- /* @__PURE__ */ jsx(FieldRow, { label: "Button Label", children: /* @__PURE__ */ jsx(
1136
+ /* @__PURE__ */ jsx(FieldRow, { label: "Button Label", htmlFor: "pp-btn-label", children: /* @__PURE__ */ jsx(
1183
1137
  "select",
1184
1138
  {
1139
+ id: "pp-btn-label",
1185
1140
  value: form.buttonLabel,
1186
1141
  onChange: (e) => setForm((p) => ({ ...p, buttonLabel: e.target.value })),
1187
1142
  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",
@@ -1200,10 +1155,6 @@ const routeModule = {
1200
1155
  Component: PayPalSettingsIndexRoute,
1201
1156
  path: "/settings/paypal"
1202
1157
  },
1203
- {
1204
- Component: AdvancedCardPaymentsTab,
1205
- path: "/settings/paypal/advanced-card-payments"
1206
- },
1207
1158
  {
1208
1159
  Component: AdditionalSettingsTab,
1209
1160
  path: "/settings/paypal/additional-settings"
@@ -1213,13 +1164,17 @@ const routeModule = {
1213
1164
  path: "/settings/paypal/apple-pay"
1214
1165
  },
1215
1166
  {
1216
- Component: PayPalConnectionPage,
1217
- path: "/settings/paypal/connection"
1167
+ Component: AdvancedCardPaymentsTab,
1168
+ path: "/settings/paypal/advanced-card-payments"
1218
1169
  },
1219
1170
  {
1220
1171
  Component: PayPalGooglePayPage,
1221
1172
  path: "/settings/paypal/google-pay"
1222
1173
  },
1174
+ {
1175
+ Component: PayPalConnectionPage,
1176
+ path: "/settings/paypal/connection"
1177
+ },
1223
1178
  {
1224
1179
  Component: PayPalPayLaterMessagingPage,
1225
1180
  path: "/settings/paypal/pay-later-messaging"