@flopay/vue 1.13.5 → 1.14.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 +44 -3
- package/dist/{chunk-VXYNYMHI.mjs → chunk-GDB2HY7D.mjs} +13 -1
- package/dist/{chunk-2PLBNCM6.mjs → chunk-SWZFYEFE.mjs} +1 -1
- package/dist/index.cjs +37 -1
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.mjs +28 -2
- package/dist/payment-method-setup-entry.cjs +12 -1
- package/dist/payment-method-setup-entry.mjs +1 -1
- package/dist/{stripe-elements-QGT45VIE.mjs → stripe-elements-B55YXBZK.mjs} +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -73,10 +73,10 @@ Every `@flopay/react` component and hook has a same-name Vue export. React's not
|
|
|
73
73
|
| Export | React (`@flopay/react`) | Vue (`@flopay/vue`) |
|
|
74
74
|
|--------|-------------------------|---------------------|
|
|
75
75
|
| `FloPayProvider` | `<FloPayProvider>` | `FloPayProvider`, provided to descendants; `@instrument` |
|
|
76
|
-
| `FloPayCheckout` | `<FloPayCheckout>` | `FloPayCheckout`: `@complete`, `@decline`, `@error`, `@button-click` |
|
|
77
|
-
| `SplitCardForm` | `<SplitCardForm>` | `SplitCardForm`: `@complete`, `@decline`, `@error` |
|
|
76
|
+
| `FloPayCheckout` | `<FloPayCheckout>` | `FloPayCheckout`: `@complete`, `@decline`, `@cancel`, `@error`, `@button-click` |
|
|
77
|
+
| `SplitCardForm` | `<SplitCardForm>` | `SplitCardForm`: `@complete`, `@decline`, `@cancel`, `@error` |
|
|
78
78
|
| `VaultCardFields` | `<VaultCardFields>` | `VaultCardFields`: `@ready`, `@error`, `@validation` |
|
|
79
|
-
| `DirectPayPalButton` | `<DirectPayPalButton>` | `DirectPayPalButton` |
|
|
79
|
+
| `DirectPayPalButton` | `<DirectPayPalButton>` | `DirectPayPalButton`: `@complete`, `@decline`, `@cancel`, `@error` |
|
|
80
80
|
| `FloPayAutomaticPaymentButton` | `<FloPayAutomaticPaymentButton>` | `FloPayAutomaticPaymentButton`: `@success`, `@error`, `@decline` |
|
|
81
81
|
| `FloPayCardSetup` | `<FloPayCardSetup>` | `FloPayCardSetup`: `@ready`, `@complete`, `@decline`, `@cancel`, `@error` |
|
|
82
82
|
| `FloPayPaymentMethodSetup` | `<FloPayPaymentMethodSetup>` | `FloPayPaymentMethodSetup` |
|
|
@@ -90,6 +90,47 @@ React `children` and custom layouts are slots. `FloPayCheckout`'s `layout` slot
|
|
|
90
90
|
|
|
91
91
|
Entry points: `@flopay/vue`, `@flopay/vue/card-setup` and `@flopay/vue/payment-method-setup`.
|
|
92
92
|
|
|
93
|
+
### PayPal buyer cancel
|
|
94
|
+
|
|
95
|
+
`FloPayCheckout`, `SplitCardForm` and `DirectPayPalButton` emit `cancel` (`@cancel`, React's `onCancel`) once per click when the buyer closes the PayPal pop-up, or returns from PayPal's app switch, without approving. The payload is a `FloPayPaymentCancelEvent`: `{ status: 'cancelled', sessionId, provider: 'paypal', paymentMethodType }`. `sessionId` is the attempt's session (the click-time patch's, otherwise the checkout's), and `paymentMethodType` is `paypal_vaulted` when the session advertises an `order` or `setup_token`, otherwise `paypal`.
|
|
96
|
+
|
|
97
|
+
It is never emitted for an approval, a decline (that stays `@decline`), a blocked pop-up, a load, render or eligibility failure, or a click your `runBeforeButtonClick` gate stopped, and a repeated cancel for the same click is ignored. It covers the direct PayPal button only (sessions with `gateways.paypal`). The button stays rendered for the next click, and nothing changes if you don't listen for it.
|
|
98
|
+
|
|
99
|
+
A "Didn't work? Pay another way" prompt that moves the buyer to the card form:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { FloPayCheckout, type FloPayPaymentCancelEvent } from '@flopay/vue';
|
|
103
|
+
import { defineComponent, h, ref } from 'vue';
|
|
104
|
+
|
|
105
|
+
export default defineComponent({
|
|
106
|
+
setup() {
|
|
107
|
+
const cancelled = ref<FloPayPaymentCancelEvent | null>(null);
|
|
108
|
+
const cardForm = ref<HTMLElement | null>(null);
|
|
109
|
+
return () => [
|
|
110
|
+
cancelled.value
|
|
111
|
+
? h('div', { role: 'status' }, [
|
|
112
|
+
"Didn't work? Pay another way. ",
|
|
113
|
+
h(
|
|
114
|
+
'button',
|
|
115
|
+
{ type: 'button', onClick: () => cardForm.value?.focus() },
|
|
116
|
+
'Pay by card or Google Pay',
|
|
117
|
+
),
|
|
118
|
+
])
|
|
119
|
+
: null,
|
|
120
|
+
h('div', { ref: cardForm, tabindex: -1 }, [
|
|
121
|
+
h(FloPayCheckout, {
|
|
122
|
+
sessionId: 'sess_123',
|
|
123
|
+
nonce: 'nonce_123',
|
|
124
|
+
onCancel: (event: FloPayPaymentCancelEvent) => {
|
|
125
|
+
cancelled.value = event;
|
|
126
|
+
},
|
|
127
|
+
}),
|
|
128
|
+
]),
|
|
129
|
+
];
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
93
134
|
## Errors
|
|
94
135
|
|
|
95
136
|
Errors are `FloPayError` instances from `@flopay/shared`, emitted through `@error`.
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
resolveSetupFutureUsage,
|
|
13
13
|
resolveWalletModeOptions,
|
|
14
14
|
shouldPreferWalletPopup,
|
|
15
|
+
stripeExpressMethodToOptionKey,
|
|
15
16
|
toStripeAppearance,
|
|
16
17
|
WALLET_SHEET_WINDOW_TOO_SMALL_CODE
|
|
17
18
|
} from "@flopay/shared";
|
|
@@ -218,6 +219,15 @@ function consumeStripePayPalReturn() {
|
|
|
218
219
|
|
|
219
220
|
// src/stripe-elements.ts
|
|
220
221
|
var WALLET_METHODS = /* @__PURE__ */ new Set(["apple_pay", "google_pay", "link", "paypal", "amazon_pay"]);
|
|
222
|
+
function buildExpressMethodMap(wallets) {
|
|
223
|
+
const enabledKeys = new Set(wallets.map(stripeExpressMethodToOptionKey));
|
|
224
|
+
return Object.fromEntries(
|
|
225
|
+
["applePay", "googlePay", "paypal", "link", "amazonPay", "klarna"].map((key) => [
|
|
226
|
+
key,
|
|
227
|
+
enabledKeys.has(key) ? "auto" : "never"
|
|
228
|
+
])
|
|
229
|
+
);
|
|
230
|
+
}
|
|
221
231
|
var EXPRESS_CHECKOUT_CLICK_BUDGET_MS = 900;
|
|
222
232
|
function checkoutButtonMethodFromProviderMethod(method) {
|
|
223
233
|
if (method === "paypal") return "paypal";
|
|
@@ -728,7 +738,9 @@ var StripePaymentMethods = defineComponent2({
|
|
|
728
738
|
if (wallets.length > 0 && walletContainer.value) {
|
|
729
739
|
if (shouldPreferWalletPopup()) cleanups.push(denyPaymentPermissionToNewFrames(document));
|
|
730
740
|
const elements = stripe.elements(walletElementsOptions(wallets));
|
|
731
|
-
const express = elements.create("expressCheckout"
|
|
741
|
+
const express = elements.create("expressCheckout", {
|
|
742
|
+
paymentMethods: buildExpressMethodMap(wallets)
|
|
743
|
+
});
|
|
732
744
|
express.on("click", (event) => gateWalletClick(event));
|
|
733
745
|
express.on("confirm", (event) => {
|
|
734
746
|
const attempt = walletAttempt;
|
|
@@ -38,7 +38,7 @@ function delay(ms) {
|
|
|
38
38
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
39
39
|
}
|
|
40
40
|
var StripeSetupMethods = defineAsyncComponent(
|
|
41
|
-
() => import("./stripe-elements-
|
|
41
|
+
() => import("./stripe-elements-B55YXBZK.mjs").then((module) => module.StripePaymentMethods)
|
|
42
42
|
);
|
|
43
43
|
var PayPalSetupMethods = defineAsyncComponent(
|
|
44
44
|
() => import("./payment-method-setup-paypal-XPSU4CHA.mjs").then((module) => module.PayPalSetupMethod)
|
package/dist/index.cjs
CHANGED
|
@@ -240,6 +240,15 @@ var stripe_elements_exports = {};
|
|
|
240
240
|
__export(stripe_elements_exports, {
|
|
241
241
|
StripePaymentMethods: () => StripePaymentMethods
|
|
242
242
|
});
|
|
243
|
+
function buildExpressMethodMap(wallets) {
|
|
244
|
+
const enabledKeys = new Set(wallets.map(import_shared6.stripeExpressMethodToOptionKey));
|
|
245
|
+
return Object.fromEntries(
|
|
246
|
+
["applePay", "googlePay", "paypal", "link", "amazonPay", "klarna"].map((key) => [
|
|
247
|
+
key,
|
|
248
|
+
enabledKeys.has(key) ? "auto" : "never"
|
|
249
|
+
])
|
|
250
|
+
);
|
|
251
|
+
}
|
|
243
252
|
function checkoutButtonMethodFromProviderMethod(method) {
|
|
244
253
|
if (method === "paypal") return "paypal";
|
|
245
254
|
if (method === "apple_pay") return "apple_pay";
|
|
@@ -761,7 +770,9 @@ var init_stripe_elements = __esm({
|
|
|
761
770
|
if (wallets.length > 0 && walletContainer.value) {
|
|
762
771
|
if ((0, import_shared6.shouldPreferWalletPopup)()) cleanups.push((0, import_shared6.denyPaymentPermissionToNewFrames)(document));
|
|
763
772
|
const elements = stripe.elements(walletElementsOptions(wallets));
|
|
764
|
-
const express = elements.create("expressCheckout"
|
|
773
|
+
const express = elements.create("expressCheckout", {
|
|
774
|
+
paymentMethods: buildExpressMethodMap(wallets)
|
|
775
|
+
});
|
|
765
776
|
express.on("click", (event) => gateWalletClick(event));
|
|
766
777
|
express.on("confirm", (event) => {
|
|
767
778
|
const attempt = walletAttempt;
|
|
@@ -1375,6 +1386,8 @@ var DirectPayPalButton = (0, import_vue3.defineComponent)({
|
|
|
1375
1386
|
emits: {
|
|
1376
1387
|
complete: (_result) => true,
|
|
1377
1388
|
decline: (_decline) => true,
|
|
1389
|
+
/** The buyer closed or left PayPal without approving (once per click attempt). */
|
|
1390
|
+
cancel: (_event) => true,
|
|
1378
1391
|
error: (_error) => true,
|
|
1379
1392
|
errorChange: (_message) => true,
|
|
1380
1393
|
buttonClick: (_method) => true,
|
|
@@ -1393,6 +1406,7 @@ var DirectPayPalButton = (0, import_vue3.defineComponent)({
|
|
|
1393
1406
|
let generation = 0;
|
|
1394
1407
|
let retryTimer = null;
|
|
1395
1408
|
let prepared = null;
|
|
1409
|
+
let attemptLive = false;
|
|
1396
1410
|
let intentIdempotencyKey;
|
|
1397
1411
|
let intentAttemptActive = false;
|
|
1398
1412
|
const beginIntentAttempt = () => {
|
|
@@ -1519,6 +1533,7 @@ var DirectPayPalButton = (0, import_vue3.defineComponent)({
|
|
|
1519
1533
|
(0, import_shared4.invokeMerchantCallback)(() => emit("errorChange", recoveryMessage));
|
|
1520
1534
|
};
|
|
1521
1535
|
const runtimeFailure = (error) => {
|
|
1536
|
+
attemptLive = false;
|
|
1522
1537
|
const message = errorMessage(error, "PayPal failed to render.");
|
|
1523
1538
|
if ((0, import_shared4.isPayPalTeardownMessage)(message)) {
|
|
1524
1539
|
prepared = null;
|
|
@@ -1614,6 +1629,7 @@ var DirectPayPalButton = (0, import_vue3.defineComponent)({
|
|
|
1614
1629
|
};
|
|
1615
1630
|
const approve = async (gen, data, actions) => {
|
|
1616
1631
|
if (!isCurrent(gen)) return;
|
|
1632
|
+
attemptLive = false;
|
|
1617
1633
|
const attempt = { ...prepared ?? {} };
|
|
1618
1634
|
submitting.value = true;
|
|
1619
1635
|
trace("onApprove");
|
|
@@ -1660,6 +1676,7 @@ var DirectPayPalButton = (0, import_vue3.defineComponent)({
|
|
|
1660
1676
|
}
|
|
1661
1677
|
beginIntentAttempt();
|
|
1662
1678
|
prepared = null;
|
|
1679
|
+
attemptLive = false;
|
|
1663
1680
|
let next = {};
|
|
1664
1681
|
const runner = props.runBeforeButtonClick;
|
|
1665
1682
|
if (runner) {
|
|
@@ -1689,9 +1706,18 @@ var DirectPayPalButton = (0, import_vue3.defineComponent)({
|
|
|
1689
1706
|
}
|
|
1690
1707
|
(0, import_shared4.invokeMerchantCallback)(() => emit("buttonClick", "paypal"));
|
|
1691
1708
|
prepared = next;
|
|
1709
|
+
attemptLive = true;
|
|
1692
1710
|
trace("onClick:resolve");
|
|
1693
1711
|
await actions.resolve();
|
|
1694
1712
|
};
|
|
1713
|
+
const cancel = (gen) => {
|
|
1714
|
+
if (!isCurrent(gen) || !attemptLive) return;
|
|
1715
|
+
attemptLive = false;
|
|
1716
|
+
const event = (0, import_shared4.buildPayPalCancelEvent)(effectiveSessionId(), configuredObjectType());
|
|
1717
|
+
prepared = null;
|
|
1718
|
+
trace("onCancel");
|
|
1719
|
+
(0, import_shared4.invokeMerchantCallback)(() => emit("cancel", event));
|
|
1720
|
+
};
|
|
1695
1721
|
const renderButtons = async (gen) => {
|
|
1696
1722
|
const normalized = (0, import_shared4.normalizeGatewayEnvironment)(props.environment);
|
|
1697
1723
|
const environment = normalized === "live" ? "production" : normalized;
|
|
@@ -1743,6 +1769,7 @@ var DirectPayPalButton = (0, import_vue3.defineComponent)({
|
|
|
1743
1769
|
...handlers,
|
|
1744
1770
|
onClick: (_data, actions) => click(gen, actions),
|
|
1745
1771
|
onApprove: (data, actions) => approve(gen, data, actions),
|
|
1772
|
+
onCancel: () => cancel(gen),
|
|
1746
1773
|
onError: (error) => {
|
|
1747
1774
|
if (!isCurrent(gen)) return;
|
|
1748
1775
|
trace(
|
|
@@ -1827,6 +1854,7 @@ var DirectPayPalButton = (0, import_vue3.defineComponent)({
|
|
|
1827
1854
|
if (retryTimer) clearTimeout(retryTimer);
|
|
1828
1855
|
retryTimer = null;
|
|
1829
1856
|
prepared = null;
|
|
1857
|
+
attemptLive = false;
|
|
1830
1858
|
intentIdempotencyKey = void 0;
|
|
1831
1859
|
intentAttemptActive = false;
|
|
1832
1860
|
closeButtons();
|
|
@@ -2192,6 +2220,8 @@ var SplitCardForm = (0, import_vue6.defineComponent)({
|
|
|
2192
2220
|
complete: (_result) => true,
|
|
2193
2221
|
error: (_error) => true,
|
|
2194
2222
|
decline: (_decline) => true,
|
|
2223
|
+
// React's `onCancel`: the direct PayPal button's buyer cancel, re-emitted once.
|
|
2224
|
+
cancel: (_event) => true,
|
|
2195
2225
|
buttonClick: (_method) => true,
|
|
2196
2226
|
countryChange: (_country) => true,
|
|
2197
2227
|
// React's `onZipChange`.
|
|
@@ -3200,6 +3230,7 @@ var SplitCardForm = (0, import_vue6.defineComponent)({
|
|
|
3200
3230
|
// React's `onTokenizedBody={dispatchTokenizedBody}`: the form
|
|
3201
3231
|
// continues the approval (or hands it to the host's handler).
|
|
3202
3232
|
onTokenizedBody: dispatchTokenizedBody,
|
|
3233
|
+
onCancel: (event) => (0, import_shared8.invokeMerchantCallback)(() => emit("cancel", event)),
|
|
3203
3234
|
onButtonClick: (method) => (0, import_shared8.invokeMerchantCallback)(() => emit("buttonClick", method)),
|
|
3204
3235
|
onErrorChange: (message) => {
|
|
3205
3236
|
failure.value = message;
|
|
@@ -3494,6 +3525,8 @@ var FloPayCheckout = (0, import_vue7.defineComponent)({
|
|
|
3494
3525
|
error: (_error) => true,
|
|
3495
3526
|
instrument: (_event) => true,
|
|
3496
3527
|
decline: (_decline) => true,
|
|
3528
|
+
// React's `onCancel`: a direct PayPal buyer cancel from the built-in form.
|
|
3529
|
+
cancel: (_event) => true,
|
|
3497
3530
|
buttonClick: (_method) => true,
|
|
3498
3531
|
countryChange: (_country) => true,
|
|
3499
3532
|
// React's `onZipChange`.
|
|
@@ -3886,6 +3919,9 @@ var FloPayCheckout = (0, import_vue7.defineComponent)({
|
|
|
3886
3919
|
enabledPaymentMethodCountries: stripeCountryGate.value,
|
|
3887
3920
|
debug: props.debug,
|
|
3888
3921
|
...relay,
|
|
3922
|
+
// React's `onCancel={onCancel}`: the built-in form's direct PayPal
|
|
3923
|
+
// cancel reaches the merchant once.
|
|
3924
|
+
onCancel: (event) => (0, import_shared9.invokeMerchantCallback)(() => emit("cancel", event)),
|
|
3889
3925
|
onCountryChange: (country) => (0, import_shared9.invokeMerchantCallback)(() => emit("countryChange", country)),
|
|
3890
3926
|
onZipChange: (zip) => (0, import_shared9.invokeMerchantCallback)(() => emit("zipChange", zip))
|
|
3891
3927
|
},
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _flopay_shared from '@flopay/shared';
|
|
2
|
-
import { InlineSessionDraft, CheckoutButtonMethod, CheckoutProduct, CheckoutItem, CheckoutSubscription, ThemeId, FloPayAppearance, ButtonsLayoutTheme, ButtonsLayoutStyles, PaymentResult, CheckoutSession, FloPayError, DeclineEvent, PayPalBuyerIdentity, GatewayEnvironment, PayPalProviderObjectType, PayPalApprovalPresentation, InlineSessionPatch, TokenizedBody, TelemetryTerminalReason, BeforeButtonClickEvent, WalletPresentation, AVSFieldConfig, VaultCardFieldKey, CheckoutMode, FloInstrumentEvent, CardCaptureAdapter, VaultCardThemeColors } from '@flopay/shared';
|
|
3
|
-
export { BeforeButtonClickEvent, CheckoutButtonMethod, DeclineEvent, FloInstrumentEvent, InlineSessionDraft, InlineSessionPatch, SentryEventLike, SentryStackFrameLike, WalletPresentation, dropThirdPartyOnlyError } from '@flopay/shared';
|
|
2
|
+
import { InlineSessionDraft, CheckoutButtonMethod, CheckoutProduct, CheckoutItem, CheckoutSubscription, ThemeId, FloPayAppearance, ButtonsLayoutTheme, ButtonsLayoutStyles, PaymentResult, CheckoutSession, FloPayError, DeclineEvent, PayPalBuyerIdentity, GatewayEnvironment, PayPalProviderObjectType, PayPalApprovalPresentation, InlineSessionPatch, TokenizedBody, TelemetryTerminalReason, FloPayPaymentCancelEvent, BeforeButtonClickEvent, WalletPresentation, AVSFieldConfig, VaultCardFieldKey, CheckoutMode, FloInstrumentEvent, CardCaptureAdapter, VaultCardThemeColors } from '@flopay/shared';
|
|
3
|
+
export { BeforeButtonClickEvent, CheckoutButtonMethod, DeclineEvent, FloInstrumentEvent, FloPayPaymentCancelEvent, InlineSessionDraft, InlineSessionPatch, SentryEventLike, SentryStackFrameLike, WalletPresentation, dropThirdPartyOnlyError } from '@flopay/shared';
|
|
4
4
|
import * as vue from 'vue';
|
|
5
5
|
import { PropType, VNode, ShallowRef, CSSProperties } from 'vue';
|
|
6
6
|
export { FloPayCardSetup, FloPayCardSetupProps } from './card-setup-entry.cjs';
|
|
@@ -480,6 +480,8 @@ declare const DirectPayPalButton: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
480
480
|
}> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
481
481
|
complete: (_result: PaymentResult) => true;
|
|
482
482
|
decline: (_decline: DeclineEvent) => true;
|
|
483
|
+
/** The buyer closed or left PayPal without approving (once per click attempt). */
|
|
484
|
+
cancel: (_event: FloPayPaymentCancelEvent) => true;
|
|
483
485
|
error: (_error: FloPayError) => true;
|
|
484
486
|
errorChange: (_message: string | null) => true;
|
|
485
487
|
buttonClick: (_method: CheckoutButtonMethod) => true;
|
|
@@ -572,6 +574,7 @@ declare const DirectPayPalButton: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
572
574
|
};
|
|
573
575
|
}>> & Readonly<{
|
|
574
576
|
onComplete?: ((_result: PaymentResult) => any) | undefined;
|
|
577
|
+
onCancel?: ((_event: FloPayPaymentCancelEvent) => any) | undefined;
|
|
575
578
|
onError?: ((_error: FloPayError) => any) | undefined;
|
|
576
579
|
onDecline?: ((_decline: DeclineEvent) => any) | undefined;
|
|
577
580
|
onErrorChange?: ((_message: string | null) => any) | undefined;
|
|
@@ -1015,6 +1018,7 @@ declare const SplitCardForm: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
1015
1018
|
complete: (_result: PaymentResult) => true;
|
|
1016
1019
|
error: (_error: FloPayError) => true;
|
|
1017
1020
|
decline: (_decline: DeclineEvent) => true;
|
|
1021
|
+
cancel: (_event: FloPayPaymentCancelEvent) => true;
|
|
1018
1022
|
buttonClick: (_method: CheckoutButtonMethod) => true;
|
|
1019
1023
|
countryChange: (_country: string) => true;
|
|
1020
1024
|
zipChange: (_zip: string) => true;
|
|
@@ -1229,6 +1233,7 @@ declare const SplitCardForm: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
1229
1233
|
};
|
|
1230
1234
|
}>> & Readonly<{
|
|
1231
1235
|
onComplete?: ((_result: PaymentResult) => any) | undefined;
|
|
1236
|
+
onCancel?: ((_event: FloPayPaymentCancelEvent) => any) | undefined;
|
|
1232
1237
|
onError?: ((_error: FloPayError) => any) | undefined;
|
|
1233
1238
|
onDecline?: ((_decline: DeclineEvent) => any) | undefined;
|
|
1234
1239
|
onErrorChange?: ((_error: string | null) => any) | undefined;
|
|
@@ -1537,6 +1542,7 @@ declare const FloPayCheckout: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
1537
1542
|
error: (_error: FloPayError) => true;
|
|
1538
1543
|
instrument: (_event: FloInstrumentEvent) => true;
|
|
1539
1544
|
decline: (_decline: DeclineEvent) => true;
|
|
1545
|
+
cancel: (_event: FloPayPaymentCancelEvent) => true;
|
|
1540
1546
|
buttonClick: (_method: CheckoutButtonMethod) => true;
|
|
1541
1547
|
countryChange: (_country: string) => true;
|
|
1542
1548
|
zipChange: (_zip: string) => true;
|
|
@@ -1679,6 +1685,7 @@ declare const FloPayCheckout: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
1679
1685
|
}>> & Readonly<{
|
|
1680
1686
|
onInstrument?: ((_event: FloInstrumentEvent) => any) | undefined;
|
|
1681
1687
|
onComplete?: ((_result: PaymentResult) => any) | undefined;
|
|
1688
|
+
onCancel?: ((_event: FloPayPaymentCancelEvent) => any) | undefined;
|
|
1682
1689
|
onError?: ((_error: FloPayError) => any) | undefined;
|
|
1683
1690
|
onDecline?: ((_decline: DeclineEvent) => any) | undefined;
|
|
1684
1691
|
onButtonClick?: ((_method: CheckoutButtonMethod) => any) | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _flopay_shared from '@flopay/shared';
|
|
2
|
-
import { InlineSessionDraft, CheckoutButtonMethod, CheckoutProduct, CheckoutItem, CheckoutSubscription, ThemeId, FloPayAppearance, ButtonsLayoutTheme, ButtonsLayoutStyles, PaymentResult, CheckoutSession, FloPayError, DeclineEvent, PayPalBuyerIdentity, GatewayEnvironment, PayPalProviderObjectType, PayPalApprovalPresentation, InlineSessionPatch, TokenizedBody, TelemetryTerminalReason, BeforeButtonClickEvent, WalletPresentation, AVSFieldConfig, VaultCardFieldKey, CheckoutMode, FloInstrumentEvent, CardCaptureAdapter, VaultCardThemeColors } from '@flopay/shared';
|
|
3
|
-
export { BeforeButtonClickEvent, CheckoutButtonMethod, DeclineEvent, FloInstrumentEvent, InlineSessionDraft, InlineSessionPatch, SentryEventLike, SentryStackFrameLike, WalletPresentation, dropThirdPartyOnlyError } from '@flopay/shared';
|
|
2
|
+
import { InlineSessionDraft, CheckoutButtonMethod, CheckoutProduct, CheckoutItem, CheckoutSubscription, ThemeId, FloPayAppearance, ButtonsLayoutTheme, ButtonsLayoutStyles, PaymentResult, CheckoutSession, FloPayError, DeclineEvent, PayPalBuyerIdentity, GatewayEnvironment, PayPalProviderObjectType, PayPalApprovalPresentation, InlineSessionPatch, TokenizedBody, TelemetryTerminalReason, FloPayPaymentCancelEvent, BeforeButtonClickEvent, WalletPresentation, AVSFieldConfig, VaultCardFieldKey, CheckoutMode, FloInstrumentEvent, CardCaptureAdapter, VaultCardThemeColors } from '@flopay/shared';
|
|
3
|
+
export { BeforeButtonClickEvent, CheckoutButtonMethod, DeclineEvent, FloInstrumentEvent, FloPayPaymentCancelEvent, InlineSessionDraft, InlineSessionPatch, SentryEventLike, SentryStackFrameLike, WalletPresentation, dropThirdPartyOnlyError } from '@flopay/shared';
|
|
4
4
|
import * as vue from 'vue';
|
|
5
5
|
import { PropType, VNode, ShallowRef, CSSProperties } from 'vue';
|
|
6
6
|
export { FloPayCardSetup, FloPayCardSetupProps } from './card-setup-entry.js';
|
|
@@ -480,6 +480,8 @@ declare const DirectPayPalButton: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
480
480
|
}> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
481
481
|
complete: (_result: PaymentResult) => true;
|
|
482
482
|
decline: (_decline: DeclineEvent) => true;
|
|
483
|
+
/** The buyer closed or left PayPal without approving (once per click attempt). */
|
|
484
|
+
cancel: (_event: FloPayPaymentCancelEvent) => true;
|
|
483
485
|
error: (_error: FloPayError) => true;
|
|
484
486
|
errorChange: (_message: string | null) => true;
|
|
485
487
|
buttonClick: (_method: CheckoutButtonMethod) => true;
|
|
@@ -572,6 +574,7 @@ declare const DirectPayPalButton: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
572
574
|
};
|
|
573
575
|
}>> & Readonly<{
|
|
574
576
|
onComplete?: ((_result: PaymentResult) => any) | undefined;
|
|
577
|
+
onCancel?: ((_event: FloPayPaymentCancelEvent) => any) | undefined;
|
|
575
578
|
onError?: ((_error: FloPayError) => any) | undefined;
|
|
576
579
|
onDecline?: ((_decline: DeclineEvent) => any) | undefined;
|
|
577
580
|
onErrorChange?: ((_message: string | null) => any) | undefined;
|
|
@@ -1015,6 +1018,7 @@ declare const SplitCardForm: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
1015
1018
|
complete: (_result: PaymentResult) => true;
|
|
1016
1019
|
error: (_error: FloPayError) => true;
|
|
1017
1020
|
decline: (_decline: DeclineEvent) => true;
|
|
1021
|
+
cancel: (_event: FloPayPaymentCancelEvent) => true;
|
|
1018
1022
|
buttonClick: (_method: CheckoutButtonMethod) => true;
|
|
1019
1023
|
countryChange: (_country: string) => true;
|
|
1020
1024
|
zipChange: (_zip: string) => true;
|
|
@@ -1229,6 +1233,7 @@ declare const SplitCardForm: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
1229
1233
|
};
|
|
1230
1234
|
}>> & Readonly<{
|
|
1231
1235
|
onComplete?: ((_result: PaymentResult) => any) | undefined;
|
|
1236
|
+
onCancel?: ((_event: FloPayPaymentCancelEvent) => any) | undefined;
|
|
1232
1237
|
onError?: ((_error: FloPayError) => any) | undefined;
|
|
1233
1238
|
onDecline?: ((_decline: DeclineEvent) => any) | undefined;
|
|
1234
1239
|
onErrorChange?: ((_error: string | null) => any) | undefined;
|
|
@@ -1537,6 +1542,7 @@ declare const FloPayCheckout: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
1537
1542
|
error: (_error: FloPayError) => true;
|
|
1538
1543
|
instrument: (_event: FloInstrumentEvent) => true;
|
|
1539
1544
|
decline: (_decline: DeclineEvent) => true;
|
|
1545
|
+
cancel: (_event: FloPayPaymentCancelEvent) => true;
|
|
1540
1546
|
buttonClick: (_method: CheckoutButtonMethod) => true;
|
|
1541
1547
|
countryChange: (_country: string) => true;
|
|
1542
1548
|
zipChange: (_zip: string) => true;
|
|
@@ -1679,6 +1685,7 @@ declare const FloPayCheckout: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
1679
1685
|
}>> & Readonly<{
|
|
1680
1686
|
onInstrument?: ((_event: FloInstrumentEvent) => any) | undefined;
|
|
1681
1687
|
onComplete?: ((_result: PaymentResult) => any) | undefined;
|
|
1688
|
+
onCancel?: ((_event: FloPayPaymentCancelEvent) => any) | undefined;
|
|
1682
1689
|
onError?: ((_error: FloPayError) => any) | undefined;
|
|
1683
1690
|
onDecline?: ((_decline: DeclineEvent) => any) | undefined;
|
|
1684
1691
|
onButtonClick?: ((_method: CheckoutButtonMethod) => any) | undefined;
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-DUU6SMKP.mjs";
|
|
4
4
|
import {
|
|
5
5
|
FloPayPaymentMethodSetup
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SWZFYEFE.mjs";
|
|
7
7
|
import {
|
|
8
8
|
FloPayCardSetupError,
|
|
9
9
|
VaultCardFields
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
FloPayProvider,
|
|
16
16
|
StripePaymentMethods,
|
|
17
17
|
hasStripePayPalReturn
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-GDB2HY7D.mjs";
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
import { dropThirdPartyOnlyError } from "@flopay/shared";
|
|
@@ -256,6 +256,7 @@ import { PaymentAPI } from "@flopay/js/card-setup";
|
|
|
256
256
|
import {
|
|
257
257
|
applyFriendlyMessageOverride,
|
|
258
258
|
buildExternalMethodRecoveryMessage,
|
|
259
|
+
buildPayPalCancelEvent,
|
|
259
260
|
buildPayPalProcessPaymentRequest,
|
|
260
261
|
buildPayPalSessionIntentRequest,
|
|
261
262
|
buildPayPalTokenizedBody,
|
|
@@ -475,6 +476,8 @@ var DirectPayPalButton = defineComponent2({
|
|
|
475
476
|
emits: {
|
|
476
477
|
complete: (_result) => true,
|
|
477
478
|
decline: (_decline) => true,
|
|
479
|
+
/** The buyer closed or left PayPal without approving (once per click attempt). */
|
|
480
|
+
cancel: (_event) => true,
|
|
478
481
|
error: (_error) => true,
|
|
479
482
|
errorChange: (_message) => true,
|
|
480
483
|
buttonClick: (_method) => true,
|
|
@@ -493,6 +496,7 @@ var DirectPayPalButton = defineComponent2({
|
|
|
493
496
|
let generation = 0;
|
|
494
497
|
let retryTimer = null;
|
|
495
498
|
let prepared = null;
|
|
499
|
+
let attemptLive = false;
|
|
496
500
|
let intentIdempotencyKey;
|
|
497
501
|
let intentAttemptActive = false;
|
|
498
502
|
const beginIntentAttempt = () => {
|
|
@@ -619,6 +623,7 @@ var DirectPayPalButton = defineComponent2({
|
|
|
619
623
|
invokeMerchantCallback(() => emit("errorChange", recoveryMessage));
|
|
620
624
|
};
|
|
621
625
|
const runtimeFailure = (error) => {
|
|
626
|
+
attemptLive = false;
|
|
622
627
|
const message = errorMessage(error, "PayPal failed to render.");
|
|
623
628
|
if (isPayPalTeardownMessage(message)) {
|
|
624
629
|
prepared = null;
|
|
@@ -714,6 +719,7 @@ var DirectPayPalButton = defineComponent2({
|
|
|
714
719
|
};
|
|
715
720
|
const approve = async (gen, data, actions) => {
|
|
716
721
|
if (!isCurrent(gen)) return;
|
|
722
|
+
attemptLive = false;
|
|
717
723
|
const attempt = { ...prepared ?? {} };
|
|
718
724
|
submitting.value = true;
|
|
719
725
|
trace("onApprove");
|
|
@@ -760,6 +766,7 @@ var DirectPayPalButton = defineComponent2({
|
|
|
760
766
|
}
|
|
761
767
|
beginIntentAttempt();
|
|
762
768
|
prepared = null;
|
|
769
|
+
attemptLive = false;
|
|
763
770
|
let next = {};
|
|
764
771
|
const runner = props.runBeforeButtonClick;
|
|
765
772
|
if (runner) {
|
|
@@ -789,9 +796,18 @@ var DirectPayPalButton = defineComponent2({
|
|
|
789
796
|
}
|
|
790
797
|
invokeMerchantCallback(() => emit("buttonClick", "paypal"));
|
|
791
798
|
prepared = next;
|
|
799
|
+
attemptLive = true;
|
|
792
800
|
trace("onClick:resolve");
|
|
793
801
|
await actions.resolve();
|
|
794
802
|
};
|
|
803
|
+
const cancel = (gen) => {
|
|
804
|
+
if (!isCurrent(gen) || !attemptLive) return;
|
|
805
|
+
attemptLive = false;
|
|
806
|
+
const event = buildPayPalCancelEvent(effectiveSessionId(), configuredObjectType());
|
|
807
|
+
prepared = null;
|
|
808
|
+
trace("onCancel");
|
|
809
|
+
invokeMerchantCallback(() => emit("cancel", event));
|
|
810
|
+
};
|
|
795
811
|
const renderButtons = async (gen) => {
|
|
796
812
|
const normalized = normalizeGatewayEnvironment(props.environment);
|
|
797
813
|
const environment = normalized === "live" ? "production" : normalized;
|
|
@@ -843,6 +859,7 @@ var DirectPayPalButton = defineComponent2({
|
|
|
843
859
|
...handlers,
|
|
844
860
|
onClick: (_data, actions) => click(gen, actions),
|
|
845
861
|
onApprove: (data, actions) => approve(gen, data, actions),
|
|
862
|
+
onCancel: () => cancel(gen),
|
|
846
863
|
onError: (error) => {
|
|
847
864
|
if (!isCurrent(gen)) return;
|
|
848
865
|
trace(
|
|
@@ -927,6 +944,7 @@ var DirectPayPalButton = defineComponent2({
|
|
|
927
944
|
if (retryTimer) clearTimeout(retryTimer);
|
|
928
945
|
retryTimer = null;
|
|
929
946
|
prepared = null;
|
|
947
|
+
attemptLive = false;
|
|
930
948
|
intentIdempotencyKey = void 0;
|
|
931
949
|
intentAttemptActive = false;
|
|
932
950
|
closeButtons();
|
|
@@ -1173,6 +1191,8 @@ var SplitCardForm = defineComponent3({
|
|
|
1173
1191
|
complete: (_result) => true,
|
|
1174
1192
|
error: (_error) => true,
|
|
1175
1193
|
decline: (_decline) => true,
|
|
1194
|
+
// React's `onCancel`: the direct PayPal button's buyer cancel, re-emitted once.
|
|
1195
|
+
cancel: (_event) => true,
|
|
1176
1196
|
buttonClick: (_method) => true,
|
|
1177
1197
|
countryChange: (_country) => true,
|
|
1178
1198
|
// React's `onZipChange`.
|
|
@@ -2181,6 +2201,7 @@ var SplitCardForm = defineComponent3({
|
|
|
2181
2201
|
// React's `onTokenizedBody={dispatchTokenizedBody}`: the form
|
|
2182
2202
|
// continues the approval (or hands it to the host's handler).
|
|
2183
2203
|
onTokenizedBody: dispatchTokenizedBody,
|
|
2204
|
+
onCancel: (event) => invokeMerchantCallback2(() => emit("cancel", event)),
|
|
2184
2205
|
onButtonClick: (method) => invokeMerchantCallback2(() => emit("buttonClick", method)),
|
|
2185
2206
|
onErrorChange: (message) => {
|
|
2186
2207
|
failure.value = message;
|
|
@@ -2475,6 +2496,8 @@ var FloPayCheckout = defineComponent4({
|
|
|
2475
2496
|
error: (_error) => true,
|
|
2476
2497
|
instrument: (_event) => true,
|
|
2477
2498
|
decline: (_decline) => true,
|
|
2499
|
+
// React's `onCancel`: a direct PayPal buyer cancel from the built-in form.
|
|
2500
|
+
cancel: (_event) => true,
|
|
2478
2501
|
buttonClick: (_method) => true,
|
|
2479
2502
|
countryChange: (_country) => true,
|
|
2480
2503
|
// React's `onZipChange`.
|
|
@@ -2867,6 +2890,9 @@ var FloPayCheckout = defineComponent4({
|
|
|
2867
2890
|
enabledPaymentMethodCountries: stripeCountryGate.value,
|
|
2868
2891
|
debug: props.debug,
|
|
2869
2892
|
...relay,
|
|
2893
|
+
// React's `onCancel={onCancel}`: the built-in form's direct PayPal
|
|
2894
|
+
// cancel reaches the merchant once.
|
|
2895
|
+
onCancel: (event) => invokeMerchantCallback3(() => emit("cancel", event)),
|
|
2870
2896
|
onCountryChange: (country) => invokeMerchantCallback3(() => emit("countryChange", country)),
|
|
2871
2897
|
onZipChange: (zip) => invokeMerchantCallback3(() => emit("zipChange", zip))
|
|
2872
2898
|
},
|
|
@@ -233,6 +233,15 @@ var stripe_elements_exports = {};
|
|
|
233
233
|
__export(stripe_elements_exports, {
|
|
234
234
|
StripePaymentMethods: () => StripePaymentMethods
|
|
235
235
|
});
|
|
236
|
+
function buildExpressMethodMap(wallets) {
|
|
237
|
+
const enabledKeys = new Set(wallets.map(import_shared5.stripeExpressMethodToOptionKey));
|
|
238
|
+
return Object.fromEntries(
|
|
239
|
+
["applePay", "googlePay", "paypal", "link", "amazonPay", "klarna"].map((key) => [
|
|
240
|
+
key,
|
|
241
|
+
enabledKeys.has(key) ? "auto" : "never"
|
|
242
|
+
])
|
|
243
|
+
);
|
|
244
|
+
}
|
|
236
245
|
function checkoutButtonMethodFromProviderMethod(method) {
|
|
237
246
|
if (method === "paypal") return "paypal";
|
|
238
247
|
if (method === "apple_pay") return "apple_pay";
|
|
@@ -754,7 +763,9 @@ var init_stripe_elements = __esm({
|
|
|
754
763
|
if (wallets.length > 0 && walletContainer.value) {
|
|
755
764
|
if ((0, import_shared5.shouldPreferWalletPopup)()) cleanups.push((0, import_shared5.denyPaymentPermissionToNewFrames)(document));
|
|
756
765
|
const elements = stripe.elements(walletElementsOptions(wallets));
|
|
757
|
-
const express = elements.create("expressCheckout"
|
|
766
|
+
const express = elements.create("expressCheckout", {
|
|
767
|
+
paymentMethods: buildExpressMethodMap(wallets)
|
|
768
|
+
});
|
|
758
769
|
express.on("click", (event) => gateWalletClick(event));
|
|
759
770
|
express.on("confirm", (event) => {
|
|
760
771
|
const attempt = walletAttempt;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flopay/vue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@flopay/js": "1.
|
|
40
|
-
"@flopay/shared": "1.
|
|
39
|
+
"@flopay/js": "1.14.1",
|
|
40
|
+
"@flopay/shared": "1.14.1",
|
|
41
41
|
"@paypal/paypal-js": "^10.1.0",
|
|
42
42
|
"@stripe/stripe-js": "^9.17.0"
|
|
43
43
|
},
|