# Changelog

## 0.19.2

### Patch Changes

- d25fc91: The README's links to the changelog work on npmjs.com. They led to a page that does not exist there.

## 0.19.1

### Patch Changes

- 8b4a21f: The README has a new "Integration requirements" section. It lists, in one place, everything a page that embeds the component must follow, such as serving the page over HTTPS, loading the package unchanged and keeping the version current. Provet may suspend the component for a page that does not follow them, or whose page is compromised.
- a7eb8e4: Text that a shipped language leaves empty, or has not translated yet, shows in English from `DEFAULT_TRANSLATIONS` instead of as an empty string or its key.

## 0.19.0

### Minor Changes

- A card form now ends 55 minutes after it opens its session, with an error, instead of taking a card into a session Adyen has ended. Adyen ends a card session an hour after it opens and tells no one, and its fields kept taking card details until Save was refused. Before, the form then showed "Something went wrong while checking the card. Try again, or use another card." and every retry failed the same way.

  Now:

  - After 55 minutes the card fields are cleared, the form ends with `onError` (`session_error`), and the banner shows the new `provetPay.errors.session_expired`, "Your session has expired, please reload the page", with `session_expired` in `data-provet-pay-elements-error`. The last 5 minutes are kept for a 3-D Secure check started just before. A check already under way finishes first.
  - A Save that Adyen refuses because the session has expired ends the form the same way.
  - No new session opens on its own: a reload or a new `mount()` opens one, and so does "Add a new card" back on the saved cards. `changeLocale` does nothing once the form has ended this way.
  - A stored session whose form has had its 55 minutes is not resumed, unless the address carries its 3-D Secure result.

  Also: a session stored by 0.18 is not resumed, since the component now stores when it opened each session. A shopper who had the card form open starts again, and a 3-D Secure return that spans the upgrade is not settled.

## 0.18.1

### Patch Changes

- Once the form has ended on Adyen's attempt limit and "Add a new card" opens a new session, `changeLocale` starts the form again in the new locale. Before, it did nothing for the rest of the mount.

## 0.18.0

### Minor Changes

- c2f3925: Breaking: an unfinished card session belongs to the `auth` it was opened with. The component stores it together with that `auth` (Provet instance, tenant, client and department), the `recurringModel` and the page it was opened on, and resumes it only for a mount with the same `auth`. A mount with another `recurringModel`, or on another page, opens its own session, unless the address carries the stored session's 3-D Secure result. A session stored by an earlier version is not resumed: a shopper who had the card form open starts again, and a 3-D Secure return that spans the upgrade is not settled.

  Also breaking:

  - `auth.clientId` must be the Provet client id as the token's audience carries it (`client:<id>`), digits only; anything else makes `mount()` throw `config_invalid`.
  - A container holds one form. A second `mount()` into it for the same shopper throws `config_invalid` and keeps the first form; one for another shopper stops the first form as well and throws.

  Fixed:

  - Mounts for the same shopper on one page share one card session. Mounting again, or calling `changeLocale`, while the form is still opening a session waits for it instead of opening a second pending card, and so do a second container, "Add a new card" beside a session another form stored, and two forms replacing a session Adyen no longer starts.
  - A session still being opened when the shopper picks a saved card or saves a card is not stored, so the next mount offers the saved cards instead of reopening the form. Clearing a finished session no longer removes a newer one another form stored.
  - `auth.refreshToken` is not called after `unmount()`, and a token it returns after `unmount()` is not used.
  - With two forms on a 3-D Secure return page, the result is submitted to Adyen once.
  - `changeLocale` does nothing after Adyen has ended the session for too many attempts, instead of opening a new session.

### Patch Changes

- cec47ff: Going back to the saved cards from a card form that shows an error (the error banner, a notice such as "The card was declined", or a field Adyen marks invalid) now resets the form, on the same card session, so "Add a new card" shows it empty. Before, the same form came back with its field errors, and after a load failure without its banner. A form with no errors still keeps what the shopper typed.

  `unmount()` with the saved-card list open now closes the list. Before, the list kept listening for presses on the page, and kept the unmounted component in memory, until the next press anywhere on the page.

- 7bb2e67: The component's loading indicator now matches the spinner Adyen shows over the card fields: the same size, colours and motion. Before, it was a smaller spinner with its own colours and speed, so the two read as two different loaders. Both draw their arc in `appearance.variables.colorAccent` and their faint track in `colorText`, so they stay alike under any appearance.

## 0.17.0

### Minor Changes

- d1cb6ee: Breaking: `appearance.secured` is now `styles`, Adyen's own option with all of its properties, and the `SecuredFieldStyle` type is now Adyen's `StyleDefinitions`. The error banner shows the component's text for the error's code (`provetPay.errors.<code>`), named in a new `data-provet-pay-elements-error` attribute, instead of `onError`'s `message`. `mount()` throws `config_invalid` for a `locale` that is not a string.

  New:

  - `translations`, Adyen's custom translations keyed by locale: Adyen's keys change the card fields, the `provetPay.*` keys (`PayCardTranslations`) the component's own text. The component resolves `locale` by Adyen's rules over the locales it has text for (British English, which this version ships, and `translations` entries holding `provetPay.*` keys), else British English.
  - With no or an empty `locale`, the component uses `en-GB` and passes it to Adyen, which ships no British English, so its card fields read US English. Both defaults are exported: `DEFAULT_LOCALE` and `DEFAULT_TRANSLATIONS`.
  - Setting `locale` on the options object given to `mount()`, or calling `changeLocale(locale)` on what `mount()` returns, starts the form again in that locale, resuming its open card session. Adyen takes its locale only when it starts, so what the shopper typed into the card fields is cleared. While a card check runs, it does nothing.
  - `disclaimerMessage`, Adyen's line under the card fields.
  - `onRefused` gets `{ resultCode }`: `Refused`, `Cancelled` or `Error`. `onSuccess` gets `resultCode` for a card saved in the form.
  - Also exported: the `CustomTranslations`, `DisclaimerMsgObject`, `ResultCode` and `StylesObject` types.

  Fixed:

  - A call to Adyen that fails during the card check no longer shows "The card was declined" or calls `onRefused`: `onError` is called, and while the card fields are on the page the form stays for another try.
  - `onError` is called once when Adyen cannot start a session, and `onReady` once per start of the form, when the shopper first has something to act on.
  - A 3-D Secure redirect result for another session is left for that session.

### Patch Changes

- 6cf60ee: When Adyen ends a card session because the shopper made too many attempts, the component now ends with one error: `onError` with `session_error` and "This card form had too many attempts. Try again later, or use another card." Before, the form said "The card was declined" and every further attempt failed the same way, while the page received both `onError` and `onRefused`. The component does not open a new session on its own: Adyen's limit is a guard against repeated card attempts, so whether to mount again is the page's decision.

## 0.16.0

### Minor Changes

- c1e92c3: The package is published on npm as `@nordhealth/provet-pay-elements`, replacing the hand-delivered tarball. Install it with `npm install @nordhealth/provet-pay-elements`; the `mount()` API is unchanged. Each version is also served on the CDN at its own URL with an SRI hash for script-tag consumers.

### Patch Changes

- c1e92c3: The package ships one flattened type declaration (`dist/types/index.d.ts`) instead of per-module files, so the published types are exactly the documented API and internal module paths cannot be imported for their types.

## 0.15.0 - 29/09/2026

- (Minor) A shopper returning from a redirect-based 3-D Secure challenge is settled. The element reads the `redirectResult` Adyen appends to the page, hands it to Adyen for the session it stored before the redirect, and then removes it from the address bar so a reload does not submit it twice. A mount that ends before Adyen has the result, as in React StrictMode, leaves it for the next mount. The card form stays out of view while Adyen answers: a saved card reaches `onSuccess` as after any other save, a refusal brings the form back with the decline notice. A result without a stored session of this mount is left alone (VPP-1077)
- (Patch) A card that fails 3-D Secure, by a wrong challenge answer or an issuer that denies or rejects the authentication, no longer leaves the shopper with the decline notice and no card fields. Adyen empties its container when that happens, so the component mounts the card again on the same session and the shopper can try another card in place. A re-mount still pending from the last failure is cancelled when the shopper presses pay again. `onReady` fires once, not again for the fields coming back (VPP-1077)
- (Minor) A failed attempt is worded for what happened. Adyen reports it as `Refused`, `Cancelled` or `Error`, and the notice used to say "That card was declined" for all three. A refusal now says "The card was declined. Try another card."; a 3-D Secure check the shopper cancelled says "The card check was cancelled. Try again."; an Adyen error says "Something went wrong while checking the card. Try again, or use another card." `onRefused` still fires for all three, so a consumer that counts attempts sees no change (VPP-1077)
- (Patch) When the card fields are mounted again after a failed 3-D Secure check, the name on the card the shopper had typed is put back. The card number, expiry date and security code cannot be, because they live in Adyen's iframes, so the shopper types those again (VPP-1077)
- (Patch) The notice about a failed attempt is taken down as soon as the shopper presses the pay button again, instead of staying over the next attempt until it finishes (VPP-1077)
- (Patch) The messages the element reports for a failed call no longer name a product: they say "the server", for example "The server did not answer in time." The shopper can read these messages in the form (VPP-1077)
- (Patch) A `checkout-sessions` answer whose card id is an empty string is refused as incomplete instead of handing the page an empty card id. A stored session is held to the same bar on resume: an empty card id or an Adyen environment other than `test` or `live` discards the record and a fresh session starts (VPP-1077)
- (Patch) `onSuccess` answers once per decision. The "Back to saved cards" control now hides while an attempt is being authorised, and picking a saved card ends an attempt the shopper had walked away from, so its late outcome can no longer call `onSuccess` a second time with another card. A save already under way when `unmount()` is called still reports, as documented (VPP-1077)

## 0.14.0 - 29/09/2026

- (Minor) A refused token now stops a remount that would have resumed a stored session. The saved-card list that runs beside a resumed session no longer swallows a 401 or 403, so the session is not continued for a token Provet will not accept, and the failure reaches `onError` as `auth_error` (VPP-1077)
- (Minor) A 403 from Provet, a token that authenticates but lacks the `card_tokenization` scope, is reported as `auth_error` at once. It used to surface as a generic session error carrying the message of Provet, and `refreshToken` is not called for it, because the same backend would mint the same token (VPP-1077)
- (Minor) An `auth.refreshToken` that does not answer within 60 seconds ends the wait with `auth_error`. It used to leave the card UI on its loading state for as long as the consumer's promise stayed pending (VPP-1077)
- (Minor) A call to Provet that does not start answering within five minutes ends in a `session_error` reading "The server did not answer in time." It used to leave the card UI on its loading state for as long as the browser waited. A call that times out is not retried: the first `checkout-sessions` call may still be running on the server, and a second would open a second pending card (VPP-1077)
- (Patch) A declined card is shown in the red alert banner instead of the yellow status one, matching every other blocking message. The yellow style is removed (VPP-1077)

## 0.13.0 - 29/09/2026

- (Minor) `auth.provetOrigin` is optional. Left out, the element calls the Provet instance its build was made for, so a consumer of a `prod` build passes nothing. Passing a Provet origin still names another instance, and a value that is not one is still refused with `config_invalid` (VPP-1077)

## 0.11.1 - 24/09/2026

- (Patch) A saved-card list that cannot be fetched is reported through `onError` instead of being read as "no saved cards", so the element no longer opens a session, and a pending card, when Provet answers with an error. Going back from the card form still shows the last list if the refetch fails (VPP-1077)
- (Patch) A new session whose card fields fail to load is reported as the error it is, for example a client key or an origin Adyen does not accept, instead of "The card session is no longer usable." followed by a second session with its own pending card. Only a resumed session that fails is treated as expired and replaced (VPP-1077)
- (Patch) An `auth.refreshToken` that rejects is reported as `auth_error` with its message, instead of `technical` (VPP-1077)
- (Patch) Picking a saved card drops a session the shopper had opened for a new card, so the next mount in the tab offers the saved cards again instead of reopening that form (VPP-1077)
- (Patch) Saved cards and the checkout-sessions response are read field by field: a card reaches `onSuccess` with only `id`, `brand`, `last4`, `expiration_date` and `default`, each only when it has the right type, and a malformed `brand` no longer breaks the saved-card list (VPP-1077)
- (Patch) The README lists the Content Security Policy a consumer page needs for the card UI (VPP-1077)

## 0.11.0 - 24/09/2026

- (Breaking) `mount()` takes who it acts for as one required `auth` object: `token`, `provetOrigin`, `provetId`, `clientId` (the Provet client, the pet owner in the token's audience) and `departmentId`, all required. A missing field, or a `provetOrigin` that is not a Provet instance, fails the mount with `config_invalid` (VPP-1077)
- (Breaking) The `Auth` class and its `AuthOptions` type are gone, and so are the top-level `provetId`, `provetCloudOrigin` and `department` options; `provetCloudOrigin` is now `auth.provetOrigin` and `department` is `auth.departmentId`. The consumer passes the token itself, and the optional `auth.refreshToken` takes over from `fetchToken` on a 401: the element retries the same call once with the fresh token. Without it, an expired token is reported through `onError` as `auth_error` (VPP-1077)
- (Patch) The stored session is keyed by the Provet origin, tenant, pet owner and department it was opened for. It used to be keyed by tenant and department only, so a second pet owner mounting in the same tab resumed the first one's session, and `onSuccess` returned the first pet owner's card (VPP-1077)

## 0.10.0 - 23/09/2026

- (Minor) Once a card is saved, the card UI shows a final success state — a green check and "Card saved" — in place of the spent form, which could otherwise be submitted again; after a 3-D Secure challenge it fills the space the challenge left. The back control hides, the view takes focus when the form had it, and it renders before `onSuccess` runs (VPP-1077)
- (Minor) The saved cards are fetched each time they are shown, so going back from the card form lists the current cards rather than the ones offered at mount; an empty list returns to the card form without opening a second session, and a list that cannot be fetched falls back to the one shown before (VPP-1077)
- (Patch) An error thrown by the consumer's `onSuccess` is reported as an uncaught error of its own. Adyen used to settle it as a failed payment, so a card that had been saved showed as declined and `onRefused` fired (VPP-1077)
- (Patch) An unmounted element does nothing more. A token that arrives after `unmount()` starts nothing, so React StrictMode's mount → unmount → mount opens one session instead of two; no `onReady`, `onRefused` or `onError` fires after it; and a session it was opening is kept for the next mount instead of being left unused. A card whose save was already under way still reports through `onSuccess` (VPP-1077)

## 0.9.0 - 23/09/2026

- (Breaking) The card UI renders in the consumer's own page instead of an iframe served from ours. `npm i @provet-pay/elements` and `mount()` are now the whole integration: there is no second document, no hosted `index.html`, `.js` or `.css`, and nothing for a consumer to serve. The package is one JavaScript file with both stylesheets — ours and Adyen's — inlined and injected at mount (VPP-1081)
- (Breaking) `elementOrigin` is gone from `mount()`; there is no element origin to point at. A consumer's own origin is what Adyen and Provet see, so it is registered once with Adyen as an allowed origin and added to `CARD_ELEMENT_ALLOWED_ORIGINS` on the Provet instance it uses (VPP-1081)
- (Minor) A redirect-based 3DS challenge is now an ordinary top-level navigation back to the consumer's `return_url`. Same-origin with the page that hosts it, the card UI is not subject to the constraint `DESIGN.md` §12 (spike S4) puts on a cross-domain frame, which cannot redirect at all (VPP-1081)
- (Minor) The stored session is keyed by the mount it belongs to — tenant and department — so a session opened for one mount is never resumed by another on the same page (VPP-1081)
- (Patch) The card UI's stylesheet is scoped to the node the mount creates: no `html`, `body` or `#root` rules, and its tokens sit on that node rather than `:root`, so a consumer's typography, spacing and background are untouched (VPP-1081)

## 0.8.0 - 22/09/2026

- (Minor) `provetCloudOrigin` on `mount()` — the Provet instance the tenant lives on. Provet runs one instance per domain, so a consumer names its own and one published version serves every consumer instead of one build per instance. Only a Provet origin is accepted (`config_invalid` otherwise), and the element falls back to the instance its build was made for (VPP-1077)
- (Patch) The element document admits every Provet instance in its CSP — `connect-src 'self' https://*.provetcloud.com https://provetcloud.com` alongside the build's own origin — so naming an instance needs no rebuild (VPP-1077)
- (Patch) Only the local build emits a source map; the element's source is not part of what a consumer receives (VPP-1077)

- (Breaking) The element owns its styling. Its chrome is drawn from its own `--pp-*` tokens instead of `@nordhealth/css`, which is no longer a dependency, and it renders in a system font stack rather than a webfont. A release is one script and one stylesheet — no font files — so nothing of a design system lands in whatever hosts it (VPP-1077)
- (Minor) `appearance.variables` now moves the element's own chrome as well as the card fields: each variable writes one `--pp-*` token, and the element's stylesheet derives Adyen's `--adyen-sdk-*` properties from those, so one value styles both. `cssVariables` takes `--pp-*` as well as `--adyen-sdk-*`, and wins over `variables` (VPP-1077)

## 0.7.0 - 22/09/2026

- (Breaking) A card is its Provet id and the details Provet prints beside it: `SavedCard` is `id`, `brand`, `last4`, `expiration_date`, `default`, and `tokenized_card_ref` is gone. No card status travels anywhere any more — not on a listed card, not on the one `onSuccess` returns, not in the stored session — and `GET /<provet_id>/api/0.1/pay/saved-cards/` lists only the cards that can be charged, so the element offers that list as it is given instead of filtering it (VPP-1077)
- (Breaking) `expiry` ("M/YYYY") is replaced by `expiration_date`, Provet's ISO date; the saved-card list prints it as the month on the card and marks it expired once that month has passed (VPP-1077)
- (Minor) Removing a saved card is off: the icon button no longer renders, so a card is picked or left alone. Provet has no delete endpoint for the element yet, and what removal means for health plans and other charges is undecided (VPP-1487)

## 0.6.0 - 10/09/2026

- (Breaking) `appearance.theme` and the `PayTheme` type are gone, and with them the light, dark and `auto` palettes. The element renders one way: Nord's light palette with no surface and no padding of its own, so it sits flush on the host page. `appearance.variables` and `appearance.secured` are unchanged and remain how a consumer matches its own design (VPP-1077)
- (Patch) `@nordhealth/themes` is no longer a dependency; its two palettes were inlined into the bundle, which is 1.6 KB smaller gzipped (VPP-1077)

## 0.5.0 - 09/09/2026

- (Minor) The Provet contract as merged (provetcloud !17554): the element mints with `POST /<provet_id>/api/0.1/pay/checkout-sessions/` sending `department`, `recurring_model` and `return_url`; `intent_key` is gone from the request and the session envelope; the integer card id is handed on as a string (VPP-1079)
- (Minor) Saved cards move to `/<provet_id>/api/0.1/pay/saved-cards/` (list and delete) (VPP-1079)
- (Minor) `test` and `prod` origins are known to the build, so `TARGET_ENV=test pnpm build` needs no environment variables; the package ships to npm, and `pnpm pack` produces the tarball a consumer takes until it is published (VPP-1083)
- (Patch) Provet error bodies — DRF `{detail, code}` and field errors — surface as the element's error message (VPP-1080)
- (Patch) `department` on `mount()` is documented as the Provet department id (VPP-1077)
- (Patch) The local host page and Provet stand-in move from port 6002 to 3000, the port the other local UIs use and therefore an origin Adyen already allows, so the card fields render locally without registering anything (VPP-1077)

## 0.4.0 - 31/07/2026

- (Minor) Project layout for the checkout card tokenizer: one package, two build targets — a host-page loader (npm + versioned CDN) and the element iframe served from our own origin, sharing one version so a pinned install always frames its matching element release (VPP-1057)
- (Minor) `mount(container, options)` + an `Auth`-style token provider as the public surface; `onSuccess({ card })` returns the Provet card id and nothing else (VPP-1057)
- (Minor) Element internals: the Provet client, the `sessionStorage` session envelope for refresh survival, the Adyen Web v6 adapter, typed error states and the saved-card offer, where a card is removed by an icon button behind a confirmation and "add a new card" is reversible — the card fields keep a back button to the offer, and returning to the fields reuses the intent already minted (VPP-1057)
- (Minor) `appearance.theme` — `plain` (the default: the light palette with no background or padding, so the element sits flush on the host page), `light`, `dark`, or `auto` (light or dark from the shopper's operating-system setting). Dark uses Nord's dark palette and reaches Adyen's cross-origin card fields, which cannot resolve a design token themselves (VPP-1057)
- (Minor) The chrome is Nord: its buttons, dropdown, popout surface, group heading and spinner carry the CSS of `nord-button` and `nord-dropdown`, so the element renders as the design system rather than an approximation of it. `appearance.variables.colorBorder` now also drives the resting card-field edge, which Adyen paints from a property of its own (VPP-1057)
- (Minor) `mount` renders a back control into the container, returning a shopper from the card form to their saved cards; it shows only when there is something to return to, sits above the frame against its trailing edge, renders as a `nord-button` of the plain variant under every theme, and carries the class `provet-pay-elements-back` (VPP-1057)
- (Minor) Local development environment on ports 6002 (host page + Provet stand-in) and 3003 (the element), minting real Adyen TEST `$0` sessions, with `PCLOUD_BASE_URL` to proxy to a real Provet (VPP-1057)
- (Minor) Both targets build with Vite per environment from `TARGET_ENV`, reading their origins from the environment so a build never guesses a hostname; the loader ships as ESM + UMD (`dist/loader/`), deploy wiring waits on those origins being decided (VPP-1057)
- (Patch) Strict TypeScript and type-aware ESLint, both gating `pnpm build` (VPP-1057)
