@kiva/kv-shop 3.0.3 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/useBraintreeDropIn.js +38 -38
- package/package.json +3 -5
- package/dist/_virtual/_commonjsHelpers.js +0 -8
- package/dist/_virtual/index.js +0 -11
- package/dist/vendor/braintree-web-drop-in/constants.js +0 -90
- package/dist/vendor/braintree-web-drop-in/dropin-model.js +0 -228
- package/dist/vendor/braintree-web-drop-in/dropin.js +0 -727
- package/dist/vendor/braintree-web-drop-in/index.js +0 -53
- package/dist/vendor/braintree-web-drop-in/lib/add-selection-event-handler.js +0 -14
- package/dist/vendor/braintree-web-drop-in/lib/analytics.js +0 -34
- package/dist/vendor/braintree-web-drop-in/lib/assign.js +0 -22
- package/dist/vendor/braintree-web-drop-in/lib/browser-detection.js +0 -15
- package/dist/vendor/braintree-web-drop-in/lib/create-from-script-tag.js +0 -74
- package/dist/vendor/braintree-web-drop-in/lib/data-collector.js +0 -38
- package/dist/vendor/braintree-web-drop-in/lib/dropin-error.js +0 -15
- package/dist/vendor/braintree-web-drop-in/lib/find-parent-form.js +0 -15
- package/dist/vendor/braintree-web-drop-in/lib/is-guest-checkout.js +0 -14
- package/dist/vendor/braintree-web-drop-in/lib/is-https.js +0 -15
- package/dist/vendor/braintree-web-drop-in/lib/is-utf-8.js +0 -10
- package/dist/vendor/braintree-web-drop-in/lib/kebab-case-to-camel-case.js +0 -15
- package/dist/vendor/braintree-web-drop-in/lib/polyfill.js +0 -26
- package/dist/vendor/braintree-web-drop-in/lib/sanitize-html.js +0 -9
- package/dist/vendor/braintree-web-drop-in/lib/supports-flexbox.js +0 -18
- package/dist/vendor/braintree-web-drop-in/lib/three-d-secure.js +0 -49
- package/dist/vendor/braintree-web-drop-in/lib/transition-helper.js +0 -26
- package/dist/vendor/braintree-web-drop-in/lib/wait.js +0 -16
- package/dist/vendor/braintree-web-drop-in/translations/ar_EG.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/cs_CZ.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/da_DK.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/de_DE.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/el_GR.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/en_AU.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/en_GB.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/en_IN.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/en_US.js +0 -84
- package/dist/vendor/braintree-web-drop-in/translations/es_ES.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/es_XC.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/fi_FI.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/fr_CA.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/fr_FR.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/fr_XC.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/he_IL.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/hu_HU.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/id_ID.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/index.js +0 -108
- package/dist/vendor/braintree-web-drop-in/translations/it_IT.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/ja_JP.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/ko_KR.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/nl_NL.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/no_NO.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/pl_PL.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/pt_BR.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/pt_PT.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/ru_RU.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/sk_SK.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/sv_SE.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/th_TH.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/zh_CN.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/zh_HK.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/zh_TW.js +0 -81
- package/dist/vendor/braintree-web-drop-in/translations/zh_XC.js +0 -81
- package/dist/vendor/braintree-web-drop-in/views/base-view.js +0 -29
- package/dist/vendor/braintree-web-drop-in/views/delete-confirmation-view.js +0 -44
- package/dist/vendor/braintree-web-drop-in/views/main-view.js +0 -152
- package/dist/vendor/braintree-web-drop-in/views/payment-method-view.js +0 -76
- package/dist/vendor/braintree-web-drop-in/views/payment-methods-view.js +0 -72
- package/dist/vendor/braintree-web-drop-in/views/payment-options-view.js +0 -61
- package/dist/vendor/braintree-web-drop-in/views/payment-sheet-views/apple-pay-view.js +0 -59
- package/dist/vendor/braintree-web-drop-in/views/payment-sheet-views/base-paypal-view.js +0 -79
- package/dist/vendor/braintree-web-drop-in/views/payment-sheet-views/card-view.js +0 -324
- package/dist/vendor/braintree-web-drop-in/views/payment-sheet-views/google-pay-view.js +0 -85
- package/dist/vendor/braintree-web-drop-in/views/payment-sheet-views/index.js +0 -17
- package/dist/vendor/braintree-web-drop-in/views/payment-sheet-views/paypal-credit-view.js +0 -20
- package/dist/vendor/braintree-web-drop-in/views/payment-sheet-views/paypal-view.js +0 -20
- package/dist/vendor/braintree-web-drop-in/views/payment-sheet-views/venmo-view.js +0 -50
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { gql as C } from "@apollo/client/core";
|
|
2
|
-
import
|
|
2
|
+
import p from "numeral";
|
|
3
3
|
import { ref as b } from "vue";
|
|
4
4
|
import { parseShopError as A, ShopError as I } from "./shopError.js";
|
|
5
5
|
const w = ["paypal", "card", "applePay", "googlePay"];
|
|
6
6
|
async function T(e) {
|
|
7
|
-
var
|
|
8
|
-
const { data: t, error:
|
|
7
|
+
var n;
|
|
8
|
+
const { data: t, error: a, errors: o } = await e.query({
|
|
9
9
|
query: C`query getClientToken {
|
|
10
10
|
shop {
|
|
11
11
|
id
|
|
@@ -13,13 +13,13 @@ async function T(e) {
|
|
|
13
13
|
}
|
|
14
14
|
}`
|
|
15
15
|
});
|
|
16
|
-
if (
|
|
17
|
-
throw A(
|
|
18
|
-
return (
|
|
16
|
+
if (a || o != null && o.length)
|
|
17
|
+
throw A(a ?? (o == null ? void 0 : o[0]));
|
|
18
|
+
return (n = t == null ? void 0 : t.shop) == null ? void 0 : n.getClientToken;
|
|
19
19
|
}
|
|
20
20
|
function D() {
|
|
21
21
|
let e, t = "";
|
|
22
|
-
const
|
|
22
|
+
const a = b(!1);
|
|
23
23
|
function o(r) {
|
|
24
24
|
return {
|
|
25
25
|
countryCode: "US",
|
|
@@ -33,7 +33,7 @@ function D() {
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function n(r) {
|
|
37
37
|
return {
|
|
38
38
|
totalPriceStatus: "FINAL",
|
|
39
39
|
totalPrice: r,
|
|
@@ -41,26 +41,26 @@ function D() {
|
|
|
41
41
|
countryCode: "US"
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
e.isPaymentMethodRequestable() && (
|
|
46
|
-
|
|
44
|
+
function s() {
|
|
45
|
+
e.isPaymentMethodRequestable() && (a.value = !0), e.on("paymentMethodRequestable", (r) => {
|
|
46
|
+
a.value = !0;
|
|
47
47
|
}), e.on("noPaymentMethodRequestable", () => {
|
|
48
|
-
|
|
48
|
+
a.value = !1;
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
async function
|
|
51
|
+
async function d({
|
|
52
52
|
amount: r,
|
|
53
53
|
authToken: u,
|
|
54
54
|
container: i,
|
|
55
|
-
googlePayMerchantId:
|
|
56
|
-
paymentTypes:
|
|
57
|
-
preselectVaultedPaymentMethod:
|
|
58
|
-
paypalFlow:
|
|
55
|
+
googlePayMerchantId: f,
|
|
56
|
+
paymentTypes: m = [...w],
|
|
57
|
+
preselectVaultedPaymentMethod: g = !0,
|
|
58
|
+
paypalFlow: h = "checkout"
|
|
59
59
|
}) {
|
|
60
|
-
t =
|
|
61
|
-
const { default:
|
|
60
|
+
t = p(r).format("0.00");
|
|
61
|
+
const { default: P } = await import("braintree-web-drop-in/index.js");
|
|
62
62
|
try {
|
|
63
|
-
e = await
|
|
63
|
+
e = await P.create({
|
|
64
64
|
authorization: u,
|
|
65
65
|
container: i,
|
|
66
66
|
dataCollector: {
|
|
@@ -68,15 +68,15 @@ function D() {
|
|
|
68
68
|
// Required if Kount fraud data collection is enabled
|
|
69
69
|
},
|
|
70
70
|
// vaultManager: true, - Useful for testing and removing payment methods easily.
|
|
71
|
-
paymentOptionPriority:
|
|
72
|
-
preselectVaultedPaymentMethod:
|
|
71
|
+
paymentOptionPriority: m,
|
|
72
|
+
preselectVaultedPaymentMethod: g,
|
|
73
73
|
card: {
|
|
74
74
|
vault: {
|
|
75
75
|
allowVaultCardOverride: !0
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
paypal: {
|
|
79
|
-
flow:
|
|
79
|
+
flow: h,
|
|
80
80
|
amount: t,
|
|
81
81
|
currency: "USD",
|
|
82
82
|
buttonStyle: {
|
|
@@ -90,8 +90,8 @@ function D() {
|
|
|
90
90
|
},
|
|
91
91
|
googlePay: {
|
|
92
92
|
googlePayVersion: 2,
|
|
93
|
-
merchantId:
|
|
94
|
-
transactionInfo:
|
|
93
|
+
merchantId: f,
|
|
94
|
+
transactionInfo: n(t),
|
|
95
95
|
button: {
|
|
96
96
|
allowedPaymentMethods: [{
|
|
97
97
|
type: "CARD",
|
|
@@ -111,34 +111,34 @@ function D() {
|
|
|
111
111
|
displayName: "Kiva",
|
|
112
112
|
paymentRequest: o(t)
|
|
113
113
|
}
|
|
114
|
-
}),
|
|
115
|
-
} catch (
|
|
114
|
+
}), s();
|
|
115
|
+
} catch (q) {
|
|
116
116
|
throw new I({
|
|
117
117
|
code: "shop.braintreeDropinInitError",
|
|
118
|
-
original:
|
|
118
|
+
original: q
|
|
119
119
|
}, "An Error has occured. Please refresh the page and try again.");
|
|
120
120
|
}
|
|
121
121
|
return e;
|
|
122
122
|
}
|
|
123
|
-
async function
|
|
123
|
+
async function c() {
|
|
124
124
|
if (e.isPaymentMethodRequestable())
|
|
125
125
|
return e.requestPaymentMethod();
|
|
126
126
|
}
|
|
127
|
-
function
|
|
127
|
+
function y(r) {
|
|
128
128
|
var i;
|
|
129
|
-
const u =
|
|
130
|
-
u !== t && (t = u, e == null || e.updateConfiguration("paypal", "amount", t), e == null || e.updateConfiguration("googlePay", "transactionInfo",
|
|
129
|
+
const u = p(r).format("0.00");
|
|
130
|
+
u !== t && (t = u, e == null || e.updateConfiguration("paypal", "amount", t), e == null || e.updateConfiguration("googlePay", "transactionInfo", n(t)), (i = e == null ? void 0 : e.updateConfiguration) == null || i.call(e, "applePay", "paymentRequest", o(t)));
|
|
131
131
|
}
|
|
132
132
|
return {
|
|
133
|
-
initDropIn:
|
|
134
|
-
paymentMethodRequestable:
|
|
135
|
-
requestPaymentMethod:
|
|
136
|
-
updateAmount:
|
|
133
|
+
initDropIn: d,
|
|
134
|
+
paymentMethodRequestable: a,
|
|
135
|
+
requestPaymentMethod: c,
|
|
136
|
+
updateAmount: y
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
-
const
|
|
139
|
+
const l = {};
|
|
140
140
|
function U(e = "default") {
|
|
141
|
-
return
|
|
141
|
+
return l[e] || (l[e] = D()), l[e];
|
|
142
142
|
}
|
|
143
143
|
export {
|
|
144
144
|
U as default,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiva/kv-shop",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -51,11 +51,9 @@
|
|
|
51
51
|
"@apollo/client": "3.x",
|
|
52
52
|
"@kiva/kv-analytics": "1.x",
|
|
53
53
|
"@kiva/kv-components": "5 || 6",
|
|
54
|
+
"braintree-web-drop-in": "1.x",
|
|
54
55
|
"numeral": "2.x",
|
|
55
56
|
"vue": "3.x"
|
|
56
57
|
},
|
|
57
|
-
"
|
|
58
|
-
"braintree-web-drop-in"
|
|
59
|
-
],
|
|
60
|
-
"gitHead": "39f5590acca695adfd392a3e80f1f8d376fff685"
|
|
58
|
+
"gitHead": "ec33189a47e173db05c396f1b09dda8fa1f19ce7"
|
|
61
59
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
var o = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
2
|
-
function l(e) {
|
|
3
|
-
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
4
|
-
}
|
|
5
|
-
export {
|
|
6
|
-
o as commonjsGlobal,
|
|
7
|
-
l as getDefaultExportFromCjs
|
|
8
|
-
};
|
package/dist/_virtual/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
|
|
2
|
-
import { __require as r } from "../vendor/braintree-web-drop-in/index.js";
|
|
3
|
-
var t = r();
|
|
4
|
-
const o = /* @__PURE__ */ e(t), n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5
|
-
__proto__: null,
|
|
6
|
-
default: o
|
|
7
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
8
|
-
export {
|
|
9
|
-
o as default,
|
|
10
|
-
n as i
|
|
11
|
-
};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
var e, a;
|
|
2
|
-
function r() {
|
|
3
|
-
return a || (a = 1, e = {
|
|
4
|
-
paymentOptionIDs: {
|
|
5
|
-
card: "card",
|
|
6
|
-
paypal: "paypal",
|
|
7
|
-
paypalCredit: "paypalCredit",
|
|
8
|
-
applePay: "applePay",
|
|
9
|
-
venmo: "venmo",
|
|
10
|
-
googlePay: "googlePay"
|
|
11
|
-
},
|
|
12
|
-
paymentMethodTypes: {
|
|
13
|
-
card: "CreditCard",
|
|
14
|
-
paypal: "PayPalAccount",
|
|
15
|
-
paypalCredit: "PayPalAccount",
|
|
16
|
-
applePay: "ApplePayCard",
|
|
17
|
-
venmo: "VenmoAccount",
|
|
18
|
-
googlePay: "AndroidPayCard"
|
|
19
|
-
},
|
|
20
|
-
analyticsKinds: {
|
|
21
|
-
CreditCard: "card",
|
|
22
|
-
PayPalAccount: "paypal",
|
|
23
|
-
ApplePayCard: "applepay",
|
|
24
|
-
VenmoAccount: "venmo",
|
|
25
|
-
AndroidPayCard: "googlepay"
|
|
26
|
-
},
|
|
27
|
-
paymentMethodCardTypes: {
|
|
28
|
-
Visa: "visa",
|
|
29
|
-
MasterCard: "master-card",
|
|
30
|
-
"American Express": "american-express",
|
|
31
|
-
"Diners Club": "diners-club",
|
|
32
|
-
Discover: "discover",
|
|
33
|
-
JCB: "jcb",
|
|
34
|
-
UnionPay: "unionpay",
|
|
35
|
-
Maestro: "maestro",
|
|
36
|
-
Elo: "elo",
|
|
37
|
-
Hiper: "hiper",
|
|
38
|
-
Hipercard: "hipercard"
|
|
39
|
-
},
|
|
40
|
-
cardTypeIcons: {
|
|
41
|
-
visa: "visa",
|
|
42
|
-
mastercard: "master-card",
|
|
43
|
-
"american-express": "american-express",
|
|
44
|
-
"diners-club": "diners-club",
|
|
45
|
-
discover: "discover",
|
|
46
|
-
jcb: "jcb",
|
|
47
|
-
"union-pay": "unionpay",
|
|
48
|
-
maestro: "maestro",
|
|
49
|
-
elo: "elo",
|
|
50
|
-
hiper: "hiper",
|
|
51
|
-
hipercard: "hipercard"
|
|
52
|
-
},
|
|
53
|
-
configurationCardTypes: {
|
|
54
|
-
visa: "Visa",
|
|
55
|
-
"master-card": "MasterCard",
|
|
56
|
-
"american-express": "American Express",
|
|
57
|
-
"diners-club": "Discover",
|
|
58
|
-
discover: "Discover",
|
|
59
|
-
jcb: "JCB",
|
|
60
|
-
unionpay: "UnionPay",
|
|
61
|
-
maestro: "Maestro",
|
|
62
|
-
elo: "Elo",
|
|
63
|
-
hiper: "Hiper",
|
|
64
|
-
hipercard: "Hipercard"
|
|
65
|
-
},
|
|
66
|
-
dependencySetupStates: {
|
|
67
|
-
DONE: "done",
|
|
68
|
-
FAILED: "failed",
|
|
69
|
-
INITIALIZING: "initializing",
|
|
70
|
-
NOT_ENABLED: "not-enabled"
|
|
71
|
-
},
|
|
72
|
-
errors: {
|
|
73
|
-
NO_PAYMENT_METHOD_ERROR: "No payment method is available.",
|
|
74
|
-
DEVELOPER_MISCONFIGURATION_MESSAGE: "Developer Error: Something went wrong. Check the console for details."
|
|
75
|
-
},
|
|
76
|
-
ANALYTICS_REQUEST_TIMEOUT_MS: 2e3,
|
|
77
|
-
ANALYTICS_PREFIX: "web.dropin.",
|
|
78
|
-
CHANGE_ACTIVE_PAYMENT_METHOD_TIMEOUT: 200,
|
|
79
|
-
CHECKOUT_JS_SOURCE: "https://www.paypalobjects.com/api/checkout.min.js",
|
|
80
|
-
GOOGLE_PAYMENT_SOURCE: "https://pay.google.com/gp/p/js/pay.js",
|
|
81
|
-
INTEGRATION: "dropin2",
|
|
82
|
-
PAYPAL_CHECKOUT_SCRIPT_ID: "braintree-dropin-paypal-checkout-script",
|
|
83
|
-
GOOGLE_PAYMENT_SCRIPT_ID: "braintree-dropin-google-payment-script",
|
|
84
|
-
DATA_COLLECTOR_SCRIPT_ID: "braintree-dropin-data-collector-script",
|
|
85
|
-
STYLESHEET_ID: "braintree-dropin-stylesheet"
|
|
86
|
-
}), e;
|
|
87
|
-
}
|
|
88
|
-
export {
|
|
89
|
-
r as __require
|
|
90
|
-
};
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { __require as A } from "./lib/analytics.js";
|
|
2
|
-
import { __require as S } from "./lib/dropin-error.js";
|
|
3
|
-
import b from "@braintree/event-emitter";
|
|
4
|
-
import { __require as C } from "./constants.js";
|
|
5
|
-
import { __require as R } from "./lib/is-guest-checkout.js";
|
|
6
|
-
import { __require as V } from "./views/payment-sheet-views/index.js";
|
|
7
|
-
import T from "braintree-web/vault-manager";
|
|
8
|
-
import { __require as L } from "./views/payment-options-view.js";
|
|
9
|
-
var y, f;
|
|
10
|
-
function $() {
|
|
11
|
-
if (f) return y;
|
|
12
|
-
f = 1;
|
|
13
|
-
var P = A(), h = S(), m = b, p = C(), u = p.paymentMethodTypes, s = p.paymentOptionIDs, d = p.dependencySetupStates, _ = R(), v = V(), M = T, E = L().ID, I = [
|
|
14
|
-
u.applePay,
|
|
15
|
-
u.googlePay,
|
|
16
|
-
u.venmo
|
|
17
|
-
], c = [
|
|
18
|
-
s.card,
|
|
19
|
-
s.paypal,
|
|
20
|
-
s.paypalCredit,
|
|
21
|
-
s.venmo,
|
|
22
|
-
s.applePay,
|
|
23
|
-
s.googlePay
|
|
24
|
-
], l = ["threeDSecure", "dataCollector"], g = c.concat(l), D = 200;
|
|
25
|
-
function n(e) {
|
|
26
|
-
for (this.rootNode = e.container, this.componentID = e.componentID, this.merchantConfiguration = e.merchantConfiguration, this.isGuestCheckout = _(e.client), this.dependencyStates = g.reduce((function(t, i) {
|
|
27
|
-
return this._shouldIncludeDependency(i) && (t[i] = d.INITIALIZING), t;
|
|
28
|
-
}).bind(this), {}), this.hiddenVaultedPaymentMethodTypes = N(
|
|
29
|
-
e.merchantConfiguration.hiddenVaultedPaymentMethodTypes
|
|
30
|
-
), this.failedDependencies = {}, this._options = e, this._setupComplete = !1, this.shouldWaitForVerifyCard = !1; this.rootNode.parentNode; )
|
|
31
|
-
this.rootNode = this.rootNode.parentNode;
|
|
32
|
-
this.isInShadowDom = this.rootNode.toString() === "[object ShadowRoot]", m.call(this);
|
|
33
|
-
}
|
|
34
|
-
m.createChild(n), n.prototype.initialize = function() {
|
|
35
|
-
var e, t = this, i = setInterval(function() {
|
|
36
|
-
for (e in t.dependencyStates)
|
|
37
|
-
if (t.dependencyStates[e] === d.INITIALIZING)
|
|
38
|
-
return;
|
|
39
|
-
clearInterval(i), t._emit("asyncDependenciesReady");
|
|
40
|
-
}, D);
|
|
41
|
-
return M.create({
|
|
42
|
-
client: t._options.client
|
|
43
|
-
}).then(function(r) {
|
|
44
|
-
return t._vaultManager = r, t._getSupportedPaymentOptions(t._options);
|
|
45
|
-
}).then(function(r) {
|
|
46
|
-
return t.supportedPaymentOptions = r, t.getVaultedPaymentMethods();
|
|
47
|
-
}).then(function(r) {
|
|
48
|
-
t._paymentMethods = r, t._paymentMethodIsRequestable = t._paymentMethods.length > 0;
|
|
49
|
-
});
|
|
50
|
-
}, n.prototype.confirmDropinReady = function() {
|
|
51
|
-
this._setupComplete = !0;
|
|
52
|
-
}, n.prototype.isPaymentMethodRequestable = function() {
|
|
53
|
-
return !!this._paymentMethodIsRequestable;
|
|
54
|
-
}, n.prototype.addPaymentMethod = function(e) {
|
|
55
|
-
this._paymentMethods.push(e), this._emit("addPaymentMethod", e), this.changeActivePaymentMethod(e);
|
|
56
|
-
}, n.prototype.removePaymentMethod = function(e) {
|
|
57
|
-
var t = this._paymentMethods.indexOf(e);
|
|
58
|
-
t !== -1 && (this._paymentMethods.splice(t, 1), this._emit("removePaymentMethod", e));
|
|
59
|
-
}, n.prototype.refreshPaymentMethods = function() {
|
|
60
|
-
var e = this;
|
|
61
|
-
return e.getVaultedPaymentMethods().then(function(t) {
|
|
62
|
-
e._paymentMethods = t, e._emit("refreshPaymentMethods");
|
|
63
|
-
});
|
|
64
|
-
}, n.prototype.changeActivePaymentMethod = function(e) {
|
|
65
|
-
this._activePaymentMethod = e, this._emit("changeActivePaymentMethod", e);
|
|
66
|
-
}, n.prototype.changeActiveView = function(e) {
|
|
67
|
-
var t = this._activePaymentViewId;
|
|
68
|
-
this._activePaymentViewId = e, this._emit("changeActiveView", {
|
|
69
|
-
previousViewId: t,
|
|
70
|
-
newViewId: e
|
|
71
|
-
});
|
|
72
|
-
}, n.prototype.removeActivePaymentMethod = function() {
|
|
73
|
-
this._activePaymentMethod = null, this._emit("removeActivePaymentMethod"), this.setPaymentMethodRequestable({
|
|
74
|
-
isRequestable: !1
|
|
75
|
-
});
|
|
76
|
-
}, n.prototype.selectPaymentOption = function(e) {
|
|
77
|
-
this._emit("paymentOptionSelected", {
|
|
78
|
-
paymentOption: e
|
|
79
|
-
});
|
|
80
|
-
}, n.prototype.enableEditMode = function() {
|
|
81
|
-
P.sendEvent(this._options.client, "manager.appeared"), this._isInEditMode = !0, this._emit("enableEditMode");
|
|
82
|
-
}, n.prototype.disableEditMode = function() {
|
|
83
|
-
this._isInEditMode = !1, this._emit("disableEditMode");
|
|
84
|
-
}, n.prototype.isInEditMode = function() {
|
|
85
|
-
return !!this._isInEditMode;
|
|
86
|
-
}, n.prototype.confirmPaymentMethodDeletion = function(e) {
|
|
87
|
-
this._paymentMethodWaitingToBeDeleted = e, this._emit("confirmPaymentMethodDeletion", e);
|
|
88
|
-
}, n.prototype._shouldIncludeDependency = function(e) {
|
|
89
|
-
if (e === "card") {
|
|
90
|
-
if (this.merchantConfiguration.card === !1)
|
|
91
|
-
return !1;
|
|
92
|
-
} else if (!this.merchantConfiguration[e])
|
|
93
|
-
return !1;
|
|
94
|
-
return l.indexOf(e) > -1 ? !0 : this.merchantConfiguration.paymentOptionPriority ? this.merchantConfiguration.paymentOptionPriority.indexOf(e) > -1 : c.indexOf(e) > -1;
|
|
95
|
-
}, n.prototype._shouldEmitRequestableEvent = function(e) {
|
|
96
|
-
var t = this.isPaymentMethodRequestable() === e.isRequestable, i = e.selectedPaymentMethod && e.selectedPaymentMethod.nonce, r = i === this._paymentMethodRequestableNonce;
|
|
97
|
-
return !(!this._setupComplete || this.shouldWaitForVerifyCard || t && (!e.isRequestable || r));
|
|
98
|
-
}, n.prototype.setPaymentMethodRequestable = function(e) {
|
|
99
|
-
var t = this._shouldEmitRequestableEvent(e), i = {
|
|
100
|
-
paymentMethodIsSelected: !!e.selectedPaymentMethod,
|
|
101
|
-
type: e.type
|
|
102
|
-
};
|
|
103
|
-
this._paymentMethodIsRequestable = e.isRequestable, e.isRequestable ? this._paymentMethodRequestableNonce = e.selectedPaymentMethod && e.selectedPaymentMethod.nonce : delete this._paymentMethodRequestableNonce, t && (e.isRequestable ? this._emit("paymentMethodRequestable", i) : this._emit("noPaymentMethodRequestable"));
|
|
104
|
-
}, n.prototype.getPaymentMethods = function() {
|
|
105
|
-
return this._paymentMethods.slice();
|
|
106
|
-
}, n.prototype.getActivePaymentMethod = function() {
|
|
107
|
-
return this._activePaymentMethod;
|
|
108
|
-
}, n.prototype.hasPaymentMethods = function() {
|
|
109
|
-
return this.getPaymentMethods().length > 0;
|
|
110
|
-
}, n.prototype.getInitialViewId = function() {
|
|
111
|
-
return this.supportedPaymentOptions.length > 1 ? E : this.supportedPaymentOptions[0];
|
|
112
|
-
}, n.prototype.getActivePaymentViewId = function() {
|
|
113
|
-
return this._activePaymentViewId;
|
|
114
|
-
}, n.prototype.reportAppSwitchPayload = function(e) {
|
|
115
|
-
this.appSwitchPayload = e;
|
|
116
|
-
}, n.prototype.reportAppSwitchError = function(e, t) {
|
|
117
|
-
this.appSwitchError = {
|
|
118
|
-
id: e,
|
|
119
|
-
error: t
|
|
120
|
-
};
|
|
121
|
-
}, n.prototype.hasAtLeastOneAvailablePaymentOption = function() {
|
|
122
|
-
var e = this, t;
|
|
123
|
-
for (t = 0; t < this.supportedPaymentOptions.length; t++)
|
|
124
|
-
if (e.dependencyStates[this.supportedPaymentOptions[t]] === d.DONE)
|
|
125
|
-
return !0;
|
|
126
|
-
return !1;
|
|
127
|
-
}, n.prototype.asyncDependencyReady = function(e) {
|
|
128
|
-
this.dependencyStates[e] = d.DONE;
|
|
129
|
-
}, n.prototype.asyncDependencyFailed = function(e) {
|
|
130
|
-
this.failedDependencies.hasOwnProperty(e.view) || (this.failedDependencies[e.view] = e.error, this.dependencyStates[e.view] = d.FAILED);
|
|
131
|
-
}, n.prototype.cancelInitialization = function(e) {
|
|
132
|
-
this._emit("cancelInitialization", e);
|
|
133
|
-
}, n.prototype.reportError = function(e) {
|
|
134
|
-
this._emit("errorOccurred", e);
|
|
135
|
-
}, n.prototype.clearError = function() {
|
|
136
|
-
this._emit("errorCleared");
|
|
137
|
-
}, n.prototype.preventUserAction = function() {
|
|
138
|
-
this._emit("preventUserAction");
|
|
139
|
-
}, n.prototype.allowUserAction = function() {
|
|
140
|
-
this._emit("allowUserAction");
|
|
141
|
-
}, n.prototype.deleteVaultedPaymentMethod = function() {
|
|
142
|
-
var e = this, t = Promise.resolve(), i;
|
|
143
|
-
return this._emit("startVaultedPaymentMethodDeletion"), e.isGuestCheckout || (t = this._vaultManager.deletePaymentMethod(this._paymentMethodWaitingToBeDeleted.nonce).catch(function(r) {
|
|
144
|
-
i = r;
|
|
145
|
-
})), t.then(function() {
|
|
146
|
-
return delete e._paymentMethodWaitingToBeDeleted, e.refreshPaymentMethods();
|
|
147
|
-
}).then(function() {
|
|
148
|
-
e.disableEditMode(), e._emit("finishVaultedPaymentMethodDeletion", i);
|
|
149
|
-
});
|
|
150
|
-
}, n.prototype.cancelDeleteVaultedPaymentMethod = function() {
|
|
151
|
-
this._emit("cancelVaultedPaymentMethodDeletion"), delete this._paymentMethodWaitingToBeDeleted;
|
|
152
|
-
}, n.prototype.getVaultedPaymentMethods = function() {
|
|
153
|
-
var e = this;
|
|
154
|
-
return e.isGuestCheckout ? Promise.resolve([]) : e._vaultManager.fetchPaymentMethods({
|
|
155
|
-
defaultFirst: this.merchantConfiguration.showDefaultPaymentMethodFirst !== !1
|
|
156
|
-
}).then(function(t) {
|
|
157
|
-
return e._getSupportedPaymentMethods(t).map(function(i) {
|
|
158
|
-
return i.vaulted = !0, i;
|
|
159
|
-
});
|
|
160
|
-
}).catch(function() {
|
|
161
|
-
return Promise.resolve([]);
|
|
162
|
-
});
|
|
163
|
-
}, n.prototype._getSupportedPaymentMethods = function(e) {
|
|
164
|
-
var t = this, i = this.supportedPaymentOptions.reduce(
|
|
165
|
-
function(r, a) {
|
|
166
|
-
var o = u[a];
|
|
167
|
-
return w(
|
|
168
|
-
o,
|
|
169
|
-
t.hiddenVaultedPaymentMethodTypes
|
|
170
|
-
) && r.push(o), r;
|
|
171
|
-
},
|
|
172
|
-
[]
|
|
173
|
-
);
|
|
174
|
-
return e.filter(function(r) {
|
|
175
|
-
return i.indexOf(r.type) > -1;
|
|
176
|
-
});
|
|
177
|
-
}, n.prototype._getSupportedPaymentOptions = function(e) {
|
|
178
|
-
var t = this, i = e.merchantConfiguration.paymentOptionPriority || c, r;
|
|
179
|
-
if (!(i instanceof Array))
|
|
180
|
-
throw new h("paymentOptionPriority must be an array.");
|
|
181
|
-
return i = i.filter(function(a, o) {
|
|
182
|
-
return i.indexOf(a) === o;
|
|
183
|
-
}), r = i.map(function(a) {
|
|
184
|
-
return O(a, e).then(function(o) {
|
|
185
|
-
return o.success || (t.dependencyStates[o.id] = d.NOT_ENABLED), o;
|
|
186
|
-
});
|
|
187
|
-
}), Promise.all(r).then(function(a) {
|
|
188
|
-
return a = a.filter(function(o) {
|
|
189
|
-
return o.success;
|
|
190
|
-
}), a.length === 0 ? Promise.reject(new h("No valid payment options available.")) : a.map(function(o) {
|
|
191
|
-
return o.id;
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
};
|
|
195
|
-
function O(e, t) {
|
|
196
|
-
return q(e, t).then(function(i) {
|
|
197
|
-
return {
|
|
198
|
-
success: i,
|
|
199
|
-
id: s[e]
|
|
200
|
-
};
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
function q(e, t) {
|
|
204
|
-
var i = v[s[e]];
|
|
205
|
-
return i ? i.isEnabled({
|
|
206
|
-
client: t.client,
|
|
207
|
-
merchantConfiguration: t.merchantConfiguration
|
|
208
|
-
}).catch(function(r) {
|
|
209
|
-
return console.error(i.ID + " view errored when checking if it was supported."), console.error(r), Promise.resolve(!1);
|
|
210
|
-
}) : Promise.reject(new h("paymentOptionPriority: Invalid payment option specified."));
|
|
211
|
-
}
|
|
212
|
-
function w(e, t) {
|
|
213
|
-
return e && t.indexOf(e) === -1;
|
|
214
|
-
}
|
|
215
|
-
function N(e) {
|
|
216
|
-
var t = [].concat(
|
|
217
|
-
I
|
|
218
|
-
);
|
|
219
|
-
return Array.isArray(e) && e.forEach(function(i) {
|
|
220
|
-
var r = u[i];
|
|
221
|
-
r && (t.indexOf(r) > -1 || t.push(r));
|
|
222
|
-
}), t;
|
|
223
|
-
}
|
|
224
|
-
return y = n, y;
|
|
225
|
-
}
|
|
226
|
-
export {
|
|
227
|
-
$ as __require
|
|
228
|
-
};
|