@kiva/kv-shop 3.0.13 → 3.0.15
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/index.d.ts +9 -0
- package/dist/useBraintreeDropIn.js +55 -54
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -319,3 +319,12 @@ export declare function watchBasketTotals(apollo: ApolloClient<any>): Observable
|
|
|
319
319
|
export declare function watchShopQuery<TData>(apollo: ApolloClient<any>, options: WatchQueryOptions<any, TData>, maxretries?: number): ObservableQuery<TData, any>;
|
|
320
320
|
|
|
321
321
|
export { }
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
declare global {
|
|
325
|
+
interface Window {
|
|
326
|
+
braintree?: {
|
|
327
|
+
dropin: typeof import('braintree-web-drop-in');
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { gql as
|
|
2
|
-
import
|
|
3
|
-
import { ref as
|
|
4
|
-
import { parseShopError as A, ShopError as
|
|
5
|
-
const
|
|
6
|
-
async function
|
|
7
|
-
var
|
|
8
|
-
const { data: t, error:
|
|
9
|
-
query:
|
|
1
|
+
import { gql as w } from "@apollo/client/core";
|
|
2
|
+
import s from "numeral";
|
|
3
|
+
import { ref as I } from "vue";
|
|
4
|
+
import { parseShopError as A, ShopError as D } from "./shopError.js";
|
|
5
|
+
const R = ["paypal", "card", "applePay", "googlePay"];
|
|
6
|
+
async function k(e) {
|
|
7
|
+
var a;
|
|
8
|
+
const { data: t, error: n, errors: o } = await e.query({
|
|
9
|
+
query: w`query getClientToken {
|
|
10
10
|
shop {
|
|
11
11
|
id
|
|
12
12
|
getClientToken(useCustomerId: true)
|
|
13
13
|
}
|
|
14
14
|
}`
|
|
15
15
|
});
|
|
16
|
-
if (
|
|
17
|
-
throw A(
|
|
18
|
-
return (
|
|
16
|
+
if (n || o != null && o.length)
|
|
17
|
+
throw A(n ?? (o == null ? void 0 : o[0]));
|
|
18
|
+
return (a = t == null ? void 0 : t.shop) == null ? void 0 : a.getClientToken;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function v() {
|
|
21
21
|
let e, t = "";
|
|
22
|
-
const
|
|
22
|
+
const n = I(!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 a(r) {
|
|
37
37
|
return {
|
|
38
38
|
totalPriceStatus: "FINAL",
|
|
39
39
|
totalPrice: r,
|
|
@@ -41,42 +41,43 @@ function D() {
|
|
|
41
41
|
countryCode: "US"
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
e.isPaymentMethodRequestable() && (
|
|
46
|
-
|
|
44
|
+
function d() {
|
|
45
|
+
e.isPaymentMethodRequestable() && (n.value = !0), e.on("paymentMethodRequestable", (r) => {
|
|
46
|
+
n.value = !0;
|
|
47
47
|
}), e.on("noPaymentMethodRequestable", () => {
|
|
48
|
-
|
|
48
|
+
n.value = !1;
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
async function
|
|
51
|
+
async function c({
|
|
52
52
|
amount: r,
|
|
53
|
-
authToken:
|
|
54
|
-
container:
|
|
55
|
-
googlePayMerchantId:
|
|
56
|
-
paymentTypes:
|
|
57
|
-
preselectVaultedPaymentMethod:
|
|
58
|
-
paypalFlow:
|
|
53
|
+
authToken: i,
|
|
54
|
+
container: u,
|
|
55
|
+
googlePayMerchantId: m,
|
|
56
|
+
paymentTypes: g = [...R],
|
|
57
|
+
preselectVaultedPaymentMethod: h = !0,
|
|
58
|
+
paypalFlow: P = "checkout"
|
|
59
59
|
}) {
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
var p;
|
|
61
|
+
t = s(r).format("0.00");
|
|
62
|
+
const { default: q } = await import("braintree-web-drop-in"), C = ((p = window == null ? void 0 : window.braintree) == null ? void 0 : p.dropin) || q;
|
|
62
63
|
try {
|
|
63
|
-
e = await
|
|
64
|
-
authorization:
|
|
65
|
-
container:
|
|
64
|
+
e = await C.create({
|
|
65
|
+
authorization: i,
|
|
66
|
+
container: u,
|
|
66
67
|
dataCollector: {
|
|
67
68
|
kount: !0
|
|
68
69
|
// Required if Kount fraud data collection is enabled
|
|
69
70
|
},
|
|
70
71
|
// vaultManager: true, - Useful for testing and removing payment methods easily.
|
|
71
|
-
paymentOptionPriority:
|
|
72
|
-
preselectVaultedPaymentMethod:
|
|
72
|
+
paymentOptionPriority: g,
|
|
73
|
+
preselectVaultedPaymentMethod: h,
|
|
73
74
|
card: {
|
|
74
75
|
vault: {
|
|
75
76
|
allowVaultCardOverride: !0
|
|
76
77
|
}
|
|
77
78
|
},
|
|
78
79
|
paypal: {
|
|
79
|
-
flow:
|
|
80
|
+
flow: P,
|
|
80
81
|
amount: t,
|
|
81
82
|
currency: "USD",
|
|
82
83
|
buttonStyle: {
|
|
@@ -90,8 +91,8 @@ function D() {
|
|
|
90
91
|
},
|
|
91
92
|
googlePay: {
|
|
92
93
|
googlePayVersion: 2,
|
|
93
|
-
merchantId:
|
|
94
|
-
transactionInfo:
|
|
94
|
+
merchantId: m,
|
|
95
|
+
transactionInfo: a(t),
|
|
95
96
|
button: {
|
|
96
97
|
allowedPaymentMethods: [{
|
|
97
98
|
type: "CARD",
|
|
@@ -111,37 +112,37 @@ function D() {
|
|
|
111
112
|
displayName: "Kiva",
|
|
112
113
|
paymentRequest: o(t)
|
|
113
114
|
}
|
|
114
|
-
}),
|
|
115
|
-
} catch (
|
|
116
|
-
throw new
|
|
115
|
+
}), d();
|
|
116
|
+
} catch (b) {
|
|
117
|
+
throw new D({
|
|
117
118
|
code: "shop.braintreeDropinInitError",
|
|
118
|
-
original:
|
|
119
|
+
original: b
|
|
119
120
|
}, "An Error has occured. Please refresh the page and try again.");
|
|
120
121
|
}
|
|
121
122
|
return e;
|
|
122
123
|
}
|
|
123
|
-
async function
|
|
124
|
+
async function y() {
|
|
124
125
|
if (e.isPaymentMethodRequestable())
|
|
125
126
|
return e.requestPaymentMethod();
|
|
126
127
|
}
|
|
127
|
-
function
|
|
128
|
-
var
|
|
129
|
-
const
|
|
130
|
-
|
|
128
|
+
function f(r) {
|
|
129
|
+
var u;
|
|
130
|
+
const i = s(r).format("0.00");
|
|
131
|
+
i !== t && (t = i, e == null || e.updateConfiguration("paypal", "amount", t), e == null || e.updateConfiguration("googlePay", "transactionInfo", a(t)), (u = e == null ? void 0 : e.updateConfiguration) == null || u.call(e, "applePay", "paymentRequest", o(t)));
|
|
131
132
|
}
|
|
132
133
|
return {
|
|
133
|
-
initDropIn:
|
|
134
|
-
paymentMethodRequestable:
|
|
135
|
-
requestPaymentMethod:
|
|
136
|
-
updateAmount:
|
|
134
|
+
initDropIn: c,
|
|
135
|
+
paymentMethodRequestable: n,
|
|
136
|
+
requestPaymentMethod: y,
|
|
137
|
+
updateAmount: f
|
|
137
138
|
};
|
|
138
139
|
}
|
|
139
140
|
const l = {};
|
|
140
|
-
function
|
|
141
|
-
return l[e] || (l[e] =
|
|
141
|
+
function E(e = "default") {
|
|
142
|
+
return l[e] || (l[e] = v()), l[e];
|
|
142
143
|
}
|
|
143
144
|
export {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
E as default,
|
|
146
|
+
R as defaultPaymentTypes,
|
|
147
|
+
k as getClientToken
|
|
147
148
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiva/kv-shop",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@apollo/client": "^3.13.1",
|
|
28
28
|
"@kiva/kv-analytics": "^1.3.0",
|
|
29
|
-
"@kiva/kv-components": "^6.
|
|
29
|
+
"@kiva/kv-components": "^6.7.0",
|
|
30
30
|
"@kiva/vite-plugin-vue-lib-css": "^2.0.0",
|
|
31
31
|
"@types/braintree-web-drop-in": "^1.39.3",
|
|
32
32
|
"@types/jest": "^29.5.14",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"numeral": "2.x",
|
|
56
56
|
"vue": "3.x"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "cf225adadfff7549bea00c6b4b90757dde66795d"
|
|
59
59
|
}
|