@flopay/shared 1.20.14 → 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/dist/types.d.ts CHANGED
@@ -328,87 +328,6 @@ export type NormalizedGatewayEnvironment = 'sandbox' | 'live';
328
328
  * then fails opaquely against sandbox credentials).
329
329
  */
330
330
  export declare function normalizeGatewayEnvironment(env: GatewayEnvironment | string | undefined | null): NormalizedGatewayEnvironment | undefined;
331
- /** Per-gateway configuration returned by the billing API. */
332
- export interface CheckoutGateway {
333
- /** Public client identifier (e.g. Stripe publishable key, PayPal client id). */
334
- publishableKey?: string | null;
335
- /** Sandbox or live mode for the gateway credentials. */
336
- environment?: GatewayEnvironment;
337
- /**
338
- * Optional Stripe PaymentIntent client secret exposed by the billing API
339
- * when additional authentication is required for a saved payment method.
340
- * Stripe-specific.
341
- */
342
- stripeClientSecret?: string | null;
343
- /**
344
- * Optional publishable key for a dedicated Stripe sub-account that renders
345
- * PayPal via Stripe Elements. Stripe-specific. Distinct from
346
- * `gateways.paypal.publishableKey`, which is a PayPal client id used by the
347
- * direct PayPal SDK.
348
- */
349
- paypalPublishableKey?: string | null;
350
- /**
351
- * Per-session list of payment method type identifiers that the gateway has
352
- * enabled for this consumer (e.g. `['apple_pay', 'google_pay', 'cashapp',
353
- * 'klarna']`). Populated by the billing API after looking up the gateway's
354
- * Payment Method Configurations. The SDK partitions this list against
355
- * {@link STRIPE_EXPRESS_METHODS} to decide which methods render in the
356
- * `ExpressCheckoutElement` row (Apple Pay / Google Pay / PayPal / Link /
357
- * Amazon Pay / Klarna) vs the `PaymentElement` accordion (Cash App Pay /
358
- * Affirm / iDEAL / Bancontact / …). `card` is never rendered by Stripe:
359
- * starting with SDK 1.4.9, its presence explicitly advertises that the
360
- * provider-neutral hosted card form can be recovered from
361
- * `POST /v1/checkouts/sessions/{id}/vault/capture` when no embedded
362
- * {@link CheckoutSession.vault} block is present. Absent on legacy backends.
363
- * `SplitCardForm` uses this list to scope the retained wallet/APM surfaces.
364
- * When a buyer selects one, the SDK requests a session-scoped intent for
365
- * that explicit method. Card checkout uses the hosted vault.
366
- */
367
- enabledPaymentMethods?: string[];
368
- /**
369
- * Per-method buyer-country gate (uppercase ISO 3166-1 alpha-2), keyed by the
370
- * same method strings as {@link enabledPaymentMethods}. A method absent here
371
- * has no country restriction. The SDK filters the rendered tile row by the
372
- * buyer's *live* country (which can change via AVS after the session is
373
- * created) against this map — so per-method country eligibility lives in one
374
- * place (the backend) rather than a hardcoded SDK table. Absent on legacy
375
- * backends (the SDK then falls back to its built-in table).
376
- */
377
- enabledPaymentMethodCountries?: Record<string, string[]>;
378
- /**
379
- * PayPal object the backend selected for this checkout continuation — which
380
- * PayPal JS flow the session needs. New backends advertise `'order'` or
381
- * `'setup_token'` (legacy provider-managed subscriptions are expressed by
382
- * omission, though `'subscription'` remains accepted for robustness). Absent
383
- * → released fallback: `isSubscription ? 'subscription' : 'order'`. The
384
- * backend suppresses this advertisement for `x-flo-sdk-version` readers
385
- * older than 1.6.0 (header-less direct integrations always see it);
386
- * advertisement only — routing follows the payment-method type the client
387
- * requests. On `gateways.paypal`, {@link enabledPaymentMethods} may also
388
- * carry an informational `'paypal_vaulted'` entry when the Flo-owned
389
- * channel is available.
390
- */
391
- providerObjectType?: PayPalProviderObjectType;
392
- /**
393
- * Backend-advertised approval presentation for a one-time PayPal Order.
394
- * Return URLs and resume capabilities remain backend-owned.
395
- */
396
- approvalPresentation?: PayPalApprovalPresentation;
397
- }
398
- /**
399
- * Map of gateways attached to a session, keyed by gateway code. A session can
400
- * advertise multiple gateways concurrently — e.g. `gateways.stripe` for card
401
- * + wallets and `gateways.paypal` for direct PayPal rendering. A session
402
- * created with the Worldpay capability may also carry
403
- * `gateways.worldpayCorporateGateway` (TeamFloPay/backend#1563): a card
404
- * gateway the billing API processes entirely server-side behind the hosted
405
- * vault form, with no browser credentials or methods.
406
- */
407
- export interface CheckoutGateways {
408
- stripe?: CheckoutGateway;
409
- paypal?: CheckoutGateway;
410
- [key: string]: CheckoutGateway | undefined;
411
- }
412
331
  /** Represents a FloPay checkout session. */
413
332
  export interface CheckoutSession {
414
333
  id: string;
@@ -500,12 +419,6 @@ export interface CheckoutSession {
500
419
  */
501
420
  totalAmount?: number;
502
421
  createdAt?: string;
503
- /**
504
- * Per-gateway configuration. A session can advertise multiple concurrent
505
- * gateways — read `gateways.stripe` for card/wallets, `gateways.paypal` for
506
- * direct PayPal, and so on.
507
- */
508
- gateways?: CheckoutGateways;
509
422
  accountData?: {
510
423
  /** Null until an anonymous checkout is attached to a buyer. */
511
424
  userId: string | null;
@@ -570,7 +483,7 @@ interface SessionIntentAuthorizationAttempt {
570
483
  authorizationAttemptId?: string;
571
484
  }
572
485
  /** Stripe wallet/APM request. Direct card is deliberately not representable. */
573
- export interface StripeSessionIntentRequest extends SessionIntentAuthorizationAttempt {
486
+ interface StripeSessionIntentRequest extends SessionIntentAuthorizationAttempt {
574
487
  provider: 'stripe';
575
488
  paymentMethodCategory: NonCardPaymentMethodCategory;
576
489
  paymentMethodType: string;
@@ -619,7 +532,7 @@ interface PayPalVaultedSetupSessionIntentRequest extends PayPalSessionIntentRequ
619
532
  */
620
533
  export type PayPalSessionIntentRequest = PayPalLegacySessionIntentRequest | PayPalVaultedPaymentSessionIntentRequest | PayPalVaultedSetupSessionIntentRequest;
621
534
  export type CreateSessionIntentRequest = StripeSessionIntentRequest | PayPalSessionIntentRequest;
622
- export interface StripeSessionIntent extends StripeSessionIntentRequest {
535
+ interface StripeSessionIntent extends StripeSessionIntentRequest {
623
536
  clientSecret: string;
624
537
  providerObjectId: string;
625
538
  }
@@ -1293,97 +1206,6 @@ export interface CheckoutProcessingPending {
1293
1206
  }
1294
1207
  /** Checkout mode: tokenize client-side or redirect to hosted page. */
1295
1208
  export type CheckoutModeKind = 'tokenize' | 'redirect';
1296
- /**
1297
- * Provider-agnostic normalized checkout session. Backend may attach multiple
1298
- * gateways per session — read each from `data.<gatewayCode>`.
1299
- */
1300
- export interface NormalizedCheckoutSession {
1301
- /** Gateway codes advertised by the backend for this session, for diagnostics. */
1302
- providers: BillingProvider[];
1303
- mode: CheckoutModeKind;
1304
- autoProcessingError?: CheckoutProcessError;
1305
- autoProcessingAttempted?: boolean;
1306
- autoProcessingPending?: CheckoutProcessingPending;
1307
- /** Immutable client context returned by the FloPay checkout-session API. */
1308
- checkoutMetadata?: CheckoutMetadata;
1309
- data: {
1310
- hostedUrl?: string;
1311
- clientToken?: string;
1312
- session?: CheckoutSession;
1313
- stripe?: {
1314
- clientSecret?: string;
1315
- publishableKey?: string;
1316
- /**
1317
- * Optional dedicated Stripe sub-account publishable key for rendering
1318
- * PayPal via Stripe Elements. When present and distinct, the saved-PM
1319
- * resume flow loads a separate FloPay instance for the PayPal PI.
1320
- */
1321
- paypalPublishableKey?: string;
1322
- environment?: GatewayEnvironment;
1323
- /**
1324
- * Mirrors {@link CheckoutGateway.enabledPaymentMethods}. Drives dynamic
1325
- * `ExpressCheckoutElement` / `PaymentElement` rendering inside
1326
- * `SplitCardForm` instead of the historic hardcoded Apple/Google/PayPal
1327
- * set. Absent on backends that have not yet adopted the field.
1328
- */
1329
- enabledPaymentMethods?: string[];
1330
- /** Mirrors {@link CheckoutGateway.enabledPaymentMethodCountries}. */
1331
- enabledPaymentMethodCountries?: Record<string, string[]>;
1332
- };
1333
- /**
1334
- * Direct PayPal gateway configuration. Present only when the backend has
1335
- * configured a dedicated PayPal gateway for the consumer; absent means the
1336
- * Stripe-rendered PayPal fallback should be used (if Stripe is configured).
1337
- */
1338
- paypal?: {
1339
- publishableKey?: string;
1340
- environment?: GatewayEnvironment;
1341
- providerObjectType?: PayPalProviderObjectType;
1342
- approvalPresentation?: PayPalApprovalPresentation;
1343
- };
1344
- };
1345
- raw?: unknown;
1346
- }
1347
- /**
1348
- * Two-phase result of a **detached** checkout-session create
1349
- * (TeamFloPay/backend#1099).
1350
- *
1351
- * `shell` resolves first, from a create that ran no catalog validation and took
1352
- * no buyer-identity advisory locks. It already carries the session id, nonce,
1353
- * routed `gateways` and the hosted `vault` block, so the card form can mount
1354
- * from it. It does **not** carry products, coupons, buyer identity or cart
1355
- * totals — those arrive with `claimed`.
1356
- *
1357
- * `claimed` starts immediately and resolves when
1358
- * `PATCH /v1/checkouts/sessions/{id}/claim` attaches the catalog. A draft with
1359
- * email uses a combined catalog+buyer claim; an email-less draft omits
1360
- * `accountData` and resolves with a fully-populated anonymous session whose
1361
- * `buyerIdentified` marker is false. Nothing may be charged until it settles:
1362
- * the billing API rejects process / intent / decline calls on an unclaimed
1363
- * session with `409 checkout_session_data_attachment_required`, and its vault
1364
- * webhook holds an unclaimed charge with a `503` until the claim lands.
1365
- */
1366
- export interface DetachedCheckoutSession {
1367
- /** Lightweight shell — mountable card form, no cart or buyer data yet. */
1368
- shell: NormalizedCheckoutSession;
1369
- /** Session id of the shell, available before `claimed` settles. */
1370
- sessionId: string;
1371
- /** Session-bound checkout token, required by the claim and every later call. */
1372
- nonce: string;
1373
- /** Resolves with the catalog-attached session once the initial claim lands. */
1374
- claimed: Promise<NormalizedCheckoutSession>;
1375
- /**
1376
- * Attach buyer identity collected after an email-less session's catalog was
1377
- * attached. Sessions created with an email return `claimed` from this method.
1378
- *
1379
- * Once a claim has actually started, repeated calls return the same
1380
- * replay-safe claim promise. A call rejected by *local* validation (e.g. a
1381
- * missing or malformed email) does not consume the operation: it returns a
1382
- * fresh rejected promise, so a later call with a valid email can still start
1383
- * buyer attachment. Blank/null identity fields are omitted from the request.
1384
- */
1385
- claim(account?: Partial<CheckoutAccount>): Promise<NormalizedCheckoutSession>;
1386
- }
1387
1209
  /** A one-time purchase item for checkout session creation. */
1388
1210
  export interface CheckoutItem {
1389
1211
  /**
@@ -13,13 +13,3 @@
13
13
  */
14
14
  /** The `vaultOutcome.code` the backend sends when the session has no buyer email. */
15
15
  export declare const CHECKOUT_SESSION_BUYER_EMAIL_REQUIRED = "checkout_session_buyer_email_required";
16
- /** Built-in prompt shown when the backend's block carries no buyer-safe message. */
17
- export declare const BUYER_EMAIL_REQUIRED_PROMPT = "Enter your email address to continue paying.";
18
- /**
19
- * The prompt to show for a relayed `vaultOutcome` block, or `null` when the
20
- * block is absent, malformed, or carries any code other than
21
- * {@link CHECKOUT_SESSION_BUYER_EMAIL_REQUIRED} (callers then keep today's path).
22
- * The backend's `message` is defined as safe to show; when it is missing or
23
- * blank the built-in {@link BUYER_EMAIL_REQUIRED_PROMPT} is used.
24
- */
25
- export declare function buyerEmailRequiredPrompt(vaultOutcome: unknown): string | null;
@@ -30,8 +30,6 @@ export declare function shouldPreferWalletPopup(input?: BrowserWindowInput): boo
30
30
  * buyer dismissing a sheet that did open.
31
31
  */
32
32
  export declare function isWalletSheetRefusedForWindowSize(context: WalletSheetCancelContext): boolean;
33
- /** Buyer copy for a wallet sheet the browser refused to open for lack of room. */
34
- export declare function buildWalletSheetWindowMessage(displayName: string): string;
35
33
  /**
36
34
  * From now until the returned function runs, every iframe created through
37
35
  * `document.createElement` carries `allow="… payment 'none'"`, whatever its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flopay/shared",
3
- "version": "1.20.14",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "publishConfig": {
@@ -1,11 +0,0 @@
1
- import { FloPayError } from './errors.js';
2
- import type { CheckoutButtonMethod } from './types.js';
3
- /** The buyer-facing name of a checkout button method ("Card" for anything unknown). */
4
- export declare function getButtonMethodLabel(method: CheckoutButtonMethod): string;
5
- /**
6
- * A value thrown by a merchant's before-click hook, as the `FloPayError` the
7
- * checkout shows and reports: a `FloPayError` is kept, an `Error` keeps its
8
- * message, anything else becomes "<Method> before-click hook failed.". All are
9
- * `validation_error`s unless the hook threw a `FloPayError` of its own.
10
- */
11
- export declare function normalizeBeforeButtonClickError(method: CheckoutButtonMethod, err: unknown): FloPayError;
@@ -1,79 +0,0 @@
1
- import type { CheckoutSession, GatewayEnvironment, PayPalApprovalPresentation, PayPalProviderObjectType } from './types.js';
2
- /** The parts of a session read that carry its advertisement. */
3
- export interface CheckoutAdvertisement {
4
- data: {
5
- session?: CheckoutSession | null;
6
- stripe?: unknown;
7
- paypal?: unknown;
8
- };
9
- }
10
- /**
11
- * The advertisement a checkout shows once a claim response lands on it.
12
- *
13
- * A detached checkout mounts from a shell, a provisional advertisement made
14
- * before the cart is known; the claim is the authority. The latest
15
- * advertisement wins, provider by provider:
16
- * - a provider the claim names wins, so `stripe: null` / `paypal: null`
17
- * removes that provider's buttons even when the shell advertised them;
18
- * - a provider key the claim leaves out (an older or partial API response)
19
- * keeps what `current` advertised.
20
- *
21
- * This chooses no gateway: it only decides which response a provider entry is
22
- * read from. Everything else comes from the claim.
23
- */
24
- export declare function applyClaimAdvertisement<T extends CheckoutAdvertisement>(current: T, claimed: T): T;
25
- /**
26
- * The PayPal gateway fields the direct PayPal button needs: the session's
27
- * `gateways.paypal`, or the normalized `data.paypal` copy of it.
28
- */
29
- export interface DirectPayPalGatewaySource {
30
- /** The PayPal client id. */
31
- publishableKey?: string | null;
32
- environment?: GatewayEnvironment;
33
- providerObjectType?: PayPalProviderObjectType;
34
- approvalPresentation?: PayPalApprovalPresentation;
35
- }
36
- /** What the checkout hands its card form as `directPaypal`. */
37
- export interface DirectPayPalConfig {
38
- clientId: string;
39
- environment?: GatewayEnvironment;
40
- providerObjectType?: PayPalProviderObjectType;
41
- approvalPresentation?: PayPalApprovalPresentation;
42
- existingOrderId?: string;
43
- }
44
- /**
45
- * The direct PayPal config for a session's PayPal gateway: its
46
- * `publishableKey` is the PayPal client id, and `existingOrderId` is an order
47
- * to resume instead of creating one. `undefined` when the gateway has no
48
- * client id.
49
- */
50
- export declare function resolveDirectPaypalConfig(paypal: DirectPayPalGatewaySource | null | undefined, existingOrderId?: string): DirectPayPalConfig | undefined;
51
- /**
52
- * The buyer-country gate on the Stripe methods outside the wallet row (iDEAL,
53
- * Bancontact, …). The buyer's live country (the AVS select, else the static
54
- * `country`) is matched against `enabledPaymentMethodCountries`: a method
55
- * without an entry, or with an empty list, has no gate. Without the map, the
56
- * built-in country table ({@link filterStripeMethodsByCountry}) decides. With
57
- * no country, nothing is filtered and `methods` is returned as it is.
58
- */
59
- export declare function filterStripeMethodsByCountryGate(methods: string[], country: string | null | undefined, enabledPaymentMethodCountries: Record<string, string[]> | undefined): string[];
60
- /**
61
- * The key of the gateway that takes the session's cards, exactly as the API
62
- * names it: the server-side card gateway when there is one, else the
63
- * browser-side card provider when the session has it, else `undefined`.
64
- */
65
- export declare function cardGatewayName(session: Pick<CheckoutSession, 'gateways'> | null | undefined): string | undefined;
66
- /**
67
- * Whether the session can route cards to a gateway the billing API processes
68
- * entirely server-side behind the hosted vault form (see
69
- * {@link serverSideCardGatewayName}). Such a gateway has no browser runtime or
70
- * credentials, and its payment references are not Stripe objects.
71
- */
72
- export declare function hasServerSideCardGateway(session: CheckoutSession | null | undefined): boolean;
73
- /**
74
- * Whether an open session can recover its hosted card form from
75
- * `/vault/capture` when the read omitted the embedded block. A server-side
76
- * card gateway is the explicit card capability; a terminal session has no
77
- * form left to recover.
78
- */
79
- export declare function canRecoverHostedCardForm(session: CheckoutSession | null | undefined): boolean;
@@ -1,5 +0,0 @@
1
- /**
2
- * The buyer-facing copy for a raw failure message: a known backend message is
3
- * replaced, anything else is returned unchanged (`undefined` for a non-string).
4
- */
5
- export declare function applyFriendlyMessageOverride(message: string | undefined | null): string | undefined;
@@ -1 +0,0 @@
1
- export declare const VENDORED_LOGO_METHODS: readonly string[];
@@ -1,67 +0,0 @@
1
- import type { NormalizedCheckoutSession } from './types.js';
2
- /** One advertised Stripe wallet/APM, with the account the backend chose for it. */
3
- interface StripeSetupAdvertisement {
4
- /** The Stripe payment method type (`apple_pay`, `sepa_debit`, ...). */
5
- method: string;
6
- /** This entry's own publishable key: the backend can pick an account per method. */
7
- publishableKey: string;
8
- /** The setup session's own currency, from the read. Never guessed. */
9
- currency: string;
10
- }
11
- /** Direct PayPal vault flow a setup session advertises. */
12
- interface PayPalSetupAdvertisement {
13
- clientId: string;
14
- environment?: string;
15
- }
16
- /**
17
- * The methods a setup session advertises. The SDK renders exactly these: no
18
- * gateway selection, filtering or inference happens on the client.
19
- */
20
- export interface PaymentMethodSetupAdvertisement {
21
- /** The hosted vault card widget (a `card` entry, or no advertisement at all). */
22
- card: boolean;
23
- /** Stripe wallets/APMs in advertised order. */
24
- stripe: StripeSetupAdvertisement[];
25
- paypal: PayPalSetupAdvertisement | null;
26
- /** The setup session's own currency from the read, or `null` when it carries none. */
27
- currency: string | null;
28
- /**
29
- * Stripe wallets/APMs the session advertises that are not rendered only
30
- * because the read carries no currency, so a session that offers nothing
31
- * else can say why instead of claiming it advertises nothing.
32
- */
33
- skippedForMissingCurrency: string[];
34
- }
35
- /**
36
- * Read the advertisement from a normalized setup session. Only the session's
37
- * `advertisedPaymentMethods` decides it (backend docs/card-setup.md,
38
- * "Advertised payment methods"); the purchase-checkout gateway block is never
39
- * read, since it lists nothing on a setup session.
40
- *
41
- * - Field absent (an older backend): the card only, exactly as `FloPayCardSetup`.
42
- * - `family: "card"`: the hosted vault card widget.
43
- * - `family: "wallet"` / `"apm"` with `providerType: "stripe"`: that Stripe
44
- * method, with the entry's own publishable key. Skipped when the read carries
45
- * no currency, and listed in `skippedForMissingCurrency`.
46
- * - `family: "paypal"` (`paypal_vaulted`): the PayPal vault flow, with the
47
- * entry's key as the client id and its environment. It owns `paypal`, so a
48
- * Stripe-rendered `paypal` entry is not drawn a second time.
49
- * - Anything else is skipped, never thrown on. The first entry for a
50
- * `paymentMethodType` wins.
51
- */
52
- export declare function readSetupAdvertisement(normalized: NormalizedCheckoutSession): PaymentMethodSetupAdvertisement;
53
- /** The marker of every method the advertisement renders, card first. */
54
- export declare function advertisedMethodKeys(advertisement: PaymentMethodSetupAdvertisement): string[];
55
- /** Whether the advertisement offers anything to render. */
56
- export declare function advertisesAnyMethod(advertisement: PaymentMethodSetupAdvertisement): boolean;
57
- /** The session-intent category for an advertised Stripe method. */
58
- export declare function stripeMethodCategory(method: string): 'wallet' | 'apm';
59
- /** Which wording the outcome overlay uses: card wording only for the card widget. */
60
- export type SetupOverlayWording = 'card' | 'payment_method';
61
- /** Processing / success / failure overlay labels for a setup outcome. */
62
- export declare function setupOverlayLabels(wording: SetupOverlayWording): {
63
- processingLabel: string;
64
- successLabel: string;
65
- errorLabel: string;
66
- };
67
- export {};
@@ -1,77 +0,0 @@
1
- import type { CheckoutSession, FloPayPaymentCancelEvent, InlineSessionPatch, PayPalProviderObjectType, PayPalSessionIntentRequest, ProcessPaymentParams, TokenizedBody } from './types.js';
2
- /**
3
- * Whether the configured PayPal object rides the Flo-owned `paypal_vaulted`
4
- * channel. An explicitly configured `order` or `setup_token` (the session's
5
- * advertisement, or the deprecated prop as a fallback) does. A legacy session
6
- * with neither, and an advertised provider-managed `subscription`, keep the
7
- * released `paypal` requests byte-identical.
8
- */
9
- export declare function usesPayPalVaultedChannel(configuredObjectType: PayPalProviderObjectType | undefined): boolean;
10
- /**
11
- * The `/intents` request body for a direct PayPal button. The payment-method
12
- * type is the in-band channel selector: the Flo-owned channel asks for
13
- * `paypal_vaulted` (with `intentKind: 'setup'` for a vault setup token); the
14
- * legacy channel asks for `paypal` with `intentKind: 'payment'`.
15
- */
16
- export declare function buildPayPalSessionIntentRequest(configuredObjectType: PayPalProviderObjectType | undefined): PayPalSessionIntentRequest;
17
- /**
18
- * The tokenized body for PayPal's approval token. A vault setup token and an
19
- * advertised order carry the Flo-owned channel so the backend can continue on
20
- * it; the legacy fallback keeps the released body byte-identical.
21
- */
22
- export declare function buildPayPalTokenizedBody(token: string, configuredObjectType: PayPalProviderObjectType | undefined): TokenizedBody;
23
- /**
24
- * The merchant-facing event for a buyer who closed or left PayPal without
25
- * approving. The session is the attempt's (the click-time patch's, else the
26
- * button's) and the payment-method type follows the same channel rule as the
27
- * attempt's `/intents` request.
28
- */
29
- export declare function buildPayPalCancelEvent(sessionId: string, configuredObjectType: PayPalProviderObjectType | undefined): FloPayPaymentCancelEvent;
30
- /** What a direct PayPal button knows when it completes an approval itself. */
31
- export interface PayPalProcessPaymentInput {
32
- /** The approval's tokenized body ({@link buildPayPalTokenizedBody}). */
33
- body: TokenizedBody;
34
- /** The session the attempt runs on (the click-time patch's, else the button's). */
35
- sessionId: string;
36
- /** The checkout session token for the attempt. */
37
- nonce: string | undefined;
38
- /** The click-time account patch from `runBeforeButtonClick`. */
39
- accountPatch?: InlineSessionPatch['account'];
40
- /** The checkout session, for the buyer's identity and address. */
41
- session?: CheckoutSession | null;
42
- /** The button's `email` prop. */
43
- email?: string;
44
- }
45
- /**
46
- * The `/process` call a direct PayPal button makes when no host takes the
47
- * tokenized body: the click-time account patch wins, then the session's
48
- * customer, then its account data. Returns the (vestigial) user id argument
49
- * and the request, in the field order the released button sends.
50
- */
51
- export declare function buildPayPalProcessPaymentRequest(input: PayPalProcessPaymentInput): {
52
- userId: string;
53
- params: ProcessPaymentParams;
54
- };
55
- /**
56
- * The buyer-facing message for a failed PayPal payment: the raw message (or
57
- * the generic fallback) through the shared friendly-message override.
58
- */
59
- export declare function friendlyPayPalFailureMessage(rawMessage: string | undefined): string;
60
- /** A rejected PayPal `/process` response body, read for the buyer message and the decline codes. */
61
- export declare function describePayPalProcessFailure(json: Record<string, unknown> | null): {
62
- message: string;
63
- code: string | undefined;
64
- declineCode: string | undefined;
65
- };
66
- /**
67
- * The `providerDeclineReason` a PayPal decline reports to `/intents/decline`:
68
- * the provider's decline code, then its error code, then the generic reason.
69
- */
70
- export declare function resolvePayPalDeclineReason(error: unknown): string;
71
- /**
72
- * Zoid (PayPal's iframe framework) reports its own teardown through `onError`:
73
- * "zoid destroyed all components", a closed window, a removed container. Those
74
- * are page navigation or unmounting, not payment errors, so no binding shows
75
- * them to the buyer.
76
- */
77
- export declare function isPayPalTeardownMessage(message: string | undefined): boolean;
@@ -1,14 +0,0 @@
1
- import type { TelemetryAppFamily, TelemetryPopupCapability } from './telemetry.js';
2
- /** Privacy-bounded browser context shared by PayPal presentation and telemetry. */
3
- export interface PayPalBrowserEnvironment {
4
- inAppBrowser: boolean;
5
- appFamily: TelemetryAppFamily;
6
- popupCapability: TelemetryPopupCapability;
7
- }
8
- /**
9
- * Classifies an in-app browser without retaining or returning its user agent.
10
- *
11
- * Static UA evidence cannot prove that a popup will open, so capability stays
12
- * `unknown`; runtime lifecycle evidence is reported separately.
13
- */
14
- export declare function detectPayPalEnvironment(userAgent?: string): PayPalBrowserEnvironment;
@@ -1,19 +0,0 @@
1
- import type { FloPayAppearance, FloPayThemeVariables } from './types.js';
2
- /**
3
- * A `FloPayAppearance` whose `theme` has been normalized to the set Stripe's
4
- * Appearance API accepts, so it can be handed straight to Stripe Elements
5
- * without tripping Stripe.js's `Invalid value … provided to "theme"` warning.
6
- */
7
- export interface StripeSafeAppearance {
8
- theme: 'stripe' | 'night' | 'flat';
9
- variables?: FloPayThemeVariables;
10
- rules?: Record<string, Record<string, string>>;
11
- }
12
- /** Maps FloPay's public appearance token to Stripe's accepted theme set. */
13
- export declare function toStripeAppearanceTheme(theme: 'default' | 'flat' | 'night' | 'none' | undefined): 'stripe' | 'night' | 'flat';
14
- /**
15
- * Normalizes a FloPay appearance before a UI binding passes it to Stripe
16
- * Elements. Lives here, free of Stripe.js, so the Stripe-free entries and
17
- * every UI binding share one mapping (TeamFloPay/sdk#410, CTO decision 1).
18
- */
19
- export declare function toStripeAppearance(appearance: FloPayAppearance): StripeSafeAppearance;
@@ -1,42 +0,0 @@
1
- import type { PayPalBrowserEnvironment, TelemetryPopupCapability, WalletPresentation } from './index.js';
2
- /**
3
- * Selects the safe Stripe-routed PayPal surface for the active checkout mount
4
- * from the merchant's `walletPresentation` preference. An in-app browser, a
5
- * pop-up the browser blocked, or `prefer_redirect` gives the full-page
6
- * redirect; anything else keeps the pop-up. Moved from @flopay/react's
7
- * `in-app-browser.ts` so @flopay/vue resolves `walletPresentation` the same way.
8
- */
9
- export declare function resolveStripePayPalPresentation(environment: PayPalBrowserEnvironment, preference: WalletPresentation, popupCapability?: TelemetryPopupCapability): 'popup' | 'redirect';
10
- /**
11
- * Storage key carrying the effective session / nonce / account patch across a
12
- * Stripe-routed PayPal redirect, so the return can `/process` against the same
13
- * session PayPal authorized (an inline-session bootstrap inside the click gate
14
- * would otherwise be lost when the page reloads after the PayPal round-trip).
15
- */
16
- export declare const STRIPE_PAYPAL_RESUME_KEY = "flopay_paypal_resume";
17
- /** The query parameters Stripe appends to the return URL after a redirect. */
18
- export declare const STRIPE_REDIRECT_PARAMS: readonly ['payment_intent', 'payment_intent_client_secret', 'redirect_status'];
19
- export interface StripePayPalResumeContinuation<TAccount = unknown> {
20
- clientSecret?: string;
21
- sessionId?: string;
22
- nonce?: string;
23
- accountPatch?: TAccount;
24
- }
25
- /** `[payment_intent, payment_intent_client_secret, redirect_status]` from the current URL. */
26
- export declare function readStripeRedirectParams(): [string | null, string | null, string | null];
27
- /** The current URL without Stripe's redirect parameters (the PayPal `return_url`). */
28
- export declare function stripeRedirectReturnUrl(): string;
29
- /**
30
- * The saved continuation, only when it belongs to `clientSecret`, so a stale
31
- * payload from a prior attempt can't replay against a different PaymentIntent.
32
- */
33
- export declare function readMatchingStripePayPalContinuation<TAccount = unknown>(clientSecret: string | null): StripePayPalResumeContinuation<TAccount> | null;
34
- /** Whether this page load is the return of a Stripe-routed PayPal redirect this browser started. */
35
- export declare function hasMatchingStripePayPalReturn(): boolean;
36
- /**
37
- * Saves the continuation, or removes it when called without one. Returns
38
- * whether storage accepted the change (a redirect must not start without it).
39
- */
40
- export declare function writeStripePayPalContinuation(continuation?: StripePayPalResumeContinuation): boolean;
41
- /** Consumes the continuation and strips Stripe's redirect parameters from the URL. */
42
- export declare function clearStripePayPalReturn(): void;
@@ -1,27 +0,0 @@
1
- import type { CaptureMethod } from './types.js';
2
- /**
3
- * Deferred Stripe Elements mode for the wallet / Express Checkout row
4
- * (Apple Pay, Google Pay), from the cart total due today.
5
- *
6
- * A $0-today cart (free trial) cannot run in `payment` mode: Stripe rejects a
7
- * `$0` amount with "amount must be greater than 0", and the historic
8
- * `amount: totalAmount || 100` floor surfaced a misleading **$1.00** charge on
9
- * the wallet sheet. Those carts run in `setup` mode instead — the wallet
10
- * collects the card for the trial with no amount shown, matching the backend's
11
- * SetupIntent. Any positive amount keeps `payment` mode with the real total.
12
- *
13
- * Moved from `@flopay/react`'s `resolveWalletElementsMode` so `@flopay/react`
14
- * and `@flopay/vue` decide the wallet row's mode, amount and capture method
15
- * with one implementation. Each caller adds its method list and the usage
16
- * from `resolveSetupFutureUsage`.
17
- *
18
- * @param amountInMinorUnits cart total due today, in the smallest currency unit.
19
- * @param captureMethod capture contract used by the subsequently created intent.
20
- */
21
- export declare function resolveWalletModeOptions(amountInMinorUnits: number | undefined, captureMethod?: CaptureMethod): {
22
- mode: 'setup';
23
- } | {
24
- mode: 'payment';
25
- amount: number;
26
- captureMethod: 'automatic_async' | 'manual';
27
- };