@flopay/react 0.3.5 → 0.3.12
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 +39 -0
- package/dist/index.cjs +574 -207
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -5
- package/dist/index.d.ts +35 -5
- package/dist/index.mjs +565 -198
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -121,6 +121,43 @@ Switch from the default form layout to stacked payment buttons with an expandabl
|
|
|
121
121
|
|
|
122
122
|
Theme presets: `'default'`, `'minimal'`, `'rounded'`, `'dark'`. Custom styles via `buttonsStyles` merge on top of the theme preset. See the [ButtonsLayoutStyles reference](https://docs.flopay.com/api-reference/react/flopay-checkout#buttonslayoutstyles-reference) for all properties.
|
|
123
123
|
|
|
124
|
+
#### Button Hooks
|
|
125
|
+
|
|
126
|
+
Use `onButtonClick` to track button interactions, `onDecline` to track declines/cancellations, and `onBeforeButtonClick` to enrich the credit card flow before the card form opens:
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
<FloPayCheckout
|
|
130
|
+
layout="buttons"
|
|
131
|
+
createSession={{
|
|
132
|
+
clientId: 'your-client-id',
|
|
133
|
+
items: [{ providerItemId: 'product-1', providerItemName: 'Widget', totalAmount: 29.99, currency: 'EUR' }],
|
|
134
|
+
account: { userId: 'user_1' },
|
|
135
|
+
successUrl: '/success',
|
|
136
|
+
cancelUrl: '/cancel',
|
|
137
|
+
}}
|
|
138
|
+
onBeforeButtonClick={async ({ method }) => {
|
|
139
|
+
if (method !== 'card') return;
|
|
140
|
+
|
|
141
|
+
const email = await openEmailCaptureModal();
|
|
142
|
+
if (!email) return false;
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
account: { email },
|
|
146
|
+
tagsData: { sessionId: 'checkout_email_captured' },
|
|
147
|
+
};
|
|
148
|
+
}}
|
|
149
|
+
onButtonClick={(method) => {
|
|
150
|
+
window.dataLayer?.push({ event: 'checkout_button_click', payment_method: method });
|
|
151
|
+
}}
|
|
152
|
+
onDecline={(decline) => {
|
|
153
|
+
window.dataLayer?.push({ event: 'checkout_decline', ...decline });
|
|
154
|
+
}}
|
|
155
|
+
onComplete={handleSuccess}
|
|
156
|
+
/>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`onBeforeButtonClick` is **credit card only**. It runs only for the "Credit / Debit Card" button in `layout="buttons"`. It does not run for PayPal, Apple Pay, or Google Pay. If you need required data before every payment method, collect it before rendering checkout.
|
|
160
|
+
|
|
124
161
|
#### Inline Session Creation
|
|
125
162
|
|
|
126
163
|
Skip the backend API route — create the session directly in the component:
|
|
@@ -141,6 +178,8 @@ Skip the backend API route — create the session directly in the component:
|
|
|
141
178
|
|
|
142
179
|
The component POSTs to the billing API, gets the full session back, and renders the form — zero backend code needed.
|
|
143
180
|
|
|
181
|
+
When you use `onBeforeButtonClick`, `createSession.account.email` can be filled in later for the card-button flow. PayPal and wallets still need all required data before they render.
|
|
182
|
+
|
|
144
183
|
### Advanced: Manual Provider Setup
|
|
145
184
|
|
|
146
185
|
For full control over initialization:
|