@flopay/vue 1.20.8 → 1.20.10
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/flopay-runtime-card-setup.d.ts +199 -0
- package/dist/flopay-runtime-payment-method-setup.d.ts +106 -0
- package/dist/index.cjs +241 -22
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +239 -14
- package/package.json +3 -3
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type { CheckoutRuntimeSetupKind } from '@flopay/js';
|
|
2
|
+
import type { ButtonsLayoutStyles, FloPayAppearance, SavedCardDisplay, ThemeId, VaultCardThemeColors } from '@flopay/shared';
|
|
3
|
+
import { FloPayError } from '@flopay/shared';
|
|
4
|
+
import type { PropType, SetupContext } from 'vue';
|
|
5
|
+
/** Verified terminal result from a no-charge setup, as 1.x's `FloPayCardSetup` emits it. */
|
|
6
|
+
export interface FloPayRuntimeSetupCompleteEvent {
|
|
7
|
+
status: 'succeeded';
|
|
8
|
+
sessionId: string;
|
|
9
|
+
paymentMethod?: SavedCardDisplay;
|
|
10
|
+
}
|
|
11
|
+
export interface FloPayRuntimeSetupDeclineEvent {
|
|
12
|
+
status: 'declined';
|
|
13
|
+
sessionId: string;
|
|
14
|
+
reason?: string;
|
|
15
|
+
message?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface FloPayRuntimeSetupCancelEvent {
|
|
18
|
+
status: 'cancelled';
|
|
19
|
+
sessionId: string;
|
|
20
|
+
}
|
|
21
|
+
/** A structured setup failure: type, code, retryable and, where supplied, param and statusCode. */
|
|
22
|
+
export type FloPayRuntimeSetupError = FloPayError & {
|
|
23
|
+
retryable: boolean;
|
|
24
|
+
};
|
|
25
|
+
/** The props of the hosted card setup and payment method setup, the same as @flopay/react's. */
|
|
26
|
+
export interface FloPayRuntimeCardSetupProps {
|
|
27
|
+
/** A setup session the merchant's server created. */
|
|
28
|
+
sessionId: string;
|
|
29
|
+
nonce: string;
|
|
30
|
+
theme?: ThemeId | VaultCardThemeColors;
|
|
31
|
+
appearance?: FloPayAppearance;
|
|
32
|
+
buttonsStyles?: ButtonsLayoutStyles;
|
|
33
|
+
containerStyle?: Record<string, string | number>;
|
|
34
|
+
strings?: Record<string, string>;
|
|
35
|
+
/** The Flo-origin runtime script. */
|
|
36
|
+
runtimeUrl: string;
|
|
37
|
+
/** How long the runtime has to load before the `error` emit. Defaults to 10 seconds. */
|
|
38
|
+
runtimeTimeoutMs?: number;
|
|
39
|
+
}
|
|
40
|
+
/** The props both hosted setup components take. */
|
|
41
|
+
export declare const setupProps: {
|
|
42
|
+
readonly sessionId: {
|
|
43
|
+
readonly type: StringConstructor;
|
|
44
|
+
readonly required: true;
|
|
45
|
+
};
|
|
46
|
+
readonly nonce: {
|
|
47
|
+
readonly type: StringConstructor;
|
|
48
|
+
readonly required: true;
|
|
49
|
+
};
|
|
50
|
+
readonly theme: {
|
|
51
|
+
readonly type: PropType<ThemeId | VaultCardThemeColors>;
|
|
52
|
+
readonly default: undefined;
|
|
53
|
+
};
|
|
54
|
+
readonly appearance: {
|
|
55
|
+
readonly type: PropType<FloPayAppearance>;
|
|
56
|
+
readonly default: undefined;
|
|
57
|
+
};
|
|
58
|
+
readonly buttonsStyles: {
|
|
59
|
+
readonly type: PropType<ButtonsLayoutStyles>;
|
|
60
|
+
readonly default: undefined;
|
|
61
|
+
};
|
|
62
|
+
readonly containerStyle: {
|
|
63
|
+
readonly type: PropType<Record<string, string | number>>;
|
|
64
|
+
readonly default: undefined;
|
|
65
|
+
};
|
|
66
|
+
readonly strings: {
|
|
67
|
+
readonly type: PropType<Record<string, string>>;
|
|
68
|
+
readonly default: undefined;
|
|
69
|
+
};
|
|
70
|
+
readonly runtimeUrl: {
|
|
71
|
+
readonly type: StringConstructor;
|
|
72
|
+
readonly required: true;
|
|
73
|
+
};
|
|
74
|
+
readonly runtimeTimeoutMs: {
|
|
75
|
+
readonly type: NumberConstructor;
|
|
76
|
+
readonly default: undefined;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/** The 1.x setup emits both hosted setup components keep. */
|
|
80
|
+
export declare const setupEmits: {
|
|
81
|
+
ready: () => boolean;
|
|
82
|
+
validation: (_message: string | null) => boolean;
|
|
83
|
+
complete: (_event: FloPayRuntimeSetupCompleteEvent) => boolean;
|
|
84
|
+
decline: (_event: FloPayRuntimeSetupDeclineEvent) => boolean;
|
|
85
|
+
cancel: (_event: FloPayRuntimeSetupCancelEvent) => boolean;
|
|
86
|
+
error: (_error: FloPayRuntimeSetupError) => boolean;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* The setup of a hosted setup component of `kind`: it loads the Flo-hosted runtime, mounts its
|
|
90
|
+
* setup with the merchant's supplied session and unresolved theme, emits the runtime's events
|
|
91
|
+
* as 1.x's component did, updates the mounted setup in place on a theme or wording change, and
|
|
92
|
+
* replaces it for a new session. An unmount unmounts it; the runtime reports the cancellation,
|
|
93
|
+
* and a saved method it is still holding is delivered to the listener after the unmount.
|
|
94
|
+
*/
|
|
95
|
+
export declare function setupRuntimeSetup(kind: CheckoutRuntimeSetupKind, props: FloPayRuntimeCardSetupProps, emit: SetupContext<typeof setupEmits>['emit']): () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
96
|
+
[key: string]: any;
|
|
97
|
+
}>;
|
|
98
|
+
/**
|
|
99
|
+
* Card setup that runs from the Flo-hosted runtime (`setup: 'card'`). It emits what 1.x's
|
|
100
|
+
* component does: `ready`, `validation`, `complete`, `decline`, `cancel` and `error`.
|
|
101
|
+
*/
|
|
102
|
+
export declare const FloPayRuntimeCardSetup: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
103
|
+
readonly sessionId: {
|
|
104
|
+
readonly type: StringConstructor;
|
|
105
|
+
readonly required: true;
|
|
106
|
+
};
|
|
107
|
+
readonly nonce: {
|
|
108
|
+
readonly type: StringConstructor;
|
|
109
|
+
readonly required: true;
|
|
110
|
+
};
|
|
111
|
+
readonly theme: {
|
|
112
|
+
readonly type: PropType<ThemeId | VaultCardThemeColors>;
|
|
113
|
+
readonly default: undefined;
|
|
114
|
+
};
|
|
115
|
+
readonly appearance: {
|
|
116
|
+
readonly type: PropType<FloPayAppearance>;
|
|
117
|
+
readonly default: undefined;
|
|
118
|
+
};
|
|
119
|
+
readonly buttonsStyles: {
|
|
120
|
+
readonly type: PropType<ButtonsLayoutStyles>;
|
|
121
|
+
readonly default: undefined;
|
|
122
|
+
};
|
|
123
|
+
readonly containerStyle: {
|
|
124
|
+
readonly type: PropType<Record<string, string | number>>;
|
|
125
|
+
readonly default: undefined;
|
|
126
|
+
};
|
|
127
|
+
readonly strings: {
|
|
128
|
+
readonly type: PropType<Record<string, string>>;
|
|
129
|
+
readonly default: undefined;
|
|
130
|
+
};
|
|
131
|
+
readonly runtimeUrl: {
|
|
132
|
+
readonly type: StringConstructor;
|
|
133
|
+
readonly required: true;
|
|
134
|
+
};
|
|
135
|
+
readonly runtimeTimeoutMs: {
|
|
136
|
+
readonly type: NumberConstructor;
|
|
137
|
+
readonly default: undefined;
|
|
138
|
+
};
|
|
139
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
140
|
+
[key: string]: any;
|
|
141
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
142
|
+
ready: () => boolean;
|
|
143
|
+
validation: (_message: string | null) => boolean;
|
|
144
|
+
complete: (_event: FloPayRuntimeSetupCompleteEvent) => boolean;
|
|
145
|
+
decline: (_event: FloPayRuntimeSetupDeclineEvent) => boolean;
|
|
146
|
+
cancel: (_event: FloPayRuntimeSetupCancelEvent) => boolean;
|
|
147
|
+
error: (_error: FloPayRuntimeSetupError) => boolean;
|
|
148
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
149
|
+
readonly sessionId: {
|
|
150
|
+
readonly type: StringConstructor;
|
|
151
|
+
readonly required: true;
|
|
152
|
+
};
|
|
153
|
+
readonly nonce: {
|
|
154
|
+
readonly type: StringConstructor;
|
|
155
|
+
readonly required: true;
|
|
156
|
+
};
|
|
157
|
+
readonly theme: {
|
|
158
|
+
readonly type: PropType<ThemeId | VaultCardThemeColors>;
|
|
159
|
+
readonly default: undefined;
|
|
160
|
+
};
|
|
161
|
+
readonly appearance: {
|
|
162
|
+
readonly type: PropType<FloPayAppearance>;
|
|
163
|
+
readonly default: undefined;
|
|
164
|
+
};
|
|
165
|
+
readonly buttonsStyles: {
|
|
166
|
+
readonly type: PropType<ButtonsLayoutStyles>;
|
|
167
|
+
readonly default: undefined;
|
|
168
|
+
};
|
|
169
|
+
readonly containerStyle: {
|
|
170
|
+
readonly type: PropType<Record<string, string | number>>;
|
|
171
|
+
readonly default: undefined;
|
|
172
|
+
};
|
|
173
|
+
readonly strings: {
|
|
174
|
+
readonly type: PropType<Record<string, string>>;
|
|
175
|
+
readonly default: undefined;
|
|
176
|
+
};
|
|
177
|
+
readonly runtimeUrl: {
|
|
178
|
+
readonly type: StringConstructor;
|
|
179
|
+
readonly required: true;
|
|
180
|
+
};
|
|
181
|
+
readonly runtimeTimeoutMs: {
|
|
182
|
+
readonly type: NumberConstructor;
|
|
183
|
+
readonly default: undefined;
|
|
184
|
+
};
|
|
185
|
+
}>> & Readonly<{
|
|
186
|
+
onCancel?: ((_event: FloPayRuntimeSetupCancelEvent) => any) | undefined;
|
|
187
|
+
onComplete?: ((_event: FloPayRuntimeSetupCompleteEvent) => any) | undefined;
|
|
188
|
+
onDecline?: ((_event: FloPayRuntimeSetupDeclineEvent) => any) | undefined;
|
|
189
|
+
onError?: ((_error: FloPayRuntimeSetupError) => any) | undefined;
|
|
190
|
+
onReady?: (() => any) | undefined;
|
|
191
|
+
onValidation?: ((_message: string | null) => any) | undefined;
|
|
192
|
+
}>, {
|
|
193
|
+
readonly theme: VaultCardThemeColors | ThemeId;
|
|
194
|
+
readonly appearance: FloPayAppearance;
|
|
195
|
+
readonly buttonsStyles: ButtonsLayoutStyles;
|
|
196
|
+
readonly containerStyle: Record<string, string | number>;
|
|
197
|
+
readonly strings: Record<string, string>;
|
|
198
|
+
readonly runtimeTimeoutMs: number;
|
|
199
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { FloPayRuntimeCardSetupProps } from './flopay-runtime-card-setup.js';
|
|
2
|
+
export type FloPayRuntimePaymentMethodSetupProps = FloPayRuntimeCardSetupProps;
|
|
3
|
+
/**
|
|
4
|
+
* Payment method setup that runs from the Flo-hosted runtime (`setup: 'payment_method'`): the
|
|
5
|
+
* runtime offers the methods the setup session advertises and verifies each saved method with
|
|
6
|
+
* the backend. It emits what 1.x's component does: `ready`, `validation`, `complete`,
|
|
7
|
+
* `decline`, `cancel` and `error`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const FloPayRuntimePaymentMethodSetup: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
10
|
+
readonly sessionId: {
|
|
11
|
+
readonly type: StringConstructor;
|
|
12
|
+
readonly required: true;
|
|
13
|
+
};
|
|
14
|
+
readonly nonce: {
|
|
15
|
+
readonly type: StringConstructor;
|
|
16
|
+
readonly required: true;
|
|
17
|
+
};
|
|
18
|
+
readonly theme: {
|
|
19
|
+
readonly type: import("vue").PropType<import("@flopay/shared").ThemeId | import("@flopay/shared").VaultCardThemeColors>;
|
|
20
|
+
readonly default: undefined;
|
|
21
|
+
};
|
|
22
|
+
readonly appearance: {
|
|
23
|
+
readonly type: import("vue").PropType<import("@flopay/shared").FloPayAppearance>;
|
|
24
|
+
readonly default: undefined;
|
|
25
|
+
};
|
|
26
|
+
readonly buttonsStyles: {
|
|
27
|
+
readonly type: import("vue").PropType<import("@flopay/shared").ButtonsLayoutStyles>;
|
|
28
|
+
readonly default: undefined;
|
|
29
|
+
};
|
|
30
|
+
readonly containerStyle: {
|
|
31
|
+
readonly type: import("vue").PropType<Record<string, string | number>>;
|
|
32
|
+
readonly default: undefined;
|
|
33
|
+
};
|
|
34
|
+
readonly strings: {
|
|
35
|
+
readonly type: import("vue").PropType<Record<string, string>>;
|
|
36
|
+
readonly default: undefined;
|
|
37
|
+
};
|
|
38
|
+
readonly runtimeUrl: {
|
|
39
|
+
readonly type: StringConstructor;
|
|
40
|
+
readonly required: true;
|
|
41
|
+
};
|
|
42
|
+
readonly runtimeTimeoutMs: {
|
|
43
|
+
readonly type: NumberConstructor;
|
|
44
|
+
readonly default: undefined;
|
|
45
|
+
};
|
|
46
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
49
|
+
ready: () => boolean;
|
|
50
|
+
validation: (_message: string | null) => boolean;
|
|
51
|
+
complete: (_event: import("./flopay-runtime-card-setup.js").FloPayRuntimeSetupCompleteEvent) => boolean;
|
|
52
|
+
decline: (_event: import("./flopay-runtime-card-setup.js").FloPayRuntimeSetupDeclineEvent) => boolean;
|
|
53
|
+
cancel: (_event: import("./flopay-runtime-card-setup.js").FloPayRuntimeSetupCancelEvent) => boolean;
|
|
54
|
+
error: (_error: import("./flopay-runtime-card-setup.js").FloPayRuntimeSetupError) => boolean;
|
|
55
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
56
|
+
readonly sessionId: {
|
|
57
|
+
readonly type: StringConstructor;
|
|
58
|
+
readonly required: true;
|
|
59
|
+
};
|
|
60
|
+
readonly nonce: {
|
|
61
|
+
readonly type: StringConstructor;
|
|
62
|
+
readonly required: true;
|
|
63
|
+
};
|
|
64
|
+
readonly theme: {
|
|
65
|
+
readonly type: import("vue").PropType<import("@flopay/shared").ThemeId | import("@flopay/shared").VaultCardThemeColors>;
|
|
66
|
+
readonly default: undefined;
|
|
67
|
+
};
|
|
68
|
+
readonly appearance: {
|
|
69
|
+
readonly type: import("vue").PropType<import("@flopay/shared").FloPayAppearance>;
|
|
70
|
+
readonly default: undefined;
|
|
71
|
+
};
|
|
72
|
+
readonly buttonsStyles: {
|
|
73
|
+
readonly type: import("vue").PropType<import("@flopay/shared").ButtonsLayoutStyles>;
|
|
74
|
+
readonly default: undefined;
|
|
75
|
+
};
|
|
76
|
+
readonly containerStyle: {
|
|
77
|
+
readonly type: import("vue").PropType<Record<string, string | number>>;
|
|
78
|
+
readonly default: undefined;
|
|
79
|
+
};
|
|
80
|
+
readonly strings: {
|
|
81
|
+
readonly type: import("vue").PropType<Record<string, string>>;
|
|
82
|
+
readonly default: undefined;
|
|
83
|
+
};
|
|
84
|
+
readonly runtimeUrl: {
|
|
85
|
+
readonly type: StringConstructor;
|
|
86
|
+
readonly required: true;
|
|
87
|
+
};
|
|
88
|
+
readonly runtimeTimeoutMs: {
|
|
89
|
+
readonly type: NumberConstructor;
|
|
90
|
+
readonly default: undefined;
|
|
91
|
+
};
|
|
92
|
+
}>> & Readonly<{
|
|
93
|
+
onCancel?: ((_event: import("./flopay-runtime-card-setup.js").FloPayRuntimeSetupCancelEvent) => any) | undefined;
|
|
94
|
+
onComplete?: ((_event: import("./flopay-runtime-card-setup.js").FloPayRuntimeSetupCompleteEvent) => any) | undefined;
|
|
95
|
+
onDecline?: ((_event: import("./flopay-runtime-card-setup.js").FloPayRuntimeSetupDeclineEvent) => any) | undefined;
|
|
96
|
+
onError?: ((_error: import("./flopay-runtime-card-setup.js").FloPayRuntimeSetupError) => any) | undefined;
|
|
97
|
+
onReady?: (() => any) | undefined;
|
|
98
|
+
onValidation?: ((_message: string | null) => any) | undefined;
|
|
99
|
+
}>, {
|
|
100
|
+
readonly theme: import("@flopay/shared").VaultCardThemeColors | import("@flopay/shared").ThemeId;
|
|
101
|
+
readonly appearance: import("@flopay/shared").FloPayAppearance;
|
|
102
|
+
readonly buttonsStyles: import("@flopay/shared").ButtonsLayoutStyles;
|
|
103
|
+
readonly containerStyle: Record<string, string | number>;
|
|
104
|
+
readonly strings: Record<string, string>;
|
|
105
|
+
readonly runtimeTimeoutMs: number;
|
|
106
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
package/dist/index.cjs
CHANGED
|
@@ -1109,16 +1109,18 @@ __export(index_exports, {
|
|
|
1109
1109
|
FloPayCheckout: () => FloPayCheckout,
|
|
1110
1110
|
FloPayPaymentMethodSetup: () => FloPayPaymentMethodSetup,
|
|
1111
1111
|
FloPayProvider: () => FloPayProvider,
|
|
1112
|
+
FloPayRuntimeCardSetup: () => FloPayRuntimeCardSetup,
|
|
1112
1113
|
FloPayRuntimeCheckout: () => FloPayRuntimeCheckout,
|
|
1114
|
+
FloPayRuntimePaymentMethodSetup: () => FloPayRuntimePaymentMethodSetup,
|
|
1113
1115
|
SplitCardForm: () => SplitCardForm,
|
|
1114
1116
|
VaultCardFields: () => VaultCardFields,
|
|
1115
|
-
dropThirdPartyOnlyError: () =>
|
|
1117
|
+
dropThirdPartyOnlyError: () => import_shared17.dropThirdPartyOnlyError,
|
|
1116
1118
|
useCheckout: () => useCheckout,
|
|
1117
1119
|
useFloPay: () => useFloPay,
|
|
1118
1120
|
usePayPalFloPay: () => usePayPalFloPay
|
|
1119
1121
|
});
|
|
1120
1122
|
module.exports = __toCommonJS(index_exports);
|
|
1121
|
-
var
|
|
1123
|
+
var import_shared17 = require("@flopay/shared");
|
|
1122
1124
|
|
|
1123
1125
|
// src/automatic-payment-button.ts
|
|
1124
1126
|
var import_js3 = require("@flopay/js");
|
|
@@ -4805,7 +4807,7 @@ function useHostedSetup(props, emitters, options) {
|
|
|
4805
4807
|
const capture = (0, import_vue10.shallowRef)(null);
|
|
4806
4808
|
const vault = (0, import_vue10.shallowRef)(null);
|
|
4807
4809
|
const session = (0, import_vue10.shallowRef)(null);
|
|
4808
|
-
const
|
|
4810
|
+
const loadError2 = (0, import_vue10.ref)(null);
|
|
4809
4811
|
let active = true;
|
|
4810
4812
|
let terminal = false;
|
|
4811
4813
|
let completed = false;
|
|
@@ -4926,7 +4928,7 @@ function useHostedSetup(props, emitters, options) {
|
|
|
4926
4928
|
if (!active) return;
|
|
4927
4929
|
terminal = true;
|
|
4928
4930
|
const failure = asCardSetupError(error);
|
|
4929
|
-
|
|
4931
|
+
loadError2.value = failure;
|
|
4930
4932
|
(0, import_shared11.invokeMerchantCallback)(() => emitters.error(failure));
|
|
4931
4933
|
} finally {
|
|
4932
4934
|
api.destroy();
|
|
@@ -4947,7 +4949,7 @@ function useHostedSetup(props, emitters, options) {
|
|
|
4947
4949
|
capture,
|
|
4948
4950
|
vault,
|
|
4949
4951
|
session,
|
|
4950
|
-
loadError,
|
|
4952
|
+
loadError: loadError2,
|
|
4951
4953
|
settle: () => {
|
|
4952
4954
|
terminal = true;
|
|
4953
4955
|
},
|
|
@@ -5342,13 +5344,217 @@ var FloPayPaymentMethodSetup = (0, import_vue13.defineComponent)({
|
|
|
5342
5344
|
}
|
|
5343
5345
|
});
|
|
5344
5346
|
|
|
5345
|
-
// src/flopay-runtime-
|
|
5347
|
+
// src/flopay-runtime-card-setup.ts
|
|
5346
5348
|
var import_js4 = require("@flopay/js");
|
|
5347
5349
|
var import_shared15 = require("@flopay/shared");
|
|
5348
5350
|
var import_vue14 = require("vue");
|
|
5351
|
+
var SETUP_CONTRACT_VERSION = "2.4.0";
|
|
5352
|
+
function isRecord(value) {
|
|
5353
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5354
|
+
}
|
|
5355
|
+
var ERROR_TYPES = /* @__PURE__ */ new Set([
|
|
5356
|
+
"validation_error",
|
|
5357
|
+
"api_error",
|
|
5358
|
+
"authentication_error",
|
|
5359
|
+
"rate_limit_error",
|
|
5360
|
+
"network_error"
|
|
5361
|
+
]);
|
|
5362
|
+
function setupError(message, type, retryable, options = {}) {
|
|
5363
|
+
return Object.assign(new import_shared15.FloPayError(message, type, options), { retryable });
|
|
5364
|
+
}
|
|
5365
|
+
function errorFromPayload(payload) {
|
|
5366
|
+
const record = isRecord(payload) ? payload : {};
|
|
5367
|
+
const type = typeof record.type === "string" && ERROR_TYPES.has(record.type) ? record.type : "";
|
|
5368
|
+
return setupError(
|
|
5369
|
+
typeof record.message === "string" ? record.message : "The setup failed.",
|
|
5370
|
+
type || "api_error",
|
|
5371
|
+
record.retryable === true,
|
|
5372
|
+
{
|
|
5373
|
+
...typeof record.code === "string" ? { code: record.code } : {},
|
|
5374
|
+
...typeof record.param === "string" ? { param: record.param } : {},
|
|
5375
|
+
...typeof record.statusCode === "number" ? { statusCode: record.statusCode } : {}
|
|
5376
|
+
}
|
|
5377
|
+
);
|
|
5378
|
+
}
|
|
5379
|
+
function loadError(caught) {
|
|
5380
|
+
if (caught instanceof import_shared15.FloPayError) {
|
|
5381
|
+
return setupError(caught.message, caught.type, true, {
|
|
5382
|
+
code: caught.code ?? "runtime_load_failed",
|
|
5383
|
+
cause: caught
|
|
5384
|
+
});
|
|
5385
|
+
}
|
|
5386
|
+
return setupError("The checkout runtime failed to load.", "network_error", true, {
|
|
5387
|
+
code: "runtime_load_failed",
|
|
5388
|
+
cause: caught
|
|
5389
|
+
});
|
|
5390
|
+
}
|
|
5391
|
+
function setupConfig(props) {
|
|
5392
|
+
return {
|
|
5393
|
+
...props.theme === void 0 ? {} : { theme: props.theme },
|
|
5394
|
+
...props.appearance === void 0 ? {} : { appearance: props.appearance },
|
|
5395
|
+
...props.buttonsStyles === void 0 ? {} : { buttonsStyles: props.buttonsStyles },
|
|
5396
|
+
...props.containerStyle === void 0 ? {} : { containerStyle: props.containerStyle },
|
|
5397
|
+
...props.strings === void 0 ? {} : { strings: props.strings }
|
|
5398
|
+
};
|
|
5399
|
+
}
|
|
5400
|
+
var setupProps = {
|
|
5401
|
+
sessionId: { type: String, required: true },
|
|
5402
|
+
nonce: { type: String, required: true },
|
|
5403
|
+
theme: {
|
|
5404
|
+
type: [String, Object],
|
|
5405
|
+
default: void 0
|
|
5406
|
+
},
|
|
5407
|
+
appearance: { type: Object, default: void 0 },
|
|
5408
|
+
buttonsStyles: { type: Object, default: void 0 },
|
|
5409
|
+
containerStyle: {
|
|
5410
|
+
type: Object,
|
|
5411
|
+
default: void 0
|
|
5412
|
+
},
|
|
5413
|
+
strings: { type: Object, default: void 0 },
|
|
5414
|
+
runtimeUrl: { type: String, required: true },
|
|
5415
|
+
runtimeTimeoutMs: { type: Number, default: void 0 }
|
|
5416
|
+
};
|
|
5417
|
+
var setupEmits = {
|
|
5418
|
+
ready: () => true,
|
|
5419
|
+
validation: (_message) => true,
|
|
5420
|
+
complete: (_event) => true,
|
|
5421
|
+
decline: (_event) => true,
|
|
5422
|
+
cancel: (_event) => true,
|
|
5423
|
+
error: (_error) => true
|
|
5424
|
+
};
|
|
5425
|
+
var LISTENERS = {
|
|
5426
|
+
ready: "onReady",
|
|
5427
|
+
validation: "onValidation",
|
|
5428
|
+
complete: "onComplete",
|
|
5429
|
+
decline: "onDecline",
|
|
5430
|
+
cancel: "onCancel",
|
|
5431
|
+
error: "onError"
|
|
5432
|
+
};
|
|
5433
|
+
function setupRuntimeSetup(kind, props, emit) {
|
|
5434
|
+
const instance = (0, import_vue14.getCurrentInstance)();
|
|
5435
|
+
const container = (0, import_vue14.ref)(null);
|
|
5436
|
+
let handle = null;
|
|
5437
|
+
let generation = 0;
|
|
5438
|
+
const deliver = (name, argument) => {
|
|
5439
|
+
try {
|
|
5440
|
+
if (instance?.isUnmounted) {
|
|
5441
|
+
const listener = instance.vnode.props?.[LISTENERS[name]];
|
|
5442
|
+
if (typeof listener === "function") listener(argument);
|
|
5443
|
+
return;
|
|
5444
|
+
}
|
|
5445
|
+
emit(
|
|
5446
|
+
name,
|
|
5447
|
+
...argument === void 0 ? [] : [argument]
|
|
5448
|
+
);
|
|
5449
|
+
} catch {
|
|
5450
|
+
}
|
|
5451
|
+
};
|
|
5452
|
+
const onEvent = (event) => {
|
|
5453
|
+
const payload = event.payload;
|
|
5454
|
+
switch (event.name) {
|
|
5455
|
+
case "setupReady":
|
|
5456
|
+
deliver("ready");
|
|
5457
|
+
return;
|
|
5458
|
+
case "setupValidation":
|
|
5459
|
+
deliver(
|
|
5460
|
+
"validation",
|
|
5461
|
+
isRecord(payload) && typeof payload.message === "string" ? payload.message : null
|
|
5462
|
+
);
|
|
5463
|
+
return;
|
|
5464
|
+
case "complete":
|
|
5465
|
+
case "decline":
|
|
5466
|
+
case "cancel":
|
|
5467
|
+
deliver(event.name, payload);
|
|
5468
|
+
return;
|
|
5469
|
+
case "error":
|
|
5470
|
+
deliver("error", errorFromPayload(payload));
|
|
5471
|
+
return;
|
|
5472
|
+
default:
|
|
5473
|
+
return;
|
|
5474
|
+
}
|
|
5475
|
+
};
|
|
5476
|
+
const stop = () => {
|
|
5477
|
+
generation += 1;
|
|
5478
|
+
const current = handle;
|
|
5479
|
+
handle = null;
|
|
5480
|
+
current?.unmount();
|
|
5481
|
+
};
|
|
5482
|
+
const start = () => {
|
|
5483
|
+
const element = container.value;
|
|
5484
|
+
if (!element) return;
|
|
5485
|
+
generation += 1;
|
|
5486
|
+
const current = generation;
|
|
5487
|
+
(0, import_js4.loadCheckoutRuntime)({
|
|
5488
|
+
runtimeUrl: props.runtimeUrl,
|
|
5489
|
+
...props.runtimeTimeoutMs === void 0 ? {} : { timeoutMs: props.runtimeTimeoutMs }
|
|
5490
|
+
}).then(
|
|
5491
|
+
(runtime) => {
|
|
5492
|
+
if (current !== generation) return;
|
|
5493
|
+
if (typeof runtime.mountSetup !== "function") {
|
|
5494
|
+
deliver(
|
|
5495
|
+
"error",
|
|
5496
|
+
setupError(
|
|
5497
|
+
"The checkout runtime on this page is too old to run setup.",
|
|
5498
|
+
"api_error",
|
|
5499
|
+
false,
|
|
5500
|
+
{ code: "runtime_setup_unsupported" }
|
|
5501
|
+
)
|
|
5502
|
+
);
|
|
5503
|
+
return;
|
|
5504
|
+
}
|
|
5505
|
+
handle = runtime.mountSetup(element, {
|
|
5506
|
+
setup: kind,
|
|
5507
|
+
sessionId: props.sessionId,
|
|
5508
|
+
nonce: props.nonce,
|
|
5509
|
+
contractVersion: SETUP_CONTRACT_VERSION,
|
|
5510
|
+
...setupConfig(props),
|
|
5511
|
+
onEvent
|
|
5512
|
+
});
|
|
5513
|
+
},
|
|
5514
|
+
(caught) => {
|
|
5515
|
+
if (current === generation) deliver("error", loadError(caught));
|
|
5516
|
+
}
|
|
5517
|
+
);
|
|
5518
|
+
};
|
|
5519
|
+
(0, import_vue14.onMounted)(start);
|
|
5520
|
+
(0, import_vue14.watch)(
|
|
5521
|
+
() => [props.sessionId, props.nonce, props.runtimeUrl, props.runtimeTimeoutMs],
|
|
5522
|
+
() => {
|
|
5523
|
+
stop();
|
|
5524
|
+
start();
|
|
5525
|
+
}
|
|
5526
|
+
);
|
|
5527
|
+
(0, import_vue14.watch)(
|
|
5528
|
+
() => JSON.stringify(setupConfig(props)),
|
|
5529
|
+
() => {
|
|
5530
|
+
handle?.update({
|
|
5531
|
+
theme: props.theme,
|
|
5532
|
+
appearance: props.appearance,
|
|
5533
|
+
buttonsStyles: props.buttonsStyles,
|
|
5534
|
+
containerStyle: props.containerStyle,
|
|
5535
|
+
strings: props.strings
|
|
5536
|
+
});
|
|
5537
|
+
}
|
|
5538
|
+
);
|
|
5539
|
+
(0, import_vue14.onBeforeUnmount)(stop);
|
|
5540
|
+
return () => (0, import_vue14.h)("div", { ref: container });
|
|
5541
|
+
}
|
|
5542
|
+
var FloPayRuntimeCardSetup = (0, import_vue14.defineComponent)({
|
|
5543
|
+
name: "FloPayRuntimeCardSetup",
|
|
5544
|
+
props: setupProps,
|
|
5545
|
+
emits: setupEmits,
|
|
5546
|
+
setup(props, { emit }) {
|
|
5547
|
+
return setupRuntimeSetup("card", props, emit);
|
|
5548
|
+
}
|
|
5549
|
+
});
|
|
5550
|
+
|
|
5551
|
+
// src/flopay-runtime-checkout.ts
|
|
5552
|
+
var import_js5 = require("@flopay/js");
|
|
5553
|
+
var import_shared16 = require("@flopay/shared");
|
|
5554
|
+
var import_vue15 = require("vue");
|
|
5349
5555
|
function asFloPayError(caught) {
|
|
5350
|
-
if (caught instanceof
|
|
5351
|
-
return new
|
|
5556
|
+
if (caught instanceof import_shared16.FloPayError) return caught;
|
|
5557
|
+
return new import_shared16.FloPayError("The checkout runtime failed to load.", "network_error", {
|
|
5352
5558
|
code: "runtime_load_failed",
|
|
5353
5559
|
cause: caught
|
|
5354
5560
|
});
|
|
@@ -5366,7 +5572,7 @@ function rulesKey(rules) {
|
|
|
5366
5572
|
function rulesFromKey(key) {
|
|
5367
5573
|
return key === void 0 ? void 0 : JSON.parse(key);
|
|
5368
5574
|
}
|
|
5369
|
-
var FloPayRuntimeCheckout = (0,
|
|
5575
|
+
var FloPayRuntimeCheckout = (0, import_vue15.defineComponent)({
|
|
5370
5576
|
name: "FloPayRuntimeCheckout",
|
|
5371
5577
|
props: {
|
|
5372
5578
|
publishableKey: { type: String, required: true },
|
|
@@ -5392,7 +5598,7 @@ var FloPayRuntimeCheckout = (0, import_vue14.defineComponent)({
|
|
|
5392
5598
|
error: (_error) => true
|
|
5393
5599
|
},
|
|
5394
5600
|
setup(props, { emit }) {
|
|
5395
|
-
const container = (0,
|
|
5601
|
+
const container = (0, import_vue15.ref)(null);
|
|
5396
5602
|
let handle = null;
|
|
5397
5603
|
let mountedLayoutRules;
|
|
5398
5604
|
let run = 0;
|
|
@@ -5404,7 +5610,7 @@ var FloPayRuntimeCheckout = (0, import_vue14.defineComponent)({
|
|
|
5404
5610
|
const start = () => {
|
|
5405
5611
|
stop();
|
|
5406
5612
|
const current = run;
|
|
5407
|
-
(0,
|
|
5613
|
+
(0, import_js5.loadCheckoutRuntime)({ runtimeUrl: props.runtimeUrl, timeoutMs: props.runtimeTimeoutMs }).then(
|
|
5408
5614
|
(runtime) => {
|
|
5409
5615
|
if (current !== run || !container.value) return;
|
|
5410
5616
|
mountedLayoutRules = rulesKey(props.paymentMethodLayout);
|
|
@@ -5433,8 +5639,8 @@ var FloPayRuntimeCheckout = (0, import_vue14.defineComponent)({
|
|
|
5433
5639
|
}
|
|
5434
5640
|
);
|
|
5435
5641
|
};
|
|
5436
|
-
(0,
|
|
5437
|
-
(0,
|
|
5642
|
+
(0, import_vue15.onMounted)(start);
|
|
5643
|
+
(0, import_vue15.watch)(
|
|
5438
5644
|
[
|
|
5439
5645
|
() => props.publishableKey,
|
|
5440
5646
|
() => props.sessionId,
|
|
@@ -5451,19 +5657,19 @@ var FloPayRuntimeCheckout = (0, import_vue14.defineComponent)({
|
|
|
5451
5657
|
],
|
|
5452
5658
|
() => start()
|
|
5453
5659
|
);
|
|
5454
|
-
(0,
|
|
5660
|
+
(0, import_vue15.watch)(
|
|
5455
5661
|
() => props.appearance,
|
|
5456
5662
|
(appearance) => {
|
|
5457
5663
|
if (appearance !== void 0) handle?.update({ appearance });
|
|
5458
5664
|
}
|
|
5459
5665
|
);
|
|
5460
|
-
(0,
|
|
5666
|
+
(0, import_vue15.watch)(
|
|
5461
5667
|
() => props.strings,
|
|
5462
5668
|
(strings) => {
|
|
5463
5669
|
if (strings !== void 0) handle?.update({ strings });
|
|
5464
5670
|
}
|
|
5465
5671
|
);
|
|
5466
|
-
(0,
|
|
5672
|
+
(0, import_vue15.watch)(
|
|
5467
5673
|
// By value, so equal rules in a new (or reactive) object ask for no new layout.
|
|
5468
5674
|
() => rulesKey(props.paymentMethodLayout),
|
|
5469
5675
|
(key) => {
|
|
@@ -5472,22 +5678,33 @@ var FloPayRuntimeCheckout = (0, import_vue14.defineComponent)({
|
|
|
5472
5678
|
handle.update({ paymentMethodLayout: rulesFromKey(key) });
|
|
5473
5679
|
}
|
|
5474
5680
|
);
|
|
5475
|
-
(0,
|
|
5476
|
-
return () => (0,
|
|
5681
|
+
(0, import_vue15.onBeforeUnmount)(stop);
|
|
5682
|
+
return () => (0, import_vue15.h)("div", { ref: container, "data-flopay-runtime-checkout": "" });
|
|
5683
|
+
}
|
|
5684
|
+
});
|
|
5685
|
+
|
|
5686
|
+
// src/flopay-runtime-payment-method-setup.ts
|
|
5687
|
+
var import_vue16 = require("vue");
|
|
5688
|
+
var FloPayRuntimePaymentMethodSetup = (0, import_vue16.defineComponent)({
|
|
5689
|
+
name: "FloPayRuntimePaymentMethodSetup",
|
|
5690
|
+
props: setupProps,
|
|
5691
|
+
emits: setupEmits,
|
|
5692
|
+
setup(props, { emit }) {
|
|
5693
|
+
return setupRuntimeSetup("payment_method", props, emit);
|
|
5477
5694
|
}
|
|
5478
5695
|
});
|
|
5479
5696
|
|
|
5480
5697
|
// src/hooks.ts
|
|
5481
|
-
var
|
|
5698
|
+
var import_vue17 = require("vue");
|
|
5482
5699
|
init_context();
|
|
5483
5700
|
function useFloPay() {
|
|
5484
|
-
return (0,
|
|
5701
|
+
return (0, import_vue17.inject)(FLOPAY_CONTEXT, null)?.flopay ?? (0, import_vue17.shallowRef)(null);
|
|
5485
5702
|
}
|
|
5486
5703
|
function usePayPalFloPay() {
|
|
5487
|
-
return (0,
|
|
5704
|
+
return (0, import_vue17.inject)(FLOPAY_CONTEXT, null)?.paypalFlopay ?? (0, import_vue17.shallowRef)(null);
|
|
5488
5705
|
}
|
|
5489
5706
|
function useCheckout() {
|
|
5490
|
-
return (0,
|
|
5707
|
+
return (0, import_vue17.inject)(CHECKOUT_STATE, null) ?? (0, import_vue17.reactive)({ session: null, loading: false, error: null });
|
|
5491
5708
|
}
|
|
5492
5709
|
|
|
5493
5710
|
// src/index.ts
|
|
@@ -5501,7 +5718,9 @@ init_provider();
|
|
|
5501
5718
|
FloPayCheckout,
|
|
5502
5719
|
FloPayPaymentMethodSetup,
|
|
5503
5720
|
FloPayProvider,
|
|
5721
|
+
FloPayRuntimeCardSetup,
|
|
5504
5722
|
FloPayRuntimeCheckout,
|
|
5723
|
+
FloPayRuntimePaymentMethodSetup,
|
|
5505
5724
|
SplitCardForm,
|
|
5506
5725
|
VaultCardFields,
|
|
5507
5726
|
dropThirdPartyOnlyError,
|
package/dist/index.d.ts
CHANGED
|
@@ -10,8 +10,12 @@ export type { FloPayCheckoutProps } from './flopay-checkout.js';
|
|
|
10
10
|
export { FloPayCheckout } from './flopay-checkout.js';
|
|
11
11
|
export type { FloPayPaymentMethodSetupCancelEvent, FloPayPaymentMethodSetupCompleteEvent, FloPayPaymentMethodSetupDeclineEvent, FloPayPaymentMethodSetupProps, } from './flopay-payment-method-setup-main.js';
|
|
12
12
|
export { FloPayPaymentMethodSetup } from './flopay-payment-method-setup-main.js';
|
|
13
|
+
export type { FloPayRuntimeCardSetupProps } from './flopay-runtime-card-setup.js';
|
|
14
|
+
export { FloPayRuntimeCardSetup } from './flopay-runtime-card-setup.js';
|
|
13
15
|
export type { FloPayRuntimeCheckoutProps } from './flopay-runtime-checkout.js';
|
|
14
16
|
export { FloPayRuntimeCheckout } from './flopay-runtime-checkout.js';
|
|
17
|
+
export type { FloPayRuntimePaymentMethodSetupProps } from './flopay-runtime-payment-method-setup.js';
|
|
18
|
+
export { FloPayRuntimePaymentMethodSetup } from './flopay-runtime-payment-method-setup.js';
|
|
15
19
|
export type { CheckoutState } from './hooks.js';
|
|
16
20
|
export { useCheckout, useFloPay, usePayPalFloPay } from './hooks.js';
|
|
17
21
|
export type { FloPayProviderProps } from './provider.js';
|
package/dist/index.mjs
CHANGED
|
@@ -3476,13 +3476,225 @@ var FloPayAutomaticPaymentButton = defineComponent5({
|
|
|
3476
3476
|
}
|
|
3477
3477
|
});
|
|
3478
3478
|
|
|
3479
|
-
// src/flopay-runtime-
|
|
3479
|
+
// src/flopay-runtime-card-setup.ts
|
|
3480
3480
|
import { loadCheckoutRuntime } from "@flopay/js";
|
|
3481
3481
|
import { FloPayError as FloPayError6 } from "@flopay/shared";
|
|
3482
|
-
import {
|
|
3482
|
+
import {
|
|
3483
|
+
defineComponent as defineComponent6,
|
|
3484
|
+
getCurrentInstance,
|
|
3485
|
+
h as h6,
|
|
3486
|
+
onBeforeUnmount as onBeforeUnmount6,
|
|
3487
|
+
onMounted as onMounted4,
|
|
3488
|
+
ref as ref6,
|
|
3489
|
+
watch as watch4
|
|
3490
|
+
} from "vue";
|
|
3491
|
+
var SETUP_CONTRACT_VERSION = "2.4.0";
|
|
3492
|
+
function isRecord(value) {
|
|
3493
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3494
|
+
}
|
|
3495
|
+
var ERROR_TYPES = /* @__PURE__ */ new Set([
|
|
3496
|
+
"validation_error",
|
|
3497
|
+
"api_error",
|
|
3498
|
+
"authentication_error",
|
|
3499
|
+
"rate_limit_error",
|
|
3500
|
+
"network_error"
|
|
3501
|
+
]);
|
|
3502
|
+
function setupError(message, type, retryable, options = {}) {
|
|
3503
|
+
return Object.assign(new FloPayError6(message, type, options), { retryable });
|
|
3504
|
+
}
|
|
3505
|
+
function errorFromPayload(payload) {
|
|
3506
|
+
const record = isRecord(payload) ? payload : {};
|
|
3507
|
+
const type = typeof record.type === "string" && ERROR_TYPES.has(record.type) ? record.type : "";
|
|
3508
|
+
return setupError(
|
|
3509
|
+
typeof record.message === "string" ? record.message : "The setup failed.",
|
|
3510
|
+
type || "api_error",
|
|
3511
|
+
record.retryable === true,
|
|
3512
|
+
{
|
|
3513
|
+
...typeof record.code === "string" ? { code: record.code } : {},
|
|
3514
|
+
...typeof record.param === "string" ? { param: record.param } : {},
|
|
3515
|
+
...typeof record.statusCode === "number" ? { statusCode: record.statusCode } : {}
|
|
3516
|
+
}
|
|
3517
|
+
);
|
|
3518
|
+
}
|
|
3519
|
+
function loadError(caught) {
|
|
3520
|
+
if (caught instanceof FloPayError6) {
|
|
3521
|
+
return setupError(caught.message, caught.type, true, {
|
|
3522
|
+
code: caught.code ?? "runtime_load_failed",
|
|
3523
|
+
cause: caught
|
|
3524
|
+
});
|
|
3525
|
+
}
|
|
3526
|
+
return setupError("The checkout runtime failed to load.", "network_error", true, {
|
|
3527
|
+
code: "runtime_load_failed",
|
|
3528
|
+
cause: caught
|
|
3529
|
+
});
|
|
3530
|
+
}
|
|
3531
|
+
function setupConfig(props) {
|
|
3532
|
+
return {
|
|
3533
|
+
...props.theme === void 0 ? {} : { theme: props.theme },
|
|
3534
|
+
...props.appearance === void 0 ? {} : { appearance: props.appearance },
|
|
3535
|
+
...props.buttonsStyles === void 0 ? {} : { buttonsStyles: props.buttonsStyles },
|
|
3536
|
+
...props.containerStyle === void 0 ? {} : { containerStyle: props.containerStyle },
|
|
3537
|
+
...props.strings === void 0 ? {} : { strings: props.strings }
|
|
3538
|
+
};
|
|
3539
|
+
}
|
|
3540
|
+
var setupProps = {
|
|
3541
|
+
sessionId: { type: String, required: true },
|
|
3542
|
+
nonce: { type: String, required: true },
|
|
3543
|
+
theme: {
|
|
3544
|
+
type: [String, Object],
|
|
3545
|
+
default: void 0
|
|
3546
|
+
},
|
|
3547
|
+
appearance: { type: Object, default: void 0 },
|
|
3548
|
+
buttonsStyles: { type: Object, default: void 0 },
|
|
3549
|
+
containerStyle: {
|
|
3550
|
+
type: Object,
|
|
3551
|
+
default: void 0
|
|
3552
|
+
},
|
|
3553
|
+
strings: { type: Object, default: void 0 },
|
|
3554
|
+
runtimeUrl: { type: String, required: true },
|
|
3555
|
+
runtimeTimeoutMs: { type: Number, default: void 0 }
|
|
3556
|
+
};
|
|
3557
|
+
var setupEmits = {
|
|
3558
|
+
ready: () => true,
|
|
3559
|
+
validation: (_message) => true,
|
|
3560
|
+
complete: (_event) => true,
|
|
3561
|
+
decline: (_event) => true,
|
|
3562
|
+
cancel: (_event) => true,
|
|
3563
|
+
error: (_error) => true
|
|
3564
|
+
};
|
|
3565
|
+
var LISTENERS = {
|
|
3566
|
+
ready: "onReady",
|
|
3567
|
+
validation: "onValidation",
|
|
3568
|
+
complete: "onComplete",
|
|
3569
|
+
decline: "onDecline",
|
|
3570
|
+
cancel: "onCancel",
|
|
3571
|
+
error: "onError"
|
|
3572
|
+
};
|
|
3573
|
+
function setupRuntimeSetup(kind, props, emit) {
|
|
3574
|
+
const instance = getCurrentInstance();
|
|
3575
|
+
const container = ref6(null);
|
|
3576
|
+
let handle = null;
|
|
3577
|
+
let generation = 0;
|
|
3578
|
+
const deliver = (name, argument) => {
|
|
3579
|
+
try {
|
|
3580
|
+
if (instance?.isUnmounted) {
|
|
3581
|
+
const listener = instance.vnode.props?.[LISTENERS[name]];
|
|
3582
|
+
if (typeof listener === "function") listener(argument);
|
|
3583
|
+
return;
|
|
3584
|
+
}
|
|
3585
|
+
emit(
|
|
3586
|
+
name,
|
|
3587
|
+
...argument === void 0 ? [] : [argument]
|
|
3588
|
+
);
|
|
3589
|
+
} catch {
|
|
3590
|
+
}
|
|
3591
|
+
};
|
|
3592
|
+
const onEvent = (event) => {
|
|
3593
|
+
const payload = event.payload;
|
|
3594
|
+
switch (event.name) {
|
|
3595
|
+
case "setupReady":
|
|
3596
|
+
deliver("ready");
|
|
3597
|
+
return;
|
|
3598
|
+
case "setupValidation":
|
|
3599
|
+
deliver(
|
|
3600
|
+
"validation",
|
|
3601
|
+
isRecord(payload) && typeof payload.message === "string" ? payload.message : null
|
|
3602
|
+
);
|
|
3603
|
+
return;
|
|
3604
|
+
case "complete":
|
|
3605
|
+
case "decline":
|
|
3606
|
+
case "cancel":
|
|
3607
|
+
deliver(event.name, payload);
|
|
3608
|
+
return;
|
|
3609
|
+
case "error":
|
|
3610
|
+
deliver("error", errorFromPayload(payload));
|
|
3611
|
+
return;
|
|
3612
|
+
default:
|
|
3613
|
+
return;
|
|
3614
|
+
}
|
|
3615
|
+
};
|
|
3616
|
+
const stop = () => {
|
|
3617
|
+
generation += 1;
|
|
3618
|
+
const current = handle;
|
|
3619
|
+
handle = null;
|
|
3620
|
+
current?.unmount();
|
|
3621
|
+
};
|
|
3622
|
+
const start = () => {
|
|
3623
|
+
const element = container.value;
|
|
3624
|
+
if (!element) return;
|
|
3625
|
+
generation += 1;
|
|
3626
|
+
const current = generation;
|
|
3627
|
+
loadCheckoutRuntime({
|
|
3628
|
+
runtimeUrl: props.runtimeUrl,
|
|
3629
|
+
...props.runtimeTimeoutMs === void 0 ? {} : { timeoutMs: props.runtimeTimeoutMs }
|
|
3630
|
+
}).then(
|
|
3631
|
+
(runtime) => {
|
|
3632
|
+
if (current !== generation) return;
|
|
3633
|
+
if (typeof runtime.mountSetup !== "function") {
|
|
3634
|
+
deliver(
|
|
3635
|
+
"error",
|
|
3636
|
+
setupError(
|
|
3637
|
+
"The checkout runtime on this page is too old to run setup.",
|
|
3638
|
+
"api_error",
|
|
3639
|
+
false,
|
|
3640
|
+
{ code: "runtime_setup_unsupported" }
|
|
3641
|
+
)
|
|
3642
|
+
);
|
|
3643
|
+
return;
|
|
3644
|
+
}
|
|
3645
|
+
handle = runtime.mountSetup(element, {
|
|
3646
|
+
setup: kind,
|
|
3647
|
+
sessionId: props.sessionId,
|
|
3648
|
+
nonce: props.nonce,
|
|
3649
|
+
contractVersion: SETUP_CONTRACT_VERSION,
|
|
3650
|
+
...setupConfig(props),
|
|
3651
|
+
onEvent
|
|
3652
|
+
});
|
|
3653
|
+
},
|
|
3654
|
+
(caught) => {
|
|
3655
|
+
if (current === generation) deliver("error", loadError(caught));
|
|
3656
|
+
}
|
|
3657
|
+
);
|
|
3658
|
+
};
|
|
3659
|
+
onMounted4(start);
|
|
3660
|
+
watch4(
|
|
3661
|
+
() => [props.sessionId, props.nonce, props.runtimeUrl, props.runtimeTimeoutMs],
|
|
3662
|
+
() => {
|
|
3663
|
+
stop();
|
|
3664
|
+
start();
|
|
3665
|
+
}
|
|
3666
|
+
);
|
|
3667
|
+
watch4(
|
|
3668
|
+
() => JSON.stringify(setupConfig(props)),
|
|
3669
|
+
() => {
|
|
3670
|
+
handle?.update({
|
|
3671
|
+
theme: props.theme,
|
|
3672
|
+
appearance: props.appearance,
|
|
3673
|
+
buttonsStyles: props.buttonsStyles,
|
|
3674
|
+
containerStyle: props.containerStyle,
|
|
3675
|
+
strings: props.strings
|
|
3676
|
+
});
|
|
3677
|
+
}
|
|
3678
|
+
);
|
|
3679
|
+
onBeforeUnmount6(stop);
|
|
3680
|
+
return () => h6("div", { ref: container });
|
|
3681
|
+
}
|
|
3682
|
+
var FloPayRuntimeCardSetup = defineComponent6({
|
|
3683
|
+
name: "FloPayRuntimeCardSetup",
|
|
3684
|
+
props: setupProps,
|
|
3685
|
+
emits: setupEmits,
|
|
3686
|
+
setup(props, { emit }) {
|
|
3687
|
+
return setupRuntimeSetup("card", props, emit);
|
|
3688
|
+
}
|
|
3689
|
+
});
|
|
3690
|
+
|
|
3691
|
+
// src/flopay-runtime-checkout.ts
|
|
3692
|
+
import { loadCheckoutRuntime as loadCheckoutRuntime2 } from "@flopay/js";
|
|
3693
|
+
import { FloPayError as FloPayError7 } from "@flopay/shared";
|
|
3694
|
+
import { defineComponent as defineComponent7, h as h7, onBeforeUnmount as onBeforeUnmount7, onMounted as onMounted5, ref as ref7, watch as watch5 } from "vue";
|
|
3483
3695
|
function asFloPayError(caught) {
|
|
3484
|
-
if (caught instanceof
|
|
3485
|
-
return new
|
|
3696
|
+
if (caught instanceof FloPayError7) return caught;
|
|
3697
|
+
return new FloPayError7("The checkout runtime failed to load.", "network_error", {
|
|
3486
3698
|
code: "runtime_load_failed",
|
|
3487
3699
|
cause: caught
|
|
3488
3700
|
});
|
|
@@ -3500,7 +3712,7 @@ function rulesKey(rules) {
|
|
|
3500
3712
|
function rulesFromKey(key) {
|
|
3501
3713
|
return key === void 0 ? void 0 : JSON.parse(key);
|
|
3502
3714
|
}
|
|
3503
|
-
var FloPayRuntimeCheckout =
|
|
3715
|
+
var FloPayRuntimeCheckout = defineComponent7({
|
|
3504
3716
|
name: "FloPayRuntimeCheckout",
|
|
3505
3717
|
props: {
|
|
3506
3718
|
publishableKey: { type: String, required: true },
|
|
@@ -3526,7 +3738,7 @@ var FloPayRuntimeCheckout = defineComponent6({
|
|
|
3526
3738
|
error: (_error) => true
|
|
3527
3739
|
},
|
|
3528
3740
|
setup(props, { emit }) {
|
|
3529
|
-
const container =
|
|
3741
|
+
const container = ref7(null);
|
|
3530
3742
|
let handle = null;
|
|
3531
3743
|
let mountedLayoutRules;
|
|
3532
3744
|
let run = 0;
|
|
@@ -3538,7 +3750,7 @@ var FloPayRuntimeCheckout = defineComponent6({
|
|
|
3538
3750
|
const start = () => {
|
|
3539
3751
|
stop();
|
|
3540
3752
|
const current = run;
|
|
3541
|
-
|
|
3753
|
+
loadCheckoutRuntime2({ runtimeUrl: props.runtimeUrl, timeoutMs: props.runtimeTimeoutMs }).then(
|
|
3542
3754
|
(runtime) => {
|
|
3543
3755
|
if (current !== run || !container.value) return;
|
|
3544
3756
|
mountedLayoutRules = rulesKey(props.paymentMethodLayout);
|
|
@@ -3567,8 +3779,8 @@ var FloPayRuntimeCheckout = defineComponent6({
|
|
|
3567
3779
|
}
|
|
3568
3780
|
);
|
|
3569
3781
|
};
|
|
3570
|
-
|
|
3571
|
-
|
|
3782
|
+
onMounted5(start);
|
|
3783
|
+
watch5(
|
|
3572
3784
|
[
|
|
3573
3785
|
() => props.publishableKey,
|
|
3574
3786
|
() => props.sessionId,
|
|
@@ -3585,19 +3797,19 @@ var FloPayRuntimeCheckout = defineComponent6({
|
|
|
3585
3797
|
],
|
|
3586
3798
|
() => start()
|
|
3587
3799
|
);
|
|
3588
|
-
|
|
3800
|
+
watch5(
|
|
3589
3801
|
() => props.appearance,
|
|
3590
3802
|
(appearance) => {
|
|
3591
3803
|
if (appearance !== void 0) handle?.update({ appearance });
|
|
3592
3804
|
}
|
|
3593
3805
|
);
|
|
3594
|
-
|
|
3806
|
+
watch5(
|
|
3595
3807
|
() => props.strings,
|
|
3596
3808
|
(strings) => {
|
|
3597
3809
|
if (strings !== void 0) handle?.update({ strings });
|
|
3598
3810
|
}
|
|
3599
3811
|
);
|
|
3600
|
-
|
|
3812
|
+
watch5(
|
|
3601
3813
|
// By value, so equal rules in a new (or reactive) object ask for no new layout.
|
|
3602
3814
|
() => rulesKey(props.paymentMethodLayout),
|
|
3603
3815
|
(key) => {
|
|
@@ -3606,8 +3818,19 @@ var FloPayRuntimeCheckout = defineComponent6({
|
|
|
3606
3818
|
handle.update({ paymentMethodLayout: rulesFromKey(key) });
|
|
3607
3819
|
}
|
|
3608
3820
|
);
|
|
3609
|
-
|
|
3610
|
-
return () =>
|
|
3821
|
+
onBeforeUnmount7(stop);
|
|
3822
|
+
return () => h7("div", { ref: container, "data-flopay-runtime-checkout": "" });
|
|
3823
|
+
}
|
|
3824
|
+
});
|
|
3825
|
+
|
|
3826
|
+
// src/flopay-runtime-payment-method-setup.ts
|
|
3827
|
+
import { defineComponent as defineComponent8 } from "vue";
|
|
3828
|
+
var FloPayRuntimePaymentMethodSetup = defineComponent8({
|
|
3829
|
+
name: "FloPayRuntimePaymentMethodSetup",
|
|
3830
|
+
props: setupProps,
|
|
3831
|
+
emits: setupEmits,
|
|
3832
|
+
setup(props, { emit }) {
|
|
3833
|
+
return setupRuntimeSetup("payment_method", props, emit);
|
|
3611
3834
|
}
|
|
3612
3835
|
});
|
|
3613
3836
|
|
|
@@ -3630,7 +3853,9 @@ export {
|
|
|
3630
3853
|
FloPayCheckout,
|
|
3631
3854
|
FloPayPaymentMethodSetup,
|
|
3632
3855
|
FloPayProvider,
|
|
3856
|
+
FloPayRuntimeCardSetup,
|
|
3633
3857
|
FloPayRuntimeCheckout,
|
|
3858
|
+
FloPayRuntimePaymentMethodSetup,
|
|
3634
3859
|
SplitCardForm,
|
|
3635
3860
|
VaultCardFields,
|
|
3636
3861
|
dropThirdPartyOnlyError,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flopay/vue",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.10",
|
|
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.20.
|
|
40
|
-
"@flopay/shared": "1.20.
|
|
39
|
+
"@flopay/js": "1.20.10",
|
|
40
|
+
"@flopay/shared": "1.20.10",
|
|
41
41
|
"@paypal/paypal-js": "^11.3.0",
|
|
42
42
|
"@stripe/stripe-js": "^10.3.0"
|
|
43
43
|
},
|