@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 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 C } from "@apollo/client/core";
2
- import p from "numeral";
3
- import { ref as b } from "vue";
4
- import { parseShopError as A, ShopError as I } from "./shopError.js";
5
- const w = ["paypal", "card", "applePay", "googlePay"];
6
- async function T(e) {
7
- var n;
8
- const { data: t, error: a, errors: o } = await e.query({
9
- query: C`query getClientToken {
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 (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;
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 D() {
20
+ function v() {
21
21
  let e, t = "";
22
- const a = b(!1);
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 n(r) {
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 s() {
45
- e.isPaymentMethodRequestable() && (a.value = !0), e.on("paymentMethodRequestable", (r) => {
46
- a.value = !0;
44
+ function d() {
45
+ e.isPaymentMethodRequestable() && (n.value = !0), e.on("paymentMethodRequestable", (r) => {
46
+ n.value = !0;
47
47
  }), e.on("noPaymentMethodRequestable", () => {
48
- a.value = !1;
48
+ n.value = !1;
49
49
  });
50
50
  }
51
- async function d({
51
+ async function c({
52
52
  amount: r,
53
- authToken: u,
54
- container: i,
55
- googlePayMerchantId: f,
56
- paymentTypes: m = [...w],
57
- preselectVaultedPaymentMethod: g = !0,
58
- paypalFlow: h = "checkout"
53
+ authToken: i,
54
+ container: u,
55
+ googlePayMerchantId: m,
56
+ paymentTypes: g = [...R],
57
+ preselectVaultedPaymentMethod: h = !0,
58
+ paypalFlow: P = "checkout"
59
59
  }) {
60
- t = p(r).format("0.00");
61
- const { default: P } = await import("braintree-web-drop-in/index.js");
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 P.create({
64
- authorization: u,
65
- container: i,
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: m,
72
- preselectVaultedPaymentMethod: g,
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: h,
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: f,
94
- transactionInfo: n(t),
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
- }), s();
115
- } catch (q) {
116
- throw new I({
115
+ }), d();
116
+ } catch (b) {
117
+ throw new D({
117
118
  code: "shop.braintreeDropinInitError",
118
- original: q
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 c() {
124
+ async function y() {
124
125
  if (e.isPaymentMethodRequestable())
125
126
  return e.requestPaymentMethod();
126
127
  }
127
- function y(r) {
128
- var i;
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)));
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: d,
134
- paymentMethodRequestable: a,
135
- requestPaymentMethod: c,
136
- updateAmount: y
134
+ initDropIn: c,
135
+ paymentMethodRequestable: n,
136
+ requestPaymentMethod: y,
137
+ updateAmount: f
137
138
  };
138
139
  }
139
140
  const l = {};
140
- function U(e = "default") {
141
- return l[e] || (l[e] = D()), l[e];
141
+ function E(e = "default") {
142
+ return l[e] || (l[e] = v()), l[e];
142
143
  }
143
144
  export {
144
- U as default,
145
- w as defaultPaymentTypes,
146
- T as getClientToken
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.13",
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.6.0",
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": "640523fa07c1542647510ed746713061bb595ded"
58
+ "gitHead": "cf225adadfff7549bea00c6b4b90757dde66795d"
59
59
  }