@flopay/vue 1.20.14 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -57
- package/dist/card-setup-entry.cjs +184 -569
- package/dist/card-setup-entry.d.ts +2 -2
- package/dist/card-setup-entry.mjs +3 -7
- package/dist/chunk-2VPPDVV7.mjs +218 -0
- package/dist/chunk-OCVTEXQA.mjs +20 -0
- package/dist/flopay-runtime-checkout.d.ts +11 -0
- package/dist/hosted-runtime-components.d.ts +587 -0
- package/dist/index.cjs +279 -5402
- package/dist/index.d.ts +3 -21
- package/dist/index.mjs +231 -3728
- package/dist/payment-method-setup-entry.cjs +194 -1852
- package/dist/payment-method-setup-entry.d.ts +2 -2
- package/dist/payment-method-setup-entry.mjs +4 -4
- package/dist/runtime-context.d.ts +11 -0
- package/package.json +3 -5
- package/dist/automatic-payment-button.d.ts +0 -296
- package/dist/buyer-identity-fallback.d.ts +0 -82
- package/dist/chunk-2USKULEH.mjs +0 -530
- package/dist/chunk-HH25IC76.mjs +0 -98
- package/dist/chunk-IJKGJSHH.mjs +0 -333
- package/dist/chunk-RAGPQWRA.mjs +0 -923
- package/dist/context.d.ts +0 -56
- package/dist/direct-paypal-button.d.ts +0 -325
- package/dist/flopay-card-setup.d.ts +0 -158
- package/dist/flopay-checkout.d.ts +0 -517
- package/dist/flopay-payment-method-setup-main.d.ts +0 -152
- package/dist/hooks.d.ts +0 -22
- package/dist/hosted-setup.d.ts +0 -116
- package/dist/payment-method-setup-paypal-D6FEQQJY.mjs +0 -151
- package/dist/payment-method-setup-paypal.d.ts +0 -108
- package/dist/processing-overlay.d.ts +0 -82
- package/dist/provider.d.ts +0 -76
- package/dist/saved-payment.d.ts +0 -44
- package/dist/split-card-form.d.ts +0 -777
- package/dist/stripe-elements-SI2PI6EO.mjs +0 -6
- package/dist/stripe-elements.d.ts +0 -280
- package/dist/stripe-paypal-continuation.d.ts +0 -28
- package/dist/vault-card-fields.d.ts +0 -129
|
@@ -20,599 +20,214 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/card-setup-entry.ts
|
|
21
21
|
var card_setup_entry_exports = {};
|
|
22
22
|
__export(card_setup_entry_exports, {
|
|
23
|
-
FloPayCardSetup: () =>
|
|
24
|
-
FloPayCardSetupError: () => FloPayCardSetupError
|
|
23
|
+
FloPayCardSetup: () => FloPayRuntimeCardSetup
|
|
25
24
|
});
|
|
26
25
|
module.exports = __toCommonJS(card_setup_entry_exports);
|
|
27
26
|
|
|
28
|
-
// src/flopay-card-setup.ts
|
|
29
|
-
var
|
|
30
|
-
var import_vue4 = require("vue");
|
|
31
|
-
|
|
32
|
-
// src/hosted-setup.ts
|
|
33
|
-
var import_card_setup = require("@flopay/js/card-setup");
|
|
27
|
+
// src/flopay-runtime-card-setup.ts
|
|
28
|
+
var import_js = require("@flopay/js");
|
|
34
29
|
var import_shared = require("@flopay/shared");
|
|
35
|
-
var import_vue2 = require("vue");
|
|
36
|
-
|
|
37
|
-
// src/processing-overlay.ts
|
|
38
30
|
var import_vue = require("vue");
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
panel: { background: "white" },
|
|
43
|
-
spinnerTrackColor: "#e5e7eb",
|
|
44
|
-
spinnerAccentColor: "#4A49FF",
|
|
45
|
-
labelColors: { processing: "#374151", success: "#16a34a", error: "#dc2626" },
|
|
46
|
-
noteColor: "#6b7280"
|
|
47
|
-
};
|
|
48
|
-
var KEYFRAMES_ID = "flopay-processing-overlay-keyframes";
|
|
49
|
-
var KEYFRAMES = [
|
|
50
|
-
"@keyframes flopay-spin { to { transform: rotate(360deg); } }",
|
|
51
|
-
"@keyframes flopay-pop { 0% { transform: scale(0); } 100% { transform: scale(1); } }",
|
|
52
|
-
"@keyframes flopay-draw { to { stroke-dashoffset: 0; } }",
|
|
53
|
-
"@keyframes flopay-shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-4px); } 40%,80% { transform: translateX(4px); } }"
|
|
54
|
-
].join("\n");
|
|
55
|
-
function ensureKeyframes() {
|
|
56
|
-
if (typeof document === "undefined" || document.getElementById(KEYFRAMES_ID)) return;
|
|
57
|
-
const style = document.createElement("style");
|
|
58
|
-
style.id = KEYFRAMES_ID;
|
|
59
|
-
style.textContent = KEYFRAMES;
|
|
60
|
-
document.head.appendChild(style);
|
|
31
|
+
var SETUP_CONTRACT_VERSION = "2.4.0";
|
|
32
|
+
function isRecord(value) {
|
|
33
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
61
34
|
}
|
|
62
|
-
var
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
return (0, import_vue.h)("svg", { ...SVG, style: { animation: "flopay-spin 0.8s linear infinite" } }, [
|
|
72
|
-
(0, import_vue.h)("circle", {
|
|
73
|
-
cx: "12",
|
|
74
|
-
cy: "12",
|
|
75
|
-
r: "10",
|
|
76
|
-
stroke: theme.spinnerTrackColor,
|
|
77
|
-
"stroke-width": "3"
|
|
78
|
-
}),
|
|
79
|
-
(0, import_vue.h)("path", { d: "M4 12a8 8 0 018-8v3a5 5 0 00-5 5H4z", fill: theme.spinnerAccentColor })
|
|
80
|
-
]);
|
|
81
|
-
}
|
|
82
|
-
if (status === "success") {
|
|
83
|
-
return (0, import_vue.h)("div", { style: { animation: "flopay-pop 0.4s cubic-bezier(0.34,1.56,0.64,1)" } }, [
|
|
84
|
-
(0, import_vue.h)("svg", SVG, [
|
|
85
|
-
(0, import_vue.h)("circle", { cx: "12", cy: "12", r: "11", fill: "#22c55e" }),
|
|
86
|
-
(0, import_vue.h)("path", {
|
|
87
|
-
d: "M7 12.5l3 3 7-7",
|
|
88
|
-
stroke: "white",
|
|
89
|
-
"stroke-width": "2.5",
|
|
90
|
-
"stroke-linecap": "round",
|
|
91
|
-
"stroke-linejoin": "round",
|
|
92
|
-
style: {
|
|
93
|
-
strokeDasharray: 20,
|
|
94
|
-
strokeDashoffset: 20,
|
|
95
|
-
animation: "flopay-draw 0.4s 0.15s ease forwards"
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
])
|
|
99
|
-
]);
|
|
100
|
-
}
|
|
101
|
-
return (0, import_vue.h)("div", { style: { animation: "flopay-shake 0.4s ease" } }, [
|
|
102
|
-
(0, import_vue.h)("svg", SVG, [
|
|
103
|
-
(0, import_vue.h)("circle", { cx: "12", cy: "12", r: "11", fill: "#ef4444" }),
|
|
104
|
-
(0, import_vue.h)("path", {
|
|
105
|
-
d: "M8 8l8 8M16 8l-8 8",
|
|
106
|
-
stroke: "white",
|
|
107
|
-
"stroke-width": "2.5",
|
|
108
|
-
"stroke-linecap": "round",
|
|
109
|
-
style: {
|
|
110
|
-
strokeDasharray: 12,
|
|
111
|
-
strokeDashoffset: 12,
|
|
112
|
-
animation: "flopay-draw 0.3s 0.1s ease forwards"
|
|
113
|
-
}
|
|
114
|
-
})
|
|
115
|
-
])
|
|
116
|
-
]);
|
|
35
|
+
var ERROR_TYPES = /* @__PURE__ */ new Set([
|
|
36
|
+
"validation_error",
|
|
37
|
+
"api_error",
|
|
38
|
+
"authentication_error",
|
|
39
|
+
"rate_limit_error",
|
|
40
|
+
"network_error"
|
|
41
|
+
]);
|
|
42
|
+
function setupError(message, type, retryable, options = {}) {
|
|
43
|
+
return Object.assign(new import_shared.FloPayError(message, type, options), { retryable });
|
|
117
44
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
errorLabel: { type: String, default: "PAYMENT FAILED" },
|
|
126
|
-
/** Success sub-note; `null` omits it (surfaces that do not redirect). */
|
|
127
|
-
successNote: {
|
|
128
|
-
type: String,
|
|
129
|
-
default: "You will be automatically redirected, do not close or navigate away from this window."
|
|
130
|
-
},
|
|
131
|
-
theme: { type: Object, default: void 0 }
|
|
132
|
-
},
|
|
133
|
-
setup(props) {
|
|
134
|
-
(0, import_vue.onMounted)(ensureKeyframes);
|
|
135
|
-
return () => {
|
|
136
|
-
const theme = props.theme ?? NEUTRAL_THEME;
|
|
137
|
-
const noteStyle = {
|
|
138
|
-
fontSize: "13px",
|
|
139
|
-
color: theme.noteColor,
|
|
140
|
-
fontWeight: 400,
|
|
141
|
-
maxWidth: "260px",
|
|
142
|
-
lineHeight: 1.4,
|
|
143
|
-
margin: 0
|
|
144
|
-
};
|
|
145
|
-
const label = {
|
|
146
|
-
processing: props.processingLabel,
|
|
147
|
-
success: props.successLabel,
|
|
148
|
-
error: props.errorLabel
|
|
149
|
-
}[props.status];
|
|
150
|
-
const note = { processing: null, success: props.successNote, error: props.errorMessage }[props.status];
|
|
151
|
-
return (0, import_vue.h)(
|
|
152
|
-
"div",
|
|
153
|
-
{
|
|
154
|
-
"data-testid": "flopay-processing-overlay",
|
|
155
|
-
"data-status": props.status,
|
|
156
|
-
// The attribute the Vue setup surfaces' overlay already carried.
|
|
157
|
-
"data-state": props.status,
|
|
158
|
-
role: "dialog",
|
|
159
|
-
"aria-modal": "true",
|
|
160
|
-
style: {
|
|
161
|
-
position: "fixed",
|
|
162
|
-
inset: 0,
|
|
163
|
-
background: "rgba(0,0,0,0.35)",
|
|
164
|
-
display: "flex",
|
|
165
|
-
alignItems: "center",
|
|
166
|
-
justifyContent: "center",
|
|
167
|
-
zIndex: 1e3,
|
|
168
|
-
backdropFilter: "blur(2px)"
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
[
|
|
172
|
-
(0, import_vue.h)(
|
|
173
|
-
"div",
|
|
174
|
-
{
|
|
175
|
-
"data-testid": "flopay-processing-overlay-panel",
|
|
176
|
-
style: {
|
|
177
|
-
borderRadius: "12px",
|
|
178
|
-
boxShadow: "0 8px 32px rgba(0,0,0,0.18)",
|
|
179
|
-
...theme.panel,
|
|
180
|
-
padding: "2rem 2.5rem",
|
|
181
|
-
textAlign: "center",
|
|
182
|
-
minWidth: "240px",
|
|
183
|
-
display: "flex",
|
|
184
|
-
flexDirection: "column",
|
|
185
|
-
alignItems: "center",
|
|
186
|
-
gap: "16px"
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
[
|
|
190
|
-
(0, import_vue.h)("div", { style: { width: "48px", height: "48px", position: "relative" } }, [
|
|
191
|
-
statusIcon(props.status, theme)
|
|
192
|
-
]),
|
|
193
|
-
(0, import_vue.h)(
|
|
194
|
-
"span",
|
|
195
|
-
{
|
|
196
|
-
"data-testid": "flopay-processing-overlay-label",
|
|
197
|
-
style: {
|
|
198
|
-
fontSize: "14px",
|
|
199
|
-
fontWeight: 600,
|
|
200
|
-
letterSpacing: "0.05em",
|
|
201
|
-
color: theme.labelColors[props.status]
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
label
|
|
205
|
-
),
|
|
206
|
-
note ? (0, import_vue.h)("p", { style: noteStyle }, note) : null
|
|
207
|
-
]
|
|
208
|
-
)
|
|
209
|
-
]
|
|
210
|
-
);
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
// src/hosted-setup.ts
|
|
216
|
-
var FloPayCardSetupError = class extends import_shared.FloPayError {
|
|
217
|
-
constructor(message, type, options) {
|
|
218
|
-
super(message, type, options);
|
|
219
|
-
this.name = "FloPayCardSetupError";
|
|
220
|
-
this.retryable = options.retryable;
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
function asCardSetupError(error, overrides = {}) {
|
|
224
|
-
const source = error instanceof import_shared.FloPayError ? error : void 0;
|
|
225
|
-
const statusCode = source?.statusCode;
|
|
226
|
-
const retryable = overrides.retryable ?? (source?.type === "network_error" || source?.type === "rate_limit_error" || typeof statusCode === "number" && statusCode >= 500 || source?.code === "vault_capture_timeout" || !source);
|
|
227
|
-
return new FloPayCardSetupError(
|
|
228
|
-
source?.message ?? (error instanceof Error ? error.message : "Failed to load the secure card form."),
|
|
229
|
-
source?.type ?? "api_error",
|
|
45
|
+
function errorFromPayload(payload) {
|
|
46
|
+
const record = isRecord(payload) ? payload : {};
|
|
47
|
+
const type = typeof record.type === "string" && ERROR_TYPES.has(record.type) ? record.type : "";
|
|
48
|
+
return setupError(
|
|
49
|
+
typeof record.message === "string" ? record.message : "The setup failed.",
|
|
50
|
+
type || "api_error",
|
|
51
|
+
record.retryable === true,
|
|
230
52
|
{
|
|
231
|
-
code:
|
|
232
|
-
|
|
233
|
-
...
|
|
234
|
-
...statusCode === void 0 ? {} : { statusCode }
|
|
53
|
+
...typeof record.code === "string" ? { code: record.code } : {},
|
|
54
|
+
...typeof record.param === "string" ? { param: record.param } : {},
|
|
55
|
+
...typeof record.statusCode === "number" ? { statusCode: record.statusCode } : {}
|
|
235
56
|
}
|
|
236
57
|
);
|
|
237
58
|
}
|
|
238
|
-
function
|
|
239
|
-
|
|
240
|
-
(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
);
|
|
250
|
-
const overlayTheme = (0, import_vue2.computed)(() => resolved.value.overlayTheme);
|
|
251
|
-
const appearance = (0, import_vue2.computed)(() => resolved.value.appearance);
|
|
252
|
-
return { vaultTheme, surfaceStyle, overlayTheme, appearance };
|
|
59
|
+
function loadError(caught) {
|
|
60
|
+
if (caught instanceof import_shared.FloPayError) {
|
|
61
|
+
return setupError(caught.message, caught.type, true, {
|
|
62
|
+
code: caught.code ?? "runtime_load_failed",
|
|
63
|
+
cause: caught
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return setupError("The checkout runtime failed to load.", "network_error", true, {
|
|
67
|
+
code: "runtime_load_failed",
|
|
68
|
+
cause: caught
|
|
69
|
+
});
|
|
253
70
|
}
|
|
254
|
-
function
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
let completed = false;
|
|
262
|
-
let submissionInFlight = false;
|
|
263
|
-
let clearTimer = null;
|
|
264
|
-
const offs = [];
|
|
265
|
-
const sessionId = () => props.sessionId ?? "";
|
|
266
|
-
const showOverlay = (state) => {
|
|
267
|
-
if (clearTimer) clearTimeout(clearTimer);
|
|
268
|
-
clearTimer = null;
|
|
269
|
-
emitters.overlay(state);
|
|
270
|
-
};
|
|
271
|
-
const holdFailure = (message) => {
|
|
272
|
-
showOverlay({ status: "error", message });
|
|
273
|
-
clearTimer = setTimeout(() => {
|
|
274
|
-
clearTimer = null;
|
|
275
|
-
if (active) emitters.overlay(null);
|
|
276
|
-
}, PROCESSING_OVERLAY_ERROR_DELAY_MS);
|
|
277
|
-
};
|
|
278
|
-
const bind = (adapter) => {
|
|
279
|
-
submissionInFlight = false;
|
|
280
|
-
offs.push(
|
|
281
|
-
adapter.on("submitting", () => {
|
|
282
|
-
submissionInFlight = true;
|
|
283
|
-
showOverlay({ status: "processing", message: null });
|
|
284
|
-
}),
|
|
285
|
-
adapter.on("complete", (event) => {
|
|
286
|
-
terminal = true;
|
|
287
|
-
submissionInFlight = false;
|
|
288
|
-
showOverlay({ status: "success", message: null });
|
|
289
|
-
setTimeout(() => {
|
|
290
|
-
if (completed) return;
|
|
291
|
-
completed = true;
|
|
292
|
-
(0, import_shared.invokeMerchantCallback)(
|
|
293
|
-
() => emitters.complete({
|
|
294
|
-
status: "succeeded",
|
|
295
|
-
sessionId: sessionId(),
|
|
296
|
-
...event.paymentMethod ? { paymentMethod: event.paymentMethod } : {}
|
|
297
|
-
})
|
|
298
|
-
);
|
|
299
|
-
if (active) emitters.overlay(null);
|
|
300
|
-
}, PROCESSING_OVERLAY_SUCCESS_DELAY_MS);
|
|
301
|
-
}),
|
|
302
|
-
adapter.on("decline", (event) => {
|
|
303
|
-
terminal = true;
|
|
304
|
-
submissionInFlight = false;
|
|
305
|
-
holdFailure(event.message ?? null);
|
|
306
|
-
(0, import_shared.invokeMerchantCallback)(
|
|
307
|
-
() => emitters.decline({
|
|
308
|
-
status: "declined",
|
|
309
|
-
sessionId: sessionId(),
|
|
310
|
-
...event.declineReason ? { reason: event.declineReason } : {},
|
|
311
|
-
...event.message ? { message: event.message } : {}
|
|
312
|
-
})
|
|
313
|
-
);
|
|
314
|
-
}),
|
|
315
|
-
// Closing the bank's authentication window is not an outcome: the hosted
|
|
316
|
-
// form keeps polling and may still report one. Drop the overlay but keep
|
|
317
|
-
// the submission in flight, so a late failure still shows "CARD NOT SAVED".
|
|
318
|
-
adapter.on("challenge_dismissed", () => {
|
|
319
|
-
showOverlay(null);
|
|
320
|
-
})
|
|
321
|
-
);
|
|
71
|
+
function setupConfig(props) {
|
|
72
|
+
return {
|
|
73
|
+
...props.theme === void 0 ? {} : { theme: props.theme },
|
|
74
|
+
...props.appearance === void 0 ? {} : { appearance: props.appearance },
|
|
75
|
+
...props.buttonsStyles === void 0 ? {} : { buttonsStyles: props.buttonsStyles },
|
|
76
|
+
...props.containerStyle === void 0 ? {} : { containerStyle: props.containerStyle },
|
|
77
|
+
...props.strings === void 0 ? {} : { strings: props.strings }
|
|
322
78
|
};
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
79
|
+
}
|
|
80
|
+
var setupProps = {
|
|
81
|
+
sessionId: { type: String, required: true },
|
|
82
|
+
nonce: { type: String, required: true },
|
|
83
|
+
theme: {
|
|
84
|
+
type: [String, Object],
|
|
85
|
+
default: void 0
|
|
86
|
+
},
|
|
87
|
+
appearance: { type: Object, default: void 0 },
|
|
88
|
+
buttonsStyles: { type: Object, default: void 0 },
|
|
89
|
+
containerStyle: {
|
|
90
|
+
type: Object,
|
|
91
|
+
default: void 0
|
|
92
|
+
},
|
|
93
|
+
strings: { type: Object, default: void 0 },
|
|
94
|
+
runtimeUrl: { type: String, required: true },
|
|
95
|
+
runtimeTimeoutMs: { type: Number, default: void 0 }
|
|
96
|
+
};
|
|
97
|
+
var setupEmits = {
|
|
98
|
+
ready: () => true,
|
|
99
|
+
validation: (_message) => true,
|
|
100
|
+
complete: (_event) => true,
|
|
101
|
+
decline: (_event) => true,
|
|
102
|
+
cancel: (_event) => true,
|
|
103
|
+
error: (_error) => true
|
|
104
|
+
};
|
|
105
|
+
var LISTENERS = {
|
|
106
|
+
ready: "onReady",
|
|
107
|
+
validation: "onValidation",
|
|
108
|
+
complete: "onComplete",
|
|
109
|
+
decline: "onDecline",
|
|
110
|
+
cancel: "onCancel",
|
|
111
|
+
error: "onError"
|
|
112
|
+
};
|
|
113
|
+
function setupRuntimeSetup(kind, props, emit) {
|
|
114
|
+
const instance = (0, import_vue.getCurrentInstance)();
|
|
115
|
+
const container = (0, import_vue.ref)(null);
|
|
116
|
+
let handle = null;
|
|
117
|
+
let generation = 0;
|
|
118
|
+
const deliver = (name, argument) => {
|
|
326
119
|
try {
|
|
327
|
-
if (
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
if (!props.nonce?.trim()) {
|
|
334
|
-
throw new import_shared.FloPayError("A setup surface requires a session nonce.", "validation_error", {
|
|
335
|
-
code: "MissingCheckoutSessionToken",
|
|
336
|
-
param: "nonce"
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
const result = await api.getUnifiedCheckoutSession(sessionId(), props.nonce);
|
|
340
|
-
const read = result.data.session;
|
|
341
|
-
if (!read || !(0, import_shared.isCardSetupCheckoutSession)(read)) {
|
|
342
|
-
throw new import_shared.FloPayError(
|
|
343
|
-
"Only a zero-amount, productless setup session is accepted.",
|
|
344
|
-
"validation_error",
|
|
345
|
-
{ code: "InvalidCardSetupSession", param: "sessionId" }
|
|
346
|
-
);
|
|
120
|
+
if (instance?.isUnmounted) {
|
|
121
|
+
const listener = instance.vnode.props?.[LISTENERS[name]];
|
|
122
|
+
if (typeof listener === "function") listener(argument);
|
|
123
|
+
return;
|
|
347
124
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
let block = read.vault;
|
|
352
|
-
if (!(0, import_shared.isMountableVaultBlock)(block))
|
|
353
|
-
block = await api.getVaultCapture(sessionId(), props.nonce);
|
|
354
|
-
const mount = (0, import_shared.resolveVaultMountOptions)(block, {
|
|
355
|
-
billingApiUrl,
|
|
356
|
-
sessionId: sessionId(),
|
|
357
|
-
nonce: props.nonce
|
|
358
|
-
});
|
|
359
|
-
if (!mount) {
|
|
360
|
-
throw new import_shared.FloPayError(
|
|
361
|
-
"FloPay: this setup session has no vault card capability. Upgrade the billing backend integration.",
|
|
362
|
-
"api_error",
|
|
363
|
-
{ code: "UnsupportedBackendVaultCapability" }
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
if (!active) return;
|
|
367
|
-
const adapter = new import_card_setup.PciVaultCardCapture({
|
|
368
|
-
sessionId: sessionId(),
|
|
369
|
-
operation: "card_setup",
|
|
370
|
-
telemetry: props.telemetry
|
|
371
|
-
});
|
|
372
|
-
bind(adapter);
|
|
373
|
-
vault.value = mount;
|
|
374
|
-
capture.value = adapter;
|
|
375
|
-
} catch (error) {
|
|
376
|
-
if (!active) return;
|
|
377
|
-
terminal = true;
|
|
378
|
-
const failure = asCardSetupError(error);
|
|
379
|
-
loadError.value = failure;
|
|
380
|
-
(0, import_shared.invokeMerchantCallback)(() => emitters.error(failure));
|
|
381
|
-
} finally {
|
|
382
|
-
api.destroy();
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
(0, import_vue2.onBeforeUnmount)(() => {
|
|
386
|
-
active = false;
|
|
387
|
-
if (clearTimer) clearTimeout(clearTimer);
|
|
388
|
-
clearTimer = null;
|
|
389
|
-
for (const off of offs.splice(0)) off();
|
|
390
|
-
if (!terminal && sessionId()) {
|
|
391
|
-
(0, import_shared.invokeMerchantCallback)(
|
|
392
|
-
() => emitters.cancel({ status: "cancelled", sessionId: sessionId() })
|
|
125
|
+
emit(
|
|
126
|
+
name,
|
|
127
|
+
...argument === void 0 ? [] : [argument]
|
|
393
128
|
);
|
|
129
|
+
} catch {
|
|
394
130
|
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
131
|
+
};
|
|
132
|
+
const onEvent = (event) => {
|
|
133
|
+
const payload = event.payload;
|
|
134
|
+
switch (event.name) {
|
|
135
|
+
case "setupReady":
|
|
136
|
+
deliver("ready");
|
|
137
|
+
return;
|
|
138
|
+
case "setupValidation":
|
|
139
|
+
deliver(
|
|
140
|
+
"validation",
|
|
141
|
+
isRecord(payload) && typeof payload.message === "string" ? payload.message : null
|
|
142
|
+
);
|
|
143
|
+
return;
|
|
144
|
+
case "complete":
|
|
145
|
+
case "decline":
|
|
146
|
+
case "cancel":
|
|
147
|
+
deliver(event.name, payload);
|
|
148
|
+
return;
|
|
149
|
+
case "error":
|
|
150
|
+
deliver("error", errorFromPayload(payload));
|
|
151
|
+
return;
|
|
152
|
+
default:
|
|
153
|
+
return;
|
|
408
154
|
}
|
|
409
155
|
};
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
let appliedTheme = null;
|
|
439
|
-
const mountWidget = () => {
|
|
440
|
-
teardown?.();
|
|
441
|
-
teardown = null;
|
|
442
|
-
const el = container.value;
|
|
443
|
-
const { capture, html } = props;
|
|
444
|
-
if (!el || !capture || !html) return;
|
|
445
|
-
let active = true;
|
|
446
|
-
let readyEmitted = false;
|
|
447
|
-
const emitReadyOnce = () => {
|
|
448
|
-
if (!active || readyEmitted) return;
|
|
449
|
-
readyEmitted = true;
|
|
450
|
-
(0, import_shared2.invokeMerchantCallback)(() => emit("ready"));
|
|
451
|
-
};
|
|
452
|
-
const offReady = capture.on("ready", emitReadyOnce);
|
|
453
|
-
const offError = capture.on("error", (event) => {
|
|
454
|
-
const message = (0, import_shared2.buyerEmailRequiredPrompt)(event.vaultOutcome) ?? event.message ?? "There was a problem loading the secure card form.";
|
|
455
|
-
(0, import_shared2.invokeMerchantCallback)(() => emit("error", message));
|
|
456
|
-
});
|
|
457
|
-
const offValidation = capture.on("validation", (event) => {
|
|
458
|
-
(0, import_shared2.invokeMerchantCallback)(() => emit("validation", event.message ?? null));
|
|
459
|
-
});
|
|
460
|
-
const label = props.submitLabel ?? void 0;
|
|
461
|
-
const labelDirective = label ?? (labelledCaptures.has(capture) ? null : void 0);
|
|
462
|
-
appliedLabel = label;
|
|
463
|
-
appliedTheme = props.theme ?? null;
|
|
464
|
-
if (label !== void 0) labelledCaptures.add(capture);
|
|
465
|
-
capture.mount(el, {
|
|
466
|
-
html,
|
|
467
|
-
...props.messageToken ? { messageToken: props.messageToken } : {},
|
|
468
|
-
...props.expectedOrigin ? { expectedOrigin: props.expectedOrigin } : {},
|
|
469
|
-
...typeof props.expiresAt === "string" ? { expiresAt: props.expiresAt } : {},
|
|
470
|
-
...props.verificationRequired ? { verificationRequired: true } : {},
|
|
471
|
-
...props.theme ? { theme: props.theme } : {},
|
|
472
|
-
...labelDirective === void 0 ? {} : { submitLabel: labelDirective }
|
|
473
|
-
}).then(emitReadyOnce).catch((error) => {
|
|
474
|
-
if (!active) return;
|
|
475
|
-
const message = error instanceof Error ? error.message : "Failed to load the secure card form.";
|
|
476
|
-
(0, import_shared2.invokeMerchantCallback)(() => emit("error", message));
|
|
477
|
-
});
|
|
478
|
-
teardown = () => {
|
|
479
|
-
active = false;
|
|
480
|
-
offReady();
|
|
481
|
-
offError();
|
|
482
|
-
offValidation();
|
|
483
|
-
capture.unmount();
|
|
484
|
-
};
|
|
485
|
-
};
|
|
486
|
-
(0, import_vue3.onMounted)(() => {
|
|
487
|
-
mountWidget();
|
|
488
|
-
(0, import_vue3.watch)(
|
|
489
|
-
() => [
|
|
490
|
-
props.capture,
|
|
491
|
-
props.html,
|
|
492
|
-
props.messageToken,
|
|
493
|
-
props.expectedOrigin,
|
|
494
|
-
props.expiresAt,
|
|
495
|
-
props.verificationRequired
|
|
496
|
-
],
|
|
497
|
-
mountWidget
|
|
498
|
-
);
|
|
499
|
-
(0, import_vue3.watch)(
|
|
500
|
-
() => props.theme,
|
|
501
|
-
(theme) => {
|
|
502
|
-
if (theme === void 0) return;
|
|
503
|
-
if (theme === null && appliedTheme === null) return;
|
|
504
|
-
appliedTheme = theme;
|
|
505
|
-
props.capture?.applyTheme?.(theme);
|
|
506
|
-
}
|
|
507
|
-
);
|
|
508
|
-
(0, import_vue3.watch)(
|
|
509
|
-
() => props.submitLabel ?? void 0,
|
|
510
|
-
(label) => {
|
|
511
|
-
if (!props.capture || label === appliedLabel) return;
|
|
512
|
-
appliedLabel = label;
|
|
513
|
-
if (label !== void 0) labelledCaptures.add(props.capture);
|
|
514
|
-
props.capture.setSubmitLabel?.(label ?? null);
|
|
515
|
-
}
|
|
516
|
-
);
|
|
517
|
-
});
|
|
518
|
-
(0, import_vue3.onBeforeUnmount)(() => {
|
|
519
|
-
teardown?.();
|
|
520
|
-
teardown = null;
|
|
521
|
-
});
|
|
522
|
-
return () => (0, import_vue3.h)("div", {
|
|
523
|
-
ref: container,
|
|
524
|
-
"data-testid": "flopay-vault-card-fields",
|
|
525
|
-
style: props.containerStyle
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
|
|
530
|
-
// src/flopay-card-setup.ts
|
|
531
|
-
var FloPayCardSetup = (0, import_vue4.defineComponent)({
|
|
532
|
-
name: "FloPayCardSetup",
|
|
533
|
-
props: {
|
|
534
|
-
sessionId: { type: String, default: void 0 },
|
|
535
|
-
nonce: { type: String, default: void 0 },
|
|
536
|
-
billingApiUrl: { type: String, default: void 0 },
|
|
537
|
-
telemetry: { type: Boolean, default: void 0 },
|
|
538
|
-
theme: {
|
|
539
|
-
type: [String, Object],
|
|
540
|
-
default: "modern-light"
|
|
541
|
-
},
|
|
542
|
-
containerStyle: {
|
|
543
|
-
type: Object,
|
|
544
|
-
default: void 0
|
|
545
|
-
},
|
|
546
|
-
appearance: { type: Object, default: void 0 },
|
|
547
|
-
buttonsStyles: { type: Object, default: void 0 }
|
|
548
|
-
},
|
|
549
|
-
emits: {
|
|
550
|
-
ready: () => true,
|
|
551
|
-
complete: (_event) => true,
|
|
552
|
-
cancel: (_event) => true,
|
|
553
|
-
decline: (_event) => true,
|
|
554
|
-
validation: (_message) => true,
|
|
555
|
-
error: (_error) => true
|
|
556
|
-
},
|
|
557
|
-
setup(props, { emit, slots }) {
|
|
558
|
-
const overlay = (0, import_vue4.shallowRef)(null);
|
|
559
|
-
const setup = useHostedSetup(
|
|
560
|
-
props,
|
|
561
|
-
{
|
|
562
|
-
complete: (event) => emit("complete", event),
|
|
563
|
-
decline: (event) => emit("decline", event),
|
|
564
|
-
cancel: (event) => emit("cancel", event),
|
|
565
|
-
error: (error) => emit("error", error),
|
|
566
|
-
overlay: (state) => {
|
|
567
|
-
overlay.value = state;
|
|
156
|
+
const stop = () => {
|
|
157
|
+
generation += 1;
|
|
158
|
+
const current = handle;
|
|
159
|
+
handle = null;
|
|
160
|
+
current?.unmount();
|
|
161
|
+
};
|
|
162
|
+
const start = () => {
|
|
163
|
+
const element = container.value;
|
|
164
|
+
if (!element) return;
|
|
165
|
+
generation += 1;
|
|
166
|
+
const current = generation;
|
|
167
|
+
(0, import_js.loadCheckoutRuntime)({
|
|
168
|
+
runtimeUrl: props.runtimeUrl,
|
|
169
|
+
...props.runtimeTimeoutMs === void 0 ? {} : { timeoutMs: props.runtimeTimeoutMs }
|
|
170
|
+
}).then(
|
|
171
|
+
(runtime) => {
|
|
172
|
+
if (current !== generation) return;
|
|
173
|
+
if (typeof runtime.mountSetup !== "function") {
|
|
174
|
+
deliver(
|
|
175
|
+
"error",
|
|
176
|
+
setupError(
|
|
177
|
+
"The checkout runtime on this page is too old to run setup.",
|
|
178
|
+
"api_error",
|
|
179
|
+
false,
|
|
180
|
+
{ code: "runtime_setup_unsupported" }
|
|
181
|
+
)
|
|
182
|
+
);
|
|
183
|
+
return;
|
|
568
184
|
}
|
|
185
|
+
handle = runtime.mountSetup(element, {
|
|
186
|
+
setup: kind,
|
|
187
|
+
sessionId: props.sessionId,
|
|
188
|
+
nonce: props.nonce,
|
|
189
|
+
contractVersion: SETUP_CONTRACT_VERSION,
|
|
190
|
+
...setupConfig(props),
|
|
191
|
+
onEvent
|
|
192
|
+
});
|
|
569
193
|
},
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
const theme = useCardSetupTheme(props);
|
|
573
|
-
return () => {
|
|
574
|
-
if (setup.loadError.value) {
|
|
575
|
-
return (0, import_vue4.h)("div", { role: "alert" }, setup.loadError.value.message);
|
|
194
|
+
(caught) => {
|
|
195
|
+
if (current === generation) deliver("error", loadError(caught));
|
|
576
196
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
}
|
|
609
|
-
})
|
|
610
|
-
];
|
|
611
|
-
};
|
|
197
|
+
);
|
|
198
|
+
};
|
|
199
|
+
(0, import_vue.onMounted)(start);
|
|
200
|
+
(0, import_vue.watch)(
|
|
201
|
+
() => [props.sessionId, props.nonce, props.runtimeUrl, props.runtimeTimeoutMs],
|
|
202
|
+
() => {
|
|
203
|
+
stop();
|
|
204
|
+
start();
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
(0, import_vue.watch)(
|
|
208
|
+
() => JSON.stringify(setupConfig(props)),
|
|
209
|
+
() => {
|
|
210
|
+
handle?.update({
|
|
211
|
+
theme: props.theme,
|
|
212
|
+
appearance: props.appearance,
|
|
213
|
+
buttonsStyles: props.buttonsStyles,
|
|
214
|
+
containerStyle: props.containerStyle,
|
|
215
|
+
strings: props.strings
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
(0, import_vue.onBeforeUnmount)(stop);
|
|
220
|
+
return () => (0, import_vue.h)("div", { ref: container });
|
|
221
|
+
}
|
|
222
|
+
var FloPayRuntimeCardSetup = (0, import_vue.defineComponent)({
|
|
223
|
+
name: "FloPayRuntimeCardSetup",
|
|
224
|
+
props: setupProps,
|
|
225
|
+
emits: setupEmits,
|
|
226
|
+
setup(props, { emit }) {
|
|
227
|
+
return setupRuntimeSetup("card", props, emit);
|
|
612
228
|
}
|
|
613
229
|
});
|
|
614
230
|
// Annotate the CommonJS export names for ESM import in node:
|
|
615
231
|
0 && (module.exports = {
|
|
616
|
-
FloPayCardSetup
|
|
617
|
-
FloPayCardSetupError
|
|
232
|
+
FloPayCardSetup
|
|
618
233
|
});
|