@flopay/react 1.14.3 → 1.14.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.
- package/README.md +50 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -201,7 +201,7 @@ The billing API can route hosted and eligible saved cards to an approved Worldpa
|
|
|
201
201
|
|
|
202
202
|
One value styles non-card Stripe Elements, the SDK-rendered wrapper and AVS fields, the hosted card form, and the automatic payment button's fallback checkout. `appearance` (Stripe-side overrides) and `buttonsStyles` (wrapper overrides) still win over the bundle for the fields they touch. The legacy `buttonsTheme` prop is deprecated in favor of `theme`; see the [ButtonsLayoutStyles reference](https://flopay.com/docs/technical-reference/react/flopay-checkout#buttonslayoutstyles-reference) for every override field.
|
|
203
203
|
|
|
204
|
-
`layout="buttons"` stacks the payment methods as buttons with an expandable card form, and can change at runtime without recreating the session. In that layout, `onButtonClick` reports every method click, `onDecline` reports declines and cancellations, and `onBeforeButtonClick` runs before a method continues: return an `InlineSessionPatch` to update the inline draft, or `false` to stop. Keep it
|
|
204
|
+
`layout="buttons"` stacks the payment methods as buttons with an expandable card form, and can change at runtime without recreating the session. In that layout, `onButtonClick` reports every method click, `onDecline` reports declines and cancellations, and `onBeforeButtonClick` runs before a method continues: return an `InlineSessionPatch` to update the inline draft, or `false` to stop. Keep it well under 900 ms for PayPal, Apple Pay, and Google Pay, because it runs during the provider's button handshake (see **Stalled wallet clicks** above).
|
|
205
205
|
|
|
206
206
|
#### Merchant instrument feed
|
|
207
207
|
|
|
@@ -307,6 +307,16 @@ When the saved payment method cannot complete silently, the button opens a `FloP
|
|
|
307
307
|
- **AVS.** With `enableAVS`, the SDK collects the billing address outside the PCI form and gates the form's submit synchronously on it. The postcode is validated against the selected country with the same rules as the billing API: a supported country blocks an empty or malformed postcode with an inline message, and a country without postcodes makes the field optional. Email and street, city, and state fields gate submit the same way. On submit, the address is saved in parallel with the charge: a rejected address (`4xx`) shows inline and reaches `onError` for the next attempt, while a transient failure or a 10-second timeout falls back to the session's saved address and still completes.
|
|
308
308
|
- `useCheckout()` exposes `claimPending`, which stays true while a detached session shell is not yet safe to charge.
|
|
309
309
|
|
|
310
|
+
### Upgrading from 1.9.x
|
|
311
|
+
|
|
312
|
+
Merchants on 1.9.4, or any other 1.9.x release, need no configuration change to adopt the wallet-recovery behaviour. Install 1.14.1 or newer: 1.14.1 is the first release that contains the complete wallet-recovery behaviour, and later versions include it. Move every installed `@flopay/*` package to the same version together.
|
|
313
|
+
|
|
314
|
+
- **Pre-click work.** Keep `onBeforeButtonClick` work, including any session update it returns, well under 900 ms. A wallet click that exhausts that budget is rejected once and reported as one `external_payment_method_failed` error whose `details.providerCode` is `express_checkout_click_timeout` (see **Stalled wallet clicks** above).
|
|
315
|
+
- **Errors.** Keep control flow on the stable top-level `error.code`: technical wallet, PayPal and alternative-method failures still use `external_payment_method_failed`. Its new optional `details` object is for diagnostics only, such as support logs; never branch on it or on provider text. The Errors reference below lists every field.
|
|
316
|
+
- **Wallet presentation.** `walletPresentation` is a bounded preference: `auto` (the default), `popup`, or `prefer_redirect`. Leaving it unset keeps the default behaviour.
|
|
317
|
+
- **PayPal.** Stripe-routed PayPal opens Stripe's full-page hosted approval proactively in Instagram, generic Android WebViews and other known in-app browsers, when you choose `prefer_redirect`, and after a positive popup block, then resumes the same checkout session on return. Direct PayPal keeps its popup or app-switch presentation.
|
|
318
|
+
- **Apple Pay and Google Pay.** Apple Pay and Google Pay appear only when Stripe reports them available for the buyer. When Stripe reports none of the enabled wallets, the wallet row collapses and PayPal and card stay.
|
|
319
|
+
|
|
310
320
|
## Examples
|
|
311
321
|
|
|
312
322
|
A complete checkout page for an existing session:
|
|
@@ -610,7 +620,7 @@ export function ComposedCheckout({ session, nonce }: { session: CheckoutSession;
|
|
|
610
620
|
| `onError` | `(error: FloPayError) => void` | A checkout error occurred |
|
|
611
621
|
| `onSessionCompleted` | `(successUrl: string) => void` | The session was already completed |
|
|
612
622
|
| `onButtonClick` | `(method: CheckoutButtonMethod) => void` | A payment method button was clicked |
|
|
613
|
-
| `onBeforeButtonClick` | `(event: BeforeButtonClickEvent) => ...` | Runs before a buttons-layout method continues; return a patch or `false
|
|
623
|
+
| `onBeforeButtonClick` | `(event: BeforeButtonClickEvent) => ...` | Runs before a buttons-layout method continues; return a patch or `false`. A wallet click gives it, and any session patch it returns, a 900 ms budget; keep the work well under that |
|
|
614
624
|
| `onInstrument` | `(event: FloInstrumentEvent) => void` | Merchant instrument feed |
|
|
615
625
|
| `onCountryChange` / `onZipChange` | `(value: string) => void` | AVS country or postcode changed |
|
|
616
626
|
| `showApplePay` / `showGooglePay` / `buttonsTheme` | deprecated | Superseded by the session's methods and `theme` |
|
|
@@ -780,6 +790,44 @@ and optional `presentationMode`. `providerCode` is sanitized and falls back to
|
|
|
780
790
|
`external_payment_method_failed`; raw provider messages, URLs, user agents,
|
|
781
791
|
credentials, payment identifiers, and customer data are never exposed.
|
|
782
792
|
|
|
793
|
+
| Detail | Type | Meaning |
|
|
794
|
+
|--------|------|---------|
|
|
795
|
+
| `providerCode` | `string` | Sanitized provider or SDK code for support. Falls back to `external_payment_method_failed`; the SDK-owned values are described below. |
|
|
796
|
+
| `popupBlocked` | `boolean` | The SDK positively classified the failure as a blocked popup. |
|
|
797
|
+
| `inAppBrowser` | `boolean` | The buyer's browser was classified as an in-app browser or WebView. |
|
|
798
|
+
| `appFamily` | `string` | The in-app browser family: `none`, `facebook`, `instagram`, `tiktok`, `generic_webview`, or `other_in_app`. |
|
|
799
|
+
| `popupCapability` | `string` | Whether a popup could open: `unknown`, `available`, or `blocked`. |
|
|
800
|
+
| `presentationMode` | `string`, optional | How the provider was presented, when known: `popup`, `app_switch`, or `redirect`. |
|
|
801
|
+
|
|
802
|
+
Key control flow on the stable top-level `error.code`, which stays
|
|
803
|
+
`external_payment_method_failed` for every technical wallet, PayPal, or
|
|
804
|
+
alternative-method failure. Treat `details` as optional and use it for
|
|
805
|
+
diagnostics only, such as support logs or analytics. Never match on provider
|
|
806
|
+
text or `error.message`, and never branch on a `details` value: new
|
|
807
|
+
`providerCode` values can appear in any release.
|
|
808
|
+
|
|
809
|
+
```tsx
|
|
810
|
+
import { FloPayCheckout } from '@flopay/react';
|
|
811
|
+
import type { FloPayError } from '@flopay/shared';
|
|
812
|
+
|
|
813
|
+
declare function logCheckoutDiagnostics(entry: Record<string, unknown>): void;
|
|
814
|
+
declare function showCheckoutProblem(code: string | undefined): void;
|
|
815
|
+
|
|
816
|
+
function handleCheckoutError(error: FloPayError) {
|
|
817
|
+
if (error.code === 'external_payment_method_failed') {
|
|
818
|
+
// The chooser already shows a retry, so the buyer can try again or pick another method.
|
|
819
|
+
// The details are diagnostics only: log them, never branch on them.
|
|
820
|
+
logCheckoutDiagnostics({ code: error.code, sessionId: error.sessionId, ...error.details });
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
showCheckoutProblem(error.code);
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
export function Checkout({ sessionId, nonce }: { sessionId: string; nonce: string }) {
|
|
827
|
+
return <FloPayCheckout sessionId={sessionId} nonce={nonce} onError={handleCheckoutError} />;
|
|
828
|
+
}
|
|
829
|
+
```
|
|
830
|
+
|
|
783
831
|
The SDK owns two `providerCode` values. The first is `wallet_sheet_window_too_small`. Desktop
|
|
784
832
|
Chrome refuses to open the Google Pay sheet when the browser window cannot fit
|
|
785
833
|
it (roughly less than 680 by 640 CSS pixels of content, so a docked DevTools
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flopay/react",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@flopay/js": "1.14.
|
|
40
|
-
"@flopay/shared": "1.14.
|
|
39
|
+
"@flopay/js": "1.14.5",
|
|
40
|
+
"@flopay/shared": "1.14.5",
|
|
41
41
|
"@paypal/paypal-js": "^10.1.0",
|
|
42
42
|
"@stripe/react-stripe-js": "^6.12.0",
|
|
43
43
|
"@stripe/stripe-js": "^9.17.0"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"react-dom": ">=18.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@testing-library/jest-dom": "^
|
|
50
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
51
51
|
"@testing-library/react": "^16.3.3",
|
|
52
52
|
"@types/react": "^19.3.0",
|
|
53
53
|
"@types/react-dom": "^19.3.0",
|