@flopay/vue 1.14.8 → 1.14.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/README.md +2 -0
- package/dist/card-setup-entry.cjs +1 -1
- package/dist/card-setup-entry.mjs +2 -2
- package/dist/{chunk-DUU6SMKP.mjs → chunk-5N47KHFQ.mjs} +1 -1
- package/dist/{chunk-W52CQTJI.mjs → chunk-Q7WDXSRE.mjs} +2 -2
- package/dist/{chunk-GDB2HY7D.mjs → chunk-RAXPWAR7.mjs} +77 -3
- package/dist/{chunk-SWZFYEFE.mjs → chunk-YN3PHIYF.mjs} +3 -3
- package/dist/index.cjs +142 -6
- package/dist/index.mjs +73 -5
- package/dist/payment-method-setup-entry.cjs +77 -5
- package/dist/payment-method-setup-entry.mjs +2 -2
- package/dist/{payment-method-setup-paypal-XPSU4CHA.mjs → payment-method-setup-paypal-D6FEQQJY.mjs} +4 -1
- package/dist/{stripe-elements-B55YXBZK.mjs → stripe-elements-SXMTHEF6.mjs} +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -140,5 +140,7 @@ Errors are `FloPayError` instances from `@flopay/shared`, emitted through `@erro
|
|
|
140
140
|
| `UnsupportedBackendVaultCapability` | The session has no hosted vault card form and no other usable method. |
|
|
141
141
|
| `stored_payment_method_unsupported` | The buyer's saved method cannot be charged; ask for another method. |
|
|
142
142
|
| `MissingCheckoutSessionToken` | A session id was given without its `nonce`. |
|
|
143
|
+
| `network_request_failed` | Type `network_error`. `FloPayCheckout` could not start because creating or reading the session never got a response, after the SDK's retries. `cause` holds the original error; `sessionId` is set when the session already existed. |
|
|
144
|
+
| `CheckoutInitializationFailed` | Type `api_error`. `FloPayCheckout` could not start for a reason that is not a network failure, with `sessionId` set once the session exists. |
|
|
143
145
|
|
|
144
146
|
Setup surfaces emit `FloPayCardSetupError`, whose `retryable` says whether trying again can help.
|
|
@@ -450,7 +450,7 @@ var VaultCardFields = (0, import_vue3.defineComponent)({
|
|
|
450
450
|
};
|
|
451
451
|
const offReady = capture.on("ready", emitReadyOnce);
|
|
452
452
|
const offError = capture.on("error", (event) => {
|
|
453
|
-
const message = event.message ?? "There was a problem loading the secure card form.";
|
|
453
|
+
const message = (0, import_shared2.buyerEmailRequiredPrompt)(event.vaultOutcome) ?? event.message ?? "There was a problem loading the secure card form.";
|
|
454
454
|
(0, import_shared2.invokeMerchantCallback)(() => emit("error", message));
|
|
455
455
|
});
|
|
456
456
|
const offValidation = capture.on("validation", (event) => {
|
|
@@ -394,7 +394,7 @@ function useHostedSetup(props, emitters, options) {
|
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
// src/vault-card-fields.ts
|
|
397
|
-
import { invokeMerchantCallback as invokeMerchantCallback2 } from "@flopay/shared";
|
|
397
|
+
import { buyerEmailRequiredPrompt, invokeMerchantCallback as invokeMerchantCallback2 } from "@flopay/shared";
|
|
398
398
|
import {
|
|
399
399
|
defineComponent as defineComponent2,
|
|
400
400
|
h as h2,
|
|
@@ -441,7 +441,7 @@ var VaultCardFields = defineComponent2({
|
|
|
441
441
|
};
|
|
442
442
|
const offReady = capture.on("ready", emitReadyOnce);
|
|
443
443
|
const offError = capture.on("error", (event) => {
|
|
444
|
-
const message = event.message ?? "There was a problem loading the secure card form.";
|
|
444
|
+
const message = buyerEmailRequiredPrompt(event.vaultOutcome) ?? event.message ?? "There was a problem loading the secure card form.";
|
|
445
445
|
invokeMerchantCallback2(() => emit("error", message));
|
|
446
446
|
});
|
|
447
447
|
const offValidation = capture.on("validation", (event) => {
|
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
import { PaymentAPI } from "@flopay/js/card-setup";
|
|
3
3
|
import {
|
|
4
4
|
buildWalletSheetWindowMessage,
|
|
5
|
+
classifyPaymentRejection,
|
|
5
6
|
denyPaymentPermissionToNewFrames,
|
|
6
7
|
detectPayPalEnvironment,
|
|
7
8
|
FloPayError,
|
|
8
9
|
invokeMerchantCallback as invokeMerchantCallback2,
|
|
9
10
|
isProviderDecline,
|
|
11
|
+
isSettledSessionIntent,
|
|
10
12
|
isWalletSheetRefusedForWindowSize,
|
|
11
13
|
readStripeRedirectParams as readStripeRedirectParams2,
|
|
12
14
|
resolveSetupFutureUsage,
|
|
13
15
|
resolveWalletModeOptions,
|
|
16
|
+
settledSessionIntentError,
|
|
14
17
|
shouldPreferWalletPopup,
|
|
15
18
|
stripeExpressMethodToOptionKey,
|
|
16
19
|
toStripeAppearance,
|
|
@@ -245,6 +248,49 @@ function stripeMethodCategory(method) {
|
|
|
245
248
|
function declineReason(error) {
|
|
246
249
|
return error.decline_code ?? error.code ?? "provider_declined";
|
|
247
250
|
}
|
|
251
|
+
var SETTLED_ACTION_REQUIRED_CODES = /* @__PURE__ */ new Map([
|
|
252
|
+
["3ds_required", "authentication_required"],
|
|
253
|
+
["paypal_direct_required", "paypal_direct_required"]
|
|
254
|
+
]);
|
|
255
|
+
async function reportSettledIntentVerdict(response, method, sessionId, session, outcomes) {
|
|
256
|
+
const json = response.status === 204 ? null : await response.json().catch(() => null);
|
|
257
|
+
if (response.ok) {
|
|
258
|
+
const authorized = session?.captureMethod === "manual" || json?.status === "authorized";
|
|
259
|
+
const paymentId = typeof json?.paymentId === "string" ? json.paymentId : session?.paymentId;
|
|
260
|
+
const authorizationExpiresAt = typeof json?.authorizationExpiresAt === "string" ? json.authorizationExpiresAt : session?.authorizationExpiresAt;
|
|
261
|
+
outcomes.complete(
|
|
262
|
+
authorized ? {
|
|
263
|
+
status: "authorized",
|
|
264
|
+
...paymentId ? { paymentId } : {},
|
|
265
|
+
sessionId: typeof json?.sessionId === "string" ? json.sessionId : sessionId,
|
|
266
|
+
...authorizationExpiresAt ? { authorizationExpiresAt } : {},
|
|
267
|
+
checkoutMethod: method
|
|
268
|
+
} : { status: "succeeded", checkoutMethod: method }
|
|
269
|
+
);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const type = typeof json?.type === "string" ? json.type : void 0;
|
|
273
|
+
const message = typeof json?.message === "string" ? json.message : void 0;
|
|
274
|
+
const code = typeof json?.code === "string" ? json.code : void 0;
|
|
275
|
+
const actionCode = type === void 0 ? void 0 : SETTLED_ACTION_REQUIRED_CODES.get(type);
|
|
276
|
+
if (actionCode === void 0 && classifyPaymentRejection(response.status, json) === "payment_declined") {
|
|
277
|
+
outcomes.decline({
|
|
278
|
+
method,
|
|
279
|
+
message: message ?? "Your payment was declined.",
|
|
280
|
+
code,
|
|
281
|
+
declineCode: typeof json?.declineCode === "string" ? json.declineCode : code,
|
|
282
|
+
sessionId
|
|
283
|
+
});
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
outcomes.error(
|
|
287
|
+
new FloPayError(message ?? "Payment could not be completed. Please try again.", "api_error", {
|
|
288
|
+
code: actionCode ?? code ?? "payment_processing_error",
|
|
289
|
+
statusCode: response.status,
|
|
290
|
+
sessionId
|
|
291
|
+
})
|
|
292
|
+
);
|
|
293
|
+
}
|
|
248
294
|
var StripePaymentMethods = defineComponent2({
|
|
249
295
|
name: "FloPayStripePaymentMethods",
|
|
250
296
|
props: {
|
|
@@ -331,11 +377,13 @@ var StripePaymentMethods = defineComponent2({
|
|
|
331
377
|
const setupFutureUsage = resolveSetupFutureUsage(props.session, methods, surface);
|
|
332
378
|
const currency = (props.currency ?? props.session?.currency ?? "usd").toLowerCase();
|
|
333
379
|
const appearance = props.appearance ? { appearance: toStripeAppearance(props.appearance) } : {};
|
|
334
|
-
return props.intentKind === "setup" ? { mode: "setup", currency,
|
|
380
|
+
return props.intentKind === "setup" ? { mode: "setup", currency, allowedPaymentMethodTypes: methods, ...appearance } : {
|
|
335
381
|
mode: props.session?.mode === "subscription" ? "subscription" : "payment",
|
|
336
382
|
amount: props.amount,
|
|
337
383
|
currency,
|
|
338
|
-
|
|
384
|
+
// Stripe.js Endive (@stripe/stripe-js 10) removed the Elements
|
|
385
|
+
// `paymentMethodTypes` option; `allowedPaymentMethodTypes` replaces it.
|
|
386
|
+
allowedPaymentMethodTypes: methods,
|
|
339
387
|
...setupFutureUsage ? { setupFutureUsage } : {},
|
|
340
388
|
...appearance
|
|
341
389
|
};
|
|
@@ -352,7 +400,7 @@ var StripePaymentMethods = defineComponent2({
|
|
|
352
400
|
return {
|
|
353
401
|
...resolveWalletModeOptions(props.totalAmount, props.session?.captureMethod),
|
|
354
402
|
currency,
|
|
355
|
-
|
|
403
|
+
allowedPaymentMethodTypes: methods,
|
|
356
404
|
...setupFutureUsage ? { setupFutureUsage } : {},
|
|
357
405
|
...props.appearance ? { appearance: toStripeAppearance(props.appearance) } : {}
|
|
358
406
|
};
|
|
@@ -458,6 +506,11 @@ var StripePaymentMethods = defineComponent2({
|
|
|
458
506
|
observeWalletSheetClick(event.expressPaymentType, clickStartedAt);
|
|
459
507
|
event.resolve();
|
|
460
508
|
};
|
|
509
|
+
const settledVerdictOutcomes = {
|
|
510
|
+
complete: (result) => invokeMerchantCallback2(() => emit("complete", result)),
|
|
511
|
+
decline: (decline) => invokeMerchantCallback2(() => emit("decline", decline)),
|
|
512
|
+
error: (failure) => invokeMerchantCallback2(() => emit("error", failure))
|
|
513
|
+
};
|
|
461
514
|
const confirm = async (elements, method, intentKind = props.intentKind, attempt = null) => {
|
|
462
515
|
if (!stripe || processing.value) return;
|
|
463
516
|
processing.value = true;
|
|
@@ -476,6 +529,17 @@ var StripePaymentMethods = defineComponent2({
|
|
|
476
529
|
paymentMethodId: null,
|
|
477
530
|
intentKind
|
|
478
531
|
});
|
|
532
|
+
if (isSettledSessionIntent(intent)) {
|
|
533
|
+
if (intentKind === "setup") throw settledSessionIntentError(sessionId);
|
|
534
|
+
await reportSettledIntentVerdict(
|
|
535
|
+
intent.response,
|
|
536
|
+
method,
|
|
537
|
+
sessionId,
|
|
538
|
+
props.session,
|
|
539
|
+
settledVerdictOutcomes
|
|
540
|
+
);
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
479
543
|
const clientSecret = intent.clientSecret ?? "";
|
|
480
544
|
const returnUrl = props.returnUrl ?? window.location.href;
|
|
481
545
|
const { error } = intentKind === "setup" ? await stripe.confirmSetup({
|
|
@@ -581,6 +645,16 @@ var StripePaymentMethods = defineComponent2({
|
|
|
581
645
|
paymentMethodId: paymentMethod?.id ?? null,
|
|
582
646
|
intentKind: "payment"
|
|
583
647
|
});
|
|
648
|
+
if (isSettledSessionIntent(intent)) {
|
|
649
|
+
await reportSettledIntentVerdict(
|
|
650
|
+
intent.response,
|
|
651
|
+
"paypal",
|
|
652
|
+
sessionId,
|
|
653
|
+
props.session,
|
|
654
|
+
settledVerdictOutcomes
|
|
655
|
+
);
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
584
658
|
if (intent.provider !== "stripe") {
|
|
585
659
|
throw new Error("Invalid provider returned for PayPal intent");
|
|
586
660
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
asCardSetupError,
|
|
7
7
|
useCardSetupTheme,
|
|
8
8
|
useHostedSetup
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-Q7WDXSRE.mjs";
|
|
10
10
|
|
|
11
11
|
// src/flopay-payment-method-setup-main.ts
|
|
12
12
|
import {
|
|
@@ -38,10 +38,10 @@ 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-SXMTHEF6.mjs").then((module) => module.StripePaymentMethods)
|
|
42
42
|
);
|
|
43
43
|
var PayPalSetupMethods = defineAsyncComponent(
|
|
44
|
-
() => import("./payment-method-setup-paypal-
|
|
44
|
+
() => import("./payment-method-setup-paypal-D6FEQQJY.mjs").then((module) => module.PayPalSetupMethod)
|
|
45
45
|
);
|
|
46
46
|
var FloPayPaymentMethodSetup = defineComponent({
|
|
47
47
|
name: "FloPayPaymentMethodSetup",
|
package/dist/index.cjs
CHANGED
|
@@ -263,7 +263,46 @@ function stripeMethodCategory(method) {
|
|
|
263
263
|
function declineReason(error) {
|
|
264
264
|
return error.decline_code ?? error.code ?? "provider_declined";
|
|
265
265
|
}
|
|
266
|
-
|
|
266
|
+
async function reportSettledIntentVerdict(response, method, sessionId, session, outcomes) {
|
|
267
|
+
const json = response.status === 204 ? null : await response.json().catch(() => null);
|
|
268
|
+
if (response.ok) {
|
|
269
|
+
const authorized = session?.captureMethod === "manual" || json?.status === "authorized";
|
|
270
|
+
const paymentId = typeof json?.paymentId === "string" ? json.paymentId : session?.paymentId;
|
|
271
|
+
const authorizationExpiresAt = typeof json?.authorizationExpiresAt === "string" ? json.authorizationExpiresAt : session?.authorizationExpiresAt;
|
|
272
|
+
outcomes.complete(
|
|
273
|
+
authorized ? {
|
|
274
|
+
status: "authorized",
|
|
275
|
+
...paymentId ? { paymentId } : {},
|
|
276
|
+
sessionId: typeof json?.sessionId === "string" ? json.sessionId : sessionId,
|
|
277
|
+
...authorizationExpiresAt ? { authorizationExpiresAt } : {},
|
|
278
|
+
checkoutMethod: method
|
|
279
|
+
} : { status: "succeeded", checkoutMethod: method }
|
|
280
|
+
);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const type = typeof json?.type === "string" ? json.type : void 0;
|
|
284
|
+
const message = typeof json?.message === "string" ? json.message : void 0;
|
|
285
|
+
const code = typeof json?.code === "string" ? json.code : void 0;
|
|
286
|
+
const actionCode = type === void 0 ? void 0 : SETTLED_ACTION_REQUIRED_CODES.get(type);
|
|
287
|
+
if (actionCode === void 0 && (0, import_shared6.classifyPaymentRejection)(response.status, json) === "payment_declined") {
|
|
288
|
+
outcomes.decline({
|
|
289
|
+
method,
|
|
290
|
+
message: message ?? "Your payment was declined.",
|
|
291
|
+
code,
|
|
292
|
+
declineCode: typeof json?.declineCode === "string" ? json.declineCode : code,
|
|
293
|
+
sessionId
|
|
294
|
+
});
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
outcomes.error(
|
|
298
|
+
new import_shared6.FloPayError(message ?? "Payment could not be completed. Please try again.", "api_error", {
|
|
299
|
+
code: actionCode ?? code ?? "payment_processing_error",
|
|
300
|
+
statusCode: response.status,
|
|
301
|
+
sessionId
|
|
302
|
+
})
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
var import_card_setup2, import_shared6, import_vue4, WALLET_METHODS, EXPRESS_CHECKOUT_CLICK_BUDGET_MS, PAYPAL_REDIRECT_TILE_HEIGHT, stripePayPalResumeAttempts, SETTLED_ACTION_REQUIRED_CODES, StripePaymentMethods;
|
|
267
306
|
var init_stripe_elements = __esm({
|
|
268
307
|
"src/stripe-elements.ts"() {
|
|
269
308
|
"use strict";
|
|
@@ -277,6 +316,10 @@ var init_stripe_elements = __esm({
|
|
|
277
316
|
EXPRESS_CHECKOUT_CLICK_BUDGET_MS = 900;
|
|
278
317
|
PAYPAL_REDIRECT_TILE_HEIGHT = 44;
|
|
279
318
|
stripePayPalResumeAttempts = /* @__PURE__ */ new Map();
|
|
319
|
+
SETTLED_ACTION_REQUIRED_CODES = /* @__PURE__ */ new Map([
|
|
320
|
+
["3ds_required", "authentication_required"],
|
|
321
|
+
["paypal_direct_required", "paypal_direct_required"]
|
|
322
|
+
]);
|
|
280
323
|
StripePaymentMethods = (0, import_vue4.defineComponent)({
|
|
281
324
|
name: "FloPayStripePaymentMethods",
|
|
282
325
|
props: {
|
|
@@ -363,11 +406,13 @@ var init_stripe_elements = __esm({
|
|
|
363
406
|
const setupFutureUsage = (0, import_shared6.resolveSetupFutureUsage)(props.session, methods, surface);
|
|
364
407
|
const currency = (props.currency ?? props.session?.currency ?? "usd").toLowerCase();
|
|
365
408
|
const appearance = props.appearance ? { appearance: (0, import_shared6.toStripeAppearance)(props.appearance) } : {};
|
|
366
|
-
return props.intentKind === "setup" ? { mode: "setup", currency,
|
|
409
|
+
return props.intentKind === "setup" ? { mode: "setup", currency, allowedPaymentMethodTypes: methods, ...appearance } : {
|
|
367
410
|
mode: props.session?.mode === "subscription" ? "subscription" : "payment",
|
|
368
411
|
amount: props.amount,
|
|
369
412
|
currency,
|
|
370
|
-
|
|
413
|
+
// Stripe.js Endive (@stripe/stripe-js 10) removed the Elements
|
|
414
|
+
// `paymentMethodTypes` option; `allowedPaymentMethodTypes` replaces it.
|
|
415
|
+
allowedPaymentMethodTypes: methods,
|
|
371
416
|
...setupFutureUsage ? { setupFutureUsage } : {},
|
|
372
417
|
...appearance
|
|
373
418
|
};
|
|
@@ -384,7 +429,7 @@ var init_stripe_elements = __esm({
|
|
|
384
429
|
return {
|
|
385
430
|
...(0, import_shared6.resolveWalletModeOptions)(props.totalAmount, props.session?.captureMethod),
|
|
386
431
|
currency,
|
|
387
|
-
|
|
432
|
+
allowedPaymentMethodTypes: methods,
|
|
388
433
|
...setupFutureUsage ? { setupFutureUsage } : {},
|
|
389
434
|
...props.appearance ? { appearance: (0, import_shared6.toStripeAppearance)(props.appearance) } : {}
|
|
390
435
|
};
|
|
@@ -490,6 +535,11 @@ var init_stripe_elements = __esm({
|
|
|
490
535
|
observeWalletSheetClick(event.expressPaymentType, clickStartedAt);
|
|
491
536
|
event.resolve();
|
|
492
537
|
};
|
|
538
|
+
const settledVerdictOutcomes = {
|
|
539
|
+
complete: (result) => (0, import_shared6.invokeMerchantCallback)(() => emit("complete", result)),
|
|
540
|
+
decline: (decline) => (0, import_shared6.invokeMerchantCallback)(() => emit("decline", decline)),
|
|
541
|
+
error: (failure) => (0, import_shared6.invokeMerchantCallback)(() => emit("error", failure))
|
|
542
|
+
};
|
|
493
543
|
const confirm = async (elements, method, intentKind = props.intentKind, attempt = null) => {
|
|
494
544
|
if (!stripe || processing.value) return;
|
|
495
545
|
processing.value = true;
|
|
@@ -508,6 +558,17 @@ var init_stripe_elements = __esm({
|
|
|
508
558
|
paymentMethodId: null,
|
|
509
559
|
intentKind
|
|
510
560
|
});
|
|
561
|
+
if ((0, import_shared6.isSettledSessionIntent)(intent)) {
|
|
562
|
+
if (intentKind === "setup") throw (0, import_shared6.settledSessionIntentError)(sessionId);
|
|
563
|
+
await reportSettledIntentVerdict(
|
|
564
|
+
intent.response,
|
|
565
|
+
method,
|
|
566
|
+
sessionId,
|
|
567
|
+
props.session,
|
|
568
|
+
settledVerdictOutcomes
|
|
569
|
+
);
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
511
572
|
const clientSecret = intent.clientSecret ?? "";
|
|
512
573
|
const returnUrl = props.returnUrl ?? window.location.href;
|
|
513
574
|
const { error } = intentKind === "setup" ? await stripe.confirmSetup({
|
|
@@ -613,6 +674,16 @@ var init_stripe_elements = __esm({
|
|
|
613
674
|
paymentMethodId: paymentMethod?.id ?? null,
|
|
614
675
|
intentKind: "payment"
|
|
615
676
|
});
|
|
677
|
+
if ((0, import_shared6.isSettledSessionIntent)(intent)) {
|
|
678
|
+
await reportSettledIntentVerdict(
|
|
679
|
+
intent.response,
|
|
680
|
+
"paypal",
|
|
681
|
+
sessionId,
|
|
682
|
+
props.session,
|
|
683
|
+
settledVerdictOutcomes
|
|
684
|
+
);
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
616
687
|
if (intent.provider !== "stripe") {
|
|
617
688
|
throw new Error("Invalid provider returned for PayPal intent");
|
|
618
689
|
}
|
|
@@ -945,6 +1016,7 @@ var init_payment_method_setup_paypal = __esm({
|
|
|
945
1016
|
paymentMethodId: null,
|
|
946
1017
|
intentKind: "setup"
|
|
947
1018
|
});
|
|
1019
|
+
if ((0, import_shared13.isSettledSessionIntent)(intent)) throw (0, import_shared13.settledSessionIntentError)(sessionId);
|
|
948
1020
|
if (intent.provider !== "paypal" || intent.providerObjectType !== "setup_token") {
|
|
949
1021
|
throw new import_shared13.FloPayError(
|
|
950
1022
|
"The billing API did not return a PayPal setup token.",
|
|
@@ -1315,6 +1387,7 @@ var BuyerIdentityFallbackPanel = (0, import_vue2.defineComponent)({
|
|
|
1315
1387
|
|
|
1316
1388
|
// src/direct-paypal-button.ts
|
|
1317
1389
|
init_context();
|
|
1390
|
+
var PAYPAL_INTENT_SETTLED_CODE = "paypal_intent_settled";
|
|
1318
1391
|
var PAYPAL_INIT_RETRY_DELAY_MS = 1e3;
|
|
1319
1392
|
var PayPalStartupFailure = class extends Error {
|
|
1320
1393
|
constructor(message, options = {}) {
|
|
@@ -1409,6 +1482,7 @@ var DirectPayPalButton = (0, import_vue3.defineComponent)({
|
|
|
1409
1482
|
let attemptLive = false;
|
|
1410
1483
|
let intentIdempotencyKey;
|
|
1411
1484
|
let intentAttemptActive = false;
|
|
1485
|
+
let attemptSettled = false;
|
|
1412
1486
|
const beginIntentAttempt = () => {
|
|
1413
1487
|
intentIdempotencyKey = (0, import_shared4.generateIdempotencyKey)();
|
|
1414
1488
|
if (!intentIdempotencyKey) {
|
|
@@ -1476,6 +1550,19 @@ var DirectPayPalButton = (0, import_vue3.defineComponent)({
|
|
|
1476
1550
|
const inAppBrowser = () => (0, import_shared4.detectPayPalEnvironment)().inAppBrowser;
|
|
1477
1551
|
const effectiveSessionId = () => prepared?.sessionId ?? props.sessionId ?? "";
|
|
1478
1552
|
const effectiveNonce = () => prepared?.nonce ?? props.nonce;
|
|
1553
|
+
const reportSettledIntentVerdict2 = async (response, sessionId) => {
|
|
1554
|
+
if (response.ok) {
|
|
1555
|
+
const result = { status: "succeeded", checkoutMethod: "paypal" };
|
|
1556
|
+
(0, import_shared4.invokeMerchantCallback)(() => emit("complete", result));
|
|
1557
|
+
return;
|
|
1558
|
+
}
|
|
1559
|
+
const json = await response.json().catch(() => null);
|
|
1560
|
+
const failure = (0, import_shared4.describePayPalProcessFailure)(json);
|
|
1561
|
+
emitDecline(failure.message, sessionId, {
|
|
1562
|
+
code: failure.code,
|
|
1563
|
+
declineCode: failure.declineCode
|
|
1564
|
+
});
|
|
1565
|
+
};
|
|
1479
1566
|
const createIntent = async () => {
|
|
1480
1567
|
if (!intentAttemptActive) beginIntentAttempt();
|
|
1481
1568
|
const intent = await api().createSessionIntent(
|
|
@@ -1484,6 +1571,15 @@ var DirectPayPalButton = (0, import_vue3.defineComponent)({
|
|
|
1484
1571
|
(0, import_shared4.buildPayPalSessionIntentRequest)(configuredObjectType()),
|
|
1485
1572
|
{ idempotencyKey: intentIdempotencyKey }
|
|
1486
1573
|
);
|
|
1574
|
+
if ((0, import_shared4.isSettledSessionIntent)(intent)) {
|
|
1575
|
+
await reportSettledIntentVerdict2(intent.response, effectiveSessionId());
|
|
1576
|
+
attemptSettled = true;
|
|
1577
|
+
attemptLive = false;
|
|
1578
|
+
prepared = null;
|
|
1579
|
+
throw new import_shared4.FloPayError("PayPal checkout already settled.", "api_error", {
|
|
1580
|
+
code: PAYPAL_INTENT_SETTLED_CODE
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1487
1583
|
if (intent.provider !== "paypal" || intent.providerObjectType !== objectType()) {
|
|
1488
1584
|
throw new import_shared4.FloPayError("PayPal could not start this payment.", "api_error", {
|
|
1489
1585
|
code: "paypal_intent_mismatch"
|
|
@@ -1549,6 +1645,17 @@ var DirectPayPalButton = (0, import_vue3.defineComponent)({
|
|
|
1549
1645
|
return;
|
|
1550
1646
|
}
|
|
1551
1647
|
prepared = null;
|
|
1648
|
+
if (error instanceof import_shared4.FloPayError && error.code === "checkout_processing_timeout") {
|
|
1649
|
+
(0, import_shared4.invokeMerchantCallback)(() => emit("error", error));
|
|
1650
|
+
notifyTechnicalFailure(error, error.message, {
|
|
1651
|
+
code: "checkout_processing_timeout",
|
|
1652
|
+
popupBlocked: false,
|
|
1653
|
+
provider: "paypal",
|
|
1654
|
+
paymentMethodCategory: "paypal",
|
|
1655
|
+
terminalReason: classification.terminalReason
|
|
1656
|
+
});
|
|
1657
|
+
return;
|
|
1658
|
+
}
|
|
1552
1659
|
const recoveryMessage = (0, import_shared4.buildExternalMethodRecoveryMessage)(
|
|
1553
1660
|
"PayPal",
|
|
1554
1661
|
classification.popupBlocked,
|
|
@@ -1677,6 +1784,7 @@ var DirectPayPalButton = (0, import_vue3.defineComponent)({
|
|
|
1677
1784
|
beginIntentAttempt();
|
|
1678
1785
|
prepared = null;
|
|
1679
1786
|
attemptLive = false;
|
|
1787
|
+
attemptSettled = false;
|
|
1680
1788
|
let next = {};
|
|
1681
1789
|
const runner = props.runBeforeButtonClick;
|
|
1682
1790
|
if (runner) {
|
|
@@ -1772,6 +1880,10 @@ var DirectPayPalButton = (0, import_vue3.defineComponent)({
|
|
|
1772
1880
|
onCancel: () => cancel(gen),
|
|
1773
1881
|
onError: (error) => {
|
|
1774
1882
|
if (!isCurrent(gen)) return;
|
|
1883
|
+
if (attemptSettled || error instanceof import_shared4.FloPayError && error.code === PAYPAL_INTENT_SETTLED_CODE) {
|
|
1884
|
+
trace("onError:settled");
|
|
1885
|
+
return;
|
|
1886
|
+
}
|
|
1775
1887
|
trace(
|
|
1776
1888
|
`onError rendered=${rendered} msg=${errorMessage(error, "PayPal failed to render.").slice(0, 120)}`
|
|
1777
1889
|
);
|
|
@@ -1857,6 +1969,7 @@ var DirectPayPalButton = (0, import_vue3.defineComponent)({
|
|
|
1857
1969
|
attemptLive = false;
|
|
1858
1970
|
intentIdempotencyKey = void 0;
|
|
1859
1971
|
intentAttemptActive = false;
|
|
1972
|
+
attemptSettled = false;
|
|
1860
1973
|
closeButtons();
|
|
1861
1974
|
if (!props.clientId) {
|
|
1862
1975
|
setState("exhausted");
|
|
@@ -1978,7 +2091,7 @@ var VaultCardFields = (0, import_vue5.defineComponent)({
|
|
|
1978
2091
|
};
|
|
1979
2092
|
const offReady = capture.on("ready", emitReadyOnce);
|
|
1980
2093
|
const offError = capture.on("error", (event) => {
|
|
1981
|
-
const message = event.message ?? "There was a problem loading the secure card form.";
|
|
2094
|
+
const message = (0, import_shared7.buyerEmailRequiredPrompt)(event.vaultOutcome) ?? event.message ?? "There was a problem loading the secure card form.";
|
|
1982
2095
|
(0, import_shared7.invokeMerchantCallback)(() => emit("error", message));
|
|
1983
2096
|
});
|
|
1984
2097
|
const offValidation = capture.on("validation", (event) => {
|
|
@@ -2761,6 +2874,21 @@ var SplitCardForm = (0, import_vue6.defineComponent)({
|
|
|
2761
2874
|
});
|
|
2762
2875
|
});
|
|
2763
2876
|
const offError = adapter.on("error", (event) => {
|
|
2877
|
+
const buyerEmailPrompt = (0, import_shared8.buyerEmailRequiredPrompt)(event.vaultOutcome);
|
|
2878
|
+
if (buyerEmailPrompt !== null) {
|
|
2879
|
+
if (overlayTimer) {
|
|
2880
|
+
clearTimeout(overlayTimer);
|
|
2881
|
+
overlayTimer = null;
|
|
2882
|
+
}
|
|
2883
|
+
overlay.value = null;
|
|
2884
|
+
failure.value = buyerEmailPrompt;
|
|
2885
|
+
emitError(
|
|
2886
|
+
new import_shared8.FloPayError(buyerEmailPrompt, "api_error", {
|
|
2887
|
+
code: import_shared8.CHECKOUT_SESSION_BUYER_EMAIL_REQUIRED
|
|
2888
|
+
})
|
|
2889
|
+
);
|
|
2890
|
+
return;
|
|
2891
|
+
}
|
|
2764
2892
|
const message = event.message ?? "There was a problem processing your card.";
|
|
2765
2893
|
failure.value = message;
|
|
2766
2894
|
holdFailureOverlay();
|
|
@@ -3683,10 +3811,12 @@ var FloPayCheckout = (0, import_vue7.defineComponent)({
|
|
|
3683
3811
|
await runSavedPayment(result);
|
|
3684
3812
|
}
|
|
3685
3813
|
};
|
|
3814
|
+
let sessionResponseReceived = false;
|
|
3686
3815
|
const start = async () => {
|
|
3687
3816
|
const api = createApi();
|
|
3688
3817
|
if (props.sessionId) {
|
|
3689
3818
|
const result = await api.getUnifiedCheckoutSession(props.sessionId, props.nonce);
|
|
3819
|
+
sessionResponseReceived = true;
|
|
3690
3820
|
adopt(result);
|
|
3691
3821
|
await settleMode(result);
|
|
3692
3822
|
return;
|
|
@@ -3711,6 +3841,7 @@ var FloPayCheckout = (0, import_vue7.defineComponent)({
|
|
|
3711
3841
|
} : {}
|
|
3712
3842
|
});
|
|
3713
3843
|
const resolved = await resolveInlineSession(api, params);
|
|
3844
|
+
sessionResponseReceived = true;
|
|
3714
3845
|
if (!resolved.claimed) {
|
|
3715
3846
|
adopt(resolved.result);
|
|
3716
3847
|
await settleMode(resolved.result);
|
|
@@ -3732,7 +3863,12 @@ var FloPayCheckout = (0, import_vue7.defineComponent)({
|
|
|
3732
3863
|
() => {
|
|
3733
3864
|
if (active) state.loading = false;
|
|
3734
3865
|
},
|
|
3735
|
-
(error) => fail(
|
|
3866
|
+
(error) => fail(
|
|
3867
|
+
(0, import_shared9.toPublicCheckoutInitError)(error, {
|
|
3868
|
+
stage: sessionResponseReceived ? "post_session" : "session_request",
|
|
3869
|
+
sessionId: props.sessionId || state.session?.id || void 0
|
|
3870
|
+
})
|
|
3871
|
+
)
|
|
3736
3872
|
);
|
|
3737
3873
|
});
|
|
3738
3874
|
(0, import_vue7.onBeforeUnmount)(() => {
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FloPayCardSetup
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5N47KHFQ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
FloPayPaymentMethodSetup
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YN3PHIYF.mjs";
|
|
7
7
|
import {
|
|
8
8
|
FloPayCardSetupError,
|
|
9
9
|
VaultCardFields
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-Q7WDXSRE.mjs";
|
|
11
11
|
import {
|
|
12
12
|
CHECKOUT_FORM_DEFAULTS,
|
|
13
13
|
CHECKOUT_STATE,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
FloPayProvider,
|
|
16
16
|
StripePaymentMethods,
|
|
17
17
|
hasStripePayPalReturn
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-RAXPWAR7.mjs";
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
import { dropThirdPartyOnlyError } from "@flopay/shared";
|
|
@@ -55,6 +55,7 @@ import {
|
|
|
55
55
|
resolveIdempotencyKey,
|
|
56
56
|
resolveTheme as resolveTheme2,
|
|
57
57
|
serializeCreateParams,
|
|
58
|
+
toPublicCheckoutInitError,
|
|
58
59
|
wasSessionRecentlyCompleted
|
|
59
60
|
} from "@flopay/shared";
|
|
60
61
|
import {
|
|
@@ -212,6 +213,8 @@ import { PaymentAPI as PaymentAPI2, PciVaultCardCapture } from "@flopay/js/card-
|
|
|
212
213
|
import {
|
|
213
214
|
buildCheckoutProcessMetadata,
|
|
214
215
|
buildProcessPaymentAvsAccount,
|
|
216
|
+
buyerEmailRequiredPrompt,
|
|
217
|
+
CHECKOUT_SESSION_BUYER_EMAIL_REQUIRED,
|
|
215
218
|
COUNTRY_OPTIONS,
|
|
216
219
|
canRecoverHostedCardForm,
|
|
217
220
|
computeVaultCardThemeColors,
|
|
@@ -270,6 +273,7 @@ import {
|
|
|
270
273
|
invokeMerchantCallback,
|
|
271
274
|
isPayPalAcknowledgementDeadWindow,
|
|
272
275
|
isPayPalTeardownMessage,
|
|
276
|
+
isSettledSessionIntent,
|
|
273
277
|
isValidEmail as isValidEmail2,
|
|
274
278
|
mergePayPalPayerIdentity,
|
|
275
279
|
needsPayPalPayerDetails,
|
|
@@ -405,6 +409,7 @@ var BuyerIdentityFallbackPanel = defineComponent({
|
|
|
405
409
|
});
|
|
406
410
|
|
|
407
411
|
// src/direct-paypal-button.ts
|
|
412
|
+
var PAYPAL_INTENT_SETTLED_CODE = "paypal_intent_settled";
|
|
408
413
|
var PAYPAL_INIT_RETRY_DELAY_MS = 1e3;
|
|
409
414
|
var PayPalStartupFailure = class extends Error {
|
|
410
415
|
constructor(message, options = {}) {
|
|
@@ -499,6 +504,7 @@ var DirectPayPalButton = defineComponent2({
|
|
|
499
504
|
let attemptLive = false;
|
|
500
505
|
let intentIdempotencyKey;
|
|
501
506
|
let intentAttemptActive = false;
|
|
507
|
+
let attemptSettled = false;
|
|
502
508
|
const beginIntentAttempt = () => {
|
|
503
509
|
intentIdempotencyKey = generateIdempotencyKey();
|
|
504
510
|
if (!intentIdempotencyKey) {
|
|
@@ -566,6 +572,19 @@ var DirectPayPalButton = defineComponent2({
|
|
|
566
572
|
const inAppBrowser = () => detectPayPalEnvironment().inAppBrowser;
|
|
567
573
|
const effectiveSessionId = () => prepared?.sessionId ?? props.sessionId ?? "";
|
|
568
574
|
const effectiveNonce = () => prepared?.nonce ?? props.nonce;
|
|
575
|
+
const reportSettledIntentVerdict = async (response, sessionId) => {
|
|
576
|
+
if (response.ok) {
|
|
577
|
+
const result = { status: "succeeded", checkoutMethod: "paypal" };
|
|
578
|
+
invokeMerchantCallback(() => emit("complete", result));
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
const json = await response.json().catch(() => null);
|
|
582
|
+
const failure = describePayPalProcessFailure(json);
|
|
583
|
+
emitDecline(failure.message, sessionId, {
|
|
584
|
+
code: failure.code,
|
|
585
|
+
declineCode: failure.declineCode
|
|
586
|
+
});
|
|
587
|
+
};
|
|
569
588
|
const createIntent = async () => {
|
|
570
589
|
if (!intentAttemptActive) beginIntentAttempt();
|
|
571
590
|
const intent = await api().createSessionIntent(
|
|
@@ -574,6 +593,15 @@ var DirectPayPalButton = defineComponent2({
|
|
|
574
593
|
buildPayPalSessionIntentRequest(configuredObjectType()),
|
|
575
594
|
{ idempotencyKey: intentIdempotencyKey }
|
|
576
595
|
);
|
|
596
|
+
if (isSettledSessionIntent(intent)) {
|
|
597
|
+
await reportSettledIntentVerdict(intent.response, effectiveSessionId());
|
|
598
|
+
attemptSettled = true;
|
|
599
|
+
attemptLive = false;
|
|
600
|
+
prepared = null;
|
|
601
|
+
throw new FloPayError2("PayPal checkout already settled.", "api_error", {
|
|
602
|
+
code: PAYPAL_INTENT_SETTLED_CODE
|
|
603
|
+
});
|
|
604
|
+
}
|
|
577
605
|
if (intent.provider !== "paypal" || intent.providerObjectType !== objectType()) {
|
|
578
606
|
throw new FloPayError2("PayPal could not start this payment.", "api_error", {
|
|
579
607
|
code: "paypal_intent_mismatch"
|
|
@@ -639,6 +667,17 @@ var DirectPayPalButton = defineComponent2({
|
|
|
639
667
|
return;
|
|
640
668
|
}
|
|
641
669
|
prepared = null;
|
|
670
|
+
if (error instanceof FloPayError2 && error.code === "checkout_processing_timeout") {
|
|
671
|
+
invokeMerchantCallback(() => emit("error", error));
|
|
672
|
+
notifyTechnicalFailure(error, error.message, {
|
|
673
|
+
code: "checkout_processing_timeout",
|
|
674
|
+
popupBlocked: false,
|
|
675
|
+
provider: "paypal",
|
|
676
|
+
paymentMethodCategory: "paypal",
|
|
677
|
+
terminalReason: classification.terminalReason
|
|
678
|
+
});
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
642
681
|
const recoveryMessage = buildExternalMethodRecoveryMessage(
|
|
643
682
|
"PayPal",
|
|
644
683
|
classification.popupBlocked,
|
|
@@ -767,6 +806,7 @@ var DirectPayPalButton = defineComponent2({
|
|
|
767
806
|
beginIntentAttempt();
|
|
768
807
|
prepared = null;
|
|
769
808
|
attemptLive = false;
|
|
809
|
+
attemptSettled = false;
|
|
770
810
|
let next = {};
|
|
771
811
|
const runner = props.runBeforeButtonClick;
|
|
772
812
|
if (runner) {
|
|
@@ -862,6 +902,10 @@ var DirectPayPalButton = defineComponent2({
|
|
|
862
902
|
onCancel: () => cancel(gen),
|
|
863
903
|
onError: (error) => {
|
|
864
904
|
if (!isCurrent(gen)) return;
|
|
905
|
+
if (attemptSettled || error instanceof FloPayError2 && error.code === PAYPAL_INTENT_SETTLED_CODE) {
|
|
906
|
+
trace("onError:settled");
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
865
909
|
trace(
|
|
866
910
|
`onError rendered=${rendered} msg=${errorMessage(error, "PayPal failed to render.").slice(0, 120)}`
|
|
867
911
|
);
|
|
@@ -947,6 +991,7 @@ var DirectPayPalButton = defineComponent2({
|
|
|
947
991
|
attemptLive = false;
|
|
948
992
|
intentIdempotencyKey = void 0;
|
|
949
993
|
intentAttemptActive = false;
|
|
994
|
+
attemptSettled = false;
|
|
950
995
|
closeButtons();
|
|
951
996
|
if (!props.clientId) {
|
|
952
997
|
setState("exhausted");
|
|
@@ -1732,6 +1777,21 @@ var SplitCardForm = defineComponent3({
|
|
|
1732
1777
|
});
|
|
1733
1778
|
});
|
|
1734
1779
|
const offError = adapter.on("error", (event) => {
|
|
1780
|
+
const buyerEmailPrompt = buyerEmailRequiredPrompt(event.vaultOutcome);
|
|
1781
|
+
if (buyerEmailPrompt !== null) {
|
|
1782
|
+
if (overlayTimer) {
|
|
1783
|
+
clearTimeout(overlayTimer);
|
|
1784
|
+
overlayTimer = null;
|
|
1785
|
+
}
|
|
1786
|
+
overlay.value = null;
|
|
1787
|
+
failure.value = buyerEmailPrompt;
|
|
1788
|
+
emitError(
|
|
1789
|
+
new FloPayError3(buyerEmailPrompt, "api_error", {
|
|
1790
|
+
code: CHECKOUT_SESSION_BUYER_EMAIL_REQUIRED
|
|
1791
|
+
})
|
|
1792
|
+
);
|
|
1793
|
+
return;
|
|
1794
|
+
}
|
|
1735
1795
|
const message = event.message ?? "There was a problem processing your card.";
|
|
1736
1796
|
failure.value = message;
|
|
1737
1797
|
holdFailureOverlay();
|
|
@@ -2654,10 +2714,12 @@ var FloPayCheckout = defineComponent4({
|
|
|
2654
2714
|
await runSavedPayment(result);
|
|
2655
2715
|
}
|
|
2656
2716
|
};
|
|
2717
|
+
let sessionResponseReceived = false;
|
|
2657
2718
|
const start = async () => {
|
|
2658
2719
|
const api = createApi();
|
|
2659
2720
|
if (props.sessionId) {
|
|
2660
2721
|
const result = await api.getUnifiedCheckoutSession(props.sessionId, props.nonce);
|
|
2722
|
+
sessionResponseReceived = true;
|
|
2661
2723
|
adopt(result);
|
|
2662
2724
|
await settleMode(result);
|
|
2663
2725
|
return;
|
|
@@ -2682,6 +2744,7 @@ var FloPayCheckout = defineComponent4({
|
|
|
2682
2744
|
} : {}
|
|
2683
2745
|
});
|
|
2684
2746
|
const resolved = await resolveInlineSession(api, params);
|
|
2747
|
+
sessionResponseReceived = true;
|
|
2685
2748
|
if (!resolved.claimed) {
|
|
2686
2749
|
adopt(resolved.result);
|
|
2687
2750
|
await settleMode(resolved.result);
|
|
@@ -2703,7 +2766,12 @@ var FloPayCheckout = defineComponent4({
|
|
|
2703
2766
|
() => {
|
|
2704
2767
|
if (active) state.loading = false;
|
|
2705
2768
|
},
|
|
2706
|
-
(error) => fail(
|
|
2769
|
+
(error) => fail(
|
|
2770
|
+
toPublicCheckoutInitError(error, {
|
|
2771
|
+
stage: sessionResponseReceived ? "post_session" : "session_request",
|
|
2772
|
+
sessionId: props.sessionId || state.session?.id || void 0
|
|
2773
|
+
})
|
|
2774
|
+
)
|
|
2707
2775
|
);
|
|
2708
2776
|
});
|
|
2709
2777
|
onBeforeUnmount4(() => {
|
|
@@ -256,7 +256,46 @@ function stripeMethodCategory(method) {
|
|
|
256
256
|
function declineReason(error) {
|
|
257
257
|
return error.decline_code ?? error.code ?? "provider_declined";
|
|
258
258
|
}
|
|
259
|
-
|
|
259
|
+
async function reportSettledIntentVerdict(response, method, sessionId, session, outcomes) {
|
|
260
|
+
const json = response.status === 204 ? null : await response.json().catch(() => null);
|
|
261
|
+
if (response.ok) {
|
|
262
|
+
const authorized = session?.captureMethod === "manual" || json?.status === "authorized";
|
|
263
|
+
const paymentId = typeof json?.paymentId === "string" ? json.paymentId : session?.paymentId;
|
|
264
|
+
const authorizationExpiresAt = typeof json?.authorizationExpiresAt === "string" ? json.authorizationExpiresAt : session?.authorizationExpiresAt;
|
|
265
|
+
outcomes.complete(
|
|
266
|
+
authorized ? {
|
|
267
|
+
status: "authorized",
|
|
268
|
+
...paymentId ? { paymentId } : {},
|
|
269
|
+
sessionId: typeof json?.sessionId === "string" ? json.sessionId : sessionId,
|
|
270
|
+
...authorizationExpiresAt ? { authorizationExpiresAt } : {},
|
|
271
|
+
checkoutMethod: method
|
|
272
|
+
} : { status: "succeeded", checkoutMethod: method }
|
|
273
|
+
);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const type = typeof json?.type === "string" ? json.type : void 0;
|
|
277
|
+
const message = typeof json?.message === "string" ? json.message : void 0;
|
|
278
|
+
const code = typeof json?.code === "string" ? json.code : void 0;
|
|
279
|
+
const actionCode = type === void 0 ? void 0 : SETTLED_ACTION_REQUIRED_CODES.get(type);
|
|
280
|
+
if (actionCode === void 0 && (0, import_shared5.classifyPaymentRejection)(response.status, json) === "payment_declined") {
|
|
281
|
+
outcomes.decline({
|
|
282
|
+
method,
|
|
283
|
+
message: message ?? "Your payment was declined.",
|
|
284
|
+
code,
|
|
285
|
+
declineCode: typeof json?.declineCode === "string" ? json.declineCode : code,
|
|
286
|
+
sessionId
|
|
287
|
+
});
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
outcomes.error(
|
|
291
|
+
new import_shared5.FloPayError(message ?? "Payment could not be completed. Please try again.", "api_error", {
|
|
292
|
+
code: actionCode ?? code ?? "payment_processing_error",
|
|
293
|
+
statusCode: response.status,
|
|
294
|
+
sessionId
|
|
295
|
+
})
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
var import_card_setup2, import_shared5, import_vue5, WALLET_METHODS, EXPRESS_CHECKOUT_CLICK_BUDGET_MS, PAYPAL_REDIRECT_TILE_HEIGHT, stripePayPalResumeAttempts, SETTLED_ACTION_REQUIRED_CODES, StripePaymentMethods;
|
|
260
299
|
var init_stripe_elements = __esm({
|
|
261
300
|
"src/stripe-elements.ts"() {
|
|
262
301
|
"use strict";
|
|
@@ -270,6 +309,10 @@ var init_stripe_elements = __esm({
|
|
|
270
309
|
EXPRESS_CHECKOUT_CLICK_BUDGET_MS = 900;
|
|
271
310
|
PAYPAL_REDIRECT_TILE_HEIGHT = 44;
|
|
272
311
|
stripePayPalResumeAttempts = /* @__PURE__ */ new Map();
|
|
312
|
+
SETTLED_ACTION_REQUIRED_CODES = /* @__PURE__ */ new Map([
|
|
313
|
+
["3ds_required", "authentication_required"],
|
|
314
|
+
["paypal_direct_required", "paypal_direct_required"]
|
|
315
|
+
]);
|
|
273
316
|
StripePaymentMethods = (0, import_vue5.defineComponent)({
|
|
274
317
|
name: "FloPayStripePaymentMethods",
|
|
275
318
|
props: {
|
|
@@ -356,11 +399,13 @@ var init_stripe_elements = __esm({
|
|
|
356
399
|
const setupFutureUsage = (0, import_shared5.resolveSetupFutureUsage)(props.session, methods, surface);
|
|
357
400
|
const currency = (props.currency ?? props.session?.currency ?? "usd").toLowerCase();
|
|
358
401
|
const appearance = props.appearance ? { appearance: (0, import_shared5.toStripeAppearance)(props.appearance) } : {};
|
|
359
|
-
return props.intentKind === "setup" ? { mode: "setup", currency,
|
|
402
|
+
return props.intentKind === "setup" ? { mode: "setup", currency, allowedPaymentMethodTypes: methods, ...appearance } : {
|
|
360
403
|
mode: props.session?.mode === "subscription" ? "subscription" : "payment",
|
|
361
404
|
amount: props.amount,
|
|
362
405
|
currency,
|
|
363
|
-
|
|
406
|
+
// Stripe.js Endive (@stripe/stripe-js 10) removed the Elements
|
|
407
|
+
// `paymentMethodTypes` option; `allowedPaymentMethodTypes` replaces it.
|
|
408
|
+
allowedPaymentMethodTypes: methods,
|
|
364
409
|
...setupFutureUsage ? { setupFutureUsage } : {},
|
|
365
410
|
...appearance
|
|
366
411
|
};
|
|
@@ -377,7 +422,7 @@ var init_stripe_elements = __esm({
|
|
|
377
422
|
return {
|
|
378
423
|
...(0, import_shared5.resolveWalletModeOptions)(props.totalAmount, props.session?.captureMethod),
|
|
379
424
|
currency,
|
|
380
|
-
|
|
425
|
+
allowedPaymentMethodTypes: methods,
|
|
381
426
|
...setupFutureUsage ? { setupFutureUsage } : {},
|
|
382
427
|
...props.appearance ? { appearance: (0, import_shared5.toStripeAppearance)(props.appearance) } : {}
|
|
383
428
|
};
|
|
@@ -483,6 +528,11 @@ var init_stripe_elements = __esm({
|
|
|
483
528
|
observeWalletSheetClick(event.expressPaymentType, clickStartedAt);
|
|
484
529
|
event.resolve();
|
|
485
530
|
};
|
|
531
|
+
const settledVerdictOutcomes = {
|
|
532
|
+
complete: (result) => (0, import_shared5.invokeMerchantCallback)(() => emit("complete", result)),
|
|
533
|
+
decline: (decline) => (0, import_shared5.invokeMerchantCallback)(() => emit("decline", decline)),
|
|
534
|
+
error: (failure) => (0, import_shared5.invokeMerchantCallback)(() => emit("error", failure))
|
|
535
|
+
};
|
|
486
536
|
const confirm = async (elements, method, intentKind = props.intentKind, attempt = null) => {
|
|
487
537
|
if (!stripe || processing.value) return;
|
|
488
538
|
processing.value = true;
|
|
@@ -501,6 +551,17 @@ var init_stripe_elements = __esm({
|
|
|
501
551
|
paymentMethodId: null,
|
|
502
552
|
intentKind
|
|
503
553
|
});
|
|
554
|
+
if ((0, import_shared5.isSettledSessionIntent)(intent)) {
|
|
555
|
+
if (intentKind === "setup") throw (0, import_shared5.settledSessionIntentError)(sessionId);
|
|
556
|
+
await reportSettledIntentVerdict(
|
|
557
|
+
intent.response,
|
|
558
|
+
method,
|
|
559
|
+
sessionId,
|
|
560
|
+
props.session,
|
|
561
|
+
settledVerdictOutcomes
|
|
562
|
+
);
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
504
565
|
const clientSecret = intent.clientSecret ?? "";
|
|
505
566
|
const returnUrl = props.returnUrl ?? window.location.href;
|
|
506
567
|
const { error } = intentKind === "setup" ? await stripe.confirmSetup({
|
|
@@ -606,6 +667,16 @@ var init_stripe_elements = __esm({
|
|
|
606
667
|
paymentMethodId: paymentMethod?.id ?? null,
|
|
607
668
|
intentKind: "payment"
|
|
608
669
|
});
|
|
670
|
+
if ((0, import_shared5.isSettledSessionIntent)(intent)) {
|
|
671
|
+
await reportSettledIntentVerdict(
|
|
672
|
+
intent.response,
|
|
673
|
+
"paypal",
|
|
674
|
+
sessionId,
|
|
675
|
+
props.session,
|
|
676
|
+
settledVerdictOutcomes
|
|
677
|
+
);
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
609
680
|
if (intent.provider !== "stripe") {
|
|
610
681
|
throw new Error("Invalid provider returned for PayPal intent");
|
|
611
682
|
}
|
|
@@ -938,6 +1009,7 @@ var init_payment_method_setup_paypal = __esm({
|
|
|
938
1009
|
paymentMethodId: null,
|
|
939
1010
|
intentKind: "setup"
|
|
940
1011
|
});
|
|
1012
|
+
if ((0, import_shared6.isSettledSessionIntent)(intent)) throw (0, import_shared6.settledSessionIntentError)(sessionId);
|
|
941
1013
|
if (intent.provider !== "paypal" || intent.providerObjectType !== "setup_token") {
|
|
942
1014
|
throw new import_shared6.FloPayError(
|
|
943
1015
|
"The billing API did not return a PayPal setup token.",
|
|
@@ -1445,7 +1517,7 @@ var VaultCardFields = (0, import_vue3.defineComponent)({
|
|
|
1445
1517
|
};
|
|
1446
1518
|
const offReady = capture.on("ready", emitReadyOnce);
|
|
1447
1519
|
const offError = capture.on("error", (event) => {
|
|
1448
|
-
const message = event.message ?? "There was a problem loading the secure card form.";
|
|
1520
|
+
const message = (0, import_shared2.buyerEmailRequiredPrompt)(event.vaultOutcome) ?? event.message ?? "There was a problem loading the secure card form.";
|
|
1449
1521
|
(0, import_shared2.invokeMerchantCallback)(() => emit("error", message));
|
|
1450
1522
|
});
|
|
1451
1523
|
const offValidation = capture.on("validation", (event) => {
|
package/dist/{payment-method-setup-paypal-XPSU4CHA.mjs → payment-method-setup-paypal-D6FEQQJY.mjs}
RENAMED
|
@@ -5,7 +5,9 @@ import {
|
|
|
5
5
|
classifyExternalMethodFailure,
|
|
6
6
|
detectPayPalEnvironment,
|
|
7
7
|
FloPayError,
|
|
8
|
-
|
|
8
|
+
isSettledSessionIntent,
|
|
9
|
+
PAYPAL_VAULTED_PAYMENT_METHOD_TYPE,
|
|
10
|
+
settledSessionIntentError
|
|
9
11
|
} from "@flopay/shared";
|
|
10
12
|
import { loadScript } from "@paypal/paypal-js";
|
|
11
13
|
import { defineComponent, h, onBeforeUnmount, onMounted, ref } from "vue";
|
|
@@ -72,6 +74,7 @@ var PayPalSetupMethod = defineComponent({
|
|
|
72
74
|
paymentMethodId: null,
|
|
73
75
|
intentKind: "setup"
|
|
74
76
|
});
|
|
77
|
+
if (isSettledSessionIntent(intent)) throw settledSessionIntentError(sessionId);
|
|
75
78
|
if (intent.provider !== "paypal" || intent.providerObjectType !== "setup_token") {
|
|
76
79
|
throw new FloPayError(
|
|
77
80
|
"The billing API did not return a PayPal setup token.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flopay/vue",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@flopay/js": "1.14.
|
|
40
|
-
"@flopay/shared": "1.14.
|
|
39
|
+
"@flopay/js": "1.14.10",
|
|
40
|
+
"@flopay/shared": "1.14.10",
|
|
41
41
|
"@paypal/paypal-js": "^10.1.0",
|
|
42
|
-
"@stripe/stripe-js": "^
|
|
42
|
+
"@stripe/stripe-js": "^10.2.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vue": ">=3.3.0"
|