@flopay/react 1.13.5 → 1.14.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 +38 -0
- package/dist/index.cjs +9 -9
- package/dist/index.d.cts +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.mjs +7 -7
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -139,6 +139,40 @@ Direct PayPal never hides its button behind a FloPay identity step: after approv
|
|
|
139
139
|
|
|
140
140
|
**Initialization recovery.** A Direct PayPal startup failure hides PayPal, waits one second, and remounts once, without creating a session, intent, or charge; other payment methods stay usable throughout. If Stripe-rendered PayPal is also available, it takes over during recovery. If both attempts fail in a mixed checkout, PayPal stays hidden and neither `onError` nor `onDecline` fires. In a PayPal-only checkout the component shows an accessible retrying status, then a **Retry PayPal** button, and calls `onError` once with `paypal_init_timeout`.
|
|
141
141
|
|
|
142
|
+
**Buyer cancel (`onCancel`).** `FloPayCheckout`, `SplitCardForm` and `DirectPayPalButton` accept an optional `onCancel?: (event: FloPayPaymentCancelEvent) => void`. It is called once per click when the buyer closes the PayPal pop-up, or returns from PayPal's app switch, without approving. The `FloPayPaymentCancelEvent` is `{ status: 'cancelled', sessionId, provider: 'paypal', paymentMethodType }`: `sessionId` is the attempt's session (the one your `onBeforeButtonClick` patch returned, otherwise the checkout's), and `paymentMethodType` is `paypal_vaulted` when the session advertises an `order` or `setup_token`, otherwise `paypal`.
|
|
143
|
+
|
|
144
|
+
- It is never called for an approval, a decline (that stays `onDecline`), a blocked pop-up, a load, render or eligibility failure, the reconciliation timeout, or a click your `onBeforeButtonClick` stopped. A repeated or stale cancel for the same click is ignored.
|
|
145
|
+
- It covers the direct PayPal button only (sessions with `gateways.paypal`). Stripe-rendered PayPal does not report it.
|
|
146
|
+
- Nothing else changes: the PayPal button still remounts for the next click and `onDecline` is untouched. If you don't pass it, checkout behaves exactly as before, and a callback that throws does not break the button.
|
|
147
|
+
|
|
148
|
+
A "Didn't work? Pay another way" prompt that moves the buyer to the card form:
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
import { FloPayCheckout, type FloPayPaymentCancelEvent } from '@flopay/react';
|
|
152
|
+
import { useRef, useState } from 'react';
|
|
153
|
+
|
|
154
|
+
function Checkout({ sessionId, nonce }: { sessionId: string; nonce: string }) {
|
|
155
|
+
const [cancelled, setCancelled] = useState<FloPayPaymentCancelEvent | null>(null);
|
|
156
|
+
const cardFormRef = useRef<HTMLDivElement>(null);
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<>
|
|
160
|
+
{cancelled && (
|
|
161
|
+
<div role="status">
|
|
162
|
+
Didn't work? Pay another way.{' '}
|
|
163
|
+
<button type="button" onClick={() => cardFormRef.current?.focus()}>
|
|
164
|
+
Pay by card or Google Pay
|
|
165
|
+
</button>
|
|
166
|
+
</div>
|
|
167
|
+
)}
|
|
168
|
+
<div ref={cardFormRef} tabIndex={-1}>
|
|
169
|
+
<FloPayCheckout sessionId={sessionId} nonce={nonce} onCancel={setCancelled} />
|
|
170
|
+
</div>
|
|
171
|
+
</>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
142
176
|
#### Server-side card gateways (Worldpay)
|
|
143
177
|
|
|
144
178
|
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:
|
|
@@ -568,6 +602,7 @@ export function ComposedCheckout({ session, nonce }: { session: CheckoutSession;
|
|
|
568
602
|
| `telemetry` | `boolean?` | Set `false` to opt out of operational telemetry |
|
|
569
603
|
| `onComplete` | `(result: PaymentResult) => void` | Payment succeeded or was authorized |
|
|
570
604
|
| `onDecline` | `(decline: DeclineEvent) => void` | A payment was declined or authentication failed. The event carries `sessionId` when a session exists |
|
|
605
|
+
| `onCancel` | `(event: FloPayPaymentCancelEvent) => void` | The buyer closed or left the direct PayPal button's PayPal window without approving. Once per click; never for an approval, decline or technical failure |
|
|
571
606
|
| `onError` | `(error: FloPayError) => void` | A checkout error occurred |
|
|
572
607
|
| `onSessionCompleted` | `(successUrl: string) => void` | The session was already completed |
|
|
573
608
|
| `onButtonClick` | `(method: CheckoutButtonMethod) => void` | A payment method button was clicked |
|
|
@@ -664,6 +699,7 @@ Also accepts every standard `button` attribute, such as `onClick`, `disabled`, a
|
|
|
664
699
|
| `onBuyerIdentityReady` | `(identity) => MaybePromise<void>` | Attach a buyer identity collected by the form; `FloPayCheckout` wires its late-buyer claim here |
|
|
665
700
|
| `onTokenizedBody` | `(body: TokenizedBody) => void` | Take over non-card backend submission yourself |
|
|
666
701
|
| `onComplete` / `onDecline` / `onError` | callbacks | Checkout outcomes |
|
|
702
|
+
| `onCancel` | `(event: FloPayPaymentCancelEvent) => void` | The buyer left the direct PayPal button's PayPal window without approving; see the PayPal section above |
|
|
667
703
|
| `directPaypal` | `object?` | Direct PayPal client configuration when wiring PayPal manually; `FloPayCheckout` resolves it from `gateways.paypal` |
|
|
668
704
|
| `showApplePay` / `showGooglePay` | deprecated | Superseded by the session's `enabledPaymentMethods` |
|
|
669
705
|
|
|
@@ -680,6 +716,7 @@ Also accepts every standard `button` attribute, such as `onClick`, `disabled`, a
|
|
|
680
716
|
| `approvalPresentation` | `PayPalApprovalPresentation?` | Billing-API-advertised approval mode |
|
|
681
717
|
| `session` | `CheckoutSession \| null` | Backing session; its advertised values are authoritative |
|
|
682
718
|
| `onComplete` / `onDecline` | callbacks | Payment outcomes |
|
|
719
|
+
| `onCancel` | `(event: FloPayPaymentCancelEvent) => void` | The buyer closed or left PayPal without approving; once per click |
|
|
683
720
|
| `onTechnicalFailure` | callback | Post-click technical failures, including `popupBlocked` |
|
|
684
721
|
|
|
685
722
|
### Types
|
|
@@ -703,6 +740,7 @@ Also accepts every standard `button` attribute, such as `onClick`, `disabled`, a
|
|
|
703
740
|
| `VaultCardFieldsProps` | Props for `VaultCardFields` |
|
|
704
741
|
| `CheckoutState` | `session`, `loading`, `error`, `claimPending?` |
|
|
705
742
|
| `DeclineEvent` | `method`, `message`, `code?`, `declineCode?` |
|
|
743
|
+
| `FloPayPaymentCancelEvent` | Buyer left the direct PayPal button without approving: `status: 'cancelled'`, `sessionId`, `provider: 'paypal'`, `paymentMethodType` (`paypal` or `paypal_vaulted`) |
|
|
706
744
|
| `BeforeButtonClickEvent` | `method`, `sessionId?`, `createSession?` |
|
|
707
745
|
| `CheckoutButtonMethod` | The payment method a button represents |
|
|
708
746
|
| `InlineSessionDraft` | Draft accepted by `FloPayCheckoutProps.createSession` |
|