@kiva/kv-shop 2.1.2 → 3.0.0

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.
Files changed (76) hide show
  1. package/dist/_virtual/_commonjs-dynamic-modules.js +6 -0
  2. package/dist/_virtual/_commonjsHelpers.js +8 -0
  3. package/dist/_virtual/_plugin-vue_export-helper.js +9 -0
  4. package/dist/_virtual/dropin.js +11 -0
  5. package/dist/_virtual/dropin2.js +4 -0
  6. package/dist/basket.js +35 -12
  7. package/dist/basketCredits.js +78 -14
  8. package/dist/basketItems.js +27 -8
  9. package/dist/basketTotals.js +38 -10
  10. package/dist/basketVerification.js +6 -6
  11. package/dist/checkoutStatus.js +52 -8
  12. package/dist/components/KvPaymentSelect.css +1 -0
  13. package/dist/components/KvPaymentSelect.js +23 -0
  14. package/dist/components/KvPaymentSelect2.js +110 -0
  15. package/dist/index.d.ts +321 -20
  16. package/dist/index.js +49 -96
  17. package/dist/managedAccount.js +62 -8
  18. package/dist/oneTimeCheckout.js +156 -12
  19. package/dist/receipt.js +143 -12
  20. package/dist/shopError.js +41 -6
  21. package/dist/shopQueries.js +82 -11
  22. package/dist/subscriptionCheckout.js +88 -7
  23. package/dist/useBraintreeDropIn.js +145 -9
  24. package/dist/util/cookie.js +11 -0
  25. package/dist/util/poll.js +17 -0
  26. package/dist/util/redirect.js +8 -0
  27. package/dist/util/visitorId.js +7 -0
  28. package/dist/validatePreCheckout.js +44 -11
  29. package/dist/vendor/braintree-web-drop-in/dist/browser/dropin.js +12223 -0
  30. package/package.json +28 -26
  31. package/dist/basket.cjs +0 -141
  32. package/dist/basket.d.ts +0 -8
  33. package/dist/basketCredits.cjs +0 -250
  34. package/dist/basketCredits.d.ts +0 -32
  35. package/dist/basketItems.cjs +0 -205
  36. package/dist/basketItems.d.ts +0 -26
  37. package/dist/basketTotals.cjs +0 -228
  38. package/dist/basketTotals.d.ts +0 -37
  39. package/dist/basketVerification.cjs +0 -41
  40. package/dist/basketVerification.d.ts +0 -10
  41. package/dist/checkoutStatus.cjs +0 -111
  42. package/dist/checkoutStatus.d.ts +0 -20
  43. package/dist/chunk-4ODZGLWK.js +0 -64
  44. package/dist/chunk-ASZJVUQ7.js +0 -72
  45. package/dist/chunk-FBF4WMN6.js +0 -49
  46. package/dist/chunk-FC4QW6QA.js +0 -106
  47. package/dist/chunk-FCAOCO7O.js +0 -17
  48. package/dist/chunk-GVVI7X2R.js +0 -196
  49. package/dist/chunk-IIN37LC7.js +0 -45
  50. package/dist/chunk-IOZ5ERDX.js +0 -121
  51. package/dist/chunk-KCUOMCSN.js +0 -58
  52. package/dist/chunk-LZ4UMRCV.js +0 -16
  53. package/dist/chunk-RQNRQ2E5.js +0 -155
  54. package/dist/chunk-SRGYGDAX.js +0 -80
  55. package/dist/chunk-TPJPGUO7.js +0 -12
  56. package/dist/chunk-UJXHTR43.js +0 -86
  57. package/dist/chunk-VZ3VDRRP.js +0 -167
  58. package/dist/chunk-Z7JRY3QE.js +0 -34
  59. package/dist/components/KvPaymentSelect.vue +0 -380
  60. package/dist/index.cjs +0 -1227
  61. package/dist/managedAccount.cjs +0 -231
  62. package/dist/managedAccount.d.ts +0 -59
  63. package/dist/oneTimeCheckout.cjs +0 -636
  64. package/dist/oneTimeCheckout.d.ts +0 -21
  65. package/dist/receipt.cjs +0 -191
  66. package/dist/receipt.d.ts +0 -16
  67. package/dist/shopError.cjs +0 -88
  68. package/dist/shopError.d.ts +0 -14
  69. package/dist/shopQueries.cjs +0 -248
  70. package/dist/shopQueries.d.ts +0 -8
  71. package/dist/subscriptionCheckout.cjs +0 -187
  72. package/dist/subscriptionCheckout.d.ts +0 -13
  73. package/dist/useBraintreeDropIn.cjs +0 -258
  74. package/dist/useBraintreeDropIn.d.ts +0 -25
  75. package/dist/validatePreCheckout.cjs +0 -218
  76. package/dist/validatePreCheckout.d.ts +0 -28
@@ -1,11 +1,147 @@
1
- import {
2
- defaultPaymentTypes,
3
- getClientToken,
4
- useBraintreeDropIn
5
- } from "./chunk-VZ3VDRRP.js";
6
- import "./chunk-4ODZGLWK.js";
1
+ import { gql as C } from "@apollo/client";
2
+ import s 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 a;
8
+ const { data: t, error: n, errors: o } = await e.query({
9
+ query: C`query getClientToken {
10
+ shop {
11
+ id
12
+ getClientToken(useCustomerId: true)
13
+ }
14
+ }`
15
+ });
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
+ }
20
+ function D() {
21
+ let e, t = "";
22
+ const n = b(!1);
23
+ function o(r) {
24
+ return {
25
+ countryCode: "US",
26
+ currencyCode: "USD",
27
+ // merchantCapabilities: ['supports3DS'], // TODO: confirm/update
28
+ requiredBillingContactFields: ["postalAddress"],
29
+ // supportedNetworks: ['amex', 'discover', 'interac', 'jcb', 'masterCard', 'visa'], // TODO: confirm/update
30
+ total: {
31
+ label: "Kiva",
32
+ amount: r
33
+ }
34
+ };
35
+ }
36
+ function a(r) {
37
+ return {
38
+ totalPriceStatus: "FINAL",
39
+ totalPrice: r,
40
+ currencyCode: "USD",
41
+ countryCode: "US"
42
+ };
43
+ }
44
+ function d() {
45
+ e.isPaymentMethodRequestable() && (n.value = !0), e.on("paymentMethodRequestable", (r) => {
46
+ n.value = !0;
47
+ }), e.on("noPaymentMethodRequestable", () => {
48
+ n.value = !1;
49
+ });
50
+ }
51
+ async function c({
52
+ amount: r,
53
+ authToken: u,
54
+ container: i,
55
+ googlePayMerchantId: m,
56
+ paymentTypes: g = [...w],
57
+ preselectVaultedPaymentMethod: h = !0,
58
+ paypalFlow: P = "checkout"
59
+ }) {
60
+ t = s(r).format("0.00");
61
+ const { default: q } = await import("./_virtual/dropin.js").then((l) => l.d);
62
+ try {
63
+ e = await q.create({
64
+ authorization: u,
65
+ container: i,
66
+ dataCollector: {
67
+ kount: !0
68
+ // Required if Kount fraud data collection is enabled
69
+ },
70
+ // vaultManager: true, - Useful for testing and removing payment methods easily.
71
+ paymentOptionPriority: g,
72
+ preselectVaultedPaymentMethod: h,
73
+ card: {
74
+ vault: {
75
+ allowVaultCardOverride: !0
76
+ }
77
+ },
78
+ paypal: {
79
+ flow: P,
80
+ amount: t,
81
+ currency: "USD",
82
+ buttonStyle: {
83
+ // @ts-ignore
84
+ color: "gold",
85
+ // @ts-ignore
86
+ shape: "rect",
87
+ // @ts-ignore
88
+ size: "responsive"
89
+ }
90
+ },
91
+ googlePay: {
92
+ googlePayVersion: 2,
93
+ merchantId: m,
94
+ transactionInfo: a(t),
95
+ button: {
96
+ allowedPaymentMethods: [{
97
+ type: "CARD",
98
+ // @ts-ignore
99
+ parameters: {
100
+ // allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'], // TODO: confirm/update
101
+ // allowedCardNetworks: ['AMEX', 'DISCOVER', 'INTERAC', 'JCB', 'MASTERCARD', 'VISA'], // TODO: confirm/update
102
+ billingAddressRequired: !0,
103
+ billingAddressParameters: {
104
+ format: "FULL"
105
+ }
106
+ }
107
+ }]
108
+ }
109
+ },
110
+ applePay: {
111
+ displayName: "Kiva",
112
+ paymentRequest: o(t)
113
+ }
114
+ }), d();
115
+ } catch (l) {
116
+ throw new I({
117
+ code: "shop.braintreeDropinInitError",
118
+ original: l
119
+ }, "An Error has occured. Please refresh the page and try again.");
120
+ }
121
+ return e;
122
+ }
123
+ async function y() {
124
+ if (e.isPaymentMethodRequestable())
125
+ return e.requestPaymentMethod();
126
+ }
127
+ function f(r) {
128
+ var i;
129
+ const u = s(r).format("0.00");
130
+ u !== t && (t = u, e == null || e.updateConfiguration("paypal", "amount", t), e == null || e.updateConfiguration("googlePay", "transactionInfo", a(t)), (i = e == null ? void 0 : e.updateConfiguration) == null || i.call(e, "applePay", "paymentRequest", o(t)));
131
+ }
132
+ return {
133
+ initDropIn: c,
134
+ paymentMethodRequestable: n,
135
+ requestPaymentMethod: y,
136
+ updateAmount: f
137
+ };
138
+ }
139
+ const p = {};
140
+ function U(e = "default") {
141
+ return p[e] || (p[e] = D()), p[e];
142
+ }
7
143
  export {
8
- useBraintreeDropIn as default,
9
- defaultPaymentTypes,
10
- getClientToken
144
+ U as default,
145
+ w as defaultPaymentTypes,
146
+ T as getClientToken
11
147
  };
@@ -0,0 +1,11 @@
1
+ const n = (e) => {
2
+ var o;
3
+ if (typeof document !== void 0)
4
+ return decodeURIComponent(((o = document.cookie.match(`(^|;)\\s*${e}\\s*=\\s*([^;]+)`)) == null ? void 0 : o.pop()) || "");
5
+ }, c = (e, o, t = "") => {
6
+ typeof document !== void 0 && (document.cookie = `${e}=${encodeURIComponent(o)};${t}`);
7
+ };
8
+ export {
9
+ n as getCookieValue,
10
+ c as setCookieValue
11
+ };
@@ -0,0 +1,17 @@
1
+ function a(t) {
2
+ return new Promise((e) => setTimeout(e, t));
3
+ }
4
+ async function w(t, e, n, o) {
5
+ const r = Date.now() + o;
6
+ let i = await t();
7
+ for (; !e(i); ) {
8
+ if (Date.now() > r)
9
+ throw new Error("Polling timed out");
10
+ await a(n), i = await t();
11
+ }
12
+ return i;
13
+ }
14
+ export {
15
+ w as poll,
16
+ a as wait
17
+ };
@@ -0,0 +1,8 @@
1
+ function o(e) {
2
+ return new Promise(() => {
3
+ window.location.href = e;
4
+ });
5
+ }
6
+ export {
7
+ o as redirectTo
8
+ };
@@ -0,0 +1,7 @@
1
+ import { getCookieValue as o } from "./cookie.js";
2
+ function e() {
3
+ return o("uiv");
4
+ }
5
+ export {
6
+ e as getVisitorID
7
+ };
@@ -1,13 +1,46 @@
1
- import {
2
- validatePreCheckout,
3
- validatePreCheckoutMutation
4
- } from "./chunk-KCUOMCSN.js";
5
- import "./chunk-TPJPGUO7.js";
6
- import "./chunk-IOZ5ERDX.js";
7
- import "./chunk-FBF4WMN6.js";
8
- import "./chunk-4ODZGLWK.js";
9
- import "./chunk-LZ4UMRCV.js";
1
+ import { gql as l } from "@apollo/client";
2
+ import { callShopMutation as m } from "./shopQueries.js";
3
+ import { getVisitorID as c } from "./util/visitorId.js";
4
+ import { parseShopError as p, ShopError as u } from "./shopError.js";
5
+ const v = l`
6
+ mutation validatePreCheckout(
7
+ $basketId: String,
8
+ $email: String,
9
+ $visitorId: String,
10
+ $emailOptIn: Boolean,
11
+ $inviter: InviterInput
12
+ ) {
13
+ shop (basketId: $basketId) {
14
+ id
15
+ validatePreCheckout (email: $email, visitorId: $visitorId, emailOptIn: $emailOptIn, inviter: $inviter) {
16
+ error
17
+ success
18
+ value
19
+ }
20
+ }
21
+ }`;
22
+ async function k({
23
+ apollo: o,
24
+ emailAddress: a,
25
+ emailOptIn: n,
26
+ valetInviter: s
27
+ }) {
28
+ var r;
29
+ const e = await m(o, {
30
+ mutation: v,
31
+ variables: {
32
+ visitorId: c(),
33
+ email: a,
34
+ emailOptIn: n,
35
+ inviter: s
36
+ }
37
+ }, 0), i = ((r = e == null ? void 0 : e.shop) == null ? void 0 : r.validatePreCheckout).filter(({ success: t }) => !t).map((t) => p(t));
38
+ if (i.length) {
39
+ const t = new u({ code: "shop.failedCheckoutValidation" });
40
+ throw t.aggregateErrors(i), t;
41
+ }
42
+ }
10
43
  export {
11
- validatePreCheckout,
12
- validatePreCheckoutMutation
44
+ k as validatePreCheckout,
45
+ v as validatePreCheckoutMutation
13
46
  };