@flopay/react 1.18.1 → 1.19.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 +37 -0
- package/dist/flopay-checkout.d.ts +12 -2
- package/dist/index.cjs +9 -9
- package/dist/index.mjs +7 -7
- package/dist/split-card-form.d.ts +11 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -143,6 +143,39 @@ Set `showCardBrandIcons` on `FloPayCheckout` or `SplitCardForm` to show the Visa
|
|
|
143
143
|
- **Compatibility.** A billing API whose card form predates the icons ignores the setting and keeps the field as it was.
|
|
144
144
|
- **Custom layouts.** `FloPayCheckout` forwards the prop to its built-in form. A `SplitCardForm` you render as a custom-layout child takes its own `showCardBrandIcons`.
|
|
145
145
|
|
|
146
|
+
#### Card field labels
|
|
147
|
+
|
|
148
|
+
Set `showCardFieldLabels` on `FloPayCheckout` or `SplitCardForm` to show visible labels above the hosted card fields, and `cardFieldLabels` to change their text:
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
<FloPayCheckout
|
|
152
|
+
sessionId={sessionId}
|
|
153
|
+
nonce={sessionNonce}
|
|
154
|
+
showCardFieldLabels
|
|
155
|
+
cardFieldLabels={{ number: 'Card number', expiry: 'Valid until', cvv: 'Security code' }}
|
|
156
|
+
appearance={{ rules: { '.Label': { color: '#475569', fontWeight: '500', marginBottom: '6px' } } }}
|
|
157
|
+
/>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
- **Opt-in.** When both props are omitted, nothing is sent and the card form looks as it does today. `false` hides the labels again.
|
|
161
|
+
- **Text.** `cardFieldLabels` takes optional `number`, `expiry`, `cvv` and `name` text (`CardFieldLabels`). Only the fields you set are sent, exactly as given: the hosted form shows the text literally. A field you leave out keeps the hosted form's default wording, and removing the prop restores all of them.
|
|
162
|
+
- **Live updates.** Changing either prop updates the hosted form in place, without remounting it or clearing entered card details. The SDK re-sends the settings whenever the hosted form becomes ready again.
|
|
163
|
+
- **Custom layouts.** `FloPayCheckout` forwards both props to its built-in form. A `SplitCardForm` you render as a custom-layout child takes its own.
|
|
164
|
+
- **Authenticated.** Like a custom submit label, the label settings are bound to the session and the card form's `messageToken`, and the SDK sends them only to the hosted form's exact `expectedOrigin`, never to `'*'`. A card form without them (an older billing API) receives no label settings and keeps its default look.
|
|
165
|
+
|
|
166
|
+
The labels are styled by the same `appearance.rules['.Label']` rule that styles Stripe's labels, so one setting styles both. The supported `.Label` properties are:
|
|
167
|
+
|
|
168
|
+
| `.Label` property | Hosted label |
|
|
169
|
+
|---|---|
|
|
170
|
+
| `color` | Text colour |
|
|
171
|
+
| `fontSize` | Font size, in `px` (`'13px'`) |
|
|
172
|
+
| `fontWeight` | Font weight (`'500'`, or `normal` / `bold`) |
|
|
173
|
+
| `letterSpacing` | Letter spacing, in `em` (`'0.05em'`) |
|
|
174
|
+
| `textTransform` | `none`, `uppercase`, `lowercase` or `capitalize` |
|
|
175
|
+
| `marginBottom` | The gap between the label and its field, in `px` (`'6px'`) |
|
|
176
|
+
|
|
177
|
+
Every other `.Label` property (for example `padding`, `border`, `marginTop`, `fontFamily` or `lineHeight`) is ignored, as are empty values and values of the wrong type; none of them raises an error. Without a supported `.Label` property, the theme sent to the hosted form is unchanged. The preset themes already style `.Label`, so their label style applies as soon as the labels are shown. The hosted form enforces its own bounds on the values.
|
|
178
|
+
|
|
146
179
|
#### Card field placeholders
|
|
147
180
|
|
|
148
181
|
Set `cardFieldPlaceholders` on `FloPayCheckout` or `SplitCardForm` to choose the placeholder text of the hosted card fields. Every field is optional: `number` (card number), `expiry` (expiry date), `cvv` (security code) and `name` (name on card):
|
|
@@ -746,6 +779,8 @@ export function ComposedCheckout({ session, nonce }: { session: CheckoutSession;
|
|
|
746
779
|
| `avsLayout` | `'row' \| 'column'` | AVS field layout |
|
|
747
780
|
| `cardFieldOrder` | `VaultCardFieldKey[]?` | Order of the hosted card rows |
|
|
748
781
|
| `showCardBrandIcons` | `boolean?` | Set `true` to show the Visa, Mastercard, Amex and Discover icons in the hosted card number field; omitted or `false` keeps the field as it is |
|
|
782
|
+
| `showCardFieldLabels` | `boolean?` | Set `true` to show visible labels above the hosted card fields, styled by `appearance.rules['.Label']`; omitted sends nothing |
|
|
783
|
+
| `cardFieldLabels` | `CardFieldLabels?` | Label text (`number`, `expiry`, `cvv`, `name`); only the fields you set are sent, verbatim |
|
|
749
784
|
| `cardFieldPlaceholders` | `CardFieldPlaceholders?` | Placeholder text for the hosted card fields: `number`, `expiry`, `cvv` and `name`, each optional; `''` shows no placeholder; updates live; omitted keeps the hosted wording |
|
|
750
785
|
| `cardAutoFocus` | `boolean?` | Set `false` to stop the checkout focusing the card form (or the identity/AVS field above it) when it opens; omitted or `true` keeps the default |
|
|
751
786
|
| `cardFieldsTimeoutMs` | `number?` | Milliseconds the card fields may take to become interactive before `onCardFieldsFailed` reports `timeout` (default 15 000) |
|
|
@@ -861,6 +896,8 @@ Also accepts every standard `button` attribute, such as `onClick`, `disabled`, a
|
|
|
861
896
|
| `enableAVS` | `boolean \| AVSFieldConfig` | Collect and validate the billing address |
|
|
862
897
|
| `cardFieldOrder` | `VaultCardFieldKey[]?` | Order of the hosted card rows |
|
|
863
898
|
| `showCardBrandIcons` | `boolean?` | Set `true` to show the Visa, Mastercard, Amex and Discover icons in the hosted card number field; omitted or `false` keeps the field as it is |
|
|
899
|
+
| `showCardFieldLabels` | `boolean?` | Set `true` to show visible labels above the hosted card fields, styled by `appearance.rules['.Label']`; omitted sends nothing |
|
|
900
|
+
| `cardFieldLabels` | `CardFieldLabels?` | Label text (`number`, `expiry`, `cvv`, `name`); only the fields you set are sent, verbatim |
|
|
864
901
|
| `cardFieldPlaceholders` | `CardFieldPlaceholders?` | Placeholder text for the hosted card fields: `number`, `expiry`, `cvv` and `name`, each optional; `''` shows no placeholder; updates live; omitted keeps the hosted wording |
|
|
865
902
|
| `cardAutoFocus` | `boolean?` | Set `false` to stop the form focusing the hosted card (or the identity/AVS field above it) when it opens; omitted or `true` keeps the default |
|
|
866
903
|
| `cardFieldsTimeoutMs` | `number?` | Milliseconds the card fields may take to become interactive before `onCardFieldsFailed` reports `timeout` (default 15 000) |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BeforeButtonClickEvent, CardFieldsFailedEvent, CardFieldsReadyEvent, CheckoutButtonMethod, CheckoutMode, DeclineEvent, FloInstrumentEvent, FloPayAppearance, FloPayPaymentCancelEvent, InlineSessionDraft, InlineSessionPatch, PaymentMethodLayoutRules, PaymentResult, WalletPresentation } from '@flopay/shared';
|
|
1
|
+
import type { BeforeButtonClickEvent, CardFieldLabels, CardFieldsFailedEvent, CardFieldsReadyEvent, CheckoutButtonMethod, CheckoutMode, DeclineEvent, FloInstrumentEvent, FloPayAppearance, FloPayPaymentCancelEvent, InlineSessionDraft, InlineSessionPatch, PaymentMethodLayoutRules, PaymentResult, WalletPresentation } from '@flopay/shared';
|
|
2
2
|
import { FloPayError } from '@flopay/shared';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
/** Props for the all-in-one `FloPayCheckout` wrapper. */
|
|
@@ -188,6 +188,16 @@ export interface FloPayCheckoutProps {
|
|
|
188
188
|
* Vault card path only; an older hosted form ignores it.
|
|
189
189
|
*/
|
|
190
190
|
showCardBrandIcons?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Show the visible labels above the hosted card fields. Omitted sends nothing,
|
|
193
|
+
* so the form looks as it does today. Vault card path only.
|
|
194
|
+
*/
|
|
195
|
+
showCardFieldLabels?: boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Replace the text of the labels (`number`, `expiry`, `cvv`, `name`). Only the
|
|
198
|
+
* fields you set are sent. Vault card path only.
|
|
199
|
+
*/
|
|
200
|
+
cardFieldLabels?: CardFieldLabels;
|
|
191
201
|
/**
|
|
192
202
|
* Placeholder text for the hosted card fields (`number`, `expiry`, `cvv`,
|
|
193
203
|
* `name`), each optional. Only the fields given are sent; the rest keep the
|
|
@@ -279,4 +289,4 @@ export interface FloPayCheckoutProps {
|
|
|
279
289
|
* />
|
|
280
290
|
* ```
|
|
281
291
|
*/
|
|
282
|
-
export declare function FloPayCheckout({ sessionId: sessionIdProp, nonce: nonceProp, createSession: createSessionParams, billingApiUrl, telemetry, appearance: appearanceOverride, locale, loading: loadingNode, error: errorNode, onComplete, onError, onInstrument, onDecline, onCancel, onCountryChange, onZipChange, showPayPal, showStripe, walletPresentation, enabledPaymentMethods: enabledPaymentMethodsProp, showApplePay, showGooglePay, debug, layout, paymentMethodLayout, moreOptionsLabel, theme, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, showSecurityFooter: _showSecurityFooter, onButtonClick, onBeforeButtonClick, enableAVS, cardFieldOrder, showCardBrandIcons, cardFieldPlaceholders, cardAutoFocus, onCardFieldsReady, onCardFieldsFailed, cardFieldsTimeoutMs, cardPreFormSlot, avsLayout, submitLabel, className, initialErrorMessage, initialPayPalOrderId, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
|
|
292
|
+
export declare function FloPayCheckout({ sessionId: sessionIdProp, nonce: nonceProp, createSession: createSessionParams, billingApiUrl, telemetry, appearance: appearanceOverride, locale, loading: loadingNode, error: errorNode, onComplete, onError, onInstrument, onDecline, onCancel, onCountryChange, onZipChange, showPayPal, showStripe, walletPresentation, enabledPaymentMethods: enabledPaymentMethodsProp, showApplePay, showGooglePay, debug, layout, paymentMethodLayout, moreOptionsLabel, theme, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, showSecurityFooter: _showSecurityFooter, onButtonClick, onBeforeButtonClick, enableAVS, cardFieldOrder, showCardBrandIcons, showCardFieldLabels, cardFieldLabels, cardFieldPlaceholders, cardAutoFocus, onCardFieldsReady, onCardFieldsFailed, cardFieldsTimeoutMs, cardPreFormSlot, avsLayout, submitLabel, className, initialErrorMessage, initialPayPalOrderId, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
|