@flopay/js 1.14.4 → 1.14.6
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/api-error.d.ts +19 -0
- package/dist/card-setup.d.ts +13 -21
- package/dist/create-checkout-session.d.ts +19 -0
- package/dist/flopay.d.ts +59 -0
- package/dist/index.d.ts +14 -232
- package/dist/load.d.ts +24 -0
- package/dist/{pci-vault-card-capture-Dt3F9i7Q.d.cts → payment-api.d.ts} +26 -285
- package/dist/pci-vault-card-capture.d.ts +231 -0
- package/dist/saved-card-action.d.ts +121 -0
- package/dist/session-create-policy.d.ts +9 -0
- package/dist/session-display-cache.d.ts +49 -0
- package/dist/{card-setup.d.cts → setup-redirect-return.d.ts} +3 -8
- package/dist/stripe-adapter.d.ts +13 -0
- package/dist/telemetry-bridge.d.ts +18 -0
- package/dist/telemetry-reporter.d.ts +81 -0
- package/package.json +4 -4
- package/dist/index.d.cts +0 -232
- package/dist/pci-vault-card-capture-Dt3F9i7Q.d.ts +0 -732
|
@@ -1,732 +0,0 @@
|
|
|
1
|
-
import { CheckoutSessionMode, AdvertisedPaymentMethod, CheckoutGateways, VaultCaptureBlock, NormalizedCheckoutSession, ProcessPaymentParams, CreateSessionIntentRequest, SessionIntent, SessionIntentDeclineRequest, InlineSessionDraft, DetachedCheckoutSession, TelemetryPaymentMethodCategory, CardCaptureAdapter, CardCaptureProviderId, CaptureMethod, CardCaptureMountOptions, CardCaptureEventType, CardCaptureOutcomeEvent, VaultCardThemeColors, VaultCardFieldKey } from '@flopay/shared';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Client-side cache for display-only checkout fields the backend no longer
|
|
5
|
-
* persists (`overrideAmount`, `totalAmount`, `providerItemName`,
|
|
6
|
-
* `providerPlanName`, per-line `currency`).
|
|
7
|
-
*
|
|
8
|
-
* The cache lives in `sessionStorage` so it survives the navigation from the
|
|
9
|
-
* page that creates the session to the checkout page that fetches it, but
|
|
10
|
-
* dies on tab close. An in-memory fallback keeps the SDK working in Node /
|
|
11
|
-
* SSR contexts where `sessionStorage` is unavailable.
|
|
12
|
-
*
|
|
13
|
-
* Values from the server response always win — cached values fill in only
|
|
14
|
-
* where the server returned `null` or `undefined`.
|
|
15
|
-
*/
|
|
16
|
-
/** Display-only fields per product that can be cached and merged back later. */
|
|
17
|
-
interface SessionDisplayProduct {
|
|
18
|
-
/** Catalog code (match key). */
|
|
19
|
-
code?: string;
|
|
20
|
-
/** Whether this product is a one-time item or a recurring subscription. */
|
|
21
|
-
type?: 'item' | 'subscription';
|
|
22
|
-
/** Display-only name for the product. */
|
|
23
|
-
name?: string | null;
|
|
24
|
-
totalAmount?: number;
|
|
25
|
-
overrideAmount?: number | null;
|
|
26
|
-
currency?: string;
|
|
27
|
-
}
|
|
28
|
-
/** Display-only payload that can be stashed for later merge into a session response. */
|
|
29
|
-
interface SessionDisplayCacheData {
|
|
30
|
-
/** Session-level currency (falls into the response only when the server omits it). */
|
|
31
|
-
currency?: string;
|
|
32
|
-
products?: SessionDisplayProduct[];
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Stash display-only data for a session. Called client-side right after the
|
|
36
|
-
* server returns a session ID, so the values survive the redirect to the
|
|
37
|
-
* checkout page.
|
|
38
|
-
*/
|
|
39
|
-
declare function cacheSessionDisplayData(sessionId: string, data: SessionDisplayCacheData, options?: {
|
|
40
|
-
ttlMs?: number;
|
|
41
|
-
}): void;
|
|
42
|
-
/**
|
|
43
|
-
* Read previously-cached display data for a session, or `null` if nothing
|
|
44
|
-
* is cached (or the TTL has elapsed).
|
|
45
|
-
*/
|
|
46
|
-
declare function getSessionDisplayData(sessionId: string): SessionDisplayCacheData | null;
|
|
47
|
-
/**
|
|
48
|
-
* Drop any cached display data for a session. Call from the success page
|
|
49
|
-
* after the payment completes; otherwise the TTL handles cleanup.
|
|
50
|
-
*/
|
|
51
|
-
declare function clearSessionDisplayData(sessionId: string): void;
|
|
52
|
-
|
|
53
|
-
/** Raw billing API response wrapper. */
|
|
54
|
-
interface BillingResponse<T> {
|
|
55
|
-
data: T;
|
|
56
|
-
}
|
|
57
|
-
/** Raw checkout session from the billing API. */
|
|
58
|
-
interface RawCheckoutSession {
|
|
59
|
-
uuid: string;
|
|
60
|
-
nonce: string;
|
|
61
|
-
status: 'pending' | 'authorized' | 'completed' | 'expired';
|
|
62
|
-
successUrl: string;
|
|
63
|
-
cancelUrl: string;
|
|
64
|
-
/** Session-level currency. */
|
|
65
|
-
currency?: string;
|
|
66
|
-
createdAt?: string;
|
|
67
|
-
checkoutUrl?: string;
|
|
68
|
-
/** Unified products list returned by the billing API (post-#760). */
|
|
69
|
-
products?: Array<{
|
|
70
|
-
uuid: string;
|
|
71
|
-
checkoutSessionId: string;
|
|
72
|
-
/** 'item' or 'subscription'. */
|
|
73
|
-
type: 'item' | 'subscription';
|
|
74
|
-
code?: string;
|
|
75
|
-
name?: string | null;
|
|
76
|
-
description?: string | null;
|
|
77
|
-
quantity: number;
|
|
78
|
-
totalAmount?: number;
|
|
79
|
-
overrideAmount?: number | null;
|
|
80
|
-
currency?: string;
|
|
81
|
-
metadata?: Record<string, unknown> | null;
|
|
82
|
-
}>;
|
|
83
|
-
coupons?: string[];
|
|
84
|
-
checkoutMetadata?: Record<string, string>;
|
|
85
|
-
/**
|
|
86
|
-
* Pre-discount total in cart-currency major units. Populated by billing
|
|
87
|
-
* API ≥ v1.1.2; absent on older backends.
|
|
88
|
-
*/
|
|
89
|
-
subtotalAmount?: number;
|
|
90
|
-
/** Total reduction from applied coupons (cart-currency major units). */
|
|
91
|
-
discountAmount?: number;
|
|
92
|
-
/** Final charge amount after coupon discount (cart-currency major units). */
|
|
93
|
-
totalAmount?: number;
|
|
94
|
-
checkoutMode?: CheckoutSessionMode;
|
|
95
|
-
/**
|
|
96
|
-
* Payment methods a setup session advertises (backend#1846). Absent on older
|
|
97
|
-
* backends and on sessions created before it.
|
|
98
|
-
*/
|
|
99
|
-
advertisedPaymentMethods?: AdvertisedPaymentMethod[];
|
|
100
|
-
/**
|
|
101
|
-
* The usage the billing API sets this session's Stripe attempts up for
|
|
102
|
-
* (backend#1984 / backend#1989), on purchase and setup reads. Absent on older
|
|
103
|
-
* backends. Typed `unknown` because only `'on_session'` / `'off_session'` are
|
|
104
|
-
* exposed.
|
|
105
|
-
*/
|
|
106
|
-
futureUse?: unknown;
|
|
107
|
-
/**
|
|
108
|
-
* Methods the billing API cannot set up for future use (backend#1989).
|
|
109
|
-
* Typed `unknown` because malformed entries are dropped.
|
|
110
|
-
*/
|
|
111
|
-
futureUseUnsupported?: unknown;
|
|
112
|
-
buyerIdentified?: boolean;
|
|
113
|
-
captureMethod?: 'automatic' | 'manual';
|
|
114
|
-
paymentId?: string;
|
|
115
|
-
authorizationExpiresAt?: string;
|
|
116
|
-
/** Backend authorization/capture lifecycle reason, normalized before exposure. */
|
|
117
|
-
failureReason?: string;
|
|
118
|
-
outcome?: string;
|
|
119
|
-
gateways?: CheckoutGateways;
|
|
120
|
-
/**
|
|
121
|
-
* Generic downstream card-method id for a card already on file
|
|
122
|
-
* (TeamFloPay/backend#823) — present for returning customers so the SDK can
|
|
123
|
-
* skip the vault widget. Absent for first-time buyers.
|
|
124
|
-
*/
|
|
125
|
-
providerPaymentMethodId?: string | null;
|
|
126
|
-
accountData: {
|
|
127
|
-
userId: string | null;
|
|
128
|
-
firstName: string | null;
|
|
129
|
-
lastName: string | null;
|
|
130
|
-
email: string | null;
|
|
131
|
-
gender?: string | null;
|
|
132
|
-
city?: string | null;
|
|
133
|
-
state?: string | null;
|
|
134
|
-
country?: string | null;
|
|
135
|
-
zip?: string | null;
|
|
136
|
-
addressLine1?: string | null;
|
|
137
|
-
addressLine2?: string | null;
|
|
138
|
-
};
|
|
139
|
-
tagsData: {
|
|
140
|
-
googleContainerId?: string | null;
|
|
141
|
-
sessionId?: string | null;
|
|
142
|
-
testEventCode?: string | null;
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
type AccountSnapshotTelemetryMode = 'blocking' | 'best_effort';
|
|
146
|
-
interface PaymentAPIOptions {
|
|
147
|
-
/** Flo-owned privacy-safe telemetry is enabled by default; set false to opt out. */
|
|
148
|
-
telemetry?: boolean;
|
|
149
|
-
}
|
|
150
|
-
declare const SESSION_CREATE_TELEMETRY: unique symbol;
|
|
151
|
-
/**
|
|
152
|
-
* Client-side payment API service.
|
|
153
|
-
*
|
|
154
|
-
* Mirrors the `PaymentAPI` class from the checkout project's
|
|
155
|
-
* `src/service/api.ts`. All methods call the billing API endpoints
|
|
156
|
-
* that the checkout backend exposes.
|
|
157
|
-
*/
|
|
158
|
-
declare class PaymentAPI {
|
|
159
|
-
private static readonly activeVaultCaptureRequests;
|
|
160
|
-
private readonly baseUrl;
|
|
161
|
-
private readonly directTelemetry?;
|
|
162
|
-
private readonly telemetryHooks?;
|
|
163
|
-
private directTelemetryCheckoutId?;
|
|
164
|
-
constructor(billingApiUrl: string, options?: PaymentAPIOptions);
|
|
165
|
-
/** Dispose the reporter owned by direct public usage. Internal hooks are never disposed here. */
|
|
166
|
-
destroy(): void;
|
|
167
|
-
private reportDirectFailure;
|
|
168
|
-
/**
|
|
169
|
-
* A hosted-vault snapshot timeout is an observed fallback, not a checkout
|
|
170
|
-
* failure: the widget charge is already proceeding with the session baseline.
|
|
171
|
-
* Every other snapshot failure and every default/direct timeout remains an
|
|
172
|
-
* alert-level technical error.
|
|
173
|
-
*/
|
|
174
|
-
private reportAccountSnapshotFailure;
|
|
175
|
-
private telemetryTimestamp;
|
|
176
|
-
private beginDirectTelemetryCheckout;
|
|
177
|
-
private beginDirectTelemetryOperation;
|
|
178
|
-
private adoptDirectTelemetryCheckout;
|
|
179
|
-
/**
|
|
180
|
-
* Fetch a raw checkout session by ID.
|
|
181
|
-
*
|
|
182
|
-
* `nonce` is the session-bound checkout token returned when the session
|
|
183
|
-
* was created. When supplied it is sent as the `x-checkout-session-token`
|
|
184
|
-
* header that post-#640 backends match against `checkout_session.nonce`
|
|
185
|
-
* before returning the row — the UUID alone is no longer sufficient.
|
|
186
|
-
* Backends that don't yet enforce it ignore the extra header.
|
|
187
|
-
*/
|
|
188
|
-
getCheckoutSession(checkoutSessionId: string, nonce?: string): Promise<BillingResponse<RawCheckoutSession>>;
|
|
189
|
-
private fetchCheckoutSession;
|
|
190
|
-
/**
|
|
191
|
-
* Stash display-only data for a session so subsequent fetches can fill in
|
|
192
|
-
* fields the backend no longer persists (`overrideAmount`, `totalAmount`,
|
|
193
|
-
* `providerItemName`, `providerPlanName`).
|
|
194
|
-
*
|
|
195
|
-
* Backed by `sessionStorage` in the browser, with an in-memory fallback in
|
|
196
|
-
* Node/SSR contexts. Default TTL: 1 hour.
|
|
197
|
-
*
|
|
198
|
-
* Server-returned values always win — cached values fill in only where the
|
|
199
|
-
* server returned `null` / `undefined`.
|
|
200
|
-
*
|
|
201
|
-
* @example
|
|
202
|
-
* ```ts
|
|
203
|
-
* paymentAPI.cacheSessionDisplayData(sessionId, {
|
|
204
|
-
* currency: 'USD',
|
|
205
|
-
* items: [{ code: 'pro_plan', overrideAmount: 24.99, providerItemName: 'Pro' }],
|
|
206
|
-
* });
|
|
207
|
-
* ```
|
|
208
|
-
*/
|
|
209
|
-
cacheSessionDisplayData(sessionId: string, data: SessionDisplayCacheData, options?: {
|
|
210
|
-
ttlMs?: number;
|
|
211
|
-
}): void;
|
|
212
|
-
/**
|
|
213
|
-
* Drop any cached display data for a session. Call after the payment
|
|
214
|
-
* completes; otherwise the TTL handles cleanup.
|
|
215
|
-
*/
|
|
216
|
-
clearSessionDisplayData(sessionId: string): void;
|
|
217
|
-
/**
|
|
218
|
-
* Fetch (re-mint) the hosted vault capture widget for a session
|
|
219
|
-
* (TeamFloPay/backend#823).
|
|
220
|
-
*
|
|
221
|
-
* `POST /v1/checkouts/sessions/{id}/vault/capture` returns the SDK-ready
|
|
222
|
-
* {@link VaultCaptureBlock} (`html` + `url`, plus `messageToken` /
|
|
223
|
-
* `expectedOrigin` once the backend mints them). The SDK injects `html` as
|
|
224
|
-
* the card-capture widget. This is the lazy path for explicitly card-capable
|
|
225
|
-
* sessions that do not receive an embedded `vault` block; the endpoint is
|
|
226
|
-
* idempotent and reuses session-cached creds when available.
|
|
227
|
-
*
|
|
228
|
-
* Because the endpoint is idempotent, transient network failures receive a
|
|
229
|
-
* bounded retry and a stalled request aborts after ten seconds. Concurrent
|
|
230
|
-
* callers for the same base URL, session, and nonce share the active promise,
|
|
231
|
-
* preventing React renders/remounts from racing competing recovery POSTs.
|
|
232
|
-
*
|
|
233
|
-
* The PCIVault submit *secret* the backend may include in the response is
|
|
234
|
-
* intentionally **not** read or surfaced — it is server-only and never enters
|
|
235
|
-
* the SDK runtime.
|
|
236
|
-
*
|
|
237
|
-
* `nonce` is forwarded as `x-checkout-session-token` (required by post-#640
|
|
238
|
-
* backends, matched against the session's stored nonce).
|
|
239
|
-
*/
|
|
240
|
-
getVaultCapture(checkoutSessionId: string, nonce?: string): Promise<VaultCaptureBlock>;
|
|
241
|
-
private requestVaultCapture;
|
|
242
|
-
/**
|
|
243
|
-
* Fetch and normalize a checkout session.
|
|
244
|
-
*
|
|
245
|
-
* Reads the backend's `gateways` map to enumerate provider-specific data,
|
|
246
|
-
* then wraps the session in a `NormalizedCheckoutSession` for provider-
|
|
247
|
-
* agnostic consumption.
|
|
248
|
-
*/
|
|
249
|
-
getUnifiedCheckoutSession(checkoutSessionId: string, nonce?: string): Promise<NormalizedCheckoutSession>;
|
|
250
|
-
private getUnifiedCheckoutSessionForRecovery;
|
|
251
|
-
private normalizeCheckoutSessionResponse;
|
|
252
|
-
/**
|
|
253
|
-
* Submit a tokenized payment to the billing backend.
|
|
254
|
-
*
|
|
255
|
-
* The backend will either succeed, return `type: '3ds_required'`
|
|
256
|
-
* (with a `threeDSecureToken`), or return `type: 'paypal_redirect_required'`.
|
|
257
|
-
*
|
|
258
|
-
* Hits the session-scoped route `POST /v1/checkouts/sessions/:id/process`
|
|
259
|
-
* and forwards `data.nonce` as `x-checkout-session-token`. Backend
|
|
260
|
-
* `TeamFloPay/backend#640` rejects callers without a matching nonce with a
|
|
261
|
-
* 401 — this method throws synchronously when `data.nonce` is missing so the
|
|
262
|
-
* problem surfaces before the network round trip.
|
|
263
|
-
*
|
|
264
|
-
* @param userId Vestigial — backend's GatewayInterceptor routes via session,
|
|
265
|
-
* not headers, so this value is no longer sent on the wire. Kept in the
|
|
266
|
-
* signature for back-compat with existing callers; will be removed in a
|
|
267
|
-
* future major version.
|
|
268
|
-
*/
|
|
269
|
-
processPayment(_userId: string, data: ProcessPaymentParams, options?: {
|
|
270
|
-
pollTimeoutMs?: number;
|
|
271
|
-
}): Promise<Response>;
|
|
272
|
-
/**
|
|
273
|
-
* Patch the buyer's account snapshot (email, name, billing address, AVS
|
|
274
|
-
* intent) onto a checkout session via
|
|
275
|
-
* `PATCH /v1/checkouts/sessions/{id}/account` (TeamFloPay/backend#823).
|
|
276
|
-
*
|
|
277
|
-
* The vault path's hosted form owns the charge end-to-end so the SDK
|
|
278
|
-
* never calls `/process` on this path; the buyer-typed AVS / billing
|
|
279
|
-
* address would otherwise be lost. The SDK calls this just before
|
|
280
|
-
* submitting the vault widget so the downstream listener mints the
|
|
281
|
-
* Stripe PaymentMethod with the right `billing_details.address` and the
|
|
282
|
-
* per-attempt + per-PM address snapshots are populated.
|
|
283
|
-
*
|
|
284
|
-
* Body shape mirrors the relevant subset of `/process`'s
|
|
285
|
-
* `ProcessCheckoutBodyDto` — same keys, same validators. The endpoint
|
|
286
|
-
* is idempotent: empty/undefined fields are not written, addresses are
|
|
287
|
-
* last-writer-wins, AVS analytics are first-writer-wins.
|
|
288
|
-
*
|
|
289
|
-
* Wrapped in `fetchWithNetworkRetry` because a transient blip on this
|
|
290
|
-
* pre-pay PATCH would silently leave AVS unsent and cause an
|
|
291
|
-
* AVS-protected charge to decline downstream.
|
|
292
|
-
*/
|
|
293
|
-
patchAccountSnapshot(sessionId: string, nonce: string, body: {
|
|
294
|
-
accountData: {
|
|
295
|
-
userId: string;
|
|
296
|
-
email: string;
|
|
297
|
-
firstName?: string | null;
|
|
298
|
-
lastName?: string | null;
|
|
299
|
-
addressLine1?: string | null;
|
|
300
|
-
addressLine2?: string | null;
|
|
301
|
-
city?: string | null;
|
|
302
|
-
state?: string | null;
|
|
303
|
-
zip?: string | null;
|
|
304
|
-
country?: string | null;
|
|
305
|
-
gender?: string | null;
|
|
306
|
-
};
|
|
307
|
-
avsCheck?: boolean;
|
|
308
|
-
avsConfig?: Record<string, unknown>;
|
|
309
|
-
}, options?: {
|
|
310
|
-
signal?: AbortSignal;
|
|
311
|
-
timeoutMs?: number;
|
|
312
|
-
/**
|
|
313
|
-
* Downgrade only a timeout to `operation.fallback` when the caller can
|
|
314
|
-
* continue safely. The promise still rejects and all other failures stay
|
|
315
|
-
* technical errors. Defaults to `blocking`.
|
|
316
|
-
*/
|
|
317
|
-
telemetryMode?: AccountSnapshotTelemetryMode;
|
|
318
|
-
}): Promise<void>;
|
|
319
|
-
/** Create a wallet/APM/PayPal intent through the session-scoped contract. */
|
|
320
|
-
createSessionIntent(sessionId: string, nonce: string, request: CreateSessionIntentRequest, options?: {
|
|
321
|
-
signal?: AbortSignal;
|
|
322
|
-
idempotencyKey?: string;
|
|
323
|
-
}): Promise<SessionIntent>;
|
|
324
|
-
/** Record a provider-neutral non-card decline with an optional validated intent correlation. */
|
|
325
|
-
reportSessionIntentDecline(sessionId: string, nonce: string, request: SessionIntentDeclineRequest, options?: {
|
|
326
|
-
signal?: AbortSignal;
|
|
327
|
-
}): Promise<void>;
|
|
328
|
-
/**
|
|
329
|
-
* Fetch user's prior payments by email.
|
|
330
|
-
* Used to determine if saved card UX should be shown.
|
|
331
|
-
*/
|
|
332
|
-
getPaymentsByEmail(email: string, options?: {
|
|
333
|
-
signal?: AbortSignal;
|
|
334
|
-
page?: number;
|
|
335
|
-
limit?: number;
|
|
336
|
-
}): Promise<{
|
|
337
|
-
data: Array<{
|
|
338
|
-
id: string;
|
|
339
|
-
}>;
|
|
340
|
-
total: number;
|
|
341
|
-
page: number;
|
|
342
|
-
limit: number;
|
|
343
|
-
}>;
|
|
344
|
-
/**
|
|
345
|
-
* Create a checkout session AND return the full session data in one call.
|
|
346
|
-
* Uses `?expand=true` so the backend returns the complete session
|
|
347
|
-
* instead of just a UUID — eliminating the need for a second GET.
|
|
348
|
-
*
|
|
349
|
-
* Falls back to create + GET if the backend doesn't support `expand`.
|
|
350
|
-
*
|
|
351
|
-
* Eligible sessions are created through the **detached** shell + claim flow
|
|
352
|
-
* (see {@link PaymentAPI.createDetachedSession}) and this method awaits the
|
|
353
|
-
* catalog claim. Callers still receive one catalog-populated session; when
|
|
354
|
-
* email is omitted it remains anonymous (`buyerIdentified: false`). The win
|
|
355
|
-
* here is server-side: the create no longer
|
|
356
|
-
* contends on buyer-identity advisory locks. Callers that want to render from
|
|
357
|
-
* the shell *before* the claim lands — mounting the card form early — should
|
|
358
|
-
* call {@link PaymentAPI.createDetachedSession} directly. Pass
|
|
359
|
-
* `deferDataAttachment: false` to force the original one-shot create.
|
|
360
|
-
*/
|
|
361
|
-
createAndFetchSession(params: InlineSessionDraft): Promise<NormalizedCheckoutSession>;
|
|
362
|
-
private createAndFetchSessionRequest;
|
|
363
|
-
/**
|
|
364
|
-
* `POST /v1/checkouts/sessions` with the SDK's bounded retry budget.
|
|
365
|
-
*
|
|
366
|
-
* Network failures and the backend's documented in-progress replay share one
|
|
367
|
-
* attempt budget and one operation-wide abort signal, so the two retry modes
|
|
368
|
-
* cannot multiply into nine POSTs during an outage. The idempotency key is
|
|
369
|
-
* resolved once, before the loop — an invalid merchant-supplied key throws
|
|
370
|
-
* before any request, and every attempt of this logical create replays the
|
|
371
|
-
* same key so a timeout cannot mint a second session
|
|
372
|
-
* (TeamFloPay/backend#972).
|
|
373
|
-
*/
|
|
374
|
-
private postCheckoutSessionCreate;
|
|
375
|
-
/**
|
|
376
|
-
* Create a checkout session **detached** from its buyer and catalog data
|
|
377
|
-
* (TeamFloPay/backend#1099).
|
|
378
|
-
*
|
|
379
|
-
* Resolves as soon as the lightweight *shell* exists. That create runs no
|
|
380
|
-
* catalog validation and takes none of the buyer-identity advisory locks that
|
|
381
|
-
* serialise concurrent checkouts for the same customer, and the backend routes
|
|
382
|
-
* a gateway for it from `currency` + the buyer's country — so the shell
|
|
383
|
-
* already carries the session id, nonce, `gateways` and the hosted `vault`
|
|
384
|
-
* block. The card form can mount from it immediately.
|
|
385
|
-
*
|
|
386
|
-
* Products and coupons are attached immediately by the stable
|
|
387
|
-
* {@link DetachedCheckoutSession.claimed} promise. With an email present that
|
|
388
|
-
* request also attaches the buyer. Without email it sends a catalog-only
|
|
389
|
-
* payload and returns a fully populated but anonymous session; the caller can
|
|
390
|
-
* later attach identity through the independent, replay-safe
|
|
391
|
-
* {@link DetachedCheckoutSession.claim} operation.
|
|
392
|
-
* **Nothing may be charged until it settles** — the billing API rejects
|
|
393
|
-
* process / intent / decline calls on an unclaimed session with
|
|
394
|
-
* `409 checkout_session_data_attachment_required`, and holds an unclaimed
|
|
395
|
-
* vault charge with a retryable `503`.
|
|
396
|
-
*
|
|
397
|
-
* Requires billing API v1.7.12+ with the independent catalog/buyer
|
|
398
|
-
* `PATCH /v1/checkouts/sessions/{id}/claim` contract; there
|
|
399
|
-
* is no fallback to the one-shot create. Callers that want the original
|
|
400
|
-
* single-request behaviour should pass `deferDataAttachment: false` and use
|
|
401
|
-
* {@link PaymentAPI.createAndFetchSession}.
|
|
402
|
-
*/
|
|
403
|
-
createDetachedSession(params: InlineSessionDraft): Promise<DetachedCheckoutSession>;
|
|
404
|
-
/**
|
|
405
|
-
* `PATCH /v1/checkouts/sessions/{id}/claim` — attach buyer identity, address,
|
|
406
|
-
* products and coupons to a detached session shell.
|
|
407
|
-
*
|
|
408
|
-
* The backend fingerprints each catalog or buyer-attachment operation, so a
|
|
409
|
-
* transport retry replaying the identical body returns the same session
|
|
410
|
-
* rather than conflicting. A materially different replay of the same
|
|
411
|
-
* operation returns `409`, which is surfaced without retrying. Invalid
|
|
412
|
-
* catalog data surfaces here as the same `422` the one-shot create would have
|
|
413
|
-
* returned — later in the flow, but with identical semantics.
|
|
414
|
-
*/
|
|
415
|
-
claimCheckoutSession(checkoutSessionId: string, nonce: string, payload: Record<string, unknown>, internal?: {
|
|
416
|
-
params: InlineSessionDraft;
|
|
417
|
-
startedAt: number;
|
|
418
|
-
deadline: {
|
|
419
|
-
signal: AbortSignal;
|
|
420
|
-
clear(): void;
|
|
421
|
-
};
|
|
422
|
-
/**
|
|
423
|
-
* Attempts the shell create needed. The `session_create` rollup below
|
|
424
|
-
* reports this rather than the claim's own attempt count, so an
|
|
425
|
-
* end-to-end span keeps meaning "attempts to create this session".
|
|
426
|
-
*/
|
|
427
|
-
createAttempt: number;
|
|
428
|
-
}): Promise<NormalizedCheckoutSession>;
|
|
429
|
-
/** Shared create/claim failure reporting so both phases classify identically. */
|
|
430
|
-
private reportSessionCreateFailure;
|
|
431
|
-
/**
|
|
432
|
-
* Record that the buyer never finished a saved-card 3DS challenge. Buyer
|
|
433
|
-
* abandonment is an expected outcome, not a technical failure, and matches
|
|
434
|
-
* what the hosted vault records for an abandoned challenge (TeamFloPay/sdk#394).
|
|
435
|
-
*/
|
|
436
|
-
reportThreeDsAbandoned(checkoutSessionId: string): void;
|
|
437
|
-
waitForCheckoutSessionCompletion(checkoutSessionId: string, options?: {
|
|
438
|
-
initialDelayMs?: number;
|
|
439
|
-
timeoutMs?: number;
|
|
440
|
-
/**
|
|
441
|
-
* Session-bound checkout token; forwarded on the poll's
|
|
442
|
-
* `GET /v1/checkouts/sessions/:id`. Required by post-#640 backends.
|
|
443
|
-
*/
|
|
444
|
-
nonce?: string;
|
|
445
|
-
/** Advertised authenticated attempt-status endpoint from a `202` response. */
|
|
446
|
-
statusUrl?: string;
|
|
447
|
-
/**
|
|
448
|
-
* Keep polling after an `ACTION_REQUIRED` attempt. Challenge UIs use this
|
|
449
|
-
* while the backend resolves the buyer's completed action server-side;
|
|
450
|
-
* ordinary callers still receive the action immediately.
|
|
451
|
-
*/
|
|
452
|
-
continueAfterActionRequired?: boolean;
|
|
453
|
-
paymentMethodCategory?: TelemetryPaymentMethodCategory;
|
|
454
|
-
/** Cancels polling when the owning UI lifecycle ends. */
|
|
455
|
-
signal?: AbortSignal;
|
|
456
|
-
}): Promise<NormalizedCheckoutSession>;
|
|
457
|
-
private reportRecoveryCompleted;
|
|
458
|
-
private resolveCheckoutSessionStatus;
|
|
459
|
-
private waitForCheckoutStatus;
|
|
460
|
-
/**
|
|
461
|
-
* Whether a failed status attempt answers this caller. A caller that names its submitted
|
|
462
|
-
* provider intent only accepts a failure for exactly that intent: another intent, or none, is
|
|
463
|
-
* unmatched. A caller that cannot name one accepts any failure the SDK has not already
|
|
464
|
-
* reported on the session, through this client or any other on the page (TeamFloPay/sdk#439).
|
|
465
|
-
*/
|
|
466
|
-
private isOwnFailedAttempt;
|
|
467
|
-
/** Record a failed status attempt the SDK is about to report to its caller. */
|
|
468
|
-
private rememberReportedFailure;
|
|
469
|
-
private fetchCheckoutStatus;
|
|
470
|
-
/** Normalize a raw session into a provider-agnostic shape. */
|
|
471
|
-
private normalizeRawSession;
|
|
472
|
-
/** Convert raw session to the SDK CheckoutSession shape. */
|
|
473
|
-
private toCheckoutSession;
|
|
474
|
-
/**
|
|
475
|
-
* Coerce a raw vault block into a typed {@link VaultCaptureBlock}. The
|
|
476
|
-
* server-only PCIVault submit `secret` is deliberately dropped so it never
|
|
477
|
-
* lands on the public session surface (logs / telemetry / client inspection).
|
|
478
|
-
*/
|
|
479
|
-
private toVaultBlock;
|
|
480
|
-
private toCheckoutSessionStatus;
|
|
481
|
-
private resolveProcessResponse;
|
|
482
|
-
private toProcessResponseFromStatus;
|
|
483
|
-
private reconcileProcessPayment;
|
|
484
|
-
private toProcessResponseFromSession;
|
|
485
|
-
private toCheckoutProcessingPending;
|
|
486
|
-
private clampRetryAfterMs;
|
|
487
|
-
/**
|
|
488
|
-
* Stash the display-only fields the consumer passed into a create-session
|
|
489
|
-
* call. Runs after the backend assigns a UUID so a later GET on the same
|
|
490
|
-
* session (typically after a redirect) can fill in fields the backend no
|
|
491
|
-
* longer persists — `overrideAmount`, `totalAmount`, `name`, etc.
|
|
492
|
-
*
|
|
493
|
-
* No-op when no UUID is available.
|
|
494
|
-
*/
|
|
495
|
-
private autoCacheDisplayData;
|
|
496
|
-
/**
|
|
497
|
-
* Merge cached display-only fields (set by {@link cacheSessionDisplayData})
|
|
498
|
-
* into a raw session response. Server values always win — cache fills in
|
|
499
|
-
* only where the server returned `null` / `undefined`.
|
|
500
|
-
*/
|
|
501
|
-
private mergeCachedDisplayData;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
/** Browser operation hosted by the PCIVault card-capture adapter. */
|
|
505
|
-
type CardCaptureOperation = 'checkout' | 'card_setup';
|
|
506
|
-
/** Configuration for a {@link PciVaultCardCapture} instance. */
|
|
507
|
-
interface PciVaultCardCaptureConfig {
|
|
508
|
-
/** Checkout session id bound to the capture (for outcome correlation + trust). */
|
|
509
|
-
sessionId?: string;
|
|
510
|
-
/** Capture behavior of the checkout session, used to classify legacy outcomes safely. */
|
|
511
|
-
captureMethod?: CaptureMethod;
|
|
512
|
-
/** Distinguishes no-charge card verification telemetry from checkout payment telemetry. */
|
|
513
|
-
operation?: CardCaptureOperation;
|
|
514
|
-
/**
|
|
515
|
-
* Default strict origin for vault `postMessage` outcomes. Overridden by
|
|
516
|
-
* {@link CardCaptureMountOptions.expectedOrigin} when that is supplied at
|
|
517
|
-
* mount. When neither is set the origin gate is skipped (the widget posts
|
|
518
|
-
* same-window in the Model-A flow).
|
|
519
|
-
*/
|
|
520
|
-
expectedOrigin?: string;
|
|
521
|
-
/** Flo-owned privacy-safe telemetry is enabled by default; set false to opt out. */
|
|
522
|
-
telemetry?: boolean;
|
|
523
|
-
/** Billing API base URL used by the standalone telemetry reporter. */
|
|
524
|
-
billingApiUrl?: string;
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* {@link CardCaptureAdapter} backed by the backend-rendered PCIVault hosted
|
|
528
|
-
* widget.
|
|
529
|
-
*
|
|
530
|
-
* `mount()` injects the server-supplied widget HTML (re-executing its bundled
|
|
531
|
-
* `<script>` so the form bootstraps) and subscribes to the widget's
|
|
532
|
-
* `postMessage` outcome. The backend owns everything else; this adapter never
|
|
533
|
-
* touches the card data, a payment intent, or 3DS.
|
|
534
|
-
*/
|
|
535
|
-
declare class PciVaultCardCapture implements CardCaptureAdapter {
|
|
536
|
-
readonly provider: CardCaptureProviderId;
|
|
537
|
-
private readonly config;
|
|
538
|
-
private telemetryReporter?;
|
|
539
|
-
/** Reporter already initialized for this adapter's setup operation. */
|
|
540
|
-
private setupTelemetryReporter?;
|
|
541
|
-
private readonly ownsTelemetryReporter;
|
|
542
|
-
private container;
|
|
543
|
-
private messageHandler;
|
|
544
|
-
/**
|
|
545
|
-
* Parent-page-level overlay rendering the provider's verification challenge
|
|
546
|
-
* (3DS-2 iframe) on `action_required`. Owned by the adapter — not the
|
|
547
|
-
* widget — so it can sit above the host SDK's processing backdrop, which
|
|
548
|
-
* would otherwise visually cover an in-widget challenge iframe.
|
|
549
|
-
*/
|
|
550
|
-
private actionOverlay;
|
|
551
|
-
/**
|
|
552
|
-
* Listener that catches the `flopay-vault-3ds-return` postMessage from the
|
|
553
|
-
* challenge return page. It is an overlay-dismissal accelerator only: the
|
|
554
|
-
* terminal outcome is resolved server-side on `/vault/3ds/return` and
|
|
555
|
-
* reaches the SDK through the widget's own `/status` poll. There is
|
|
556
|
-
* deliberately no client-side completion bridge back into the widget
|
|
557
|
-
* (TeamFloPay/backend#1674).
|
|
558
|
-
*/
|
|
559
|
-
private threeDsReturnHandler;
|
|
560
|
-
/**
|
|
561
|
-
* Element that held focus when the challenge overlay opened, restored on
|
|
562
|
-
* teardown. A keyboard or screen-reader buyer would otherwise be stranded on
|
|
563
|
-
* the obscured page behind the modal once the challenge is gone.
|
|
564
|
-
*/
|
|
565
|
-
private actionOverlayPreviousFocus;
|
|
566
|
-
/** Bound on how long the challenge overlay may stay up (see above). */
|
|
567
|
-
private actionOverlayTimer;
|
|
568
|
-
/** Per-session integrity token to require on outcomes (from mount options). */
|
|
569
|
-
private messageToken;
|
|
570
|
-
/** Strict origin to require on outcomes, when configured. */
|
|
571
|
-
private expectedOrigin;
|
|
572
|
-
/**
|
|
573
|
-
* Latest theme directive to push into the (cross-origin) widget: a theme
|
|
574
|
-
* object, `null` for the explicit classic reset (the hosted asset restores
|
|
575
|
-
* every historical neutral value), or `undefined` when the host has never
|
|
576
|
-
* expressed one — nothing is posted then, so a freshly injected widget keeps
|
|
577
|
-
* its own defaults.
|
|
578
|
-
*/
|
|
579
|
-
private theme;
|
|
580
|
-
/** Latest host submit-gate state to push into the widget (block its submit). */
|
|
581
|
-
private submitGateBlocked;
|
|
582
|
-
/** Latest card-field order + autofocus directive to push into the widget. */
|
|
583
|
-
private cardFieldOrder;
|
|
584
|
-
private cardAutoFocus;
|
|
585
|
-
/**
|
|
586
|
-
* Latest merchant submit wording: a label, `null` for the explicit reset to
|
|
587
|
-
* the hosted session default, or `undefined` when the host has never set
|
|
588
|
-
* one — nothing is posted then, so the widget keeps its own default.
|
|
589
|
-
*/
|
|
590
|
-
private submitLabel;
|
|
591
|
-
/** Monotonic start of the current widget mount-to-ready machine interval. */
|
|
592
|
-
private mountStartedAt;
|
|
593
|
-
private vaultReadyReported;
|
|
594
|
-
/**
|
|
595
|
-
* The mounted form sits behind the backend's production human check, so a
|
|
596
|
-
* pre-submit `error` is the check's own state, not a vault load failure.
|
|
597
|
-
*/
|
|
598
|
-
private verificationRequired;
|
|
599
|
-
private submissionStarted;
|
|
600
|
-
private submissionStartedAt;
|
|
601
|
-
private readonly listeners;
|
|
602
|
-
constructor(config?: PciVaultCardCaptureConfig);
|
|
603
|
-
mount(container: HTMLElement, options: CardCaptureMountOptions): Promise<void>;
|
|
604
|
-
private reportVaultLoadFailure;
|
|
605
|
-
on(event: CardCaptureEventType, handler: (event: CardCaptureOutcomeEvent) => void): () => void;
|
|
606
|
-
unmount(): void;
|
|
607
|
-
/**
|
|
608
|
-
* Inject the server-rendered widget HTML. `innerHTML` does not execute
|
|
609
|
-
* embedded `<script>` tags, so each script node is replaced with a freshly
|
|
610
|
-
* created element that the browser will load and run (this is what boots the
|
|
611
|
-
* PCIVault form bundle against the `data-flopay-config` container).
|
|
612
|
-
*/
|
|
613
|
-
private injectWidget;
|
|
614
|
-
private attachMessageListener;
|
|
615
|
-
/**
|
|
616
|
-
* A pre-submit `error` from a form mounted behind the production human check
|
|
617
|
-
* whose cause is the check's own buyer-facing state (see
|
|
618
|
-
* {@link isVerificationStateCause}).
|
|
619
|
-
*/
|
|
620
|
-
private isVerificationStateError;
|
|
621
|
-
private reportOutcome;
|
|
622
|
-
/**
|
|
623
|
-
* Push merchant theme colors into the hosted widget (live). The host calls
|
|
624
|
-
* this on a runtime theme switch; the widget applies them to its CSS variables
|
|
625
|
-
* without a remount. Stores the latest theme so `ready` can re-push it.
|
|
626
|
-
*/
|
|
627
|
-
applyTheme(theme: VaultCardThemeColors | null): void;
|
|
628
|
-
/**
|
|
629
|
-
* postMessage the current theme directive to the widget's (cross-origin)
|
|
630
|
-
* document. `null` travels as-is: it is the merged hosted contract's explicit
|
|
631
|
-
* reset, retained so a widget that (re)becomes ready replays it.
|
|
632
|
-
*/
|
|
633
|
-
private postTheme;
|
|
634
|
-
/**
|
|
635
|
-
* Gate the widget's submit from the host. When `blocked`, the widget cancels
|
|
636
|
-
* its next submit and emits `'blocked'` instead of `'submitting'` so the host
|
|
637
|
-
* can validate merchant-DOM fields (AVS) first. Stored so `ready` re-pushes it.
|
|
638
|
-
*/
|
|
639
|
-
setSubmitGate(blocked: boolean): void;
|
|
640
|
-
/**
|
|
641
|
-
* postMessage the current submit-gate state to the widget's document. If it
|
|
642
|
-
* cannot be delivered, the host still validates and surfaces errors on its side.
|
|
643
|
-
*/
|
|
644
|
-
private postSubmitGate;
|
|
645
|
-
/**
|
|
646
|
-
* Push the card-field order + autofocus directive into the widget (live). The
|
|
647
|
-
* widget re-sequences its rows (DOM order, so tab order follows) and focuses
|
|
648
|
-
* its first field unless `autoFocus` is false. Stored so `ready` re-pushes it.
|
|
649
|
-
*/
|
|
650
|
-
setCardFieldOrder(order: VaultCardFieldKey[] | null, autoFocus: boolean): void;
|
|
651
|
-
/** postMessage the current field order + autofocus to the widget's document. */
|
|
652
|
-
private postCardFieldOrder;
|
|
653
|
-
/**
|
|
654
|
-
* Replace the hosted form's final submit wording (live, no remount). The
|
|
655
|
-
* text is forwarded verbatim — the hosted form owns normalization and falls
|
|
656
|
-
* back to its session default for blank or invalid text; `null` is the
|
|
657
|
-
* explicit reset. Stored so `ready` re-pushes it.
|
|
658
|
-
*/
|
|
659
|
-
setSubmitLabel(label: string | null): void;
|
|
660
|
-
/**
|
|
661
|
-
* postMessage the current submit-label directive to the widget's document.
|
|
662
|
-
* Unlike the other host directives it carries merchant text, so it is sent
|
|
663
|
-
* only with the session + message-token binding the hosted form checks, and
|
|
664
|
-
* only to the vault block's exact origin — never to `'*'`.
|
|
665
|
-
*/
|
|
666
|
-
private postSubmitLabel;
|
|
667
|
-
/** The mounted widget's (cross-origin) document window, once its iframe exists. */
|
|
668
|
-
private hostedWindow;
|
|
669
|
-
/** postMessage a host directive to the widget's document once its iframe exists. */
|
|
670
|
-
private postToHostedWindow;
|
|
671
|
-
/**
|
|
672
|
-
* `postMessage` target for the cosmetic host directives: the vault block's
|
|
673
|
-
* exact origin when known. A widget mounted without `expectedOrigin` (e.g. an
|
|
674
|
-
* opaque `srcdoc` form, which no origin can target) falls back to `'*'`.
|
|
675
|
-
*/
|
|
676
|
-
private directiveTargetOrigin;
|
|
677
|
-
private emit;
|
|
678
|
-
/**
|
|
679
|
-
* Render the provider-hosted verification challenge (e.g. Stripe 3DS-2) in a
|
|
680
|
-
* full-page overlay at the PARENT page level. The widget's inline-iframe
|
|
681
|
-
* approach is unusable because the SDK's processing backdrop sits above the
|
|
682
|
-
* vault iframe, hiding any challenge mounted inside it — by lifting the
|
|
683
|
-
* iframe to the host page the adapter can give it a z-index that wins.
|
|
684
|
-
*
|
|
685
|
-
* The overlay tears down on the next terminal outcome
|
|
686
|
-
* (`complete`/`decline`/`error`) or when the buyer closes it via the backdrop
|
|
687
|
-
* close button. Closing manually is a soft abandon — it emits the
|
|
688
|
-
* non-terminal `challenge_dismissed` so the host can drop its processing
|
|
689
|
-
* backdrop, while the widget keeps polling `/status` and still owns the
|
|
690
|
-
* eventual outcome (an out-of-band approval can land after the challenge is
|
|
691
|
-
* gone).
|
|
692
|
-
*/
|
|
693
|
-
private showActionRequiredOverlay;
|
|
694
|
-
/**
|
|
695
|
-
* (Re)start the overlay bound. Deliberately longer than the widget's own
|
|
696
|
-
* `/status` poll window so the widget's deterministic timeout lands first;
|
|
697
|
-
* this only fires when nothing at all came back.
|
|
698
|
-
*/
|
|
699
|
-
private armActionRequiredTimeout;
|
|
700
|
-
/**
|
|
701
|
-
* Report a challenge the buyer never finished. Both ways out of a challenge
|
|
702
|
-
* without an outcome — closing the overlay, or never coming back at all —
|
|
703
|
-
* are the same `customer_abandoned` terminal event.
|
|
704
|
-
*/
|
|
705
|
-
private reportChallengeAbandoned;
|
|
706
|
-
/**
|
|
707
|
-
* Tear the challenge down and give the buyer a terminal, provider-neutral
|
|
708
|
-
* error. Unlike a manual close, nothing is left to come back to, so this also
|
|
709
|
-
* ends the attempt for the host.
|
|
710
|
-
*/
|
|
711
|
-
private timeOutActionRequiredOverlay;
|
|
712
|
-
/**
|
|
713
|
-
* The buyer closed the challenge. Report it as abandoned and tell the host —
|
|
714
|
-
* `challenge_dismissed` is deliberately NON-terminal: the widget is still
|
|
715
|
-
* polling `/status` and a late `complete`/`decline`/`error` must still be
|
|
716
|
-
* delivered. Without it the host's processing backdrop (raised on
|
|
717
|
-
* `submitting`) would hold the buyer behind a modal for the rest of the
|
|
718
|
-
* widget's authentication window.
|
|
719
|
-
*/
|
|
720
|
-
private abandonActionRequiredOverlay;
|
|
721
|
-
private hideActionRequiredOverlay;
|
|
722
|
-
/**
|
|
723
|
-
* Size the hosted-widget iframe to the height reported by the form inside it.
|
|
724
|
-
* Cross-origin iframes don't auto-size to their content, so the widget posts
|
|
725
|
-
* its measured height and we apply it here (clamped to a sane range). This is
|
|
726
|
-
* what lets the card form shrink/grow to fit instead of sitting at a fixed
|
|
727
|
-
* height.
|
|
728
|
-
*/
|
|
729
|
-
private applyHeight;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
export { type CardCaptureOperation as C, PaymentAPI as P, SESSION_CREATE_TELEMETRY as S, PciVaultCardCapture as a, type PciVaultCardCaptureConfig as b, type SessionDisplayCacheData as c, type SessionDisplayProduct as d, cacheSessionDisplayData as e, clearSessionDisplayData as f, getSessionDisplayData as g };
|