@flopay/shared 1.20.15 → 2.0.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 +18 -13
- package/dist/constants.d.ts +1 -281
- package/dist/external-method-recovery.d.ts +0 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +8 -21
- package/dist/index.mjs +1 -1
- package/dist/paypal-buyer-identity.d.ts +1 -29
- package/dist/public-session.d.ts +20 -0
- package/dist/types.d.ts +2 -180
- package/dist/vault-buyer-email.d.ts +0 -10
- package/dist/wallet-sheet-window.d.ts +0 -2
- package/package.json +1 -1
- package/dist/before-button-click.d.ts +0 -11
- package/dist/checkout-gateway-rules.d.ts +0 -79
- package/dist/friendly-message.d.ts +0 -5
- package/dist/payment-logos.generated.d.ts +0 -1
- package/dist/payment-method-setup-advertisement.d.ts +0 -67
- package/dist/paypal-channel.d.ts +0 -77
- package/dist/paypal-environment.d.ts +0 -14
- package/dist/stripe-appearance.d.ts +0 -19
- package/dist/stripe-paypal-presentation.d.ts +0 -42
- package/dist/wallet-elements-mode.d.ts +0 -27
package/README.md
CHANGED
|
@@ -54,11 +54,11 @@ The postal-code helpers are a faithful mirror of the billing API's own postcode
|
|
|
54
54
|
|
|
55
55
|
### Gateway decisions belong to the billing API
|
|
56
56
|
|
|
57
|
-
`@flopay/shared` exposes no helper for declaring, selecting, or filtering payment gateways or gateway capabilities, and none should be added. Which gateway processes a session (Stripe, PayPal, Worldpay Corporate Gateway, or a future provider) is decided by the billing API from the merchant's configured gateways and their approved capability records. Clients that build `POST /v1/checkouts/sessions` themselves send the same provider-neutral body the SDK sends and render whatever
|
|
57
|
+
`@flopay/shared` exposes no helper for declaring, selecting, or filtering payment gateways or gateway capabilities, and none should be added. Which gateway processes a session (Stripe, PayPal, Worldpay Corporate Gateway, or a future provider) is decided by the billing API from the merchant's configured gateways and their approved capability records. Clients that build `POST /v1/checkouts/sessions` themselves send the same provider-neutral body the SDK sends and render whatever payment methods the response advertises in `paymentMethods` (`normalizePublicSession()` gives a session that still carries processor gateway keys that shape). Card setup follows the same rule: the optional `country`, `currency`, and `futureUse` on `CreateCardSetupSessionRequest` describe the transaction the card is set up for, and the billing API alone decides which gateway verifies the card.
|
|
58
58
|
|
|
59
59
|
Saved payment methods of any type follow the same rule. A setup session's optional `advertisedPaymentMethods` lists what the billing API advertises, and `isSetupCheckoutSession()` recognises the session without reading that list. `ListSavedPaymentMethodsQuery` filters only by method type (a `SavedPaymentMethodListType`), and no type here names a gateway or a provider.
|
|
60
60
|
|
|
61
|
-
An Auto-mode create may send `x-flo-sdk-capabilities: async-auto-checkout-v1`. This generic response-shape negotiation says only that the client can consume a `202 checkout_processing` response and its authenticated status endpoint. It is not a gateway hint, a saved-card eligibility claim, or a Worldpay opt-in. Confirm and Full creates do not send it. A client that reloads Stripe and re-mounts its wallets when a claim changes the advertised Stripe account may send `stripe-account-switch-v1` on a detached create and its claims (`@flopay
|
|
61
|
+
An Auto-mode create may send `x-flo-sdk-capabilities: async-auto-checkout-v1`. This generic response-shape negotiation says only that the client can consume a `202 checkout_processing` response and its authenticated status endpoint. It is not a gateway hint, a saved-card eligibility claim, or a Worldpay opt-in. Confirm and Full creates do not send it. A client that reloads Stripe and re-mounts its wallets when a claim changes the advertised Stripe account may send `stripe-account-switch-v1` on a detached create and its claims (no 2.0 `@flopay/*` package sends it: the 1.x `stripeAccountSwitch` option was removed with the browser billing API client); a detached create may also carry the cart's product codes as `routingProducts`, routing input only. Neither selects a gateway.
|
|
62
62
|
|
|
63
63
|
### Privacy-safe telemetry contract
|
|
64
64
|
|
|
@@ -193,7 +193,7 @@ try {
|
|
|
193
193
|
| `CheckoutMode` | Checkout mode: `'full'` / `'auto'` / `'confirm'` |
|
|
194
194
|
| `CheckoutSessionMode` | Mode accepted on session reads: any `CheckoutMode` plus `'setup'`. Browser session-creation types deliberately reject `'setup'`. |
|
|
195
195
|
| `CheckoutMetadata` | Caller-owned checkout snapshot: `Record<string, string>`. Creation accepts this shape or `null`; session reads contain the map only when the billing API returns it. |
|
|
196
|
-
| `CheckoutSession` | Session object: `id`, `clientSecret`, `mode`, `status` (`open`/`authorized`/`complete`/`expired`), `amount`, `currency`, `captureMethod?`, `paymentId?`, `authorizationExpiresAt?`, `failureOutcome?`, `customer?`, `checkoutMode?`, `checkoutMetadata?`, `buyerIdentified?` (false for a catalog-attached anonymous session), `vault?` (the hosted card form), `products?`, `successUrl?`, `cancelUrl?`, `coupons?`, `subtotalAmount?` / `discountAmount?` / `totalAmount?` (cart-currency major units), `
|
|
196
|
+
| `CheckoutSession` | Session object: `id`, `clientSecret`, `mode`, `status` (`open`/`authorized`/`complete`/`expired`), `amount`, `currency`, `captureMethod?`, `paymentId?`, `authorizationExpiresAt?`, `failureOutcome?`, `customer?`, `checkoutMode?`, `checkoutMetadata?`, `buyerIdentified?` (false for a catalog-attached anonymous session), `vault?` (the hosted card form), `products?`, `successUrl?`, `cancelUrl?`, `coupons?`, `subtotalAmount?` / `discountAmount?` / `totalAmount?` (cart-currency major units), `accountData?`, `tagsData?`, `advertisedPaymentMethods?` (the methods the billing API advertises a setup session can save, exactly as received; absent on older backends) |
|
|
197
197
|
| `SavedCardDisplay` | Display-only saved card: FloPay `id`, `brand`, `lastFour`, `expiryMonth`, `expiryYear`, and lifecycle `status`. It contains no reusable credential. |
|
|
198
198
|
| `SavedPaymentMethodFamily` | Family a saved payment method belongs to, for grouping: `'card'` / `'wallet'` / `'paypal'` / `'apm'`. It is the `type` that discriminates `SavedPaymentMethodDisplay`, and the same grouping as `AdvertisedPaymentMethod`'s `family`. |
|
|
199
199
|
| `SavedPaymentMethodType` | Deprecated alias of `SavedPaymentMethodFamily`, with the same values: `'card'` / `'wallet'` / `'paypal'` / `'apm'` |
|
|
@@ -206,9 +206,7 @@ try {
|
|
|
206
206
|
| `CheckoutSessionProduct` | Product from a session response: `uuid`, `checkoutSessionId`, `type` (`'item'`/`'subscription'`), `code?`, `name?`, `description?`, `quantity`, `totalAmount?`, `overrideAmount?`, `currency?`, `metadata?` |
|
|
207
207
|
| `CheckoutProductType` | `'item'` / `'subscription'` |
|
|
208
208
|
| `CheckoutProduct` | Product input for session creation: `type?`, `code?`, `name?`, `quantity?`, `totalAmount?`, `overrideAmount?`, `currency?`, `metadata?` |
|
|
209
|
-
| `CheckoutGateway` | Per-gateway config from the billing API. `publishableKey?` identifies the keyed gateway, including the direct-PayPal client ID. `paypalPublishableKey?` is Stripe-only: the dedicated Stripe account key used to render PayPal through Stripe Elements. Also `environment?` (`'sandbox'`/`'live'`), `stripeClientSecret?` (Stripe-only), `providerObjectType?` (direct PayPal: `'order'`/`'subscription'`/`'setup_token'`), `approvalPresentation?` (direct PayPal: `'app_switch'`/`'redirect'`), and `enabledPaymentMethods?` (Stripe-only). |
|
|
210
209
|
| `WalletPresentation` | Closed merchant preference for supported wallet approval presentation: `'auto'`, `'popup'`, or `'prefer_redirect'` |
|
|
211
|
-
| `CheckoutGateways` | Map keyed by gateway code (`stripe`, `paypal`). A session can advertise several gateways at once. A session opted into server-owned card routing may also carry `worldpayCorporateGateway`: a card gateway processed entirely server-side behind the hosted card form, with no browser credentials. Merchant code never needs to branch on it. |
|
|
212
210
|
| `GatewayEnvironment` | `'sandbox'` / `'live'`, which selects the PayPal JS SDK script and other environment-scoped behavior |
|
|
213
211
|
| `PaymentResult` | Payment outcome: `status` (`'authorized'`/`'succeeded'`/`'processing'`/`'requires_action'`/`'failed'`); authorized results carry `paymentId?`, `sessionId?`, and `authorizationExpiresAt?` |
|
|
214
212
|
| `CheckoutFailureOutcome` | Stable authorization lifecycle failure: `'authorization_declined'` / `'authentication_required'` / `'authorization_expired'` / `'capture_failed'` |
|
|
@@ -229,7 +227,6 @@ try {
|
|
|
229
227
|
| `RecurringInterval` | `interval` (`'month'`/`'year'`), `intervalCount?` |
|
|
230
228
|
| `BillingProvider` | Gateway code advertised for a session: `'stripe'` / `'paypal'` |
|
|
231
229
|
| `TokenizedBody` | `id?`, `type?`, `threeDSecureActionResultTokenId?`, `originalPaymentMethodId?`, `gateway?`, `paymentMethodType?` (the gateway's wire identifier, such as `'card'` or `'apple_pay'` for Stripe and `'paypal'` for PayPal), `isPaypal?` (deprecated in favor of `gateway` and `paymentMethodType`; still populated as the boolean `true` for PayPal) |
|
|
232
|
-
| `NormalizedCheckoutSession` | Provider-agnostic session: `providers` (every advertised gateway code), `mode`, `data`, `checkoutMetadata?`, `raw?`. The session itself is `data.session`, which also exposes `data.session.checkoutMetadata`. |
|
|
233
230
|
| `CheckoutModeKind` | `'tokenize'` / `'redirect'` |
|
|
234
231
|
| `CreateSessionParams` | Full session-creation params: `billingApiUrl`, `checkoutBaseUrl`, `clientId`, `currency` (required, or resolvable from the first item, subscription, or product), `captureMethod?` (`'automatic'`/`'manual'`; omitted keeps immediate capture), `products?` (takes precedence), `items?`, `subscriptions?` (legacy, folded into products before sending), `account`, `successUrl`, `cancelUrl`, `checkoutMode?`, `checkoutMetadata?`, `couponCodes?`, `tagsData?`, `redirectParams?`, `setCookie?`, `timeoutMs?`, `utmMetadata?`, `idempotencyKey?` |
|
|
235
232
|
| `CheckoutSessionResult` | `{ status: 201; redirectUrl; nonce }` / `{ status: 204 }` / `{ status: number }`. The `nonce` is the session-bound checkout token: forward it as `x-checkout-session-token` on every continuation call for the same session. |
|
|
@@ -239,7 +236,6 @@ try {
|
|
|
239
236
|
| `InlineSessionParams` | Browser session-creation parameters, including nullable `checkoutMetadata?`. For detached creation, `timeoutMs` applies independently to the shell request and the initial catalog claim. |
|
|
240
237
|
| `InlineSessionDraft` | Browser checkout draft. Keeps `account.userId` required but lets `account.email` be omitted and collected during checkout. |
|
|
241
238
|
| `InlineSessionPatch` | Just-in-time draft update. `checkoutMetadata` replaces the whole current map and accepts an explicit `null`. |
|
|
242
|
-
| `DetachedCheckoutSession` | Mountable `shell`, the catalog-attachment `claimed` promise, the session `nonce`, and an independently replay-safe `claim()` that attaches a late buyer identity. |
|
|
243
239
|
| `ProcessPaymentParams` | `sessionId`, `nonce` (required session-bound checkout token), `tokenizedData?`, `accountData`, `chv?` |
|
|
244
240
|
| `PaymentMethodRemovalError` | Merchant-server saved-method removal union: an indistinguishable `404 payment_method_not_found`, three stable `409` conflict codes, and a retry-safe `502 payment_method_deletion_failed` |
|
|
245
241
|
| `CreateCardSetupSessionRequest` | Body a merchant server sends to the authenticated `POST /v1/checkouts/sessions/setup` route: `userId` (an existing FloPay customer), `successUrl?`, `cancelUrl?`, and independent, nullable transaction context: `country?` (ISO 3166-1 alpha-2), `currency?` (three letters; a supplied value becomes the setup session's currency), and `futureUse?` (`CardSetupFutureUse`). The context needs billing API v1.9.48+, and older billing APIs silently ignore it. Type-only: no FloPay package sends this request, and the billing API owns normalization, validation, defaults, and gateway routing. |
|
|
@@ -294,12 +290,10 @@ try {
|
|
|
294
290
|
| `BUTTONS_LAYOUT_GLASS_LIGHT` | Buttons-layout styles paired with `GLASS_LIGHT_APPEARANCE` |
|
|
295
291
|
| `BUTTONS_LAYOUT_GLASS_DARK` | Buttons-layout styles paired with `GLASS_DARK_APPEARANCE` |
|
|
296
292
|
| `THEMES` | `Record<ThemeBundleId, ThemeBundle>`: `THEMES['glass-dark']` is `{ appearance, buttonsLayout }` |
|
|
297
|
-
| `PAYPAL_VAULTED_PAYMENT_METHOD_TYPE` | `'paypal_vaulted'`: the payment-method channel that opts a session intent or process request into Flo-owned PayPal Order and setup-token continuations; legacy `paypal` keeps provider-managed semantics |
|
|
298
293
|
| `SUPPORTED_CARD_BRANDS` | `'visa'`, `'mastercard'`, `'mastercard_debit'`, `'amex'`, `'discover'` |
|
|
299
294
|
| `SAVED_PAYMENT_METHOD_FAMILIES` | `'card'`, `'wallet'`, `'paypal'`, `'apm'`: every `SavedPaymentMethodFamily`, for exhaustive handling and grouping |
|
|
300
295
|
| `SAVED_PAYMENT_METHOD_TYPES` | Deprecated alias of `SAVED_PAYMENT_METHOD_FAMILIES`, with the same values: `'card'`, `'wallet'`, `'paypal'`, `'apm'` |
|
|
301
296
|
| `SAVED_PAYMENT_METHOD_LIST_TYPES` | `'card'`, `'paypal'`, `'apple_pay'`, `'google_pay'`, `'sepa_debit'`, `'us_bank_account'`: every `SavedPaymentMethodListType`, exactly the values the billing API's saved-method list accepts as its `type` filter |
|
|
302
|
-
| `STRIPE_EXPRESS_METHODS` | `'apple_pay'`, `'google_pay'`, `'paypal'`, `'link'`, `'amazon_pay'`, `'klarna'`: Stripe methods rendered as express buttons. Every other enabled Stripe method appears in the React SDK's payment-method accordion. |
|
|
303
297
|
| `CURRENCY_MAP` | Country code to `CurrencyInfo` mapping (EU, GB, US, CA, NZ, AU) |
|
|
304
298
|
| `DEFAULT_CURRENCY` | The USD fallback `CurrencyInfo` |
|
|
305
299
|
| `IDEMPOTENCY_KEY_HEADER` | `'Idempotency-Key'`, sent on `POST /v1/checkouts/sessions` |
|
|
@@ -308,7 +302,6 @@ try {
|
|
|
308
302
|
| `FLO_SDK_CAPABILITIES_HEADER` | `'x-flo-sdk-capabilities'`, the generic response-shape negotiation header |
|
|
309
303
|
| `ASYNC_AUTO_CHECKOUT_CAPABILITY` | `'async-auto-checkout-v1'`: advertises support for authenticated asynchronous Auto status responses, never gateway routing |
|
|
310
304
|
| `STORED_PAYMENT_METHOD_UNSUPPORTED_CODE` | `'stored_payment_method_unsupported'`, the stable provider-neutral unsupported-use outcome |
|
|
311
|
-
| `STORED_PAYMENT_METHOD_UNSUPPORTED_MESSAGE` | The buyer-safe instruction to choose another payment method for that outcome |
|
|
312
305
|
| `TELEMETRY_LOG_NAMES` | The complete SDK-authored lifecycle log catalog |
|
|
313
306
|
| `TELEMETRY_FAILURE_CATEGORIES` | `'server_error'`, `'transport_error'`, `'invalid_response'`, `'provider_runtime'` |
|
|
314
307
|
|
|
@@ -320,8 +313,6 @@ try {
|
|
|
320
313
|
| `resolveButtonsLayoutTheme(name)` | Maps a `ButtonsLayoutTheme` name to its `ButtonsLayoutStyles` preset |
|
|
321
314
|
| `computeVaultLabelTheme(appearance)` | Maps the supported `appearance.rules['.Label']` properties (`color`, `fontSize`, `fontWeight`, `letterSpacing`, `textTransform`, and `marginBottom` as `gap`) to a `VaultLabelTheme`. Other properties, empty values and wrong-typed values are ignored without error; no `.Label` rule gives `{}` |
|
|
322
315
|
| `buildCardFieldLabelsPayload(labels)` | The label text sent to the hosted card form: only the string `number`, `expiry`, `cvv` and `name` fields, verbatim. `null`, `undefined` or no string field gives `{}` |
|
|
323
|
-
| `partitionStripeMethods(enabledMethods, options?)` | Splits the billing API's enabled Stripe methods into `{ expressMethods, paymentElementMethods }`. Drops `card`, and also `paypal` when `excludePaypal` is true. |
|
|
324
|
-
| `stripeExpressMethodToOptionKey(method)` | Maps Stripe wire identifiers (`apple_pay`, `google_pay`, `amazon_pay`) to the camelCase option keys Stripe's express checkout expects |
|
|
325
316
|
|
|
326
317
|
### Validation helpers
|
|
327
318
|
|
|
@@ -372,6 +363,20 @@ try {
|
|
|
372
363
|
| `serializeTelemetryBatch(events, options)` | Serializes events into the billing API's v1 telemetry envelope |
|
|
373
364
|
| `dropThirdPartyOnlyError(event)` | Sentry `beforeSend` predicate that drops recognized third-party-only exception stacks and otherwise returns the original event |
|
|
374
365
|
|
|
366
|
+
### Breaking changes in 2.0.0
|
|
367
|
+
|
|
368
|
+
`@flopay/shared` 2.0.0 is reduced to the public types plus `FloPayError` and the non-provider helpers (validation and idempotency). Provider rules, gateway selection and buyer-facing checkout wording now live in the hosted checkout runtime, which applies them itself; none of the removed exports has a package replacement. `@flopay/js`, `@flopay/react`, `@flopay/vue`, `@flopay/node` and `@flopay/shared` are released together as 2.0.0.
|
|
369
|
+
|
|
370
|
+
- Stripe method filters and tables: `filterStripeMethodsByAmount`, `filterStripeMethodsByCountry`, `filterStripeMethodsByCurrency`, `filterStripeMethodsByCountryGate`, `partitionStripeMethods`, getStripeMethodDisplayName, `hasVendoredStripeMethodLogo`, `needsStripeMethodExplicitConfirm`, `resolveStripeMethodBrandVariant`, `stripeExpressMethodToOptionKey`, `stripeMethodCategory`, `STRIPE_EXPRESS_METHODS`, `STRIPE_METHOD_AMOUNT_LIMITS`, `STRIPE_METHOD_COUNTRIES`, `STRIPE_METHOD_CURRENCIES`, `STRIPE_METHOD_MATRIX`: No replacement: the hosted runtime decides which methods to show. Hide methods with the components' `hiddenPaymentMethods`.
|
|
371
|
+
- Stripe appearance adapter: `toStripeAppearance`, `toStripeAppearanceTheme`: Pass `appearance` and `theme` to the components unchanged; the runtime resolves them.
|
|
372
|
+
- PayPal channel and environment helpers: `buildPayPalCancelEvent`, `buildPayPalProcessPaymentRequest`, `buildPayPalSessionIntentRequest`, `buildPayPalTokenizedBody`, `describePayPalProcessFailure`, `friendlyPayPalFailureMessage`, `isPayPalTeardownMessage`, `resolvePayPalDeclineReason`, `usesPayPalVaultedChannel`, detectPayPalEnvironment, `isPayPalAcknowledgementDeadWindow`, `mergePayPalPayerIdentity`, `readPayPalPayerIdentity`, `resolvePayPalApprovalIdentity`, resolvePayPalPresentationMode, `needsPayPalPayerDetails`, `paypalProviderIdentityRequired`, PAYPAL_VAULTED_PAYMENT_METHOD_TYPE: No replacement: the hosted runtime runs PayPal.
|
|
373
|
+
- Processor-routed PayPal continuation: `resolveStripePayPalPresentation`, clearStripePayPalReturn, `hasMatchingStripePayPalReturn`, readMatchingStripePayPalContinuation, readStripeRedirectParams, `STRIPE_PAYPAL_RESUME_KEY`, `STRIPE_REDIRECT_PARAMS`, stripeRedirectReturnUrl, writeStripePayPalContinuation: No replacement: the hosted runtime handles redirect returns.
|
|
374
|
+
- Gateway selection: `applyClaimAdvertisement`, canRecoverHostedCardForm, cardGatewayName, hasServerSideCardGateway, `resolveDirectPaypalConfig`: `paymentMethods` on the public session (see below).
|
|
375
|
+
- Buyer-facing checkout wording: `BUYER_EMAIL_REQUIRED_PROMPT`, `buyerEmailRequiredPrompt`, CHECKOUT_PROCESSING_TIMEOUT_MESSAGE, STORED_PAYMENT_METHOD_UNSUPPORTED_MESSAGE, `applyFriendlyMessageOverride`, buildExternalMethodRecoveryMessage, `getButtonMethodLabel`, `normalizeBeforeButtonClickError`, `buildWalletSheetWindowMessage`, `setupOverlayLabels`: No replacement: the hosted runtime owns the wording. Pass `strings` to the components to override it.
|
|
376
|
+
- CheckoutGateways (`gateways.stripe`, `gateways.paypal`): `paymentMethods`: availability of `card`, `paypal`, `wallets` and `apms`, with no processor key and no processor publishable key. `gateways.stripe` becomes `card`, `wallets` and `apms`; `gateways.paypal` becomes `paypal`. `normalizePublicSession()` turns a session that still carries processor gateway keys into this shape.
|
|
377
|
+
|
|
378
|
+
**Default checkout mode.** A session created with no `checkoutMode` now defaults to `'full'` (it was `'confirm'` in 1.x), in `@flopay/js` and `@flopay/node`. An explicit `'confirm'`, `'auto'` or `'full'` is sent unchanged. Merchants who want the old default must set `checkoutMode: 'confirm'` and create the session from a server with merchant credentials.
|
|
379
|
+
|
|
375
380
|
## Errors
|
|
376
381
|
|
|
377
382
|
Errors the FloPay SDK creates or normalizes are `FloPayError`s. Other failures can still surface unchanged, such as an underlying `fetch()` rejection, a Stripe error, or a native `Error` from a payload builder, so check `error instanceof FloPayError` before reading `type` or `code`. Branch on its stable `type` and `code`, never on `message`.
|
|
@@ -404,6 +409,6 @@ Codes raised by this package's helpers:
|
|
|
404
409
|
Billing API outcomes described by shared types:
|
|
405
410
|
|
|
406
411
|
- `IDEMPOTENCY_IN_PROGRESS_CODE` marks a retryable in-progress replay of the same idempotency key; retry with the same key. A `409` payload conflict for a reused key is not retryable.
|
|
407
|
-
- `STORED_PAYMENT_METHOD_UNSUPPORTED_CODE` marks an explicit, provider-neutral saved-method failure. Show
|
|
412
|
+
- `STORED_PAYMENT_METHOD_UNSUPPORTED_CODE` marks an explicit, provider-neutral saved-method failure. Show STORED_PAYMENT_METHOD_UNSUPPORTED_MESSAGE and let the buyer choose another method; do not silently retry with different payment behavior. The optional `CheckoutProcessError.code` remains absent-safe for older billing APIs.
|
|
408
413
|
- `CheckoutFailureOutcome` classifies an authorization that did not complete: `authorization_declined`, `authentication_required`, `authorization_expired`, or `capture_failed`.
|
|
409
414
|
- `PaymentMethodRemovalError` covers saved-method removal from your server: `payment_method_not_found` (404, also returned for a method you cannot access), the `409` conflicts `payment_method_has_active_payment`, `payment_method_in_use`, and `payment_method_reassignment_requires_payer_action`, and `payment_method_deletion_failed` (502, retry-safe, with a `reason` and `resolution`).
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AVSFieldConfig, ButtonsLayoutStyles, ButtonsLayoutTheme, CountryOption, CurrencyInfo, FloPayAppearance, ThemeBundle, ThemeBundleId, ThemeId } from './types.js';
|
|
2
2
|
/** Current SDK version. */
|
|
3
|
-
export declare const SDK_VERSION = "
|
|
3
|
+
export declare const SDK_VERSION = "2.0.0";
|
|
4
4
|
/**
|
|
5
5
|
* HTTP header the SDK sends on checkout-session create/read requests so the
|
|
6
6
|
* backend can observe compatibility. Version 1.4.9 is the first release that
|
|
@@ -20,30 +20,8 @@ export declare const FLO_SDK_CAPABILITIES_HEADER = "x-flo-sdk-capabilities";
|
|
|
20
20
|
export declare const ASYNC_AUTO_CHECKOUT_CAPABILITY = "async-auto-checkout-v1";
|
|
21
21
|
/** Shared buyer-interaction window for saved-card and hosted-vault 3DS challenges. */
|
|
22
22
|
export declare const THREE_DS_CHALLENGE_WINDOW_MS = 300000;
|
|
23
|
-
/**
|
|
24
|
-
* In-band payment-method CHANNEL for Flo-owned PayPal continuations.
|
|
25
|
-
*
|
|
26
|
-
* The payment-method type sent to `POST /v1/checkouts/sessions/{id}/intents`
|
|
27
|
-
* is the channel selector: requesting `paypal_vaulted` opts a single request
|
|
28
|
-
* into the Flo-owned channel (an Order for `intentKind: 'payment'`, a vault
|
|
29
|
-
* setup token for `intentKind: 'setup'`), while the legacy `paypal` type keeps
|
|
30
|
-
* the released provider-managed semantics byte-identical — even when the
|
|
31
|
-
* backend feature flag is on. Sessions advertise availability via
|
|
32
|
-
* `gateways.paypal.providerObjectType` and an informational `paypal_vaulted`
|
|
33
|
-
* entry in `gateways.paypal.enabledPaymentMethods`; there is no capability
|
|
34
|
-
* header and no version-gated routing.
|
|
35
|
-
*/
|
|
36
|
-
export declare const PAYPAL_VAULTED_PAYMENT_METHOD_TYPE = "paypal_vaulted";
|
|
37
23
|
/** Stable provider-neutral saved-method outcome published by the billing API. */
|
|
38
24
|
export declare const STORED_PAYMENT_METHOD_UNSUPPORTED_CODE = "stored_payment_method_unsupported";
|
|
39
|
-
/** Buyer-safe recovery copy paired with {@link STORED_PAYMENT_METHOD_UNSUPPORTED_CODE}. */
|
|
40
|
-
export declare const STORED_PAYMENT_METHOD_UNSUPPORTED_MESSAGE = "This saved payment method can\u2019t be used for this payment. Choose another payment method.";
|
|
41
|
-
/**
|
|
42
|
-
* Buyer-facing copy for `checkout_processing_timeout`. The SDK could not confirm
|
|
43
|
-
* the outcome in time and the payment may still complete, so the buyer must
|
|
44
|
-
* never be invited to pay again (TeamFloPay/sdk#395).
|
|
45
|
-
*/
|
|
46
|
-
export declare const CHECKOUT_PROCESSING_TIMEOUT_MESSAGE = "We\u2019re still confirming your payment. Please don\u2019t pay again.";
|
|
47
25
|
/** Billing API URL for staging environment. */
|
|
48
26
|
export declare const BILLING_API_URL_STAGING = "https://api.stage.flopay.com";
|
|
49
27
|
/** Billing API URL for production environment. */
|
|
@@ -159,264 +137,6 @@ export declare const THEMES: Record<ThemeBundleId, ThemeBundle>;
|
|
|
159
137
|
* `appearance` / `buttonsStyles` props still override the resolved bundle.
|
|
160
138
|
*/
|
|
161
139
|
export declare function resolveTheme(id?: ThemeId | null): ThemeBundle | undefined;
|
|
162
|
-
/**
|
|
163
|
-
* Map Stripe wire identifiers (`apple_pay`, `google_pay`, `amazon_pay`) to the
|
|
164
|
-
* camelCase keys that `ExpressCheckoutElement`'s `paymentMethods` options
|
|
165
|
-
* map expects. Everything not in this map is already camelCase compatible.
|
|
166
|
-
*/
|
|
167
|
-
export declare function stripeExpressMethodToOptionKey(method: string): string;
|
|
168
|
-
/**
|
|
169
|
-
* Per-method metadata for every Stripe payment-method type the SDK
|
|
170
|
-
* recognises. One source of truth instead of half a dozen disjoint maps —
|
|
171
|
-
* `STRIPE_METHOD_CURRENCIES`, `STRIPE_METHOD_AMOUNT_LIMITS`, the React
|
|
172
|
-
* package's display-name table, and the inline-form heuristic all derive
|
|
173
|
-
* from entries here.
|
|
174
|
-
*
|
|
175
|
-
* Source: Stripe payment-method support matrices at
|
|
176
|
-
* <https://docs.stripe.com/payments/payment-methods/integration-options>.
|
|
177
|
-
* Update entries when Stripe ships a new currency / amount limit / method
|
|
178
|
-
* — the SDK falls back to safe defaults for any wire identifier not listed.
|
|
179
|
-
*/
|
|
180
|
-
export interface StripeMethodEntry {
|
|
181
|
-
/**
|
|
182
|
-
* Human-readable label, used by consumers for "Pay with X" buttons and
|
|
183
|
-
* other UI surfaces that need the brand name.
|
|
184
|
-
*/
|
|
185
|
-
displayName: string;
|
|
186
|
-
/**
|
|
187
|
-
* Lowercase ISO-4217 currency codes Stripe accepts for this method. The
|
|
188
|
-
* sentinel `'*'` means "currency-agnostic" — only the universal big-button
|
|
189
|
-
* wallets (Apple Pay / Google Pay) use this today.
|
|
190
|
-
*/
|
|
191
|
-
currencies: readonly string[];
|
|
192
|
-
/**
|
|
193
|
-
* Uppercase ISO 3166-1 alpha-2 codes for the buyer countries Stripe makes
|
|
194
|
-
* this method available to (matched against the session customer's
|
|
195
|
-
* country). Many local APMs are country-gated independently of currency —
|
|
196
|
-
* Bancontact is Belgium-only, EPS Austria-only, iDEAL Netherlands-only,
|
|
197
|
-
* SEPA Debit the whole SEPA zone — so a EUR cart still must not offer
|
|
198
|
-
* Bancontact to a Dutch buyer.
|
|
199
|
-
*
|
|
200
|
-
* **Omit** for methods with no meaningful country restriction (the global
|
|
201
|
-
* wallets, Alipay, Klarna, …) — a missing list means "no country gate", so
|
|
202
|
-
* the method passes {@link filterStripeMethodsByCountry} for every buyer.
|
|
203
|
-
*/
|
|
204
|
-
countries?: readonly string[];
|
|
205
|
-
/**
|
|
206
|
-
* Per-currency amount min/max in the smallest currency unit (cents for USD,
|
|
207
|
-
* pence for GBP, etc.). Omit when there is no notable limit. Stripe's
|
|
208
|
-
* `/v1/elements/sessions` rejects the whole accordion when an entry is in
|
|
209
|
-
* `paymentMethodTypes` and the deferred-intent amount falls outside its
|
|
210
|
-
* advertised range, so filtering here matches Stripe's reality.
|
|
211
|
-
*/
|
|
212
|
-
amounts?: Record<string, {
|
|
213
|
-
min?: number;
|
|
214
|
-
max?: number;
|
|
215
|
-
}>;
|
|
216
|
-
/**
|
|
217
|
-
* True when this method renders inside Stripe's `ExpressCheckoutElement`
|
|
218
|
-
* (apple_pay, google_pay, paypal, link, amazon_pay, klarna). Everything
|
|
219
|
-
* else lives in the `PaymentElement` accordion.
|
|
220
|
-
*/
|
|
221
|
-
express?: boolean;
|
|
222
|
-
/**
|
|
223
|
-
* When `false`, the SDK auto-submits the moment the buyer clicks the
|
|
224
|
-
* method card — the buyer is taken straight to Stripe's authorization UI
|
|
225
|
-
* (popup / redirect) without an intermediate confirm step. Only set this
|
|
226
|
-
* for *pure* redirect-only methods that have no inline data collection
|
|
227
|
-
* (Cash App, Affirm).
|
|
228
|
-
*
|
|
229
|
-
* **Default `true`**: render an explicit "Pay with X" button at the
|
|
230
|
-
* bottom of the accordion. Safer-by-default — any new/unknown APM, or
|
|
231
|
-
* any method whose Stripe UI changes to add inline inputs, will surface
|
|
232
|
-
* a deliberate confirm action instead of silently auto-submitting on a
|
|
233
|
-
* stray keystroke. Bancontact / Giropay are theoretically redirect-only
|
|
234
|
-
* but ship with a Name input by default, so they stay on the default
|
|
235
|
-
* (button) path.
|
|
236
|
-
*/
|
|
237
|
-
needsExplicitConfirm?: boolean;
|
|
238
|
-
/**
|
|
239
|
-
* Per-mode brand styling for the method tile button. The SDK looks up
|
|
240
|
-
* `theme.dark` when the active FloPay theme is one of the `*-dark`
|
|
241
|
-
* bundles, otherwise `theme.light` (also used for `classic`, since
|
|
242
|
-
* brand assets are designed primarily against light surfaces).
|
|
243
|
-
*
|
|
244
|
-
* Entries are optional — methods without a `theme` fall back to the
|
|
245
|
-
* neutral tile styling derived from the theme's `buttonsStyles.cardButton`
|
|
246
|
-
* + `derivePrimaryTileStyle`. Consumers can override per-tile via
|
|
247
|
-
* `buttonAppearance` on the inner component.
|
|
248
|
-
*/
|
|
249
|
-
theme?: {
|
|
250
|
-
light?: StripeMethodThemeVariant;
|
|
251
|
-
dark?: StripeMethodThemeVariant;
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Per-mode visual treatment for a Stripe method tile button. Applies brand
|
|
256
|
-
* colors and (optionally) an inline mark so each APM tile reads
|
|
257
|
-
* unmistakably as itself.
|
|
258
|
-
*
|
|
259
|
-
* `logoSvg` is an inline SVG string rendered at ~22px tall inside the
|
|
260
|
-
* button before the label. The SDK ships a small generic placeholder mark
|
|
261
|
-
* per method (a colored disc + initial) authored as original geometry —
|
|
262
|
-
* **not** a reproduction of any official trademarked logo. Consumers who
|
|
263
|
-
* have rights to a brand's artwork can replace these per-entry by
|
|
264
|
-
* overriding the matrix in their own deployment.
|
|
265
|
-
*/
|
|
266
|
-
export interface StripeMethodThemeVariant {
|
|
267
|
-
backgroundColor?: string;
|
|
268
|
-
borderColor?: string;
|
|
269
|
-
textColor?: string;
|
|
270
|
-
/**
|
|
271
|
-
* Inline SVG markup, e.g. `'<svg viewBox="0 0 24 24">…</svg>'`. Trusted
|
|
272
|
-
* by the renderer (mounted via `dangerouslySetInnerHTML`) — only edit
|
|
273
|
-
* via this matrix or a controlled override; never wire user input here.
|
|
274
|
-
*/
|
|
275
|
-
logoSvg?: string;
|
|
276
|
-
}
|
|
277
|
-
export declare const STRIPE_METHOD_MATRIX: Record<string, StripeMethodEntry>;
|
|
278
|
-
/**
|
|
279
|
-
* Whether a method's `logoSvg` is a vendored real brand logo (from
|
|
280
|
-
* `fetch:logos`) rather than the SDK's generated placeholder mark. Tile
|
|
281
|
-
* buttons use this to size the gap between logo and label: the real logos
|
|
282
|
-
* are self-contained cards that read as a separate mark (8px gap), whereas
|
|
283
|
-
* the generated placeholder monogram reads as part of the label (0px gap).
|
|
284
|
-
*/
|
|
285
|
-
export declare function hasVendoredStripeMethodLogo(type: string | null | undefined): boolean;
|
|
286
|
-
/**
|
|
287
|
-
* Stripe payment method types that render as native big buttons in the
|
|
288
|
-
* `ExpressCheckoutElement`. Everything else falls into the `PaymentElement`
|
|
289
|
-
* accordion. Derived from {@link STRIPE_METHOD_MATRIX} entries flagged
|
|
290
|
-
* `express: true` — insertion order in the matrix dictates the wallet-row
|
|
291
|
-
* ordering (apple_pay → google_pay → paypal → link → amazon_pay → klarna).
|
|
292
|
-
*/
|
|
293
|
-
export declare const STRIPE_EXPRESS_METHODS: readonly string[];
|
|
294
|
-
/**
|
|
295
|
-
* Stripe payment-method → supported-currencies map. Derived from
|
|
296
|
-
* {@link STRIPE_METHOD_MATRIX} — kept as a separate export for callers that
|
|
297
|
-
* just want the currency list without the rest of the entry.
|
|
298
|
-
*
|
|
299
|
-
* Stripe rejects the entire `PaymentElement` mount with an `IntegrationError`
|
|
300
|
-
* when `paymentMethodTypes` contains a method that doesn't support the session
|
|
301
|
-
* currency (e.g. `bancontact` on a USD session). The SDK drops those methods
|
|
302
|
-
* before forwarding them to Stripe so a single mis-matched method doesn't
|
|
303
|
-
* blank out the whole accordion.
|
|
304
|
-
*
|
|
305
|
-
* Unknown methods (anything not in the matrix) pass through unchanged so a
|
|
306
|
-
* brand-new Stripe APM keeps working until the matrix is refreshed.
|
|
307
|
-
*/
|
|
308
|
-
export declare const STRIPE_METHOD_CURRENCIES: Record<string, readonly string[]>;
|
|
309
|
-
/**
|
|
310
|
-
* Stripe payment-method → supported-buyer-countries map (uppercase ISO
|
|
311
|
-
* 3166-1 alpha-2). Derived from {@link STRIPE_METHOD_MATRIX}; only methods
|
|
312
|
-
* that declared a `countries` list appear here. Methods absent from this map
|
|
313
|
-
* have no country gate and are offered to every buyer (subject to the
|
|
314
|
-
* currency / amount filters).
|
|
315
|
-
*
|
|
316
|
-
* Local APMs like Bancontact (BE), EPS (AT) and iDEAL (NL) are available
|
|
317
|
-
* only to buyers in their home country even on a EUR cart, so the SDK drops
|
|
318
|
-
* them when the session customer's country doesn't match — mirroring what
|
|
319
|
-
* Stripe's `PaymentElement` would do from the buyer's locale anyway.
|
|
320
|
-
*/
|
|
321
|
-
export declare const STRIPE_METHOD_COUNTRIES: Record<string, readonly string[]>;
|
|
322
|
-
/**
|
|
323
|
-
* Display-name lookup. Falls back to a title-cased version of the wire id
|
|
324
|
-
* (e.g. `au_becs_debit` → `Au Becs Debit`) for methods not in the matrix so
|
|
325
|
-
* a brand-new APM still produces a legible label until the matrix catches up.
|
|
326
|
-
*/
|
|
327
|
-
export declare function getStripeMethodDisplayName(type: string | null | undefined): string;
|
|
328
|
-
/**
|
|
329
|
-
* Whether the SDK should render an explicit "Pay with X" button for this
|
|
330
|
-
* method rather than auto-submitting on click. Defaults to `true` (safer for
|
|
331
|
-
* unknown methods) — only methods explicitly flagged `needsExplicitConfirm:
|
|
332
|
-
* false` in the matrix (Cash App, Affirm) auto-submit.
|
|
333
|
-
*/
|
|
334
|
-
export declare function needsStripeMethodExplicitConfirm(type: string | null | undefined): boolean;
|
|
335
|
-
/**
|
|
336
|
-
* Resolve the per-mode brand styling for a method tile button, given the
|
|
337
|
-
* active FloPay theme id. Returns `null` when the method has no `theme`
|
|
338
|
-
* entry in the matrix — callers fall back to the neutral tile styling
|
|
339
|
-
* derived from `buttonsStyles.cardButton`.
|
|
340
|
-
*
|
|
341
|
-
* Theme-id → variant rule:
|
|
342
|
-
* - `*-dark` themes get `theme.dark` (then `theme.light` as fallback).
|
|
343
|
-
* - Everything else (`classic`, `*-light`, undefined) gets `theme.light`.
|
|
344
|
-
*/
|
|
345
|
-
export declare function resolveStripeMethodBrandVariant(type: string | null | undefined, themeId: ThemeId | null | undefined): StripeMethodThemeVariant | null;
|
|
346
|
-
/**
|
|
347
|
-
* Filter a Stripe payment-method wire-identifier list down to those that
|
|
348
|
-
* support the supplied ISO-4217 currency code. Unknown methods (anything not
|
|
349
|
-
* in {@link STRIPE_METHOD_CURRENCIES}) pass through unchanged so a brand-new
|
|
350
|
-
* Stripe APM keeps working until the SDK ships an updated map.
|
|
351
|
-
*
|
|
352
|
-
* The currency comparison is case-insensitive (`USD` and `usd` both match).
|
|
353
|
-
* An empty / missing currency disables filtering entirely (returns the input
|
|
354
|
-
* list as-is) — callers that don't know the currency are still better off
|
|
355
|
-
* letting Stripe fail loudly than dropping everything to silence.
|
|
356
|
-
*/
|
|
357
|
-
export declare function filterStripeMethodsByCurrency(methods: readonly string[] | undefined, currency: string | undefined): string[];
|
|
358
|
-
/**
|
|
359
|
-
* Filter a Stripe payment-method wire-identifier list down to those available
|
|
360
|
-
* to the supplied buyer country (ISO 3166-1 alpha-2). Methods with no country
|
|
361
|
-
* gate in {@link STRIPE_METHOD_COUNTRIES} — the global wallets, Alipay,
|
|
362
|
-
* Klarna, unknown methods — pass through unchanged.
|
|
363
|
-
*
|
|
364
|
-
* The country comparison is case-insensitive (`be` and `BE` both match). An
|
|
365
|
-
* empty / missing country disables filtering entirely (returns the input list
|
|
366
|
-
* as-is) — when the session doesn't know the buyer's country we'd rather let
|
|
367
|
-
* Stripe make the final call than drop every country-gated method.
|
|
368
|
-
*/
|
|
369
|
-
export declare function filterStripeMethodsByCountry(methods: readonly string[] | undefined, country: string | undefined): string[];
|
|
370
|
-
/**
|
|
371
|
-
* Per-method amount limits (in the smallest currency unit, e.g. cents for USD)
|
|
372
|
-
* keyed by Stripe wire identifier and then currency code. Derived from
|
|
373
|
-
* {@link STRIPE_METHOD_MATRIX} — kept as a separate export for callers that
|
|
374
|
-
* just want the amount limits without the rest of the entry.
|
|
375
|
-
*
|
|
376
|
-
* Stripe's `/v1/elements/sessions` endpoint hard-400's when
|
|
377
|
-
* `paymentMethodTypes` contains a method whose per-currency minimum or
|
|
378
|
-
* maximum is violated by the deferred-intent amount — and a single rejected
|
|
379
|
-
* method blanks out the entire `PaymentElement` accordion ("Frame not
|
|
380
|
-
* initialized" / empty `<div class="">` shell). Filtering here matches
|
|
381
|
-
* Stripe's reality so an incompatible amount silently drops the offending
|
|
382
|
-
* method instead of poisoning the whole mount.
|
|
383
|
-
*/
|
|
384
|
-
export declare const STRIPE_METHOD_AMOUNT_LIMITS: Record<string, Record<string, {
|
|
385
|
-
min?: number;
|
|
386
|
-
max?: number;
|
|
387
|
-
}>>;
|
|
388
|
-
/**
|
|
389
|
-
* Filter a Stripe payment-method wire-identifier list down to those whose
|
|
390
|
-
* per-currency amount range accepts {@link amountInMinorUnits}. Unknown methods
|
|
391
|
-
* (anything not in {@link STRIPE_METHOD_AMOUNT_LIMITS}) pass through unchanged
|
|
392
|
-
* so a brand-new Stripe APM keeps working without an SDK update.
|
|
393
|
-
*
|
|
394
|
-
* Currency comparison is case-insensitive. Missing currency / amount disables
|
|
395
|
-
* filtering — callers that don't know the cart yet should pass through the
|
|
396
|
-
* full list rather than silently dropping everything.
|
|
397
|
-
*/
|
|
398
|
-
export declare function filterStripeMethodsByAmount(methods: readonly string[] | undefined, currency: string | undefined, amountInMinorUnits: number | undefined): string[];
|
|
399
|
-
/**
|
|
400
|
-
* Partition the backend's `enabledPaymentMethods` list into the two SDK
|
|
401
|
-
* regions inside `SplitCardForm`:
|
|
402
|
-
*
|
|
403
|
-
* - `expressMethods` — intersected with {@link STRIPE_EXPRESS_METHODS} so
|
|
404
|
-
* only `ExpressCheckoutElement`-supported methods land in the big-button
|
|
405
|
-
* row.
|
|
406
|
-
* - `paymentElementMethods` — every remaining method (Cash App Pay, Affirm,
|
|
407
|
-
* iDEAL, Bancontact, SEPA debit, …) for the `PaymentElement` accordion.
|
|
408
|
-
*
|
|
409
|
-
* `card` is dropped from both lists — the card path stays on the split
|
|
410
|
-
* fields. When `options.excludePaypal` is `true`, the SDK is rendering
|
|
411
|
-
* `DirectPayPalButton` separately and PayPal is also pulled out of the
|
|
412
|
-
* express list to avoid double-rendering.
|
|
413
|
-
*/
|
|
414
|
-
export declare function partitionStripeMethods(enabledPaymentMethods: readonly string[] | undefined, options?: {
|
|
415
|
-
excludePaypal?: boolean;
|
|
416
|
-
}): {
|
|
417
|
-
expressMethods: string[];
|
|
418
|
-
paymentElementMethods: string[];
|
|
419
|
-
};
|
|
420
140
|
export declare const SUPPORTED_CARD_BRANDS: readonly ['visa', 'mastercard', 'mastercard_debit', 'amex', 'discover'];
|
|
421
141
|
/** Country code to currency information mapping. */
|
|
422
142
|
export declare const CURRENCY_MAP: Record<string, CurrencyInfo>;
|
|
@@ -12,13 +12,10 @@ export interface ExternalMethodFailureClassification {
|
|
|
12
12
|
providerDeclined: boolean;
|
|
13
13
|
terminalReason: TelemetryTerminalReason;
|
|
14
14
|
}
|
|
15
|
-
/** One buyer-copy contract shared by wallets and both PayPal integrations. */
|
|
16
|
-
export declare function buildExternalMethodRecoveryMessage(displayName: string, popupBlocked: boolean, inAppBrowser: boolean): string;
|
|
17
15
|
export declare function sanitizeExternalFailureCode(value: unknown): string | undefined;
|
|
18
16
|
export declare function getProviderErrorCode(err: unknown): string | undefined;
|
|
19
17
|
export declare function getProviderDeclineCode(err: unknown): string | undefined;
|
|
20
18
|
export declare function isProviderDecline(err: unknown): boolean;
|
|
21
|
-
export declare function isPayPalAcknowledgementDeadWindow(err: unknown): boolean;
|
|
22
19
|
/** Classifies only bounded, positive evidence; time by itself is never evidence. */
|
|
23
20
|
export declare function classifyExternalMethodFailure(err: unknown, context: ExternalMethodFailureContext): ExternalMethodFailureClassification;
|
|
24
21
|
export declare function isPopupBlockedError(err: unknown): boolean;
|