@flopay/shared 1.16.2 → 1.16.4
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/card-fields.d.ts +31 -0
- package/dist/constants.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.mjs +1 -1
- package/dist/instrument-dispatch.d.ts +14 -0
- package/dist/instruments.d.ts +19 -1
- package/dist/payment-decline.d.ts +35 -3
- package/dist/telemetry.d.ts +7 -1
- package/dist/types.d.ts +13 -0
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CardFieldsEvent } from './card-fields.js';
|
|
1
2
|
import type { FloInstrumentEvent } from './instruments.js';
|
|
2
3
|
import type { TelemetryErrorCode, TelemetryLogName, TelemetryProviderInput, TelemetryRequestCategory } from './telemetry.js';
|
|
3
4
|
/**
|
|
@@ -12,6 +13,9 @@ export declare function invokeMerchantCallback(callback: (() => unknown) | undef
|
|
|
12
13
|
export type FloInstrumentSource = {
|
|
13
14
|
class: 'lifecycle';
|
|
14
15
|
name: TelemetryLogName;
|
|
16
|
+
/** Only on `vault.fields.ready` / `vault.fields.failed`. */
|
|
17
|
+
elapsedMs?: number;
|
|
18
|
+
loadFailureReason?: string;
|
|
15
19
|
provider?: TelemetryProviderInput;
|
|
16
20
|
} | {
|
|
17
21
|
class: 'technical_error';
|
|
@@ -24,6 +28,16 @@ export type FloInstrumentSource = {
|
|
|
24
28
|
} | {
|
|
25
29
|
class: 'more_options';
|
|
26
30
|
};
|
|
31
|
+
/** The feed source for an adapter card-field event (the same shape telemetry observes). */
|
|
32
|
+
export declare function cardFieldsInstrumentSource(event: CardFieldsEvent): FloInstrumentSource;
|
|
33
|
+
/**
|
|
34
|
+
* Whether an observation is a card-field lifecycle event. UI bindings feed those from the
|
|
35
|
+
* card-capture adapter subscription, so they leave the telemetry copy out of the feed.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isCardFieldsInstrumentSource(source: {
|
|
38
|
+
class: string;
|
|
39
|
+
name?: unknown;
|
|
40
|
+
}): boolean;
|
|
27
41
|
/** Project the closed internal taxonomy onto the smaller merchant-safe v1 contract. */
|
|
28
42
|
export declare function projectFloInstrument(source: FloInstrumentSource): FloInstrumentEvent | null;
|
|
29
43
|
/** Instruments a checkout emits at most once per checkout identity. */
|
package/dist/instruments.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CardFieldsFailureReason } from './card-fields.js';
|
|
1
2
|
import type { BillingProvider } from './types.js';
|
|
2
3
|
/** Schema version for the privacy-safe instrument callback contract. */
|
|
3
4
|
export declare const FLO_INSTRUMENT_SCHEMA_VERSION: 1;
|
|
@@ -44,10 +45,27 @@ interface FloInstrumentCommonFields {
|
|
|
44
45
|
/** Gateway selected for this transition, when the checkout has selected one. */
|
|
45
46
|
gateway?: BillingProvider;
|
|
46
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Card-field lifecycle events on the merchant instrument feed, emitted once per card form
|
|
50
|
+
* (never once per checkout). `reason` is the closed `CardFieldsFailureReason` set.
|
|
51
|
+
*/
|
|
52
|
+
export type FloCardFieldsInstrumentEvent = (FloInstrumentCommonFields & {
|
|
53
|
+
name: 'card_fields_ready';
|
|
54
|
+
elapsedMs: number;
|
|
55
|
+
}) | (FloInstrumentCommonFields & {
|
|
56
|
+
name: 'card_fields_failed';
|
|
57
|
+
reason: CardFieldsFailureReason;
|
|
58
|
+
elapsedMs: number;
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Every event on the merchant instrument feed: the catalogued checkout funnel signals, plus the
|
|
62
|
+
* per-card-form lifecycle events (issue #539), which are not catalogue entries because they fire
|
|
63
|
+
* once per card form rather than once per checkout.
|
|
64
|
+
*/
|
|
47
65
|
export type FloInstrumentEvent = (FloInstrumentCommonFields & {
|
|
48
66
|
name: FloInstrumentLifecycleName;
|
|
49
67
|
}) | (FloInstrumentCommonFields & {
|
|
50
68
|
name: 'checkout_error';
|
|
51
69
|
phase: FloInstrumentErrorPhase;
|
|
52
|
-
});
|
|
70
|
+
}) | FloCardFieldsInstrumentEvent;
|
|
53
71
|
export {};
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* as `payment_declined`. A 5xx, or any other status, is a technical failure
|
|
9
9
|
* whatever decline fields it carries.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* This rule decides telemetry. Merchant callback routing uses
|
|
12
|
+
* {@link isDeclineCallbackFailure}, which also sends an authentication failure
|
|
13
|
+
* to `onDecline` (sdk#558).
|
|
14
14
|
*/
|
|
15
15
|
export declare function isExpectedPaymentDecline(error: {
|
|
16
16
|
readonly statusCode?: number;
|
|
@@ -18,3 +18,35 @@ export declare function isExpectedPaymentDecline(error: {
|
|
|
18
18
|
readonly declineCode?: string;
|
|
19
19
|
readonly telemetryOutcome?: string;
|
|
20
20
|
}): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether a failed payment is an authentication failure: 3DS or PayPal
|
|
23
|
+
* authentication ended the attempt (a 3DS timeout, a failed challenge, or PayPal
|
|
24
|
+
* asking the buyer to re-authenticate). Like a decline, it has no HTTP status
|
|
25
|
+
* or a 4xx one; a 5xx is a technical failure whatever code it carries.
|
|
26
|
+
*
|
|
27
|
+
* Telemetry does not use this: a 3DS timeout is still recorded as an
|
|
28
|
+
* abandonment, not as `payment_declined` (see {@link isExpectedPaymentDecline}).
|
|
29
|
+
*/
|
|
30
|
+
export declare function isPaymentAuthenticationFailure(error: {
|
|
31
|
+
readonly statusCode?: number;
|
|
32
|
+
readonly code?: string;
|
|
33
|
+
}): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether a failed payment reaches the merchant through `onDecline` (Vue:
|
|
36
|
+
* `decline`) rather than `onError` (Vue: `error`): an expected decline (sdk#557)
|
|
37
|
+
* or an authentication failure (sdk#558). Every other failure is technical and
|
|
38
|
+
* reaches `onError` only. Each failure therefore reaches exactly one of the two
|
|
39
|
+
* callbacks.
|
|
40
|
+
*
|
|
41
|
+
* Every saved-payment, PayPal-return and automatic-payment path in React and
|
|
42
|
+
* Vue uses this one rule for its callback routing, so the paths cannot drift
|
|
43
|
+
* apart. A path that cannot emit a decline (Vue without a session id, the
|
|
44
|
+
* automatic payment button without `emitDecline: true`) still reports the
|
|
45
|
+
* failure through `onError`, so none is lost.
|
|
46
|
+
*/
|
|
47
|
+
export declare function isDeclineCallbackFailure(error: {
|
|
48
|
+
readonly statusCode?: number;
|
|
49
|
+
readonly code?: string;
|
|
50
|
+
readonly declineCode?: string;
|
|
51
|
+
readonly telemetryOutcome?: string;
|
|
52
|
+
}): boolean;
|
package/dist/telemetry.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export type TelemetryErrorReason = (typeof TELEMETRY_ERROR_REASONS)[number];
|
|
|
40
40
|
/** Closed catalog of SDK-authored lifecycle and operational log names. */
|
|
41
41
|
export declare const TELEMETRY_LOG_NAMES: readonly ['sdk.initialize.started', 'sdk.initialize.ready', 'sdk.cache.hit', 'sdk.cache.miss', 'checkout.mount', 'session.create.started', 'session.shell.ready', 'session.claim.started', 'session.claim.completed', 'session.read.started', 'session.request.first_byte', 'session.request.completed', 'checkout.data.ready', 'checkout.rendered', 'checkout.recovery.started', 'checkout.recovery.completed', 'checkout.unmount', 'provider.load.started', 'provider.eligibility.checked', 'provider.availability.checked', 'provider.ready', 'provider.handoff.requested', 'provider.popup.opened', 'provider.overlay.opened', 'provider.overlay.returned', 'provider.callback.ignored', 'provider.redirect.started', 'provider.redirect.resumed', 'vault.capture.requested', 'vault.widget.mounted', 'vault.widget.ready', 'vault.submission.started', 'vault.action.required', 'vault.three_ds.handoff', 'vault.three_ds.returned', 'vault.terminal', 'payment.method.selected', 'payment.intent.started', 'payment.intent.completed', 'payment.provider_confirmation.started', 'payment.provider_confirmation.returned', 'payment.tokenization.started', 'payment.tokenization.completed', 'payment.processing.started', 'payment.processing.completed', 'payment.three_ds.handoff', 'payment.three_ds.returned', 'operation.retry', 'operation.deduplicated', 'operation.fallback', 'operation.cache.hit', 'operation.cache.miss', 'operation.recovery.started', 'operation.recovery.completed', 'operation.state_transition',
|
|
42
42
|
/** One closed 3DS challenge lifecycle record (`ThreeDsChallengeRecord` fields). */
|
|
43
|
-
'three_ds.challenge'];
|
|
43
|
+
'three_ds.challenge', 'vault.fields.ready', 'vault.fields.failed'];
|
|
44
44
|
export type TelemetryLogName = (typeof TELEMETRY_LOG_NAMES)[number];
|
|
45
45
|
/**
|
|
46
46
|
* Closed reasons a provider callback was ignored instead of reaching checkout
|
|
@@ -142,6 +142,10 @@ export interface TelemetryLogEvent extends TelemetryCommonFields {
|
|
|
142
142
|
evidenceBasis?: ThreeDsEvidenceBasis;
|
|
143
143
|
terminalSource?: ThreeDsTerminalSource;
|
|
144
144
|
providerOutcome?: ThreeDsProviderOutcome;
|
|
145
|
+
/** Only on `vault.fields.ready` / `vault.fields.failed`: the checkout session UUID. */
|
|
146
|
+
checkoutSessionId?: string;
|
|
147
|
+
/** Only on `vault.fields.failed`, from the closed `CardFieldsFailureReason` set. */
|
|
148
|
+
loadFailureReason?: import('./card-fields.js').CardFieldsFailureReason;
|
|
145
149
|
}
|
|
146
150
|
export interface BuildTelemetryLogEventInput extends BuildTelemetryCommonInput {
|
|
147
151
|
name: TelemetryLogName;
|
|
@@ -153,6 +157,8 @@ export interface BuildTelemetryLogEventInput extends BuildTelemetryCommonInput {
|
|
|
153
157
|
evidenceBasis?: string;
|
|
154
158
|
terminalSource?: string;
|
|
155
159
|
providerOutcome?: string;
|
|
160
|
+
checkoutSessionId?: string;
|
|
161
|
+
loadFailureReason?: string;
|
|
156
162
|
}
|
|
157
163
|
export interface TelemetryExpectedOutcomeEvent extends TelemetryCommonFields {
|
|
158
164
|
class: 'expected_outcome';
|
package/dist/types.d.ts
CHANGED
|
@@ -906,6 +906,13 @@ export interface VaultCaptureResultMessage {
|
|
|
906
906
|
nextActionRedirectUrl?: string;
|
|
907
907
|
/** Display-only saved card produced by a successful setup, when supplied. */
|
|
908
908
|
paymentMethod?: SavedCardDisplay;
|
|
909
|
+
/**
|
|
910
|
+
* Optional protocol features the hosted form announces on its `ready`. A form that lists
|
|
911
|
+
* `'fields_interactive'` posts a separate `fields_interactive` message once the buyer can type
|
|
912
|
+
* in the card fields. A form that announces nothing is an older widget: its `ready` stands in
|
|
913
|
+
* as the card-fields-ready signal (backwards-compatible fallback, issue #539).
|
|
914
|
+
*/
|
|
915
|
+
capabilities?: readonly string[];
|
|
909
916
|
}
|
|
910
917
|
/** Options for mounting the hosted vault widget into a container element. */
|
|
911
918
|
export interface CardCaptureMountOptions {
|
|
@@ -1127,6 +1134,12 @@ export interface CardCaptureAdapter {
|
|
|
1127
1134
|
* widget (it focuses the first AVS field itself). Re-applied on `ready`.
|
|
1128
1135
|
*/
|
|
1129
1136
|
setCardFieldOrder?(order: VaultCardFieldKey[] | null, autoFocus: boolean): void;
|
|
1137
|
+
/**
|
|
1138
|
+
* Subscribe to the card-field lifecycle: `card_fields_ready` once per card form when the
|
|
1139
|
+
* fields are interactive, `card_fields_failed` when they fail to load or time out. Returns
|
|
1140
|
+
* an unsubscribe fn.
|
|
1141
|
+
*/
|
|
1142
|
+
onCardFields?(handler: (event: import('./card-fields.js').CardFieldsEvent) => void): () => void;
|
|
1130
1143
|
/**
|
|
1131
1144
|
* Set the hosted card form's final submit wording (live, billing API
|
|
1132
1145
|
* v1.9.35+). The text replaces the button label in place, so the widget is
|