@easypayment/medusa-paypal-ui 1.2.8 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +82 -0
- package/LICENSE +21 -1
- package/README.md +8 -2
- package/dist/index.cjs +605 -676
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -28
- package/dist/index.d.ts +101 -28
- package/dist/index.mjs +601 -676
- package/dist/index.mjs.map +1 -1
- package/dist/order.cjs +11 -8
- package/dist/order.cjs.map +1 -1
- package/dist/order.d.cts +1 -1
- package/dist/order.d.ts +1 -1
- package/dist/order.mjs +10 -8
- package/dist/order.mjs.map +1 -1
- package/package.json +43 -4
- package/src/adapters/MedusaNextPayPalAdapter.tsx +48 -10
- package/src/client/config-cache.ts +96 -0
- package/src/client/http.ts +24 -5
- package/src/client/paypal.ts +28 -6
- package/src/components/PayPalAdvancedCard.tsx +88 -214
- package/src/components/PayPalPaymentSection.tsx +17 -6
- package/src/components/PayPalProvider.tsx +4 -1
- package/src/components/PayPalSmartButtons.tsx +92 -224
- package/src/components/internal/ui.tsx +221 -0
- package/src/hooks/usePayPalConfig.ts +43 -32
- package/src/hooks/usePayPalPaymentMethods.ts +59 -54
- package/src/index.ts +4 -0
- package/src/order.ts +16 -8
- package/src/utils/processing-overlay.ts +25 -21
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,88 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@easypayment/medusa-paypal-ui` are documented here.
|
|
4
4
|
|
|
5
|
+
## 1.3.0 — 2026-10-06
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **"PayPal is disabled" (403) detection works again.** It matched the text
|
|
10
|
+
"403"/"Forbidden" in error messages, but the HTTP client prefers the
|
|
11
|
+
backend's JSON message, which rarely contains either — so a disabled plugin
|
|
12
|
+
fell back to showing both payment methods as enabled. Detection is now by
|
|
13
|
+
status code (`HttpError.status === 403`), and `HttpError` is exported so
|
|
14
|
+
storefronts can branch on statuses too.
|
|
15
|
+
- **A currency/region switch no longer serves a stale config for up to 5
|
|
16
|
+
minutes.** The config cache key now includes the publishable API key and an
|
|
17
|
+
optional `currencyCode` (new prop on `PayPalPaymentSection`,
|
|
18
|
+
`MedusaNextPayPalAdapter`, and both hooks — pass the cart's currency);
|
|
19
|
+
`invalidatePayPalConfigCache(cartId?)` is exported for manual invalidation.
|
|
20
|
+
- **Double-click on the PayPal button can no longer create two orders.** The
|
|
21
|
+
guard read async React state, so two clicks in the same tick both passed;
|
|
22
|
+
it now uses a synchronous ref (as the card form already did).
|
|
23
|
+
- Malformed 2xx responses (non-JSON content type, JSON parse failure) are no
|
|
24
|
+
longer treated as transient and retried — a server answering 200 with HTML
|
|
25
|
+
answers the same on a retry.
|
|
26
|
+
- The full-screen processing overlay no longer monkeypatches
|
|
27
|
+
`history.pushState`/`replaceState` to detect soft navigations (fragile next
|
|
28
|
+
to the Next.js router); it watches the URL instead. The in-component and
|
|
29
|
+
shared DOM overlays also no longer stack on top of each other.
|
|
30
|
+
- The server-safe `fetchPayPalConfig` (order entrypoint) now composes a
|
|
31
|
+
caller-supplied `AbortSignal` with its 30s timeout instead of letting the
|
|
32
|
+
signal replace the timeout entirely.
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- `credentials` prop on `PayPalPaymentSection`, `MedusaNextPayPalAdapter`,
|
|
37
|
+
`PayPalSmartButtons`, and `PayPalAdvancedCard`, forwarded to every API call
|
|
38
|
+
(previously only `createPayPalStoreApi` accepted it, so the README's
|
|
39
|
+
wildcard-CORS advice didn't reach the components).
|
|
40
|
+
- `usePayPalConfig` returns a `retry()` function, and the adapter's
|
|
41
|
+
config-error card shows a "Try again" button instead of requiring a reload.
|
|
42
|
+
- Both hooks share one config cache and deduplicate in-flight requests — a
|
|
43
|
+
checkout page that mounts both issues a single `/store/paypal/config` call.
|
|
44
|
+
- `createOrder` / `captureOrder` / `getSettings` accept an `AbortSignal`;
|
|
45
|
+
`markPaymentComplete` accepts an options object (`{ publishableApiKey,
|
|
46
|
+
credentials, timeoutMs, signal }` — the legacy string argument still works);
|
|
47
|
+
`createHttpClient` accepts `timeoutMs`.
|
|
48
|
+
- Accessibility: decorative icons are `aria-hidden`, overlays/spinners
|
|
49
|
+
announce their visible text (no overriding `aria-label`), `aria-busy`
|
|
50
|
+
reflects busy (not disabled) state, and animations respect
|
|
51
|
+
`prefers-reduced-motion`.
|
|
52
|
+
|
|
53
|
+
### Changed
|
|
54
|
+
|
|
55
|
+
- **PayPal partner attribution (BN) code changed to `MBJ_Medusa_SI`** — the
|
|
56
|
+
Medusa-platform code PayPal assigned (2026-10-06), passed to the PayPal JS
|
|
57
|
+
SDK as `data-partner-attribution-id` (previously `MBJTechnolabs_SI_SPB`),
|
|
58
|
+
matching the backend's REST attribution.
|
|
59
|
+
- `onPaid` / `onSuccess` callback types are now `void | Promise<void>` (they
|
|
60
|
+
were always awaited).
|
|
61
|
+
- `PAYPAL_PROVIDER_IDS` and the `PayPalProviderId` type are actually exported
|
|
62
|
+
from both entrypoints now (1.2.8 exported them from an internal module that
|
|
63
|
+
consumers couldn't reach).
|
|
64
|
+
- The spinner/overlay/error markup that was copied across four components
|
|
65
|
+
lives in one shared internal module.
|
|
66
|
+
|
|
67
|
+
### Dev
|
|
68
|
+
|
|
69
|
+
- ESLint (typescript-eslint + react-hooks + jsx-a11y) added and clean; lint,
|
|
70
|
+
format, and a React 18 test job run in CI; `tsc` now typechecks the tests.
|
|
71
|
+
- 40 new tests (73 total): shared config cache (TTL, dedupe, invalidation,
|
|
72
|
+
eviction), hooks under React Testing Library (403 handling, retry, shared
|
|
73
|
+
in-flight fetch, currency-change refetch), client timeout/abort/credentials
|
|
74
|
+
behavior, and the server-safe order helpers.
|
|
75
|
+
- `react`/`react-dom` are proper devDependencies; full MIT license text;
|
|
76
|
+
npm keywords, `engines`, `homepage`/`bugs` metadata added.
|
|
77
|
+
|
|
78
|
+
## 1.2.8 — 2026-09-28
|
|
79
|
+
|
|
80
|
+
### Changed
|
|
81
|
+
|
|
82
|
+
- `isPayPalProviderId` is now a type guard and the `PayPalProviderId` type is
|
|
83
|
+
exported from an internal constants module (aligned with
|
|
84
|
+
`@easypayment/medusa-payment-paypal` 1.2.8). Superseded by 1.3.0, which
|
|
85
|
+
exports them from the public entrypoints.
|
|
86
|
+
|
|
5
87
|
## 1.2.7 — 2026-09-23
|
|
6
88
|
|
|
7
89
|
### Changed
|
package/LICENSE
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -786,9 +786,15 @@ You don't need to do anything for these — they're automatic:
|
|
|
786
786
|
|
|
787
787
|
<br>
|
|
788
788
|
|
|
789
|
-
- `usePayPalPaymentMethods` returns an `error` field (non-null when the config fetch failed and the enabled flags are optimistic defaults).
|
|
789
|
+
- `usePayPalPaymentMethods` returns an `error` field (non-null when the config fetch failed and the enabled flags are optimistic defaults). A `403` from the backend (plugin disabled) is detected by status code and flips both methods off.
|
|
790
|
+
- `usePayPalConfig` returns `{ config, loading, error, retry }` — call `retry()` to refetch after a failure (the adapter's error card has a built-in "Try again" button).
|
|
791
|
+
- Pass `currencyCode` (the cart's currency) to the components/hooks: it's part of the config cache key, so a region/currency switch refetches instead of serving a stale config. `invalidatePayPalConfigCache(cartId?)` is exported for manual invalidation.
|
|
792
|
+
- Both hooks share one config cache **and one in-flight request** — a page that mounts both issues a single `/store/paypal/config` call.
|
|
793
|
+
- `HttpError` is exported: every non-2xx API failure carries a `status` you can branch on.
|
|
794
|
+
- All API calls time out after 30s by default (`timeoutMs` option on `createHttpClient` / `markPaymentComplete`), retry transient failures on idempotent endpoints, and accept an `AbortSignal`.
|
|
790
795
|
- Captured-state helpers are exported for custom flows: `markCartCaptured` / `wasCartCaptured` / `clearCartCaptured` (per-cart `sessionStorage` flag behind the reload-safe retry).
|
|
791
|
-
- If your backend responds with `Access-Control-Allow-Origin: *`, pass `credentials: "omit"` to `createPayPalStoreApi({ ... })`
|
|
796
|
+
- If your backend responds with `Access-Control-Allow-Origin: *`, pass `credentials: "omit"` — either to `createPayPalStoreApi({ ... })` or directly as a `credentials` prop on `PayPalPaymentSection` / `MedusaNextPayPalAdapter` / the components. Default stays `"include"`.
|
|
797
|
+
- Accessibility: spinners and overlays are `role="status"`, errors are `role="alert"`, decorative icons are `aria-hidden`, and animations respect `prefers-reduced-motion`.
|
|
792
798
|
|
|
793
799
|
</details>
|
|
794
800
|
|