@flopay/vue 1.16.3 → 1.16.5
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 -0
- package/dist/automatic-payment-button.d.ts +20 -1
- package/dist/{chunk-RAXPWAR7.mjs → chunk-RAGPQWRA.mjs} +6 -2
- package/dist/{chunk-YN3PHIYF.mjs → chunk-XLVMVLVL.mjs} +1 -1
- package/dist/flopay-checkout.d.ts +16 -1
- package/dist/index.cjs +118 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +116 -9
- package/dist/payment-method-setup-entry.cjs +5 -2
- package/dist/payment-method-setup-entry.mjs +1 -1
- package/dist/split-card-form.d.ts +18 -1
- package/dist/{stripe-elements-SXMTHEF6.mjs → stripe-elements-SI2PI6EO.mjs} +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -131,6 +131,24 @@ export default defineComponent({
|
|
|
131
131
|
});
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
+
### Card-field lifecycle
|
|
135
|
+
|
|
136
|
+
`FloPayCheckout` and `SplitCardForm` emit `cardFieldsReady` (`@card-fields-ready` in templates, `onCardFieldsReady` in `h()`, React's `onCardFieldsReady`) once per hosted card form, when the card fields are on screen and the buyer can type in them, with `{ type: 'card_fields_ready', elapsedMs }`: the milliseconds since that card form mounted. They emit `cardFieldsFailed` (`@card-fields-failed`, `onCardFieldsFailed`) when the card fields fail to load, or are not ready within the `cardFieldsTimeoutMs` prop (default 15 000 ms, the same on every device; a value that is not a positive number keeps the default), with `{ type: 'card_fields_failed', reason, elapsedMs }`. `reason` is always one of `load_error` (the form failed to load), `timeout` (not interactive in time), `blocked` (a content-security policy blocked the form's own script or frame) or `other`.
|
|
137
|
+
|
|
138
|
+
A card-field failure is not a declined or failed payment: it never emits `decline`, and on `@instrument` it is `card_fields_failed`, never `checkout_error`. If the fields become ready after a `timeout`, `cardFieldsReady` still follows, with no second failure. Both events also reach `@instrument` (`card_fields_ready`, `card_fields_failed`) and Flo's SDK telemetry with the checkout session id, and never carry card data. A throwing listener does not affect the checkout, and nothing changes if you listen for neither.
|
|
139
|
+
|
|
140
|
+
The `error` event is unchanged: it is still emitted, as before, when the hosted form itself reports that it failed to load. A timeout, a blocked form or any other failure the SDK detects only emits `cardFieldsFailed`. With an older hosted form that does not report when its fields become interactive, `cardFieldsReady` is emitted when that form reports its own ready instead.
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
h(FloPayCheckout, {
|
|
144
|
+
sessionId: 'sess_123',
|
|
145
|
+
nonce: 'nonce_123',
|
|
146
|
+
cardFieldsTimeoutMs: 20_000,
|
|
147
|
+
onCardFieldsReady: (event) => console.log('card fields ready', event.elapsedMs),
|
|
148
|
+
onCardFieldsFailed: (event) => console.warn('card fields failed', event.reason, event.elapsedMs),
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
134
152
|
## Errors
|
|
135
153
|
|
|
136
154
|
Errors are `FloPayError` instances from `@flopay/shared`, emitted through `@error`.
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type { ButtonsLayoutStyles, ButtonsLayoutTheme, CheckoutButtonMethod, CheckoutItem, CheckoutProduct, CheckoutSession, CheckoutSubscription, DeclineEvent, FloPayAppearance, InlineSessionDraft, PaymentResult, ThemeId } from '@flopay/shared';
|
|
1
|
+
import type { ButtonsLayoutStyles, ButtonsLayoutTheme, CheckoutButtonMethod, CheckoutItem, CheckoutProduct, CheckoutSession, CheckoutSubscription, DeclineEvent, FloPayAppearance, InlineSessionDraft, OneClickSession, PaymentResult, ThemeId } from '@flopay/shared';
|
|
2
2
|
import { FloPayError } from '@flopay/shared';
|
|
3
3
|
import { type PropType } from 'vue';
|
|
4
|
+
/** Fetches a server-minted one-click session on click; React's `getSession` prop. */
|
|
5
|
+
type GetOneClickSession = (options: {
|
|
6
|
+
signal: AbortSignal;
|
|
7
|
+
}) => Promise<OneClickSession>;
|
|
4
8
|
/** Payload of the `success` event — identical to React's `onSuccess` argument. */
|
|
5
9
|
export interface FloPayAutomaticPaymentSuccessEvent {
|
|
6
10
|
result: PaymentResult;
|
|
@@ -20,6 +24,11 @@ export interface FloPayAutomaticPaymentButtonProps {
|
|
|
20
24
|
/** Session-bound checkout token for a supplied {@link sessionId}. */
|
|
21
25
|
nonce?: string;
|
|
22
26
|
createSession?: InlineSessionDraft;
|
|
27
|
+
/**
|
|
28
|
+
* Called on click to fetch a server-minted one-click session (`{ sessionId, nonce }`),
|
|
29
|
+
* as in React. Give exactly one of `sessionId`, `getSession` or an inline draft.
|
|
30
|
+
*/
|
|
31
|
+
getSession?: GetOneClickSession;
|
|
23
32
|
/**
|
|
24
33
|
* @deprecated Ignored, as in React: the backend picks the customer's most
|
|
25
34
|
* recent vaulted method. Accepted only so existing integrations keep working.
|
|
@@ -74,6 +83,10 @@ export declare const FloPayAutomaticPaymentButton: import("vue").DefineComponent
|
|
|
74
83
|
type: PropType<InlineSessionDraft>;
|
|
75
84
|
default: undefined;
|
|
76
85
|
};
|
|
86
|
+
getSession: {
|
|
87
|
+
type: PropType<GetOneClickSession>;
|
|
88
|
+
default: undefined;
|
|
89
|
+
};
|
|
77
90
|
paymentMethodId: {
|
|
78
91
|
type: StringConstructor;
|
|
79
92
|
default: undefined;
|
|
@@ -169,6 +182,10 @@ export declare const FloPayAutomaticPaymentButton: import("vue").DefineComponent
|
|
|
169
182
|
type: PropType<InlineSessionDraft>;
|
|
170
183
|
default: undefined;
|
|
171
184
|
};
|
|
185
|
+
getSession: {
|
|
186
|
+
type: PropType<GetOneClickSession>;
|
|
187
|
+
default: undefined;
|
|
188
|
+
};
|
|
172
189
|
paymentMethodId: {
|
|
173
190
|
type: StringConstructor;
|
|
174
191
|
default: undefined;
|
|
@@ -253,6 +270,7 @@ export declare const FloPayAutomaticPaymentButton: import("vue").DefineComponent
|
|
|
253
270
|
sessionId: string;
|
|
254
271
|
nonce: string;
|
|
255
272
|
createSession: InlineSessionDraft;
|
|
273
|
+
getSession: GetOneClickSession;
|
|
256
274
|
paymentMethodId: string;
|
|
257
275
|
checkoutMethod: CheckoutButtonMethod;
|
|
258
276
|
clientId: string;
|
|
@@ -275,3 +293,4 @@ export declare const FloPayAutomaticPaymentButton: import("vue").DefineComponent
|
|
|
275
293
|
buttonsTheme: ButtonsLayoutTheme;
|
|
276
294
|
buttonsStyles: ButtonsLayoutStyles;
|
|
277
295
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
296
|
+
export {};
|
|
@@ -32,6 +32,7 @@ var CHECKOUT_FORM_DEFAULTS = /* @__PURE__ */ Symbol(
|
|
|
32
32
|
import {
|
|
33
33
|
FLO_INSTRUMENT_ONCE_NAMES,
|
|
34
34
|
invokeMerchantCallback,
|
|
35
|
+
isCardFieldsInstrumentSource,
|
|
35
36
|
projectFloInstrument,
|
|
36
37
|
resolveBillingApiUrl
|
|
37
38
|
} from "@flopay/shared";
|
|
@@ -87,6 +88,9 @@ var FloPayProvider = defineComponent({
|
|
|
87
88
|
if (!listener) return emit("instrument", event);
|
|
88
89
|
for (const handler of [listener].flat()) handler(event);
|
|
89
90
|
});
|
|
91
|
+
const emitTelemetryInstrument = (source) => {
|
|
92
|
+
if (!isCardFieldsInstrumentSource(source)) emitInstrument(source);
|
|
93
|
+
};
|
|
90
94
|
provide(FLOPAY_CONTEXT, {
|
|
91
95
|
flopay,
|
|
92
96
|
paypalFlopay,
|
|
@@ -130,7 +134,7 @@ var FloPayProvider = defineComponent({
|
|
|
130
134
|
(instance, _previous, onCleanup) => {
|
|
131
135
|
if (!instance) return;
|
|
132
136
|
emitInstrument({ class: "lifecycle", name: "sdk.initialize.ready" });
|
|
133
|
-
const unsubscribe = telemetryBridge(instance)?.subscribe?.(
|
|
137
|
+
const unsubscribe = telemetryBridge(instance)?.subscribe?.(emitTelemetryInstrument);
|
|
134
138
|
onCleanup(() => unsubscribe?.());
|
|
135
139
|
void nextTick(() => emitInstrument({ class: "lifecycle", name: "checkout.rendered" }));
|
|
136
140
|
},
|
|
@@ -138,7 +142,7 @@ var FloPayProvider = defineComponent({
|
|
|
138
142
|
);
|
|
139
143
|
watch(paypalFlopay, (instance, _previous, onCleanup) => {
|
|
140
144
|
if (!instance || instance === flopay.value) return;
|
|
141
|
-
const unsubscribe = telemetryBridge(instance)?.subscribe?.(
|
|
145
|
+
const unsubscribe = telemetryBridge(instance)?.subscribe?.(emitTelemetryInstrument);
|
|
142
146
|
onCleanup(() => unsubscribe?.());
|
|
143
147
|
});
|
|
144
148
|
});
|
|
@@ -38,7 +38,7 @@ function delay(ms) {
|
|
|
38
38
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
39
39
|
}
|
|
40
40
|
var StripeSetupMethods = defineAsyncComponent(
|
|
41
|
-
() => import("./stripe-elements-
|
|
41
|
+
() => import("./stripe-elements-SI2PI6EO.mjs").then((module) => module.StripePaymentMethods)
|
|
42
42
|
);
|
|
43
43
|
var PayPalSetupMethods = defineAsyncComponent(
|
|
44
44
|
() => import("./payment-method-setup-paypal-D6FEQQJY.mjs").then((module) => module.PayPalSetupMethod)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AVSFieldConfig, ButtonsLayoutStyles, ButtonsLayoutTheme, CheckoutButtonMethod, CheckoutMode, DeclineEvent, FloInstrumentEvent, FloPayAppearance, FloPayPaymentCancelEvent, InlineSessionDraft, PaymentResult, ThemeId, VaultCardFieldKey, WalletPresentation } from '@flopay/shared';
|
|
1
|
+
import type { AVSFieldConfig, ButtonsLayoutStyles, ButtonsLayoutTheme, CardFieldsFailedEvent, CardFieldsReadyEvent, CheckoutButtonMethod, CheckoutMode, DeclineEvent, FloInstrumentEvent, FloPayAppearance, FloPayPaymentCancelEvent, InlineSessionDraft, PaymentResult, ThemeId, VaultCardFieldKey, WalletPresentation } from '@flopay/shared';
|
|
2
2
|
import { FloPayError } from '@flopay/shared';
|
|
3
3
|
import { type PropType } from 'vue';
|
|
4
4
|
import { type SplitCardFormBeforeButtonClick } from './split-card-form.js';
|
|
@@ -53,6 +53,8 @@ export interface FloPayCheckoutProps {
|
|
|
53
53
|
* checkout opens. Omitted or `true` keeps the default. See React.
|
|
54
54
|
*/
|
|
55
55
|
cardAutoFocus?: boolean;
|
|
56
|
+
/** Milliseconds the card fields may take to become ready before `timeout` (default 15 000). */
|
|
57
|
+
cardFieldsTimeoutMs?: number;
|
|
56
58
|
/**
|
|
57
59
|
* @deprecated Not rendered, as in React: the default-layout security footer
|
|
58
60
|
* was removed. Accepted so integrations ported from React keep compiling.
|
|
@@ -216,6 +218,10 @@ export declare const FloPayCheckout: import("vue").DefineComponent<import("vue")
|
|
|
216
218
|
type: BooleanConstructor;
|
|
217
219
|
default: boolean;
|
|
218
220
|
};
|
|
221
|
+
cardFieldsTimeoutMs: {
|
|
222
|
+
type: NumberConstructor;
|
|
223
|
+
default: undefined;
|
|
224
|
+
};
|
|
219
225
|
/** @deprecated Not rendered (React parity); see {@link FloPayCheckoutProps.showSecurityFooter}. */
|
|
220
226
|
showSecurityFooter: {
|
|
221
227
|
type: BooleanConstructor;
|
|
@@ -260,6 +266,8 @@ export declare const FloPayCheckout: import("vue").DefineComponent<import("vue")
|
|
|
260
266
|
error: (_error: FloPayError) => true;
|
|
261
267
|
instrument: (_event: FloInstrumentEvent) => true;
|
|
262
268
|
decline: (_decline: DeclineEvent) => true;
|
|
269
|
+
cardFieldsReady: (_event: CardFieldsReadyEvent) => true;
|
|
270
|
+
cardFieldsFailed: (_event: CardFieldsFailedEvent) => true;
|
|
263
271
|
cancel: (_event: FloPayPaymentCancelEvent) => true;
|
|
264
272
|
buttonClick: (_method: CheckoutButtonMethod) => true;
|
|
265
273
|
countryChange: (_country: string) => true;
|
|
@@ -369,6 +377,10 @@ export declare const FloPayCheckout: import("vue").DefineComponent<import("vue")
|
|
|
369
377
|
type: BooleanConstructor;
|
|
370
378
|
default: boolean;
|
|
371
379
|
};
|
|
380
|
+
cardFieldsTimeoutMs: {
|
|
381
|
+
type: NumberConstructor;
|
|
382
|
+
default: undefined;
|
|
383
|
+
};
|
|
372
384
|
/** @deprecated Not rendered (React parity); see {@link FloPayCheckoutProps.showSecurityFooter}. */
|
|
373
385
|
showSecurityFooter: {
|
|
374
386
|
type: BooleanConstructor;
|
|
@@ -407,6 +419,8 @@ export declare const FloPayCheckout: import("vue").DefineComponent<import("vue")
|
|
|
407
419
|
}>> & Readonly<{
|
|
408
420
|
onButtonClick?: ((_method: CheckoutButtonMethod) => any) | undefined;
|
|
409
421
|
onCancel?: ((_event: FloPayPaymentCancelEvent) => any) | undefined;
|
|
422
|
+
onCardFieldsFailed?: ((_event: CardFieldsFailedEvent) => any) | undefined;
|
|
423
|
+
onCardFieldsReady?: ((_event: CardFieldsReadyEvent) => any) | undefined;
|
|
410
424
|
onComplete?: ((_result: PaymentResult) => any) | undefined;
|
|
411
425
|
onCountryChange?: ((_country: string) => any) | undefined;
|
|
412
426
|
onDecline?: ((_decline: DeclineEvent) => any) | undefined;
|
|
@@ -439,6 +453,7 @@ export declare const FloPayCheckout: import("vue").DefineComponent<import("vue")
|
|
|
439
453
|
avsLayout: "column" | "row";
|
|
440
454
|
cardFieldOrder: VaultCardFieldKey[];
|
|
441
455
|
cardAutoFocus: boolean;
|
|
456
|
+
cardFieldsTimeoutMs: number;
|
|
442
457
|
showSecurityFooter: boolean;
|
|
443
458
|
fallbackPublishableKey: string;
|
|
444
459
|
confirmLabel: string;
|
package/dist/index.cjs
CHANGED
|
@@ -99,6 +99,9 @@ var init_provider = __esm({
|
|
|
99
99
|
if (!listener) return emit("instrument", event);
|
|
100
100
|
for (const handler of [listener].flat()) handler(event);
|
|
101
101
|
});
|
|
102
|
+
const emitTelemetryInstrument = (source) => {
|
|
103
|
+
if (!(0, import_shared.isCardFieldsInstrumentSource)(source)) emitInstrument(source);
|
|
104
|
+
};
|
|
102
105
|
(0, import_vue.provide)(FLOPAY_CONTEXT, {
|
|
103
106
|
flopay,
|
|
104
107
|
paypalFlopay,
|
|
@@ -142,7 +145,7 @@ var init_provider = __esm({
|
|
|
142
145
|
(instance, _previous, onCleanup) => {
|
|
143
146
|
if (!instance) return;
|
|
144
147
|
emitInstrument({ class: "lifecycle", name: "sdk.initialize.ready" });
|
|
145
|
-
const unsubscribe = telemetryBridge(instance)?.subscribe?.(
|
|
148
|
+
const unsubscribe = telemetryBridge(instance)?.subscribe?.(emitTelemetryInstrument);
|
|
146
149
|
onCleanup(() => unsubscribe?.());
|
|
147
150
|
void (0, import_vue.nextTick)(() => emitInstrument({ class: "lifecycle", name: "checkout.rendered" }));
|
|
148
151
|
},
|
|
@@ -150,7 +153,7 @@ var init_provider = __esm({
|
|
|
150
153
|
);
|
|
151
154
|
(0, import_vue.watch)(paypalFlopay, (instance, _previous, onCleanup) => {
|
|
152
155
|
if (!instance || instance === flopay.value) return;
|
|
153
|
-
const unsubscribe = telemetryBridge(instance)?.subscribe?.(
|
|
156
|
+
const unsubscribe = telemetryBridge(instance)?.subscribe?.(emitTelemetryInstrument);
|
|
154
157
|
onCleanup(() => unsubscribe?.());
|
|
155
158
|
});
|
|
156
159
|
});
|
|
@@ -2302,6 +2305,8 @@ var SplitCardForm = (0, import_vue6.defineComponent)({
|
|
|
2302
2305
|
className: { type: String, default: void 0 },
|
|
2303
2306
|
cardFieldOrder: { type: Array, default: void 0 },
|
|
2304
2307
|
cardAutoFocus: { type: Boolean, default: true },
|
|
2308
|
+
/** Milliseconds the card fields may take to become ready before `timeout` (default 15 000). */
|
|
2309
|
+
cardFieldsTimeoutMs: { type: Number, default: void 0 },
|
|
2305
2310
|
onBeforeButtonClick: {
|
|
2306
2311
|
type: Function,
|
|
2307
2312
|
default: void 0
|
|
@@ -2348,7 +2353,11 @@ var SplitCardForm = (0, import_vue6.defineComponent)({
|
|
|
2348
2353
|
// React's `onZipChange`.
|
|
2349
2354
|
zipChange: (_zip) => true,
|
|
2350
2355
|
// React's `onErrorChange`: the form's own error message changed (`null` when cleared).
|
|
2351
|
-
errorChange: (_error) => true
|
|
2356
|
+
errorChange: (_error) => true,
|
|
2357
|
+
// React's `onCardFieldsReady`: the hosted card fields are interactive, once per card form.
|
|
2358
|
+
cardFieldsReady: (_event) => true,
|
|
2359
|
+
// React's `onCardFieldsFailed`: the card fields failed to load or timed out; not a decline.
|
|
2360
|
+
cardFieldsFailed: (_event) => true
|
|
2352
2361
|
},
|
|
2353
2362
|
/**
|
|
2354
2363
|
* Slots (React's content props):
|
|
@@ -2948,13 +2957,31 @@ var SplitCardForm = (0, import_vue6.defineComponent)({
|
|
|
2948
2957
|
if (!vault.value || !id) return;
|
|
2949
2958
|
const captureMethod = session.value?.captureMethod;
|
|
2950
2959
|
const flopay = provider?.flopay.value;
|
|
2951
|
-
const
|
|
2960
|
+
const cardFieldsTimeoutMs = props.cardFieldsTimeoutMs;
|
|
2961
|
+
const adapter = flopay ? flopay.cardCapture({
|
|
2962
|
+
sessionId: id,
|
|
2963
|
+
...captureMethod ? { captureMethod } : {},
|
|
2964
|
+
cardFieldsTimeoutMs
|
|
2965
|
+
}) : new import_card_setup3.PciVaultCardCapture({
|
|
2952
2966
|
sessionId: id,
|
|
2953
2967
|
...captureMethod ? { captureMethod } : {},
|
|
2954
2968
|
billingApiUrl: billingApiUrl.value,
|
|
2955
|
-
telemetry: props.telemetry
|
|
2969
|
+
telemetry: props.telemetry,
|
|
2970
|
+
cardFieldsTimeoutMs
|
|
2956
2971
|
});
|
|
2957
|
-
|
|
2972
|
+
const detachAdapterOutcomes = bindOutcomes(adapter);
|
|
2973
|
+
const detachCardFields = adapter.onCardFields?.((event) => {
|
|
2974
|
+
provider?.emitInstrument((0, import_shared8.cardFieldsInstrumentSource)(event));
|
|
2975
|
+
if (event.type === "card_fields_ready") {
|
|
2976
|
+
(0, import_shared8.invokeMerchantCallback)(() => emit("cardFieldsReady", event));
|
|
2977
|
+
} else {
|
|
2978
|
+
(0, import_shared8.invokeMerchantCallback)(() => emit("cardFieldsFailed", event));
|
|
2979
|
+
}
|
|
2980
|
+
});
|
|
2981
|
+
detachOutcomes = () => {
|
|
2982
|
+
detachAdapterOutcomes?.();
|
|
2983
|
+
detachCardFields?.();
|
|
2984
|
+
};
|
|
2958
2985
|
adapter.setSubmitGate?.(gateClosed.value);
|
|
2959
2986
|
capture.value = adapter;
|
|
2960
2987
|
};
|
|
@@ -3639,6 +3666,7 @@ var FloPayCheckout = (0, import_vue7.defineComponent)({
|
|
|
3639
3666
|
avsLayout: { type: String, default: void 0 },
|
|
3640
3667
|
cardFieldOrder: { type: Array, default: void 0 },
|
|
3641
3668
|
cardAutoFocus: { type: Boolean, default: true },
|
|
3669
|
+
cardFieldsTimeoutMs: { type: Number, default: void 0 },
|
|
3642
3670
|
/** @deprecated Not rendered (React parity); see {@link FloPayCheckoutProps.showSecurityFooter}. */
|
|
3643
3671
|
showSecurityFooter: { type: Boolean, default: void 0 },
|
|
3644
3672
|
/** @deprecated Ignored (React parity); see {@link FloPayCheckoutProps.fallbackPublishableKey}. */
|
|
@@ -3662,6 +3690,9 @@ var FloPayCheckout = (0, import_vue7.defineComponent)({
|
|
|
3662
3690
|
error: (_error) => true,
|
|
3663
3691
|
instrument: (_event) => true,
|
|
3664
3692
|
decline: (_decline) => true,
|
|
3693
|
+
// React's `onCardFieldsReady` / `onCardFieldsFailed`: the hosted card-field lifecycle.
|
|
3694
|
+
cardFieldsReady: (_event) => true,
|
|
3695
|
+
cardFieldsFailed: (_event) => true,
|
|
3665
3696
|
// React's `onCancel`: a direct PayPal buyer cancel from the built-in form.
|
|
3666
3697
|
cancel: (_event) => true,
|
|
3667
3698
|
buttonClick: (_method) => true,
|
|
@@ -3904,7 +3935,9 @@ var FloPayCheckout = (0, import_vue7.defineComponent)({
|
|
|
3904
3935
|
onButtonClick: (method) => {
|
|
3905
3936
|
clearModeError();
|
|
3906
3937
|
(0, import_shared9.invokeMerchantCallback)(() => emit("buttonClick", method));
|
|
3907
|
-
}
|
|
3938
|
+
},
|
|
3939
|
+
onCardFieldsReady: (event) => (0, import_shared9.invokeMerchantCallback)(() => emit("cardFieldsReady", event)),
|
|
3940
|
+
onCardFieldsFailed: (event) => (0, import_shared9.invokeMerchantCallback)(() => emit("cardFieldsFailed", event))
|
|
3908
3941
|
};
|
|
3909
3942
|
const withProvider = (content) => (0, import_vue7.h)(
|
|
3910
3943
|
FloPayProvider,
|
|
@@ -4041,6 +4074,7 @@ var FloPayCheckout = (0, import_vue7.defineComponent)({
|
|
|
4041
4074
|
avsLayout: props.avsLayout,
|
|
4042
4075
|
cardFieldOrder: props.cardFieldOrder,
|
|
4043
4076
|
cardAutoFocus: props.cardAutoFocus,
|
|
4077
|
+
cardFieldsTimeoutMs: props.cardFieldsTimeoutMs,
|
|
4044
4078
|
session,
|
|
4045
4079
|
dataAttachmentPending: Boolean(state.claimPending),
|
|
4046
4080
|
dataAttachmentRequiresIdentity: Boolean(state.claimRequiresIdentity),
|
|
@@ -4081,6 +4115,37 @@ var FloPayCheckout = (0, import_vue7.defineComponent)({
|
|
|
4081
4115
|
|
|
4082
4116
|
// src/automatic-payment-button.ts
|
|
4083
4117
|
var SUCCESS_DELAY_MS2 = SAVED_PAYMENT_SUCCESS_DELAY_MS;
|
|
4118
|
+
var GET_SESSION_TIMEOUT_MS = 15e3;
|
|
4119
|
+
function sessionFetchFailed(message, cause) {
|
|
4120
|
+
return new import_shared10.FloPayError(message, "api_error", {
|
|
4121
|
+
code: "session_fetch_failed",
|
|
4122
|
+
...cause === void 0 ? {} : { cause }
|
|
4123
|
+
});
|
|
4124
|
+
}
|
|
4125
|
+
function settleUnlessAborted(promise, signal) {
|
|
4126
|
+
return new Promise((resolve, reject) => {
|
|
4127
|
+
const onAbort = () => reject(signal.reason);
|
|
4128
|
+
if (signal.aborted) {
|
|
4129
|
+
onAbort();
|
|
4130
|
+
return;
|
|
4131
|
+
}
|
|
4132
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
4133
|
+
promise.then(
|
|
4134
|
+
(value) => {
|
|
4135
|
+
signal.removeEventListener("abort", onAbort);
|
|
4136
|
+
resolve(value);
|
|
4137
|
+
},
|
|
4138
|
+
(error) => {
|
|
4139
|
+
signal.removeEventListener("abort", onAbort);
|
|
4140
|
+
reject(error);
|
|
4141
|
+
}
|
|
4142
|
+
);
|
|
4143
|
+
});
|
|
4144
|
+
}
|
|
4145
|
+
function isOneClickSession(value) {
|
|
4146
|
+
const session = value;
|
|
4147
|
+
return typeof session?.sessionId === "string" && session.sessionId.length > 0 && typeof session.nonce === "string" && session.nonce.length > 0;
|
|
4148
|
+
}
|
|
4084
4149
|
function resolveDraft(props) {
|
|
4085
4150
|
if (props.createSession) return { ...props.createSession, checkoutMode: "auto" };
|
|
4086
4151
|
if (!props.clientId || !props.account || !props.successUrl || !props.cancelUrl) return null;
|
|
@@ -4112,6 +4177,7 @@ var FloPayAutomaticPaymentButton = (0, import_vue8.defineComponent)({
|
|
|
4112
4177
|
sessionId: { type: String, default: void 0 },
|
|
4113
4178
|
nonce: { type: String, default: void 0 },
|
|
4114
4179
|
createSession: { type: Object, default: void 0 },
|
|
4180
|
+
getSession: { type: Function, default: void 0 },
|
|
4115
4181
|
// Deprecated and ignored, as in React (see the props interface).
|
|
4116
4182
|
paymentMethodId: { type: String, default: void 0 },
|
|
4117
4183
|
checkoutMethod: { type: String, default: void 0 },
|
|
@@ -4147,9 +4213,11 @@ var FloPayAutomaticPaymentButton = (0, import_vue8.defineComponent)({
|
|
|
4147
4213
|
const fallback = (0, import_vue8.ref)(null);
|
|
4148
4214
|
let mounted = true;
|
|
4149
4215
|
const lifecycle = new AbortController();
|
|
4216
|
+
let sessionFetch = null;
|
|
4150
4217
|
(0, import_vue8.onBeforeUnmount)(() => {
|
|
4151
4218
|
mounted = false;
|
|
4152
4219
|
lifecycle.abort();
|
|
4220
|
+
sessionFetch?.abort();
|
|
4153
4221
|
});
|
|
4154
4222
|
const billingApiUrl = () => (0, import_shared10.resolveBillingApiUrl)(props.billingApiUrl);
|
|
4155
4223
|
const themeBundle = (0, import_vue8.computed)(() => (0, import_shared10.resolveTheme)(props.theme));
|
|
@@ -4217,15 +4285,50 @@ var FloPayAutomaticPaymentButton = (0, import_vue8.defineComponent)({
|
|
|
4217
4285
|
fallback.value = { sessionId, ...nonce ? { nonce } : {} };
|
|
4218
4286
|
}
|
|
4219
4287
|
};
|
|
4288
|
+
const fetchOneClickSession = async (getSession) => {
|
|
4289
|
+
const controller = new AbortController();
|
|
4290
|
+
sessionFetch = controller;
|
|
4291
|
+
let timedOut = false;
|
|
4292
|
+
const timer = setTimeout(() => {
|
|
4293
|
+
timedOut = true;
|
|
4294
|
+
controller.abort();
|
|
4295
|
+
}, GET_SESSION_TIMEOUT_MS);
|
|
4296
|
+
try {
|
|
4297
|
+
const fetched = await settleUnlessAborted(
|
|
4298
|
+
(async () => getSession({ signal: controller.signal }))(),
|
|
4299
|
+
controller.signal
|
|
4300
|
+
);
|
|
4301
|
+
if (!mounted) return null;
|
|
4302
|
+
if (!isOneClickSession(fetched)) {
|
|
4303
|
+
throw sessionFetchFailed(
|
|
4304
|
+
"getSession must resolve to a server-minted { sessionId, nonce }."
|
|
4305
|
+
);
|
|
4306
|
+
}
|
|
4307
|
+
return { sessionId: fetched.sessionId, nonce: fetched.nonce };
|
|
4308
|
+
} catch (error) {
|
|
4309
|
+
if (!mounted) return null;
|
|
4310
|
+
if (error instanceof import_shared10.FloPayError && error.code === "session_fetch_failed") throw error;
|
|
4311
|
+
if (timedOut) {
|
|
4312
|
+
throw sessionFetchFailed(
|
|
4313
|
+
`getSession did not resolve within ${GET_SESSION_TIMEOUT_MS / 1e3} seconds.`
|
|
4314
|
+
);
|
|
4315
|
+
}
|
|
4316
|
+
throw sessionFetchFailed("Could not fetch the one-click session.", error);
|
|
4317
|
+
} finally {
|
|
4318
|
+
clearTimeout(timer);
|
|
4319
|
+
if (sessionFetch === controller) sessionFetch = null;
|
|
4320
|
+
}
|
|
4321
|
+
};
|
|
4220
4322
|
const run = async () => {
|
|
4221
4323
|
if (processing.value || props.disabled) return;
|
|
4222
4324
|
fallback.value = null;
|
|
4223
4325
|
notice.value = null;
|
|
4224
4326
|
const draft = resolveDraft(props);
|
|
4225
|
-
|
|
4327
|
+
const sourceCount = [props.sessionId, props.getSession, draft].filter(Boolean).length;
|
|
4328
|
+
if (sourceCount !== 1) {
|
|
4226
4329
|
fail(
|
|
4227
4330
|
new import_shared10.FloPayError(
|
|
4228
|
-
|
|
4331
|
+
sourceCount > 1 ? "Provide exactly one of sessionId, getSession or create-session props." : "Provide a sessionId or the props required to create an automatic payment session.",
|
|
4229
4332
|
"validation_error"
|
|
4230
4333
|
),
|
|
4231
4334
|
null
|
|
@@ -4240,6 +4343,12 @@ var FloPayAutomaticPaymentButton = (0, import_vue8.defineComponent)({
|
|
|
4240
4343
|
let result;
|
|
4241
4344
|
if (props.sessionId) {
|
|
4242
4345
|
result = await api.getUnifiedCheckoutSession(props.sessionId, props.nonce);
|
|
4346
|
+
} else if (props.getSession) {
|
|
4347
|
+
const fetched = await fetchOneClickSession(props.getSession);
|
|
4348
|
+
if (!fetched) return;
|
|
4349
|
+
sessionId = fetched.sessionId;
|
|
4350
|
+
nonce = fetched.nonce;
|
|
4351
|
+
result = await api.getUnifiedCheckoutSession(fetched.sessionId, fetched.nonce);
|
|
4243
4352
|
} else {
|
|
4244
4353
|
try {
|
|
4245
4354
|
result = await api.createAndFetchSession(draft);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { BeforeButtonClickEvent, CheckoutButtonMethod, DeclineEvent, FloInstrumentEvent, FloPayPaymentCancelEvent, InlineSessionDraft, InlineSessionPatch, PaymentMethodCountryRule, PaymentMethodGroup, PaymentMethodLayoutRules, SentryEventLike, SentryStackFrameLike, WalletPresentation, } from '@flopay/shared';
|
|
1
|
+
export type { BeforeButtonClickEvent, CardFieldsEvent, CardFieldsFailedEvent, CardFieldsFailureReason, CardFieldsReadyEvent, CheckoutButtonMethod, DeclineEvent, FloInstrumentEvent, FloPayPaymentCancelEvent, InlineSessionDraft, InlineSessionPatch, PaymentMethodCountryRule, PaymentMethodGroup, PaymentMethodLayoutRules, SentryEventLike, SentryStackFrameLike, WalletPresentation, } from '@flopay/shared';
|
|
2
2
|
export { dropThirdPartyOnlyError } from '@flopay/shared';
|
|
3
3
|
export type { FloPayAutomaticPaymentButtonProps, FloPayAutomaticPaymentSuccessEvent, } from './automatic-payment-button.js';
|
|
4
4
|
export { FloPayAutomaticPaymentButton } from './automatic-payment-button.js';
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-5N47KHFQ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
FloPayPaymentMethodSetup
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-XLVMVLVL.mjs";
|
|
7
7
|
import {
|
|
8
8
|
FloPayCardSetupError,
|
|
9
9
|
VaultCardFields
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
FloPayProvider,
|
|
16
16
|
StripePaymentMethods,
|
|
17
17
|
hasStripePayPalReturn
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-RAGPQWRA.mjs";
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
import { dropThirdPartyOnlyError } from "@flopay/shared";
|
|
@@ -223,6 +223,7 @@ import {
|
|
|
223
223
|
CHECKOUT_SESSION_BUYER_EMAIL_REQUIRED,
|
|
224
224
|
COUNTRY_OPTIONS,
|
|
225
225
|
canRecoverHostedCardForm,
|
|
226
|
+
cardFieldsInstrumentSource,
|
|
226
227
|
computeVaultCardThemeColors,
|
|
227
228
|
derivePrimaryTileStyle,
|
|
228
229
|
detectPayPalEnvironment as detectPayPalEnvironment2,
|
|
@@ -1204,6 +1205,8 @@ var SplitCardForm = defineComponent3({
|
|
|
1204
1205
|
className: { type: String, default: void 0 },
|
|
1205
1206
|
cardFieldOrder: { type: Array, default: void 0 },
|
|
1206
1207
|
cardAutoFocus: { type: Boolean, default: true },
|
|
1208
|
+
/** Milliseconds the card fields may take to become ready before `timeout` (default 15 000). */
|
|
1209
|
+
cardFieldsTimeoutMs: { type: Number, default: void 0 },
|
|
1207
1210
|
onBeforeButtonClick: {
|
|
1208
1211
|
type: Function,
|
|
1209
1212
|
default: void 0
|
|
@@ -1250,7 +1253,11 @@ var SplitCardForm = defineComponent3({
|
|
|
1250
1253
|
// React's `onZipChange`.
|
|
1251
1254
|
zipChange: (_zip) => true,
|
|
1252
1255
|
// React's `onErrorChange`: the form's own error message changed (`null` when cleared).
|
|
1253
|
-
errorChange: (_error) => true
|
|
1256
|
+
errorChange: (_error) => true,
|
|
1257
|
+
// React's `onCardFieldsReady`: the hosted card fields are interactive, once per card form.
|
|
1258
|
+
cardFieldsReady: (_event) => true,
|
|
1259
|
+
// React's `onCardFieldsFailed`: the card fields failed to load or timed out; not a decline.
|
|
1260
|
+
cardFieldsFailed: (_event) => true
|
|
1254
1261
|
},
|
|
1255
1262
|
/**
|
|
1256
1263
|
* Slots (React's content props):
|
|
@@ -1850,13 +1857,31 @@ var SplitCardForm = defineComponent3({
|
|
|
1850
1857
|
if (!vault.value || !id) return;
|
|
1851
1858
|
const captureMethod = session.value?.captureMethod;
|
|
1852
1859
|
const flopay = provider?.flopay.value;
|
|
1853
|
-
const
|
|
1860
|
+
const cardFieldsTimeoutMs = props.cardFieldsTimeoutMs;
|
|
1861
|
+
const adapter = flopay ? flopay.cardCapture({
|
|
1862
|
+
sessionId: id,
|
|
1863
|
+
...captureMethod ? { captureMethod } : {},
|
|
1864
|
+
cardFieldsTimeoutMs
|
|
1865
|
+
}) : new PciVaultCardCapture({
|
|
1854
1866
|
sessionId: id,
|
|
1855
1867
|
...captureMethod ? { captureMethod } : {},
|
|
1856
1868
|
billingApiUrl: billingApiUrl.value,
|
|
1857
|
-
telemetry: props.telemetry
|
|
1869
|
+
telemetry: props.telemetry,
|
|
1870
|
+
cardFieldsTimeoutMs
|
|
1858
1871
|
});
|
|
1859
|
-
|
|
1872
|
+
const detachAdapterOutcomes = bindOutcomes(adapter);
|
|
1873
|
+
const detachCardFields = adapter.onCardFields?.((event) => {
|
|
1874
|
+
provider?.emitInstrument(cardFieldsInstrumentSource(event));
|
|
1875
|
+
if (event.type === "card_fields_ready") {
|
|
1876
|
+
invokeMerchantCallback2(() => emit("cardFieldsReady", event));
|
|
1877
|
+
} else {
|
|
1878
|
+
invokeMerchantCallback2(() => emit("cardFieldsFailed", event));
|
|
1879
|
+
}
|
|
1880
|
+
});
|
|
1881
|
+
detachOutcomes = () => {
|
|
1882
|
+
detachAdapterOutcomes?.();
|
|
1883
|
+
detachCardFields?.();
|
|
1884
|
+
};
|
|
1860
1885
|
adapter.setSubmitGate?.(gateClosed.value);
|
|
1861
1886
|
capture.value = adapter;
|
|
1862
1887
|
};
|
|
@@ -2541,6 +2566,7 @@ var FloPayCheckout = defineComponent4({
|
|
|
2541
2566
|
avsLayout: { type: String, default: void 0 },
|
|
2542
2567
|
cardFieldOrder: { type: Array, default: void 0 },
|
|
2543
2568
|
cardAutoFocus: { type: Boolean, default: true },
|
|
2569
|
+
cardFieldsTimeoutMs: { type: Number, default: void 0 },
|
|
2544
2570
|
/** @deprecated Not rendered (React parity); see {@link FloPayCheckoutProps.showSecurityFooter}. */
|
|
2545
2571
|
showSecurityFooter: { type: Boolean, default: void 0 },
|
|
2546
2572
|
/** @deprecated Ignored (React parity); see {@link FloPayCheckoutProps.fallbackPublishableKey}. */
|
|
@@ -2564,6 +2590,9 @@ var FloPayCheckout = defineComponent4({
|
|
|
2564
2590
|
error: (_error) => true,
|
|
2565
2591
|
instrument: (_event) => true,
|
|
2566
2592
|
decline: (_decline) => true,
|
|
2593
|
+
// React's `onCardFieldsReady` / `onCardFieldsFailed`: the hosted card-field lifecycle.
|
|
2594
|
+
cardFieldsReady: (_event) => true,
|
|
2595
|
+
cardFieldsFailed: (_event) => true,
|
|
2567
2596
|
// React's `onCancel`: a direct PayPal buyer cancel from the built-in form.
|
|
2568
2597
|
cancel: (_event) => true,
|
|
2569
2598
|
buttonClick: (_method) => true,
|
|
@@ -2806,7 +2835,9 @@ var FloPayCheckout = defineComponent4({
|
|
|
2806
2835
|
onButtonClick: (method) => {
|
|
2807
2836
|
clearModeError();
|
|
2808
2837
|
invokeMerchantCallback3(() => emit("buttonClick", method));
|
|
2809
|
-
}
|
|
2838
|
+
},
|
|
2839
|
+
onCardFieldsReady: (event) => invokeMerchantCallback3(() => emit("cardFieldsReady", event)),
|
|
2840
|
+
onCardFieldsFailed: (event) => invokeMerchantCallback3(() => emit("cardFieldsFailed", event))
|
|
2810
2841
|
};
|
|
2811
2842
|
const withProvider = (content) => h4(
|
|
2812
2843
|
FloPayProvider,
|
|
@@ -2943,6 +2974,7 @@ var FloPayCheckout = defineComponent4({
|
|
|
2943
2974
|
avsLayout: props.avsLayout,
|
|
2944
2975
|
cardFieldOrder: props.cardFieldOrder,
|
|
2945
2976
|
cardAutoFocus: props.cardAutoFocus,
|
|
2977
|
+
cardFieldsTimeoutMs: props.cardFieldsTimeoutMs,
|
|
2946
2978
|
session,
|
|
2947
2979
|
dataAttachmentPending: Boolean(state.claimPending),
|
|
2948
2980
|
dataAttachmentRequiresIdentity: Boolean(state.claimRequiresIdentity),
|
|
@@ -2983,6 +3015,37 @@ var FloPayCheckout = defineComponent4({
|
|
|
2983
3015
|
|
|
2984
3016
|
// src/automatic-payment-button.ts
|
|
2985
3017
|
var SUCCESS_DELAY_MS2 = SAVED_PAYMENT_SUCCESS_DELAY_MS;
|
|
3018
|
+
var GET_SESSION_TIMEOUT_MS = 15e3;
|
|
3019
|
+
function sessionFetchFailed(message, cause) {
|
|
3020
|
+
return new FloPayError5(message, "api_error", {
|
|
3021
|
+
code: "session_fetch_failed",
|
|
3022
|
+
...cause === void 0 ? {} : { cause }
|
|
3023
|
+
});
|
|
3024
|
+
}
|
|
3025
|
+
function settleUnlessAborted(promise, signal) {
|
|
3026
|
+
return new Promise((resolve, reject) => {
|
|
3027
|
+
const onAbort = () => reject(signal.reason);
|
|
3028
|
+
if (signal.aborted) {
|
|
3029
|
+
onAbort();
|
|
3030
|
+
return;
|
|
3031
|
+
}
|
|
3032
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
3033
|
+
promise.then(
|
|
3034
|
+
(value) => {
|
|
3035
|
+
signal.removeEventListener("abort", onAbort);
|
|
3036
|
+
resolve(value);
|
|
3037
|
+
},
|
|
3038
|
+
(error) => {
|
|
3039
|
+
signal.removeEventListener("abort", onAbort);
|
|
3040
|
+
reject(error);
|
|
3041
|
+
}
|
|
3042
|
+
);
|
|
3043
|
+
});
|
|
3044
|
+
}
|
|
3045
|
+
function isOneClickSession(value) {
|
|
3046
|
+
const session = value;
|
|
3047
|
+
return typeof session?.sessionId === "string" && session.sessionId.length > 0 && typeof session.nonce === "string" && session.nonce.length > 0;
|
|
3048
|
+
}
|
|
2986
3049
|
function resolveDraft(props) {
|
|
2987
3050
|
if (props.createSession) return { ...props.createSession, checkoutMode: "auto" };
|
|
2988
3051
|
if (!props.clientId || !props.account || !props.successUrl || !props.cancelUrl) return null;
|
|
@@ -3014,6 +3077,7 @@ var FloPayAutomaticPaymentButton = defineComponent5({
|
|
|
3014
3077
|
sessionId: { type: String, default: void 0 },
|
|
3015
3078
|
nonce: { type: String, default: void 0 },
|
|
3016
3079
|
createSession: { type: Object, default: void 0 },
|
|
3080
|
+
getSession: { type: Function, default: void 0 },
|
|
3017
3081
|
// Deprecated and ignored, as in React (see the props interface).
|
|
3018
3082
|
paymentMethodId: { type: String, default: void 0 },
|
|
3019
3083
|
checkoutMethod: { type: String, default: void 0 },
|
|
@@ -3049,9 +3113,11 @@ var FloPayAutomaticPaymentButton = defineComponent5({
|
|
|
3049
3113
|
const fallback = ref5(null);
|
|
3050
3114
|
let mounted = true;
|
|
3051
3115
|
const lifecycle = new AbortController();
|
|
3116
|
+
let sessionFetch = null;
|
|
3052
3117
|
onBeforeUnmount5(() => {
|
|
3053
3118
|
mounted = false;
|
|
3054
3119
|
lifecycle.abort();
|
|
3120
|
+
sessionFetch?.abort();
|
|
3055
3121
|
});
|
|
3056
3122
|
const billingApiUrl = () => resolveBillingApiUrl4(props.billingApiUrl);
|
|
3057
3123
|
const themeBundle = computed3(() => resolveTheme3(props.theme));
|
|
@@ -3119,15 +3185,50 @@ var FloPayAutomaticPaymentButton = defineComponent5({
|
|
|
3119
3185
|
fallback.value = { sessionId, ...nonce ? { nonce } : {} };
|
|
3120
3186
|
}
|
|
3121
3187
|
};
|
|
3188
|
+
const fetchOneClickSession = async (getSession) => {
|
|
3189
|
+
const controller = new AbortController();
|
|
3190
|
+
sessionFetch = controller;
|
|
3191
|
+
let timedOut = false;
|
|
3192
|
+
const timer = setTimeout(() => {
|
|
3193
|
+
timedOut = true;
|
|
3194
|
+
controller.abort();
|
|
3195
|
+
}, GET_SESSION_TIMEOUT_MS);
|
|
3196
|
+
try {
|
|
3197
|
+
const fetched = await settleUnlessAborted(
|
|
3198
|
+
(async () => getSession({ signal: controller.signal }))(),
|
|
3199
|
+
controller.signal
|
|
3200
|
+
);
|
|
3201
|
+
if (!mounted) return null;
|
|
3202
|
+
if (!isOneClickSession(fetched)) {
|
|
3203
|
+
throw sessionFetchFailed(
|
|
3204
|
+
"getSession must resolve to a server-minted { sessionId, nonce }."
|
|
3205
|
+
);
|
|
3206
|
+
}
|
|
3207
|
+
return { sessionId: fetched.sessionId, nonce: fetched.nonce };
|
|
3208
|
+
} catch (error) {
|
|
3209
|
+
if (!mounted) return null;
|
|
3210
|
+
if (error instanceof FloPayError5 && error.code === "session_fetch_failed") throw error;
|
|
3211
|
+
if (timedOut) {
|
|
3212
|
+
throw sessionFetchFailed(
|
|
3213
|
+
`getSession did not resolve within ${GET_SESSION_TIMEOUT_MS / 1e3} seconds.`
|
|
3214
|
+
);
|
|
3215
|
+
}
|
|
3216
|
+
throw sessionFetchFailed("Could not fetch the one-click session.", error);
|
|
3217
|
+
} finally {
|
|
3218
|
+
clearTimeout(timer);
|
|
3219
|
+
if (sessionFetch === controller) sessionFetch = null;
|
|
3220
|
+
}
|
|
3221
|
+
};
|
|
3122
3222
|
const run = async () => {
|
|
3123
3223
|
if (processing.value || props.disabled) return;
|
|
3124
3224
|
fallback.value = null;
|
|
3125
3225
|
notice.value = null;
|
|
3126
3226
|
const draft = resolveDraft(props);
|
|
3127
|
-
|
|
3227
|
+
const sourceCount = [props.sessionId, props.getSession, draft].filter(Boolean).length;
|
|
3228
|
+
if (sourceCount !== 1) {
|
|
3128
3229
|
fail(
|
|
3129
3230
|
new FloPayError5(
|
|
3130
|
-
|
|
3231
|
+
sourceCount > 1 ? "Provide exactly one of sessionId, getSession or create-session props." : "Provide a sessionId or the props required to create an automatic payment session.",
|
|
3131
3232
|
"validation_error"
|
|
3132
3233
|
),
|
|
3133
3234
|
null
|
|
@@ -3142,6 +3243,12 @@ var FloPayAutomaticPaymentButton = defineComponent5({
|
|
|
3142
3243
|
let result;
|
|
3143
3244
|
if (props.sessionId) {
|
|
3144
3245
|
result = await api.getUnifiedCheckoutSession(props.sessionId, props.nonce);
|
|
3246
|
+
} else if (props.getSession) {
|
|
3247
|
+
const fetched = await fetchOneClickSession(props.getSession);
|
|
3248
|
+
if (!fetched) return;
|
|
3249
|
+
sessionId = fetched.sessionId;
|
|
3250
|
+
nonce = fetched.nonce;
|
|
3251
|
+
result = await api.getUnifiedCheckoutSession(fetched.sessionId, fetched.nonce);
|
|
3145
3252
|
} else {
|
|
3146
3253
|
try {
|
|
3147
3254
|
result = await api.createAndFetchSession(draft);
|
|
@@ -95,6 +95,9 @@ var init_provider = __esm({
|
|
|
95
95
|
if (!listener) return emit("instrument", event);
|
|
96
96
|
for (const handler of [listener].flat()) handler(event);
|
|
97
97
|
});
|
|
98
|
+
const emitTelemetryInstrument = (source) => {
|
|
99
|
+
if (!(0, import_shared3.isCardFieldsInstrumentSource)(source)) emitInstrument(source);
|
|
100
|
+
};
|
|
98
101
|
(0, import_vue4.provide)(FLOPAY_CONTEXT, {
|
|
99
102
|
flopay,
|
|
100
103
|
paypalFlopay,
|
|
@@ -138,7 +141,7 @@ var init_provider = __esm({
|
|
|
138
141
|
(instance, _previous, onCleanup) => {
|
|
139
142
|
if (!instance) return;
|
|
140
143
|
emitInstrument({ class: "lifecycle", name: "sdk.initialize.ready" });
|
|
141
|
-
const unsubscribe = telemetryBridge(instance)?.subscribe?.(
|
|
144
|
+
const unsubscribe = telemetryBridge(instance)?.subscribe?.(emitTelemetryInstrument);
|
|
142
145
|
onCleanup(() => unsubscribe?.());
|
|
143
146
|
void (0, import_vue4.nextTick)(() => emitInstrument({ class: "lifecycle", name: "checkout.rendered" }));
|
|
144
147
|
},
|
|
@@ -146,7 +149,7 @@ var init_provider = __esm({
|
|
|
146
149
|
);
|
|
147
150
|
(0, import_vue4.watch)(paypalFlopay, (instance, _previous, onCleanup) => {
|
|
148
151
|
if (!instance || instance === flopay.value) return;
|
|
149
|
-
const unsubscribe = telemetryBridge(instance)?.subscribe?.(
|
|
152
|
+
const unsubscribe = telemetryBridge(instance)?.subscribe?.(emitTelemetryInstrument);
|
|
150
153
|
onCleanup(() => unsubscribe?.());
|
|
151
154
|
});
|
|
152
155
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AVSFieldConfig, BeforeButtonClickEvent, ButtonsLayoutStyles, ButtonsLayoutTheme, CheckoutButtonMethod, CheckoutSession, DeclineEvent, FloPayAppearance, FloPayPaymentCancelEvent, InlineSessionPatch, PaymentResult, ThemeId, TokenizedBody, VaultCardFieldKey, WalletPresentation } from '@flopay/shared';
|
|
1
|
+
import type { AVSFieldConfig, BeforeButtonClickEvent, ButtonsLayoutStyles, ButtonsLayoutTheme, CardFieldsFailedEvent, CardFieldsReadyEvent, CheckoutButtonMethod, CheckoutSession, DeclineEvent, FloPayAppearance, FloPayPaymentCancelEvent, InlineSessionPatch, PaymentResult, ThemeId, TokenizedBody, VaultCardFieldKey, WalletPresentation } from '@flopay/shared';
|
|
2
2
|
import { FloPayError } from '@flopay/shared';
|
|
3
3
|
import { type PropType, type VNode } from 'vue';
|
|
4
4
|
/**
|
|
@@ -116,6 +116,8 @@ export interface SplitCardFormProps {
|
|
|
116
116
|
* the default, which never focuses the card over AVS fields above it.
|
|
117
117
|
*/
|
|
118
118
|
cardAutoFocus?: boolean;
|
|
119
|
+
/** Milliseconds the card fields may take to become ready before `timeout` (default 15 000). */
|
|
120
|
+
cardFieldsTimeoutMs?: number;
|
|
119
121
|
/**
|
|
120
122
|
* React's `onBeforeButtonClick` (a function prop: its result is read). It
|
|
121
123
|
* runs before the buttons-layout card tile opens and before PayPal creates
|
|
@@ -351,6 +353,11 @@ export declare const SplitCardForm: import("vue").DefineComponent<import("vue").
|
|
|
351
353
|
type: BooleanConstructor;
|
|
352
354
|
default: boolean;
|
|
353
355
|
};
|
|
356
|
+
/** Milliseconds the card fields may take to become ready before `timeout` (default 15 000). */
|
|
357
|
+
cardFieldsTimeoutMs: {
|
|
358
|
+
type: NumberConstructor;
|
|
359
|
+
default: undefined;
|
|
360
|
+
};
|
|
354
361
|
onBeforeButtonClick: {
|
|
355
362
|
type: PropType<SplitCardFormBeforeButtonClick>;
|
|
356
363
|
default: undefined;
|
|
@@ -429,6 +436,8 @@ export declare const SplitCardForm: import("vue").DefineComponent<import("vue").
|
|
|
429
436
|
countryChange: (_country: string) => true;
|
|
430
437
|
zipChange: (_zip: string) => true;
|
|
431
438
|
errorChange: (_error: string | null) => true;
|
|
439
|
+
cardFieldsReady: (_event: CardFieldsReadyEvent) => true;
|
|
440
|
+
cardFieldsFailed: (_event: CardFieldsFailedEvent) => true;
|
|
432
441
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
433
442
|
session: {
|
|
434
443
|
type: PropType<CheckoutSession | null>;
|
|
@@ -574,6 +583,11 @@ export declare const SplitCardForm: import("vue").DefineComponent<import("vue").
|
|
|
574
583
|
type: BooleanConstructor;
|
|
575
584
|
default: boolean;
|
|
576
585
|
};
|
|
586
|
+
/** Milliseconds the card fields may take to become ready before `timeout` (default 15 000). */
|
|
587
|
+
cardFieldsTimeoutMs: {
|
|
588
|
+
type: NumberConstructor;
|
|
589
|
+
default: undefined;
|
|
590
|
+
};
|
|
577
591
|
onBeforeButtonClick: {
|
|
578
592
|
type: PropType<SplitCardFormBeforeButtonClick>;
|
|
579
593
|
default: undefined;
|
|
@@ -644,6 +658,8 @@ export declare const SplitCardForm: import("vue").DefineComponent<import("vue").
|
|
|
644
658
|
}>> & Readonly<{
|
|
645
659
|
onButtonClick?: ((_method: CheckoutButtonMethod) => any) | undefined;
|
|
646
660
|
onCancel?: ((_event: FloPayPaymentCancelEvent) => any) | undefined;
|
|
661
|
+
onCardFieldsFailed?: ((_event: CardFieldsFailedEvent) => any) | undefined;
|
|
662
|
+
onCardFieldsReady?: ((_event: CardFieldsReadyEvent) => any) | undefined;
|
|
647
663
|
onComplete?: ((_result: PaymentResult) => any) | undefined;
|
|
648
664
|
onCountryChange?: ((_country: string) => any) | undefined;
|
|
649
665
|
onDecline?: ((_decline: DeclineEvent) => any) | undefined;
|
|
@@ -687,6 +703,7 @@ export declare const SplitCardForm: import("vue").DefineComponent<import("vue").
|
|
|
687
703
|
className: string;
|
|
688
704
|
cardFieldOrder: VaultCardFieldKey[];
|
|
689
705
|
cardAutoFocus: boolean;
|
|
706
|
+
cardFieldsTimeoutMs: number;
|
|
690
707
|
onBeforeButtonClick: SplitCardFormBeforeButtonClick;
|
|
691
708
|
onBuyerIdentityReady: SplitCardFormBuyerIdentityReady;
|
|
692
709
|
userId: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flopay/vue",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@flopay/js": "1.16.
|
|
40
|
-
"@flopay/shared": "1.16.
|
|
39
|
+
"@flopay/js": "1.16.5",
|
|
40
|
+
"@flopay/shared": "1.16.5",
|
|
41
41
|
"@paypal/paypal-js": "^11.3.0",
|
|
42
42
|
"@stripe/stripe-js": "^10.3.0"
|
|
43
43
|
},
|