@flopay/react 1.19.0 → 1.20.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/README.md CHANGED
@@ -93,6 +93,7 @@ Skip your own session-creation route and create the session inside the component
93
93
 
94
94
  - **Currency is required.** Pass `currency` on `createSession`, or on the first item, subscription, or product. Without one the SDK throws a `CurrencyRequired` validation error before sending anything.
95
95
  - **Detached creation (default).** The checkout creates a lightweight session *shell* first, then attaches the catalog in a background claim. The hosted card form mounts from the shell without waiting for the claim or Stripe.js; wallets, alternative payment methods, and PayPal load in parallel and appear when the claim lands. The card form's submit button stays gated until the claim settles, because the billing API refuses to charge an unclaimed session; a buyer who clicks during that window is asked to press pay again. Catalog and coupon errors surface as a checkout load error. `createSession.timeoutMs` applies separately to the shell and the claim (12 seconds each by default). Detached creation requires billing API v1.7.12 or newer and `checkoutMode: 'full'`, and is skipped when `tokenizedData` is supplied; pass `deferDataAttachment: false` to force a single request.
96
+ - **Stripe account routing.** A detached create also sends the cart's distinct catalogue product codes as `routingProducts` (`[{ code }]`, one entry per code), a routing hint only: the billing API uses it to advertise the cart's Stripe account on the first response, so Stripe.js, fraud signals, Apple Pay and Google Pay start on that account from first paint, and it never stores the hint. An empty cart and a create that is not detached send no `routingProducts` at all, and for a merchant that does not use gateway selection the hint changes nothing. The claim stays the authority: when the claim changes the checkout to a different Stripe account, `FloPayCheckout` loads Stripe.js for the new account, drops the old instance and its Elements, and re-mounts the wallet buttons on the new account before showing the claimed session, so a wallet payment confirms on the new account only. A claim that keeps the account re-initialises nothing. If Stripe.js cannot load for the new account, the wallets stay hidden, the hosted card form and direct PayPal keep working, and **Retry payment methods** loads the new account. `FloPayCheckout` declares that it can switch with the `stripe-account-switch-v1` token in the `x-flo-sdk-capabilities` header of the detached create and its claims, so the billing API keeps Apple Pay and Google Pay on such a claim instead of hiding them. The SDK still never chooses or filters a gateway: it renders what the session advertises. `@flopay/vue` does not declare the capability; its port follows with SDK 2.0.
96
97
  - **Supplied buyer names.** When `createSession.account` has a non-blank `firstName` or `lastName`, the first session request (the shell) already carries the trimmed first and last name, so the billing API issues the hosted card form with its cardholder name field hidden from the start: the field is never rendered. A first name alone or a last name alone is sent on its own. Email, `userId`, the address, and the cart still arrive with the claim, and names are not part of the inline-session cache identity, so editing a name does not start a new session. Blank or whitespace-only names count as absent and leave the request and the form unchanged. The buyer types no name in this case, so no name input is reported. A billing API that does not yet keep names on the shell ignores them and shows the field as before.
97
98
  - **Late buyer identity.** Any still-anonymous session the checkout renders (including an existing session passed as `sessionId` and `nonce` with `buyerIdentified: false`) attaches the buyer email the checkout collects, or a wallet or PayPal approval supplies, through the session claim before payment.
98
99
  - **Checkout metadata.** `checkoutMetadata` is sent unchanged on the initial request and never repeated in a claim. Omitting it keeps the request shape; an explicit `null` and `{}` stay distinct. Returned metadata is on the normalized session and its `data.session`. The billing API alone enforces size limits.
@@ -267,7 +268,7 @@ function Checkout({ sessionId, nonce }: { sessionId: string; nonce: string }) {
267
268
 
268
269
  The billing API can route hosted and eligible saved cards to an approved Worldpay Corporate Gateway, processed entirely server-side. Your checkout code does not change:
269
270
 
270
- - **No gateway choice.** The billing API selects the gateway and decides stored-credential eligibility. The SDK sends no gateway hint, Worldpay capability, merchant code, scheme reference, or eligibility assertion. An Auto create advertises only the provider-neutral `async-auto-checkout-v1` response capability; Confirm and Full creates do not send it.
271
+ - **No gateway choice.** The billing API selects the gateway and decides stored-credential eligibility. The SDK sends no gateway choice, Worldpay capability, merchant code, scheme reference, or eligibility assertion; the detached create's `routingProducts` names the cart's products, never a gateway. An Auto create advertises only the provider-neutral `async-auto-checkout-v1` response capability; Confirm and Full creates do not send it. A detached Full create and its claims carry only `stripe-account-switch-v1` (see **Stripe account routing** above).
271
272
  - **Same card surface.** No Stripe runtime, Worldpay SDK, or browser credential is involved. An open session that advertises `gateways.worldpayCorporateGateway` but omits the embedded card form recovers it on demand; a completed or authorized session is never shown the card form again.
272
273
  - **Same saved-card flow.** Returning-buyer Auto and Confirm checkouts, including subscription creation, call the provider-neutral `/process` route without card re-entry or `tokenizedData`. Immediate and asynchronously reconciled success, authorization, decline, and error outcomes reach the existing callbacks and UI states. Scheduled rebills, retry, dunning, credential eligibility, and reconciliation remain backend-owned.
273
274
  - **Explicit unsupported use.** `stored_payment_method_unsupported` reaches `onError` with the buyer-safe instruction to choose another payment method. The SDK does not silently switch behavior, and older backends that omit the optional code remain compatible.
@@ -0,0 +1,31 @@
1
+ import { Elements } from '@stripe/react-stripe-js';
2
+ import type { ComponentProps, ReactElement } from 'react';
3
+ /**
4
+ * Records that a checkout is moving its Elements groups from the `current`
5
+ * Stripe instances to the `next` ones, because a claim moved it to another
6
+ * Stripe account. Call it before the new instances reach any group.
7
+ *
8
+ * Each `next` instance that is not already in use gets a fresh group key, so
9
+ * every `<AccountBoundElements>` handed it mounts a new group on the new
10
+ * account, even when the page switched to that account before. An instance
11
+ * still in use (an account that did not change, such as an unchanged PayPal
12
+ * account) keeps its key, so its groups stay mounted.
13
+ */
14
+ export declare function bindSwitchedStripeAccounts(next: unknown[], current: unknown[]): void;
15
+ /**
16
+ * Stripe's `<Elements>`, re-mounted when the checkout switches Stripe account.
17
+ *
18
+ * `<Elements>` binds to the first `stripe` it is given and ignores a later one.
19
+ * When a claim moves a checkout to another Stripe account, `FloPayCheckout`
20
+ * records the new account's instances (`bindSwitchedStripeAccounts`) before it
21
+ * hands them to its groups. The group key then changes in the same render as
22
+ * the `stripe` prop, so React unmounts the old group, and the wallet buttons
23
+ * inside it, and mounts a fresh group on the new account: no button keeps
24
+ * confirming on the old account.
25
+ *
26
+ * Only that switch changes the key. Any other render, including one that
27
+ * passes another instance for the same account or moves the group within the
28
+ * layout, keeps the group, and everything in it, mounted exactly as plain
29
+ * `<Elements>` would.
30
+ */
31
+ export declare function AccountBoundElements(props: ComponentProps<typeof Elements>): ReactElement;