@flopay/vue 1.20.15 → 2.0.1
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 +298 -5402
- package/dist/index.d.ts +3 -21
- package/dist/index.mjs +250 -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
package/dist/chunk-IJKGJSHH.mjs
DELETED
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PROCESSING_OVERLAY_ERROR_DELAY_MS,
|
|
3
|
-
PROCESSING_OVERLAY_SUCCESS_DELAY_MS,
|
|
4
|
-
ProcessingOverlay,
|
|
5
|
-
VaultCardFields,
|
|
6
|
-
asCardSetupError,
|
|
7
|
-
useCardSetupTheme,
|
|
8
|
-
useHostedSetup
|
|
9
|
-
} from "./chunk-2USKULEH.mjs";
|
|
10
|
-
|
|
11
|
-
// src/flopay-payment-method-setup-main.ts
|
|
12
|
-
import {
|
|
13
|
-
clearSetupRedirectParams,
|
|
14
|
-
PaymentAPI,
|
|
15
|
-
readSetupRedirectReturn
|
|
16
|
-
} from "@flopay/js/card-setup";
|
|
17
|
-
import {
|
|
18
|
-
FloPayError,
|
|
19
|
-
invokeMerchantCallback,
|
|
20
|
-
readSetupAdvertisement,
|
|
21
|
-
resolveBillingApiUrl,
|
|
22
|
-
setupOverlayLabels,
|
|
23
|
-
stripeMethodCategory
|
|
24
|
-
} from "@flopay/shared";
|
|
25
|
-
import {
|
|
26
|
-
defineAsyncComponent,
|
|
27
|
-
defineComponent,
|
|
28
|
-
h,
|
|
29
|
-
onBeforeUnmount,
|
|
30
|
-
onMounted,
|
|
31
|
-
ref,
|
|
32
|
-
shallowRef,
|
|
33
|
-
watch
|
|
34
|
-
} from "vue";
|
|
35
|
-
var VERIFY_ATTEMPTS = 15;
|
|
36
|
-
var VERIFY_INTERVAL_MS = 2e3;
|
|
37
|
-
function delay(ms) {
|
|
38
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
39
|
-
}
|
|
40
|
-
var StripeSetupMethods = defineAsyncComponent(
|
|
41
|
-
() => import("./stripe-elements-SI2PI6EO.mjs").then((module) => module.StripePaymentMethods)
|
|
42
|
-
);
|
|
43
|
-
var PayPalSetupMethods = defineAsyncComponent(
|
|
44
|
-
() => import("./payment-method-setup-paypal-D6FEQQJY.mjs").then((module) => module.PayPalSetupMethod)
|
|
45
|
-
);
|
|
46
|
-
var FloPayPaymentMethodSetup = defineComponent({
|
|
47
|
-
name: "FloPayPaymentMethodSetup",
|
|
48
|
-
props: {
|
|
49
|
-
sessionId: { type: String, default: void 0 },
|
|
50
|
-
nonce: { type: String, default: void 0 },
|
|
51
|
-
billingApiUrl: { type: String, default: void 0 },
|
|
52
|
-
telemetry: { type: Boolean, default: void 0 },
|
|
53
|
-
theme: {
|
|
54
|
-
type: [String, Object],
|
|
55
|
-
default: "modern-light"
|
|
56
|
-
},
|
|
57
|
-
containerStyle: {
|
|
58
|
-
type: Object,
|
|
59
|
-
default: void 0
|
|
60
|
-
},
|
|
61
|
-
appearance: { type: Object, default: void 0 },
|
|
62
|
-
buttonsStyles: { type: Object, default: void 0 }
|
|
63
|
-
},
|
|
64
|
-
emits: {
|
|
65
|
-
ready: () => true,
|
|
66
|
-
complete: (_event) => true,
|
|
67
|
-
cancel: (_event) => true,
|
|
68
|
-
decline: (_event) => true,
|
|
69
|
-
validation: (_message) => true,
|
|
70
|
-
error: (_error) => true
|
|
71
|
-
},
|
|
72
|
-
setup(props, { emit, slots }) {
|
|
73
|
-
const overlay = shallowRef(null);
|
|
74
|
-
const setup = useHostedSetup(
|
|
75
|
-
props,
|
|
76
|
-
{
|
|
77
|
-
complete: (event) => emit("complete", event),
|
|
78
|
-
decline: (event) => emit("decline", event),
|
|
79
|
-
cancel: (event) => emit("cancel", event),
|
|
80
|
-
error: (error) => emit("error", error),
|
|
81
|
-
// The hosted card's outcome overlay, in card wording (React's `'card'`).
|
|
82
|
-
overlay: (state) => {
|
|
83
|
-
showOverlay(state ? { ...state, wording: "card" } : null);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
{ requireVault: (session) => readSetupAdvertisement(session).card }
|
|
87
|
-
);
|
|
88
|
-
const theme = useCardSetupTheme(props);
|
|
89
|
-
const verified = ref(false);
|
|
90
|
-
let mounted = false;
|
|
91
|
-
let submissionInFlight = false;
|
|
92
|
-
let completionEmitted = false;
|
|
93
|
-
let verificationGeneration = 0;
|
|
94
|
-
let overlayTimer = null;
|
|
95
|
-
const sessionId = () => props.sessionId ?? "";
|
|
96
|
-
const showOverlay = (next) => {
|
|
97
|
-
if (overlayTimer) clearTimeout(overlayTimer);
|
|
98
|
-
overlayTimer = null;
|
|
99
|
-
overlay.value = next;
|
|
100
|
-
};
|
|
101
|
-
const clearOverlayLater = () => {
|
|
102
|
-
overlayTimer = setTimeout(() => {
|
|
103
|
-
overlayTimer = null;
|
|
104
|
-
if (mounted) overlay.value = null;
|
|
105
|
-
}, PROCESSING_OVERLAY_ERROR_DELAY_MS);
|
|
106
|
-
};
|
|
107
|
-
onMounted(() => {
|
|
108
|
-
mounted = true;
|
|
109
|
-
});
|
|
110
|
-
onBeforeUnmount(() => {
|
|
111
|
-
mounted = false;
|
|
112
|
-
verificationGeneration += 1;
|
|
113
|
-
if (overlayTimer) clearTimeout(overlayTimer);
|
|
114
|
-
overlayTimer = null;
|
|
115
|
-
});
|
|
116
|
-
const reportVerified = () => {
|
|
117
|
-
setup.settle();
|
|
118
|
-
submissionInFlight = false;
|
|
119
|
-
verified.value = true;
|
|
120
|
-
showOverlay({ status: "success", wording: "payment_method", message: null });
|
|
121
|
-
setTimeout(() => {
|
|
122
|
-
if (completionEmitted) return;
|
|
123
|
-
completionEmitted = true;
|
|
124
|
-
invokeMerchantCallback(
|
|
125
|
-
() => emit("complete", { status: "succeeded", sessionId: sessionId() })
|
|
126
|
-
);
|
|
127
|
-
if (mounted) overlay.value = null;
|
|
128
|
-
}, PROCESSING_OVERLAY_SUCCESS_DELAY_MS);
|
|
129
|
-
};
|
|
130
|
-
const reportDecline = (event) => {
|
|
131
|
-
setup.settle();
|
|
132
|
-
submissionInFlight = false;
|
|
133
|
-
showOverlay({ status: "error", wording: "payment_method", message: event.message ?? null });
|
|
134
|
-
invokeMerchantCallback(
|
|
135
|
-
() => emit("decline", {
|
|
136
|
-
status: "declined",
|
|
137
|
-
sessionId: sessionId(),
|
|
138
|
-
...event.reason ? { reason: event.reason } : {},
|
|
139
|
-
...event.message ? { message: event.message } : {}
|
|
140
|
-
})
|
|
141
|
-
);
|
|
142
|
-
clearOverlayLater();
|
|
143
|
-
};
|
|
144
|
-
const reportFailure = (error) => {
|
|
145
|
-
if (submissionInFlight) {
|
|
146
|
-
submissionInFlight = false;
|
|
147
|
-
showOverlay({ status: "error", wording: "payment_method", message: error.message });
|
|
148
|
-
clearOverlayLater();
|
|
149
|
-
} else {
|
|
150
|
-
showOverlay(null);
|
|
151
|
-
}
|
|
152
|
-
invokeMerchantCallback(() => emit("error", error));
|
|
153
|
-
};
|
|
154
|
-
const verifySetup = async (options = {}) => {
|
|
155
|
-
verificationGeneration += 1;
|
|
156
|
-
const generation = verificationGeneration;
|
|
157
|
-
const stale = () => !mounted || generation !== verificationGeneration;
|
|
158
|
-
submissionInFlight = true;
|
|
159
|
-
showOverlay({ status: "processing", wording: "payment_method", message: null });
|
|
160
|
-
const api = new PaymentAPI(resolveBillingApiUrl(props.billingApiUrl), {
|
|
161
|
-
telemetry: props.telemetry
|
|
162
|
-
});
|
|
163
|
-
try {
|
|
164
|
-
for (let attempt = 0; attempt < VERIFY_ATTEMPTS; attempt += 1) {
|
|
165
|
-
if (attempt > 0 || options.waitFirst) await delay(VERIFY_INTERVAL_MS);
|
|
166
|
-
if (stale()) return;
|
|
167
|
-
const result = await api.getUnifiedCheckoutSession(sessionId(), props.nonce);
|
|
168
|
-
if (stale()) return;
|
|
169
|
-
const status = result.data.session?.status;
|
|
170
|
-
if (status === "complete") {
|
|
171
|
-
reportVerified();
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (status === "expired") {
|
|
175
|
-
throw new FloPayError(
|
|
176
|
-
"This setup session expired before the payment method was saved.",
|
|
177
|
-
"validation_error",
|
|
178
|
-
{ code: "payment_method_setup_expired" }
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
throw new FloPayError(
|
|
183
|
-
"The payment method could not be confirmed yet. Please try again.",
|
|
184
|
-
"api_error",
|
|
185
|
-
{ code: "payment_method_setup_unverified" }
|
|
186
|
-
);
|
|
187
|
-
} catch (error) {
|
|
188
|
-
if (stale()) return;
|
|
189
|
-
const unverified = error instanceof FloPayError && error.code === "payment_method_setup_unverified";
|
|
190
|
-
reportFailure(asCardSetupError(error, unverified ? { retryable: true } : {}));
|
|
191
|
-
} finally {
|
|
192
|
-
api.destroy();
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
const redirectReturn = readSetupRedirectReturn();
|
|
196
|
-
if (redirectReturn) {
|
|
197
|
-
const stopRedirectWatch = watch(
|
|
198
|
-
() => setup.session.value,
|
|
199
|
-
(normalized) => {
|
|
200
|
-
if (!normalized) return;
|
|
201
|
-
stopRedirectWatch();
|
|
202
|
-
clearSetupRedirectParams();
|
|
203
|
-
if (normalized.data.session?.status === "complete") {
|
|
204
|
-
reportVerified();
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
if (redirectReturn.failed) {
|
|
208
|
-
reportDecline({ reason: "redirect_failed" });
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
void verifySetup({ waitFirst: true });
|
|
212
|
-
}
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
const overlayNode = () => {
|
|
216
|
-
const state = overlay.value;
|
|
217
|
-
if (!state) return null;
|
|
218
|
-
return h(ProcessingOverlay, {
|
|
219
|
-
status: state.status,
|
|
220
|
-
errorMessage: state.message,
|
|
221
|
-
...setupOverlayLabels(state.wording),
|
|
222
|
-
successNote: null,
|
|
223
|
-
...theme.overlayTheme.value ? { theme: theme.overlayTheme.value } : {}
|
|
224
|
-
});
|
|
225
|
-
};
|
|
226
|
-
return () => {
|
|
227
|
-
if (setup.loadError.value) {
|
|
228
|
-
return h("div", { role: "alert" }, setup.loadError.value.message);
|
|
229
|
-
}
|
|
230
|
-
const normalized = setup.session.value;
|
|
231
|
-
if (!normalized) return slots.loading?.() ?? null;
|
|
232
|
-
if (verified.value) {
|
|
233
|
-
return h("div", { "data-testid": "flopay-payment-method-setup" }, [overlayNode()]);
|
|
234
|
-
}
|
|
235
|
-
const advertisement = readSetupAdvertisement(normalized);
|
|
236
|
-
const session = normalized.data.session ?? null;
|
|
237
|
-
const billingApiUrl = resolveBillingApiUrl(props.billingApiUrl);
|
|
238
|
-
const stripeBranch = (entry) => h("div", { key: entry.method, "data-flopay-payment-method": entry.method }, [
|
|
239
|
-
h(StripeSetupMethods, {
|
|
240
|
-
session,
|
|
241
|
-
sessionId: sessionId(),
|
|
242
|
-
nonce: props.nonce,
|
|
243
|
-
billingApiUrl,
|
|
244
|
-
publishableKey: entry.publishableKey,
|
|
245
|
-
methods: [entry.method],
|
|
246
|
-
intentKind: "setup",
|
|
247
|
-
currency: entry.currency,
|
|
248
|
-
...theme.appearance.value ? { appearance: theme.appearance.value } : {},
|
|
249
|
-
// The provider said yes; wait for the backend to agree.
|
|
250
|
-
onComplete: () => {
|
|
251
|
-
void verifySetup();
|
|
252
|
-
},
|
|
253
|
-
onDecline: (decline) => reportDecline({
|
|
254
|
-
...decline.code ? { reason: decline.code } : {},
|
|
255
|
-
...decline.message ? { message: decline.message } : {}
|
|
256
|
-
}),
|
|
257
|
-
onError: (error) => reportFailure(asCardSetupError(error))
|
|
258
|
-
})
|
|
259
|
-
]);
|
|
260
|
-
const paypal = advertisement.paypal;
|
|
261
|
-
const paypalBranch = paypal ? h("div", { key: "paypal", "data-flopay-payment-method": "paypal" }, [
|
|
262
|
-
h(PayPalSetupMethods, {
|
|
263
|
-
clientId: paypal.clientId,
|
|
264
|
-
...paypal.environment ? { environment: paypal.environment } : {},
|
|
265
|
-
...advertisement.currency ? { currency: advertisement.currency } : {},
|
|
266
|
-
sessionId: sessionId(),
|
|
267
|
-
nonce: props.nonce ?? "",
|
|
268
|
-
billingApiUrl,
|
|
269
|
-
telemetry: props.telemetry,
|
|
270
|
-
customer: {
|
|
271
|
-
userId: session?.customer?.id ?? "",
|
|
272
|
-
email: session?.customer?.email ?? ""
|
|
273
|
-
},
|
|
274
|
-
onSubmitting: () => {
|
|
275
|
-
submissionInFlight = true;
|
|
276
|
-
showOverlay({ status: "processing", wording: "payment_method", message: null });
|
|
277
|
-
},
|
|
278
|
-
onConfirmed: () => {
|
|
279
|
-
void verifySetup();
|
|
280
|
-
},
|
|
281
|
-
onFailed: (error, options) => reportFailure(asCardSetupError(error, options)),
|
|
282
|
-
// Closing PayPal's window is not an outcome: no cancel, decline or error.
|
|
283
|
-
onAbandoned: () => {
|
|
284
|
-
submissionInFlight = false;
|
|
285
|
-
showOverlay(null);
|
|
286
|
-
}
|
|
287
|
-
})
|
|
288
|
-
]) : null;
|
|
289
|
-
const capture = setup.capture.value;
|
|
290
|
-
const vault = setup.vault.value;
|
|
291
|
-
const card = advertisement.card && capture && vault?.html ? h("div", { key: "card", "data-flopay-payment-method": "card" }, [
|
|
292
|
-
h(VaultCardFields, {
|
|
293
|
-
capture,
|
|
294
|
-
html: vault.html,
|
|
295
|
-
messageToken: vault.messageToken,
|
|
296
|
-
expectedOrigin: vault.expectedOrigin,
|
|
297
|
-
expiresAt: vault.expiresAt,
|
|
298
|
-
verificationRequired: vault.verificationRequired,
|
|
299
|
-
theme: theme.vaultTheme.value,
|
|
300
|
-
containerStyle: theme.surfaceStyle.value,
|
|
301
|
-
onReady: () => invokeMerchantCallback(() => emit("ready")),
|
|
302
|
-
onValidation: (message) => invokeMerchantCallback(() => emit("validation", message)),
|
|
303
|
-
onError: (message) => {
|
|
304
|
-
if (!message) return;
|
|
305
|
-
setup.widgetFailed(message);
|
|
306
|
-
const error = asCardSetupError(new Error(message), {
|
|
307
|
-
code: "card_setup_widget_failed",
|
|
308
|
-
retryable: true
|
|
309
|
-
});
|
|
310
|
-
invokeMerchantCallback(() => emit("error", error));
|
|
311
|
-
}
|
|
312
|
-
})
|
|
313
|
-
]) : null;
|
|
314
|
-
const wallets = advertisement.stripe.filter(
|
|
315
|
-
({ method }) => stripeMethodCategory(method) === "wallet"
|
|
316
|
-
);
|
|
317
|
-
const tiles = advertisement.stripe.filter(
|
|
318
|
-
({ method }) => stripeMethodCategory(method) !== "wallet"
|
|
319
|
-
);
|
|
320
|
-
return h("div", { "data-testid": "flopay-payment-method-setup" }, [
|
|
321
|
-
overlayNode(),
|
|
322
|
-
...wallets.map(stripeBranch),
|
|
323
|
-
paypalBranch,
|
|
324
|
-
...tiles.map(stripeBranch),
|
|
325
|
-
card
|
|
326
|
-
]);
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
export {
|
|
332
|
-
FloPayPaymentMethodSetup
|
|
333
|
-
};
|