@easypayment/medusa-paypal 0.4.1 → 0.4.3

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 (31) hide show
  1. package/.medusa/server/src/admin/index.js +54 -135
  2. package/.medusa/server/src/admin/index.mjs +54 -135
  3. package/.medusa/server/src/api/admin/paypal/environment/route.js +1 -1
  4. package/.medusa/server/src/api/admin/paypal/environment/route.js.map +1 -1
  5. package/.medusa/server/src/api/admin/paypal/onboarding-status/route.js +1 -1
  6. package/.medusa/server/src/api/admin/paypal/onboarding-status/route.js.map +1 -1
  7. package/.medusa/server/src/api/store/paypal/config/route.d.ts.map +1 -1
  8. package/.medusa/server/src/api/store/paypal/config/route.js +0 -4
  9. package/.medusa/server/src/api/store/paypal/config/route.js.map +1 -1
  10. package/.medusa/server/src/api/store/paypal/create-order/route.d.ts.map +1 -1
  11. package/.medusa/server/src/api/store/paypal/create-order/route.js +32 -6
  12. package/.medusa/server/src/api/store/paypal/create-order/route.js.map +1 -1
  13. package/.medusa/server/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.d.ts +6 -0
  14. package/.medusa/server/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.d.ts.map +1 -0
  15. package/.medusa/server/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.js +14 -0
  16. package/.medusa/server/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.js.map +1 -0
  17. package/.medusa/server/src/modules/paypal/service.d.ts +2 -4
  18. package/.medusa/server/src/modules/paypal/service.d.ts.map +1 -1
  19. package/.medusa/server/src/modules/paypal/service.js +8 -46
  20. package/.medusa/server/src/modules/paypal/service.js.map +1 -1
  21. package/README.md +130 -102
  22. package/package.json +1 -1
  23. package/src/admin/routes/settings/paypal/additional-settings/page.tsx +0 -2
  24. package/src/admin/routes/settings/paypal/connection/page.tsx +25 -21
  25. package/src/admin/routes/settings/paypal/paypal-settings/page.tsx +3 -126
  26. package/src/api/admin/paypal/environment/route.ts +1 -1
  27. package/src/api/admin/paypal/onboarding-status/route.ts +1 -1
  28. package/src/api/store/paypal/config/route.ts +0 -4
  29. package/src/api/store/paypal/create-order/route.ts +34 -7
  30. package/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.ts +11 -0
  31. package/src/modules/paypal/service.ts +9 -51
@@ -77,8 +77,7 @@ const DEFAULT_FORM$1 = {
77
77
  requireInstantPayment: false,
78
78
  sendItemDetails: true,
79
79
  invoicePrefix: "WC-",
80
- creditCardStatementName: "PayPal",
81
- logPath: "/uploads/wc-logs/"
80
+ creditCardStatementName: "PayPal"
82
81
  };
83
82
  function mergeWithDefaults$1(saved) {
84
83
  if (!saved) return { ...DEFAULT_FORM$1 };
@@ -376,10 +375,10 @@ if (typeof window !== "undefined") {
376
375
  }
377
376
  }
378
377
  function PayPalConnectionPage() {
379
- const [env, setEnv] = react.useState("sandbox");
378
+ const [env, setEnv] = react.useState("live");
380
379
  react.useEffect(() => {
381
380
  fetch("/admin/paypal/environment", { method: "GET" }).then((r) => r.json()).then((d) => {
382
- const v = (d == null ? void 0 : d.environment) === "live" ? "live" : "sandbox";
381
+ const v = (d == null ? void 0 : d.environment) === "sandbox" ? "sandbox" : "live";
383
382
  setEnv(v);
384
383
  }).catch(() => {
385
384
  });
@@ -390,7 +389,6 @@ function PayPalConnectionPage() {
390
389
  const [showManual, setShowManual] = react.useState(false);
391
390
  const [clientId, setClientId] = react.useState("");
392
391
  const [secret, setSecret] = react.useState("");
393
- const [merchantId, setMerchantId] = react.useState("");
394
392
  const [statusInfo, setStatusInfo] = react.useState(null);
395
393
  const [onboardingInProgress, setOnboardingInProgress] = react.useState(false);
396
394
  const initLoaderRef = react.useRef(null);
@@ -707,7 +705,7 @@ function PayPalConnectionPage() {
707
705
  ]
708
706
  }
709
707
  ) }),
710
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium pt-2", children: env === "sandbox" ? "Connect to PayPal Sandbox" : "Connect to PayPal Live" }),
708
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium pt-2", children: env === "sandbox" ? "Connect to PayPal (Sandbox)" : "Connect to PayPal" }),
711
709
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-xl", children: connState === "connected" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
712
710
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm text-green-600 bg-green-50 p-3 rounded border border-green-200", children: [
713
711
  "✅ Successfully connected to PayPal!",
@@ -766,13 +764,8 @@ function PayPalConnectionPage() {
766
764
  href: finalUrl || "#",
767
765
  "data-paypal-onboard-complete": "onboardingCallback",
768
766
  onClick: handleConnectClick,
769
- className: "btn-paypal",
767
+ className: "btn-paypal inline-flex items-center justify-center rounded-full bg-[#FFC439] px-6 py-2 text-sm font-semibold text-[#111827] no-underline shadow-sm transition hover:bg-[#f7b916]",
770
768
  style: {
771
- borderRadius: "50px",
772
- textDecoration: "none",
773
- display: "inline-block",
774
- fontWeight: "bold",
775
- border: "none",
776
769
  cursor: onboardingInProgress ? "not-allowed" : "pointer",
777
770
  opacity: onboardingInProgress ? 0.6 : 1,
778
771
  pointerEvents: onboardingInProgress ? "none" : "auto"
@@ -839,7 +832,7 @@ function PayPalConnectionPage() {
839
832
  )
840
833
  ] }),
841
834
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
842
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Client Secret" }),
835
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Secret" }),
843
836
  /* @__PURE__ */ jsxRuntime.jsx(
844
837
  "input",
845
838
  {
@@ -852,19 +845,42 @@ function PayPalConnectionPage() {
852
845
  }
853
846
  )
854
847
  ] }),
855
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:col-span-2", children: [
856
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Merchant ID (optional)" }),
857
- /* @__PURE__ */ jsxRuntime.jsx(
858
- "input",
859
- {
860
- type: "text",
861
- value: merchantId,
862
- onChange: (e) => setMerchantId(e.target.value),
863
- disabled: onboardingInProgress,
864
- className: "rounded-md border border-ui-border-base bg-transparent px-3 py-2 text-sm disabled:opacity-50",
865
- placeholder: "Merchant ID"
866
- }
867
- )
848
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "md:col-span-2 rounded-md border border-ui-border-base bg-ui-bg-subtle p-4 text-sm text-ui-fg-subtle", children: [
849
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium text-ui-fg-base", children: "Get your Client ID and Client Secret in 3 steps:" }),
850
+ /* @__PURE__ */ jsxRuntime.jsxs("ol", { className: "mt-2 list-decimal space-y-2 pl-5", children: [
851
+ /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
852
+ "Open",
853
+ " ",
854
+ /* @__PURE__ */ jsxRuntime.jsx(
855
+ "a",
856
+ {
857
+ href: "https://developer.paypal.com/dashboard/",
858
+ target: "_blank",
859
+ rel: "noreferrer",
860
+ className: "text-ui-fg-interactive underline",
861
+ children: "Log in to Dashboard"
862
+ }
863
+ ),
864
+ " ",
865
+ "and sign in or create an account."
866
+ ] }),
867
+ /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
868
+ "Select ",
869
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-ui-fg-base", children: "Apps & Credentials" }),
870
+ ", then choose ",
871
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-ui-fg-base", children: "Create App" }),
872
+ " if you need a new project."
873
+ ] }),
874
+ /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
875
+ "Copy your app's ",
876
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-ui-fg-base", children: "Client ID" }),
877
+ " and ",
878
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-ui-fg-base", children: "Client Secret" }),
879
+ ", paste them above, then click ",
880
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-ui-fg-base", children: "Save credentials" }),
881
+ "."
882
+ ] })
883
+ ] })
868
884
  ] }),
869
885
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "md:col-span-2 flex items-center gap-2 mt-2", children: [
870
886
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -913,6 +929,9 @@ function PayPalConnectionPage() {
913
929
  function PayPalGooglePayPage() {
914
930
  return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
915
931
  }
932
+ function PayPalPayLaterMessagingPage() {
933
+ return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
934
+ }
916
935
  async function adminFetch(path, opts = {}) {
917
936
  var _a;
918
937
  const { method = "GET", body, query } = opts;
@@ -946,21 +965,6 @@ async function adminFetch(path, opts = {}) {
946
965
  return {};
947
966
  }
948
967
  }
949
- const DISABLE_BUTTON_OPTIONS = [
950
- { value: "paypal", label: "PayPal" },
951
- { value: "paylater", label: "Pay Later" },
952
- { value: "card", label: "Debit / Credit Card" },
953
- { value: "venmo", label: "Venmo" },
954
- { value: "applepay", label: "Apple Pay" },
955
- { value: "googlepay", label: "Google Pay" }
956
- ];
957
- const HIDDEN_DISABLE_BUTTONS = /* @__PURE__ */ new Set(["applepay", "googlepay", "paylater"]);
958
- const VISIBLE_DISABLE_BUTTON_OPTIONS = DISABLE_BUTTON_OPTIONS.filter(
959
- (option) => !HIDDEN_DISABLE_BUTTONS.has(option.value)
960
- );
961
- function filterHiddenDisableButtons(list = []) {
962
- return list.filter((value) => !HIDDEN_DISABLE_BUTTONS.has(value));
963
- }
964
968
  const COLOR_OPTIONS = [
965
969
  { value: "gold", label: "Gold (Recommended)" },
966
970
  { value: "blue", label: "Blue" },
@@ -980,42 +984,11 @@ const WIDTH_OPTIONS = [
980
984
  ];
981
985
  const HEIGHT_OPTIONS = [32, 36, 40, 44, 48, 52, 56];
982
986
  const LABEL_OPTIONS = [
983
- { value: "paypal", label: "PayPal (Recommended)" },
987
+ { value: "paypal", label: "PayPal" },
984
988
  { value: "checkout", label: "Checkout" },
985
989
  { value: "buynow", label: "Buy Now" },
986
990
  { value: "pay", label: "Pay" }
987
991
  ];
988
- function cx(...parts) {
989
- return parts.filter(Boolean).join(" ");
990
- }
991
- function Pill({
992
- children,
993
- onRemove,
994
- disabled
995
- }) {
996
- return /* @__PURE__ */ jsxRuntime.jsxs(
997
- "span",
998
- {
999
- className: cx(
1000
- "inline-flex items-center gap-1 rounded-md border px-2 py-1 text-sm",
1001
- disabled ? "opacity-60" : "opacity-100"
1002
- ),
1003
- children: [
1004
- children,
1005
- onRemove ? /* @__PURE__ */ jsxRuntime.jsx(
1006
- "button",
1007
- {
1008
- type: "button",
1009
- onClick: onRemove,
1010
- className: "ml-1 rounded px-1 text-ui-fg-subtle hover:text-ui-fg-base",
1011
- "aria-label": "Remove",
1012
- children: "×"
1013
- }
1014
- ) : null
1015
- ]
1016
- }
1017
- );
1018
- }
1019
992
  function SectionCard({
1020
993
  title,
1021
994
  description,
@@ -1051,7 +1024,6 @@ function PayPalSettingsTab() {
1051
1024
  enabled: true,
1052
1025
  title: "PayPal",
1053
1026
  description: "Pay via PayPal; you can pay with your credit card if you don't have a PayPal account",
1054
- disableButtons: [],
1055
1027
  buttonColor: "gold",
1056
1028
  buttonShape: "rect",
1057
1029
  buttonWidth: "medium",
@@ -1076,8 +1048,7 @@ function PayPalSettingsTab() {
1076
1048
  if (saved && typeof saved === "object") {
1077
1049
  setForm((prev) => ({
1078
1050
  ...prev,
1079
- ...saved,
1080
- disableButtons: filterHiddenDisableButtons(saved.disableButtons)
1051
+ ...saved
1081
1052
  }));
1082
1053
  }
1083
1054
  } catch {
@@ -1089,10 +1060,7 @@ function PayPalSettingsTab() {
1089
1060
  async function onSave() {
1090
1061
  try {
1091
1062
  setSaving(true);
1092
- const cleaned = {
1093
- ...form,
1094
- disableButtons: filterHiddenDisableButtons(form.disableButtons)
1095
- };
1063
+ const cleaned = { ...form };
1096
1064
  const json = await adminFetch(
1097
1065
  "/admin/paypal/settings",
1098
1066
  {
@@ -1105,8 +1073,7 @@ function PayPalSettingsTab() {
1105
1073
  if (saved && typeof saved === "object") {
1106
1074
  setForm((prev) => ({
1107
1075
  ...prev,
1108
- ...saved,
1109
- disableButtons: filterHiddenDisableButtons(saved.disableButtons)
1076
+ ...saved
1110
1077
  }));
1111
1078
  }
1112
1079
  setToast({ type: "success", message: "Settings saved" });
@@ -1121,20 +1088,6 @@ function PayPalSettingsTab() {
1121
1088
  setSaving(false);
1122
1089
  }
1123
1090
  }
1124
- function toggleMulti(key, value) {
1125
- setForm((prev) => {
1126
- const list = prev[key] || [];
1127
- const exists = list.includes(value);
1128
- const next = exists ? list.filter((v) => v !== value) : [...list, value];
1129
- return { ...prev, [key]: next };
1130
- });
1131
- }
1132
- function removeMulti(key, value) {
1133
- setForm((prev) => {
1134
- const list = prev[key] || [];
1135
- return { ...prev, [key]: list.filter((v) => v !== value) };
1136
- });
1137
- }
1138
1091
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
1139
1092
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-4", children: [
1140
1093
  /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Gateway By Easy Payment" }) }),
@@ -1197,39 +1150,8 @@ function PayPalSettingsTab() {
1197
1150
  SectionCard,
1198
1151
  {
1199
1152
  title: "Button Appearance",
1200
- description: "Control PayPal Smart Button styling (color/shape/size/label) and optionally disable specific buttons.",
1153
+ description: "Control PayPal Smart Button styling (color/shape/size/label).",
1201
1154
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
1202
- /* @__PURE__ */ jsxRuntime.jsx(
1203
- FieldRow,
1204
- {
1205
- label: "Disable Specific Payment Buttons",
1206
- hint: "Hide individual funding sources (ex: Card, Venmo).",
1207
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
1208
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-2", children: [
1209
- filterHiddenDisableButtons(form.disableButtons).map((v) => {
1210
- const opt = VISIBLE_DISABLE_BUTTON_OPTIONS.find((o) => o.value === v);
1211
- return /* @__PURE__ */ jsxRuntime.jsx(Pill, { onRemove: () => removeMulti("disableButtons", v), children: (opt == null ? void 0 : opt.label) ?? v }, v);
1212
- }),
1213
- filterHiddenDisableButtons(form.disableButtons).length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "No buttons disabled." }) : null
1214
- ] }),
1215
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-ui-border-base p-3", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-2 md:grid-cols-2", children: VISIBLE_DISABLE_BUTTON_OPTIONS.map((o) => {
1216
- const checked = form.disableButtons.includes(o.value);
1217
- return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2 rounded-md p-2 hover:bg-ui-bg-subtle", children: [
1218
- /* @__PURE__ */ jsxRuntime.jsx(
1219
- "input",
1220
- {
1221
- type: "checkbox",
1222
- checked,
1223
- onChange: () => toggleMulti("disableButtons", o.value),
1224
- className: "h-4 w-4 rounded border-ui-border-base"
1225
- }
1226
- ),
1227
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: o.label })
1228
- ] }, o.value);
1229
- }) }) })
1230
- ] })
1231
- }
1232
- ),
1233
1155
  /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Button Color", children: /* @__PURE__ */ jsxRuntime.jsx(
1234
1156
  "select",
1235
1157
  {
@@ -1305,9 +1227,6 @@ function PayPalSettingsTab() {
1305
1227
  ] })
1306
1228
  ] }) });
1307
1229
  }
1308
- function PayPalPayLaterMessagingPage() {
1309
- return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
1310
- }
1311
1230
  const widgetModule = { widgets: [] };
1312
1231
  const routeModule = {
1313
1232
  routes: [
@@ -1335,13 +1254,13 @@ const routeModule = {
1335
1254
  Component: PayPalGooglePayPage,
1336
1255
  path: "/settings/paypal/google-pay"
1337
1256
  },
1338
- {
1339
- Component: PayPalSettingsTab,
1340
- path: "/settings/paypal/paypal-settings"
1341
- },
1342
1257
  {
1343
1258
  Component: PayPalPayLaterMessagingPage,
1344
1259
  path: "/settings/paypal/pay-later-messaging"
1260
+ },
1261
+ {
1262
+ Component: PayPalSettingsTab,
1263
+ path: "/settings/paypal/paypal-settings"
1345
1264
  }
1346
1265
  ]
1347
1266
  };
@@ -76,8 +76,7 @@ const DEFAULT_FORM$1 = {
76
76
  requireInstantPayment: false,
77
77
  sendItemDetails: true,
78
78
  invoicePrefix: "WC-",
79
- creditCardStatementName: "PayPal",
80
- logPath: "/uploads/wc-logs/"
79
+ creditCardStatementName: "PayPal"
81
80
  };
82
81
  function mergeWithDefaults$1(saved) {
83
82
  if (!saved) return { ...DEFAULT_FORM$1 };
@@ -375,10 +374,10 @@ if (typeof window !== "undefined") {
375
374
  }
376
375
  }
377
376
  function PayPalConnectionPage() {
378
- const [env, setEnv] = useState("sandbox");
377
+ const [env, setEnv] = useState("live");
379
378
  useEffect(() => {
380
379
  fetch("/admin/paypal/environment", { method: "GET" }).then((r) => r.json()).then((d) => {
381
- const v = (d == null ? void 0 : d.environment) === "live" ? "live" : "sandbox";
380
+ const v = (d == null ? void 0 : d.environment) === "sandbox" ? "sandbox" : "live";
382
381
  setEnv(v);
383
382
  }).catch(() => {
384
383
  });
@@ -389,7 +388,6 @@ function PayPalConnectionPage() {
389
388
  const [showManual, setShowManual] = useState(false);
390
389
  const [clientId, setClientId] = useState("");
391
390
  const [secret, setSecret] = useState("");
392
- const [merchantId, setMerchantId] = useState("");
393
391
  const [statusInfo, setStatusInfo] = useState(null);
394
392
  const [onboardingInProgress, setOnboardingInProgress] = useState(false);
395
393
  const initLoaderRef = useRef(null);
@@ -706,7 +704,7 @@ function PayPalConnectionPage() {
706
704
  ]
707
705
  }
708
706
  ) }),
709
- /* @__PURE__ */ jsx("div", { className: "text-sm font-medium pt-2", children: env === "sandbox" ? "Connect to PayPal Sandbox" : "Connect to PayPal Live" }),
707
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-medium pt-2", children: env === "sandbox" ? "Connect to PayPal (Sandbox)" : "Connect to PayPal" }),
710
708
  /* @__PURE__ */ jsx("div", { className: "max-w-xl", children: connState === "connected" ? /* @__PURE__ */ jsxs("div", { children: [
711
709
  /* @__PURE__ */ jsxs("div", { className: "text-sm text-green-600 bg-green-50 p-3 rounded border border-green-200", children: [
712
710
  "✅ Successfully connected to PayPal!",
@@ -765,13 +763,8 @@ function PayPalConnectionPage() {
765
763
  href: finalUrl || "#",
766
764
  "data-paypal-onboard-complete": "onboardingCallback",
767
765
  onClick: handleConnectClick,
768
- className: "btn-paypal",
766
+ className: "btn-paypal inline-flex items-center justify-center rounded-full bg-[#FFC439] px-6 py-2 text-sm font-semibold text-[#111827] no-underline shadow-sm transition hover:bg-[#f7b916]",
769
767
  style: {
770
- borderRadius: "50px",
771
- textDecoration: "none",
772
- display: "inline-block",
773
- fontWeight: "bold",
774
- border: "none",
775
768
  cursor: onboardingInProgress ? "not-allowed" : "pointer",
776
769
  opacity: onboardingInProgress ? 0.6 : 1,
777
770
  pointerEvents: onboardingInProgress ? "none" : "auto"
@@ -838,7 +831,7 @@ function PayPalConnectionPage() {
838
831
  )
839
832
  ] }),
840
833
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
841
- /* @__PURE__ */ jsx("label", { className: "text-sm font-medium", children: "Client Secret" }),
834
+ /* @__PURE__ */ jsx("label", { className: "text-sm font-medium", children: "Secret" }),
842
835
  /* @__PURE__ */ jsx(
843
836
  "input",
844
837
  {
@@ -851,19 +844,42 @@ function PayPalConnectionPage() {
851
844
  }
852
845
  )
853
846
  ] }),
854
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 md:col-span-2", children: [
855
- /* @__PURE__ */ jsx("label", { className: "text-sm font-medium", children: "Merchant ID (optional)" }),
856
- /* @__PURE__ */ jsx(
857
- "input",
858
- {
859
- type: "text",
860
- value: merchantId,
861
- onChange: (e) => setMerchantId(e.target.value),
862
- disabled: onboardingInProgress,
863
- className: "rounded-md border border-ui-border-base bg-transparent px-3 py-2 text-sm disabled:opacity-50",
864
- placeholder: "Merchant ID"
865
- }
866
- )
847
+ /* @__PURE__ */ jsxs("div", { className: "md:col-span-2 rounded-md border border-ui-border-base bg-ui-bg-subtle p-4 text-sm text-ui-fg-subtle", children: [
848
+ /* @__PURE__ */ jsx("p", { className: "font-medium text-ui-fg-base", children: "Get your Client ID and Client Secret in 3 steps:" }),
849
+ /* @__PURE__ */ jsxs("ol", { className: "mt-2 list-decimal space-y-2 pl-5", children: [
850
+ /* @__PURE__ */ jsxs("li", { children: [
851
+ "Open",
852
+ " ",
853
+ /* @__PURE__ */ jsx(
854
+ "a",
855
+ {
856
+ href: "https://developer.paypal.com/dashboard/",
857
+ target: "_blank",
858
+ rel: "noreferrer",
859
+ className: "text-ui-fg-interactive underline",
860
+ children: "Log in to Dashboard"
861
+ }
862
+ ),
863
+ " ",
864
+ "and sign in or create an account."
865
+ ] }),
866
+ /* @__PURE__ */ jsxs("li", { children: [
867
+ "Select ",
868
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: "Apps & Credentials" }),
869
+ ", then choose ",
870
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: "Create App" }),
871
+ " if you need a new project."
872
+ ] }),
873
+ /* @__PURE__ */ jsxs("li", { children: [
874
+ "Copy your app's ",
875
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: "Client ID" }),
876
+ " and ",
877
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: "Client Secret" }),
878
+ ", paste them above, then click ",
879
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: "Save credentials" }),
880
+ "."
881
+ ] })
882
+ ] })
867
883
  ] }),
868
884
  /* @__PURE__ */ jsxs("div", { className: "md:col-span-2 flex items-center gap-2 mt-2", children: [
869
885
  /* @__PURE__ */ jsx(
@@ -912,6 +928,9 @@ function PayPalConnectionPage() {
912
928
  function PayPalGooglePayPage() {
913
929
  return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
914
930
  }
931
+ function PayPalPayLaterMessagingPage() {
932
+ return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
933
+ }
915
934
  async function adminFetch(path, opts = {}) {
916
935
  var _a;
917
936
  const { method = "GET", body, query } = opts;
@@ -945,21 +964,6 @@ async function adminFetch(path, opts = {}) {
945
964
  return {};
946
965
  }
947
966
  }
948
- const DISABLE_BUTTON_OPTIONS = [
949
- { value: "paypal", label: "PayPal" },
950
- { value: "paylater", label: "Pay Later" },
951
- { value: "card", label: "Debit / Credit Card" },
952
- { value: "venmo", label: "Venmo" },
953
- { value: "applepay", label: "Apple Pay" },
954
- { value: "googlepay", label: "Google Pay" }
955
- ];
956
- const HIDDEN_DISABLE_BUTTONS = /* @__PURE__ */ new Set(["applepay", "googlepay", "paylater"]);
957
- const VISIBLE_DISABLE_BUTTON_OPTIONS = DISABLE_BUTTON_OPTIONS.filter(
958
- (option) => !HIDDEN_DISABLE_BUTTONS.has(option.value)
959
- );
960
- function filterHiddenDisableButtons(list = []) {
961
- return list.filter((value) => !HIDDEN_DISABLE_BUTTONS.has(value));
962
- }
963
967
  const COLOR_OPTIONS = [
964
968
  { value: "gold", label: "Gold (Recommended)" },
965
969
  { value: "blue", label: "Blue" },
@@ -979,42 +983,11 @@ const WIDTH_OPTIONS = [
979
983
  ];
980
984
  const HEIGHT_OPTIONS = [32, 36, 40, 44, 48, 52, 56];
981
985
  const LABEL_OPTIONS = [
982
- { value: "paypal", label: "PayPal (Recommended)" },
986
+ { value: "paypal", label: "PayPal" },
983
987
  { value: "checkout", label: "Checkout" },
984
988
  { value: "buynow", label: "Buy Now" },
985
989
  { value: "pay", label: "Pay" }
986
990
  ];
987
- function cx(...parts) {
988
- return parts.filter(Boolean).join(" ");
989
- }
990
- function Pill({
991
- children,
992
- onRemove,
993
- disabled
994
- }) {
995
- return /* @__PURE__ */ jsxs(
996
- "span",
997
- {
998
- className: cx(
999
- "inline-flex items-center gap-1 rounded-md border px-2 py-1 text-sm",
1000
- disabled ? "opacity-60" : "opacity-100"
1001
- ),
1002
- children: [
1003
- children,
1004
- onRemove ? /* @__PURE__ */ jsx(
1005
- "button",
1006
- {
1007
- type: "button",
1008
- onClick: onRemove,
1009
- className: "ml-1 rounded px-1 text-ui-fg-subtle hover:text-ui-fg-base",
1010
- "aria-label": "Remove",
1011
- children: "×"
1012
- }
1013
- ) : null
1014
- ]
1015
- }
1016
- );
1017
- }
1018
991
  function SectionCard({
1019
992
  title,
1020
993
  description,
@@ -1050,7 +1023,6 @@ function PayPalSettingsTab() {
1050
1023
  enabled: true,
1051
1024
  title: "PayPal",
1052
1025
  description: "Pay via PayPal; you can pay with your credit card if you don't have a PayPal account",
1053
- disableButtons: [],
1054
1026
  buttonColor: "gold",
1055
1027
  buttonShape: "rect",
1056
1028
  buttonWidth: "medium",
@@ -1075,8 +1047,7 @@ function PayPalSettingsTab() {
1075
1047
  if (saved && typeof saved === "object") {
1076
1048
  setForm((prev) => ({
1077
1049
  ...prev,
1078
- ...saved,
1079
- disableButtons: filterHiddenDisableButtons(saved.disableButtons)
1050
+ ...saved
1080
1051
  }));
1081
1052
  }
1082
1053
  } catch {
@@ -1088,10 +1059,7 @@ function PayPalSettingsTab() {
1088
1059
  async function onSave() {
1089
1060
  try {
1090
1061
  setSaving(true);
1091
- const cleaned = {
1092
- ...form,
1093
- disableButtons: filterHiddenDisableButtons(form.disableButtons)
1094
- };
1062
+ const cleaned = { ...form };
1095
1063
  const json = await adminFetch(
1096
1064
  "/admin/paypal/settings",
1097
1065
  {
@@ -1104,8 +1072,7 @@ function PayPalSettingsTab() {
1104
1072
  if (saved && typeof saved === "object") {
1105
1073
  setForm((prev) => ({
1106
1074
  ...prev,
1107
- ...saved,
1108
- disableButtons: filterHiddenDisableButtons(saved.disableButtons)
1075
+ ...saved
1109
1076
  }));
1110
1077
  }
1111
1078
  setToast({ type: "success", message: "Settings saved" });
@@ -1120,20 +1087,6 @@ function PayPalSettingsTab() {
1120
1087
  setSaving(false);
1121
1088
  }
1122
1089
  }
1123
- function toggleMulti(key, value) {
1124
- setForm((prev) => {
1125
- const list = prev[key] || [];
1126
- const exists = list.includes(value);
1127
- const next = exists ? list.filter((v) => v !== value) : [...list, value];
1128
- return { ...prev, [key]: next };
1129
- });
1130
- }
1131
- function removeMulti(key, value) {
1132
- setForm((prev) => {
1133
- const list = prev[key] || [];
1134
- return { ...prev, [key]: list.filter((v) => v !== value) };
1135
- });
1136
- }
1137
1090
  return /* @__PURE__ */ jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
1138
1091
  /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4", children: [
1139
1092
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Gateway By Easy Payment" }) }),
@@ -1196,39 +1149,8 @@ function PayPalSettingsTab() {
1196
1149
  SectionCard,
1197
1150
  {
1198
1151
  title: "Button Appearance",
1199
- description: "Control PayPal Smart Button styling (color/shape/size/label) and optionally disable specific buttons.",
1152
+ description: "Control PayPal Smart Button styling (color/shape/size/label).",
1200
1153
  children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-ui-border-base", children: [
1201
- /* @__PURE__ */ jsx(
1202
- FieldRow,
1203
- {
1204
- label: "Disable Specific Payment Buttons",
1205
- hint: "Hide individual funding sources (ex: Card, Venmo).",
1206
- children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
1207
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
1208
- filterHiddenDisableButtons(form.disableButtons).map((v) => {
1209
- const opt = VISIBLE_DISABLE_BUTTON_OPTIONS.find((o) => o.value === v);
1210
- return /* @__PURE__ */ jsx(Pill, { onRemove: () => removeMulti("disableButtons", v), children: (opt == null ? void 0 : opt.label) ?? v }, v);
1211
- }),
1212
- filterHiddenDisableButtons(form.disableButtons).length === 0 ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "No buttons disabled." }) : null
1213
- ] }),
1214
- /* @__PURE__ */ jsx("div", { className: "rounded-md border border-ui-border-base p-3", children: /* @__PURE__ */ jsx("div", { className: "grid gap-2 md:grid-cols-2", children: VISIBLE_DISABLE_BUTTON_OPTIONS.map((o) => {
1215
- const checked = form.disableButtons.includes(o.value);
1216
- return /* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 rounded-md p-2 hover:bg-ui-bg-subtle", children: [
1217
- /* @__PURE__ */ jsx(
1218
- "input",
1219
- {
1220
- type: "checkbox",
1221
- checked,
1222
- onChange: () => toggleMulti("disableButtons", o.value),
1223
- className: "h-4 w-4 rounded border-ui-border-base"
1224
- }
1225
- ),
1226
- /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: o.label })
1227
- ] }, o.value);
1228
- }) }) })
1229
- ] })
1230
- }
1231
- ),
1232
1154
  /* @__PURE__ */ jsx(FieldRow, { label: "Button Color", children: /* @__PURE__ */ jsx(
1233
1155
  "select",
1234
1156
  {
@@ -1304,9 +1226,6 @@ function PayPalSettingsTab() {
1304
1226
  ] })
1305
1227
  ] }) });
1306
1228
  }
1307
- function PayPalPayLaterMessagingPage() {
1308
- return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
1309
- }
1310
1229
  const widgetModule = { widgets: [] };
1311
1230
  const routeModule = {
1312
1231
  routes: [
@@ -1334,13 +1253,13 @@ const routeModule = {
1334
1253
  Component: PayPalGooglePayPage,
1335
1254
  path: "/settings/paypal/google-pay"
1336
1255
  },
1337
- {
1338
- Component: PayPalSettingsTab,
1339
- path: "/settings/paypal/paypal-settings"
1340
- },
1341
1256
  {
1342
1257
  Component: PayPalPayLaterMessagingPage,
1343
1258
  path: "/settings/paypal/pay-later-messaging"
1259
+ },
1260
+ {
1261
+ Component: PayPalSettingsTab,
1262
+ path: "/settings/paypal/paypal-settings"
1344
1263
  }
1345
1264
  ]
1346
1265
  };
@@ -11,7 +11,7 @@ async function POST(req, res) {
11
11
  try {
12
12
  const paypal = req.scope.resolve("paypal_onboarding");
13
13
  const body = (req.body || {});
14
- const env = body.environment === "live" ? "live" : "sandbox";
14
+ const env = body.environment === "sandbox" ? "sandbox" : "live";
15
15
  await paypal.setEnvironment(env);
16
16
  const status = await paypal.getStatus();
17
17
  return res.json(status);
@@ -1 +1 @@
1
- {"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../src/api/admin/paypal/environment/route.ts"],"names":[],"mappings":";;AAOA,kBAIC;AAED,oBAWC;AAjBM,KAAK,UAAU,GAAG,CAAC,GAAkB,EAAE,GAAmB;IAC/D,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAsB,mBAAmB,CAAC,CAAA;IAC1E,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,EAAE,CAAA;IACvC,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;AACtD,CAAC;AAEM,KAAK,UAAU,IAAI,CAAC,GAAkB,EAAE,GAAmB;IAChE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAsB,mBAAmB,CAAC,CAAA;QAC1E,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAS,CAAA;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;QAC5D,MAAM,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;QAChC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,EAAE,CAAA;QACvC,OAAO,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACzB,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,IAAI,eAAe,EAAE,CAAC,CAAA;IACzE,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../src/api/admin/paypal/environment/route.ts"],"names":[],"mappings":";;AAOA,kBAIC;AAED,oBAWC;AAjBM,KAAK,UAAU,GAAG,CAAC,GAAkB,EAAE,GAAmB;IAC/D,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAsB,mBAAmB,CAAC,CAAA;IAC1E,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,EAAE,CAAA;IACvC,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;AACtD,CAAC;AAEM,KAAK,UAAU,IAAI,CAAC,GAAkB,EAAE,GAAmB;IAChE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAsB,mBAAmB,CAAC,CAAA;QAC1E,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAS,CAAA;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAA;QAC/D,MAAM,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;QAChC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,EAAE,CAAA;QACvC,OAAO,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACzB,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,IAAI,eAAe,EAAE,CAAC,CAAA;IACzE,CAAC;AACH,CAAC"}