@kiva/kv-shop 2.1.2 → 3.0.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.
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
@@ -0,0 +1,6 @@
1
+ function r(o) {
2
+ throw new Error('Could not dynamically require "' + o + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
3
+ }
4
+ export {
5
+ r as commonjsRequire
6
+ };
@@ -0,0 +1,8 @@
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
+ };
@@ -0,0 +1,9 @@
1
+ const s = (t, e) => {
2
+ const o = t.__vccOpts || t;
3
+ for (const [r, c] of e)
4
+ o[r] = c;
5
+ return o;
6
+ };
7
+ export {
8
+ s as default
9
+ };
@@ -0,0 +1,11 @@
1
+ import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
2
+ import { __require as o } from "../vendor/braintree-web-drop-in/dist/browser/dropin.js";
3
+ var e = o();
4
+ const t = /* @__PURE__ */ r(e), a = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5
+ __proto__: null,
6
+ default: t
7
+ }, Symbol.toStringTag, { value: "Module" }));
8
+ export {
9
+ a as d,
10
+ t as default
11
+ };
@@ -0,0 +1,4 @@
1
+ var o = { exports: {} };
2
+ export {
3
+ o as __module
4
+ };
package/dist/basket.js CHANGED
@@ -1,14 +1,37 @@
1
- import {
2
- createBasket,
3
- getBasketID,
4
- hasBasketExpired,
5
- setBasketID
6
- } from "./chunk-FBF4WMN6.js";
7
- import "./chunk-4ODZGLWK.js";
8
- import "./chunk-LZ4UMRCV.js";
1
+ import { gql as i } from "@apollo/client";
2
+ import { getCookieValue as c, setCookieValue as o } from "./util/cookie.js";
3
+ import { parseShopError as u } from "./shopError.js";
4
+ function B() {
5
+ return c("kvbskt");
6
+ }
7
+ function k(t) {
8
+ o("kvbskt", t, "path=/;secure;");
9
+ }
10
+ async function p(t) {
11
+ try {
12
+ return t.mutate({
13
+ mutation: i`mutation createNewBasketForUser { shop { id createBasket } }`
14
+ }).then(({ data: e }) => {
15
+ var n;
16
+ const a = ((n = e.shop) == null ? void 0 : n.createBasket) ?? null;
17
+ a && k(a);
18
+ });
19
+ } catch (e) {
20
+ throw u(e);
21
+ }
22
+ }
23
+ let s = null;
24
+ async function f(t) {
25
+ return s || (s = p(t), s);
26
+ }
27
+ function m(t) {
28
+ var a;
29
+ const e = (t == null ? void 0 : t.code) ?? ((a = t == null ? void 0 : t.extensions) == null ? void 0 : a.code) ?? (t == null ? void 0 : t.name) ?? "";
30
+ return ["shop.invalidBasketId", "shop.basketRequired", "shop.alreadyCheckedOut"].includes(e);
31
+ }
9
32
  export {
10
- createBasket,
11
- getBasketID,
12
- hasBasketExpired,
13
- setBasketID
33
+ f as createBasket,
34
+ B as getBasketID,
35
+ m as hasBasketExpired,
36
+ k as setBasketID
14
37
  };
@@ -1,16 +1,80 @@
1
- import {
2
- applyKivaCredit,
3
- applyPromoCredit,
4
- removeKivaCredit,
5
- removePromoCredit
6
- } from "./chunk-UJXHTR43.js";
7
- import "./chunk-IOZ5ERDX.js";
8
- import "./chunk-FBF4WMN6.js";
9
- import "./chunk-4ODZGLWK.js";
10
- import "./chunk-LZ4UMRCV.js";
1
+ import { gql as i } from "@apollo/client";
2
+ import { callShopMutation as m } from "./shopQueries.js";
3
+ async function C(t) {
4
+ var r;
5
+ const e = await m(t, {
6
+ awaitRefetchQueries: !0,
7
+ mutation: i`mutation applyKivaCredit($basketId: String) {
8
+ shop (basketId: $basketId) {
9
+ id
10
+ addCreditByType(creditType: kiva_credit)
11
+ }
12
+ }`
13
+ });
14
+ return !!((r = e == null ? void 0 : e.shop) != null && r.addCreditByType);
15
+ }
16
+ async function l(t) {
17
+ var r;
18
+ const e = await m(t, {
19
+ awaitRefetchQueries: !0,
20
+ mutation: i`mutation removeKivaCredit($basketId: String) {
21
+ shop (basketId: $basketId) {
22
+ id
23
+ removeCreditByType(creditType: kiva_credit)
24
+ }
25
+ }`
26
+ });
27
+ return !!((r = e == null ? void 0 : e.shop) != null && r.removeCreditByType);
28
+ }
29
+ async function v(t, e) {
30
+ var a, d;
31
+ return !((a = e == null ? void 0 : e.variables) != null && a.creditType) || !((d = e == null ? void 0 : e.variables) != null && d.redemptionCode) ? Promise.resolve({
32
+ errors: [
33
+ {
34
+ message: "Missing required parameter.",
35
+ extensions: { code: "upc.missing_parameter" }
36
+ }
37
+ ]
38
+ }) : await m(t, {
39
+ awaitRefetchQueries: !0,
40
+ fetchPolicy: (e == null ? void 0 : e.fetchPolicy) ?? "network-only",
41
+ mutation: i`mutation applyPromoCredit(
42
+ $basketId: String,
43
+ $creditType: CreditTypeEnum!,
44
+ $redemptionCode: String
45
+ ) {
46
+ shop (basketId: $basketId) {
47
+ id
48
+ addCreditByType(creditType: $creditType, redemptionCode: $redemptionCode)
49
+ }
50
+ }`,
51
+ variables: { ...e == null ? void 0 : e.variables }
52
+ });
53
+ }
54
+ async function b(t, e) {
55
+ var a, d, y;
56
+ if (!((a = e == null ? void 0 : e.variables) != null && a.creditType) && !((d = e == null ? void 0 : e.variables) != null && d.redemptionCode))
57
+ return Promise.resolve(!1);
58
+ const r = await m(t, {
59
+ awaitRefetchQueries: !0,
60
+ fetchPolicy: (e == null ? void 0 : e.fetchPolicy) ?? "network-only",
61
+ mutation: i`mutation removePromoCredit(
62
+ $basketId: String,
63
+ $creditType: CreditTypeEnum!,
64
+ $redemptionCode: String
65
+ ) {
66
+ shop (basketId: $basketId) {
67
+ id
68
+ removeCreditByType(creditType: $creditType, redemptionCode: $redemptionCode)
69
+ }
70
+ }`,
71
+ variables: { ...e == null ? void 0 : e.variables }
72
+ });
73
+ return !!((y = r == null ? void 0 : r.shop) != null && y.removeCreditByType);
74
+ }
11
75
  export {
12
- applyKivaCredit,
13
- applyPromoCredit,
14
- removeKivaCredit,
15
- removePromoCredit
76
+ C as applyKivaCredit,
77
+ v as applyPromoCredit,
78
+ l as removeKivaCredit,
79
+ b as removePromoCredit
16
80
  };
@@ -1,10 +1,29 @@
1
- import {
2
- setTipDonation
3
- } from "./chunk-Z7JRY3QE.js";
4
- import "./chunk-IOZ5ERDX.js";
5
- import "./chunk-FBF4WMN6.js";
6
- import "./chunk-4ODZGLWK.js";
7
- import "./chunk-LZ4UMRCV.js";
1
+ import { gql as r } from "@apollo/client";
2
+ import p from "numeral";
3
+ import { callShopMutation as m } from "./shopQueries.js";
4
+ async function d({ amount: a, apollo: o, metadata: e }) {
5
+ var i;
6
+ const n = p(a).format("0.00"), t = await m(o, {
7
+ awaitRefetchQueries: !0,
8
+ mutation: r`mutation setTipDonation($price: Money!, $basketId: String, $metadata: String) {
9
+ shop (basketId: $basketId) {
10
+ id
11
+ updateDonation (donation: {
12
+ price: $price,
13
+ isTip: true,
14
+ metadata: $metadata,
15
+ })
16
+ {
17
+ id
18
+ price
19
+ isTip
20
+ }
21
+ }
22
+ }`,
23
+ variables: { price: n, metadata: e }
24
+ });
25
+ return (i = t == null ? void 0 : t.shop) == null ? void 0 : i.updateDonation;
26
+ }
8
27
  export {
9
- setTipDonation
28
+ d as setTipDonation
10
29
  };
@@ -1,12 +1,40 @@
1
- import {
2
- basketTotalsQuery,
3
- watchBasketTotals
4
- } from "./chunk-IIN37LC7.js";
5
- import "./chunk-IOZ5ERDX.js";
6
- import "./chunk-FBF4WMN6.js";
7
- import "./chunk-4ODZGLWK.js";
8
- import "./chunk-LZ4UMRCV.js";
1
+ import { gql as e } from "@apollo/client";
2
+ import { watchShopQuery as t } from "./shopQueries.js";
3
+ const l = e`query basketTotals($basketId: String) {
4
+ shop (basketId: $basketId) {
5
+ id
6
+ basket {
7
+ id
8
+ totals {
9
+ bonusAppliedTotal
10
+ bonusAvailableTotal
11
+ creditAmountNeeded
12
+ creditAppliedTotal
13
+ creditAvailableTotal
14
+ donationTotal
15
+ itemTotal
16
+ freeTrialAppliedTotal
17
+ freeTrialAvailableTotal
18
+ loanReservationTotal
19
+ kivaCardTotal
20
+ kivaCreditAppliedTotal
21
+ kivaCreditAvailableTotal
22
+ kivaCreditRemaining
23
+ kivaCreditToReapply
24
+ redemptionCodeAppliedTotal
25
+ redemptionCodeAvailableTotal
26
+ universalCodeAppliedTotal
27
+ universalCodeAvailableTotal
28
+ }
29
+ }
30
+ }
31
+ }`;
32
+ function r(a) {
33
+ return t(a, {
34
+ query: l
35
+ });
36
+ }
9
37
  export {
10
- basketTotalsQuery,
11
- watchBasketTotals
38
+ l as basketTotalsQuery,
39
+ r as watchBasketTotals
12
40
  };
@@ -1,8 +1,8 @@
1
- import {
2
- VerificationState,
3
- isBasketVerified
4
- } from "./chunk-FCAOCO7O.js";
1
+ var E = /* @__PURE__ */ ((e) => (e.VERIFIED = "verified", e.PENDING = "pending", e.REQUIRED = "required", e.MAY_BE_NEEDED = "may_be_needed", e.NOT_NEEDED = "not_needed", e))(E || {});
2
+ function d(e) {
3
+ return e === "verified" || e === "not_needed";
4
+ }
5
5
  export {
6
- VerificationState,
7
- isBasketVerified
6
+ E as VerificationState,
7
+ d as isBasketVerified
8
8
  };
@@ -1,10 +1,54 @@
1
- import {
2
- getCheckoutStatus,
3
- pollForFinishedCheckout
4
- } from "./chunk-SRGYGDAX.js";
5
- import "./chunk-TPJPGUO7.js";
6
- import "./chunk-LZ4UMRCV.js";
1
+ import { gql as u } from "@apollo/client";
2
+ import { poll as d } from "./util/poll.js";
3
+ import { getVisitorID as I } from "./util/visitorId.js";
4
+ async function f({ apollo: t, transactionSagaId: r }) {
5
+ return t.query({
6
+ query: u`
7
+ query checkoutStatus($transactionId: String!, $visitorId: String) {
8
+ checkoutStatus(transactionId: $transactionId, visitorId: $visitorId) {
9
+ basketId
10
+ errorCode
11
+ errorMessage
12
+ receipt {
13
+ checkoutId
14
+ }
15
+ requestedAt
16
+ status
17
+ transactionId
18
+ updatedAt
19
+ }
20
+ }
21
+ `,
22
+ variables: {
23
+ transactionId: r,
24
+ visitorId: I()
25
+ },
26
+ fetchPolicy: "network-only"
27
+ });
28
+ }
29
+ async function g({
30
+ apollo: t,
31
+ transactionSagaId: r,
32
+ interval: i = 1e3,
33
+ timeout: a = 6e4
34
+ }) {
35
+ return d(
36
+ // function to poll
37
+ () => f({
38
+ apollo: t,
39
+ transactionSagaId: r
40
+ }),
41
+ // function to check for completed status
42
+ (o) => {
43
+ var e;
44
+ const { status: n, errorCode: s, errorMessage: c } = (e = o == null ? void 0 : o.data) == null ? void 0 : e.checkoutStatus;
45
+ return !!(n === "COMPLETED" || s || c);
46
+ },
47
+ i,
48
+ a
49
+ );
50
+ }
7
51
  export {
8
- getCheckoutStatus,
9
- pollForFinishedCheckout
52
+ f as getCheckoutStatus,
53
+ g as pollForFinishedCheckout
10
54
  };
@@ -0,0 +1 @@
1
+ .kv-payment-select .braintree-dropin{font-family:inherit}.kv-payment-select [data-braintree-id=sheet-error]{@apply tw-bg-white;}.kv-payment-select .braintree-method__label,.kv-payment-select .braintree-option__label,.kv-payment-select .braintree-methods--active .braintree-method__label,.kv-payment-select .braintree-method .braintree-method__label .braintree-method__label--small{@apply tw-text-primary tw-text-left tw-font-book;}.kv-payment-select [data-braintree-id=methods-container] .braintree-method--active{@apply tw-border tw-border-brand tw-bg-secondary;}.kv-payment-select [data-braintree-id=methods-container] .braintree-method__check{padding:.3125rem;height:1.95rem;width:1.95rem;margin-right:.25rem;@apply tw-bg-brand;}.kv-payment-select [data-braintree-id=paypal],.kv-payment-select [data-braintree-id=applePay],.kv-payment-select [data-braintree-id=googlePay],.kv-payment-select [data-braintree-id=card]{border:0}.kv-payment-select [data-braintree-id=card] .braintree-sheet__content.braintree-sheet__content--form{padding:0}.kv-payment-select [data-braintree-id=card] .braintree-sheet__content .braintree-form__field-error{@apply tw-text-danger tw-text-left tw-font-medium;}.kv-payment-select [data-braintree-id=card] .braintree-sheet__content .braintree-form__field-group{padding-left:0;margin-bottom:1.25rem}.kv-payment-select [data-braintree-id=card] .braintree-sheet__content .braintree-form__field-group.braintree-form__field-group--has-error .braintree-form__hosted-field{@apply tw-bg-danger/[.15] tw-border-danger tw-rounded-sm;}.kv-payment-select [data-braintree-id=card] .braintree-sheet__content .braintree-form__field-group:not(.braintree-form__field-group--has-error) .braintree-form__field:not(.braintree-form__checkbox) .braintree-form__hosted-field{@apply tw-text-tertiary tw-bg-secondary tw-rounded-sm tw-border-secondary;}.kv-payment-select [data-braintree-id=card] .braintree-sheet__content span.braintree-form__descriptor{display:none}.kv-payment-select [data-braintree-id=card] .braintree-sheet__content [data-braintree-id=expiration-date-field-group],.kv-payment-select [data-braintree-id=card] .braintree-sheet__content [data-braintree-id=cvv-field-group],.kv-payment-select [data-braintree-id=card] .braintree-sheet__content [data-braintree-id=postal-code-field-group]{width:49%;flex-basis:auto;flex-grow:unset}.kv-payment-select [data-braintree-id=card-view-icons]{padding-bottom:0}.kv-payment-select [data-braintree-id=card-view-icons]>div{padding:0;border:1px solid #f3f3f3;border-radius:.25rem;line-height:.6875 rem}.kv-payment-select [data-braintree-id=paypal-button]{width:99%}@screen md{.kv-payment-select [data-braintree-id="paypal-button"] {width: 250px;}}.kv-payment-select [data-braintree-id=number-field-group]:not(.braintree-form__field-group--card-type-known) svg{display:none}.kv-payment-select iframe[type=number]{box-shadow:none;padding:0;background-color:transparent}.kv-payment-select [data-braintree-id=choose-a-way-to-pay],.kv-payment-select [data-braintree-id=methods-label],.kv-payment-select [data-braintree-id=other-ways-to-pay]{@apply tw-text-small tw-text-primary tw-text-tertiary tw-w-full;}.kv-payment-select [data-braintree-id=sheet-container]{@apply tw-bg-white;}.kv-payment-select [data-braintree-id=paypal-sheet-header],.kv-payment-select [data-braintree-id=apple-pay-sheet-header],.kv-payment-select [data-braintree-id=google-pay-sheet-header],.kv-payment-select [data-braintree-id=card-sheet-header]{@apply tw-bg-transparent tw-border-0 tw-p-0 tw-pb-1 tw-mb-1;}.kv-payment-select [data-braintree-id=paypal-sheet-header] .braintree-sheet__logo--header,.kv-payment-select [data-braintree-id=apple-pay-sheet-header] .braintree-sheet__logo--header,.kv-payment-select [data-braintree-id=google-pay-sheet-header] .braintree-sheet__logo--header,.kv-payment-select [data-braintree-id=card-sheet-header] .braintree-sheet__logo--header{@apply tw-hidden;}.kv-payment-select [data-braintree-id=paypal-sheet-header] .braintree-sheet__header-label,.kv-payment-select [data-braintree-id=apple-pay-sheet-header] .braintree-sheet__header-label,.kv-payment-select [data-braintree-id=google-pay-sheet-header] .braintree-sheet__header-label,.kv-payment-select [data-braintree-id=card-sheet-header] .braintree-sheet__header-label{@apply tw-w-full;}.kv-payment-select [data-braintree-id=paypal-sheet-header] .braintree-sheet__text,.kv-payment-select [data-braintree-id=apple-pay-sheet-header] .braintree-sheet__text,.kv-payment-select [data-braintree-id=google-pay-sheet-header] .braintree-sheet__text,.kv-payment-select [data-braintree-id=card-sheet-header] .braintree-sheet__text,.kv-payment-select [data-braintree-id=paypal-sheet-header] .braintree-sheet__label,.kv-payment-select [data-braintree-id=apple-pay-sheet-header] .braintree-sheet__label,.kv-payment-select [data-braintree-id=google-pay-sheet-header] .braintree-sheet__label,.kv-payment-select [data-braintree-id=card-sheet-header] .braintree-sheet__label{@apply tw-ml-0 tw-text-h4 tw-text-primary tw-text-left;}.kv-payment-select [data-braintree-id=upper-container]:before{background-color:transparent}.kv-payment-select [data-braintree-id=methods-container] .braintree-method{@apply tw-border-solid tw-border-tertiary tw-w-full tw-border tw-p-2;}.kv-payment-select [data-braintree-id=methods-container] .braintree-method:first-child{@apply tw-rounded-tr tw-rounded-tl tw-rounded-bl-none tw-rounded-br-none;}.kv-payment-select [data-braintree-id=methods-container] .braintree-method:last-child{@apply tw-rounded-br tw-rounded-bl;}.kv-payment-select [data-braintree-id=payment-options-container] .braintree-option{@apply tw-border-solid tw-border-tertiary tw-w-full tw-border tw-border-b-0 tw-p-2;}.kv-payment-select [data-braintree-id=payment-options-container] .braintree-option:first-child{@apply tw-rounded-tr tw-rounded-tl tw-rounded-bl-none tw-rounded-br-none;}.kv-payment-select [data-braintree-id=payment-options-container] .braintree-option:last-child{@apply tw-rounded-br tw-rounded-bl tw-border-b;}.kv-payment-select [data-braintree-id=toggle],.kv-payment-select [data-braintree-id=toggle]:hover{@apply tw-bg-transparent tw-text-h4 tw-text-link;}.kv-payment-select [data-braintree-id=toggle] span,.kv-payment-select [data-braintree-id=toggle] span:focus,.kv-payment-select [data-braintree-id=toggle] span:hover{@apply tw-text-base tw-no-underline tw-border-0;@apply tw-font-medium;}.kv-payment-select [data-braintree-id=card] .braintree-sheet__content .braintree-form__label{@apply tw-text-base;@apply tw-font-medium;}.braintree-sheet__container>.braintree-sheet:not(.braintree-card):before{@apply tw-absolute tw-w-full tw-left-0 tw-top-3 tw-font-medium;content:"Click payment method again to continue"}
@@ -0,0 +1,23 @@
1
+ import o from "./KvPaymentSelect2.js";
2
+ import { resolveComponent as r, createElementBlock as s, openBlock as e, createElementVNode as a, createBlock as c, createCommentVNode as p } from "vue";
3
+ import "./KvPaymentSelect.css";
4
+ import i from "../_virtual/_plugin-vue_export-helper.js";
5
+ const m = { class: "kv-payment-select tw-text-center" }, d = {
6
+ ref: "container",
7
+ class: "data-hj-suppress",
8
+ "data-testid": "braintree-drop-in"
9
+ };
10
+ function l(t, _, f, u, k, v) {
11
+ const n = r("kv-loading-spinner");
12
+ return e(), s("div", m, [
13
+ a("div", d, null, 512),
14
+ t.updatingPaymentWrapper ? (e(), c(n, {
15
+ key: 0,
16
+ class: "tw-mb-2"
17
+ })) : p("", !0)
18
+ ]);
19
+ }
20
+ const x = /* @__PURE__ */ i(o, [["render", l]]);
21
+ export {
22
+ x as default
23
+ };
@@ -0,0 +1,110 @@
1
+ import { toRefs as v, ref as l, watch as p, onMounted as M } from "vue";
2
+ import { KvLoadingSpinner as P } from "@kiva/kv-components";
3
+ import T, { defaultPaymentTypes as I } from "../useBraintreeDropIn.js";
4
+ const k = {
5
+ components: {
6
+ KvLoadingSpinner: P
7
+ },
8
+ props: {
9
+ amount: {
10
+ type: [String, Number],
11
+ default: ""
12
+ },
13
+ /**
14
+ * Braintree authorization token.
15
+ */
16
+ authToken: {
17
+ type: String,
18
+ required: !0
19
+ },
20
+ /**
21
+ * Braintree Drop In instance name.
22
+ */
23
+ dropInName: {
24
+ type: String,
25
+ default: "default"
26
+ },
27
+ /**
28
+ * Paypal flow options.
29
+ * Must be 'checkout' or 'vault'
30
+ * */
31
+ flow: {
32
+ type: String,
33
+ default: "checkout"
34
+ },
35
+ /**
36
+ * Google Pay merchant ID
37
+ * Required if using the 'googlePay' option (which is on by default)
38
+ */
39
+ googlePayMerchantId: {
40
+ type: String,
41
+ default: ""
42
+ },
43
+ /**
44
+ * Payment type options to be displayed.
45
+ * Also controls the order to display them in.
46
+ * All options in default order:
47
+ * ['card', 'paypal', 'paypalCredit', 'venmo', 'applePay', 'googlePay']
48
+ * */
49
+ paymentTypes: {
50
+ type: Array,
51
+ default: () => I
52
+ },
53
+ /**
54
+ * Preselect Vaulted Payment Method
55
+ * Braintree option to preselect payment method
56
+ * */
57
+ preselectVaultedPaymentMethod: {
58
+ type: Boolean,
59
+ default: !0
60
+ }
61
+ },
62
+ emits: ["transactions-enabled", "error"],
63
+ setup(o, { emit: a }) {
64
+ const {
65
+ amount: u,
66
+ authToken: s,
67
+ flow: d,
68
+ googlePayMerchantId: y,
69
+ paymentTypes: i,
70
+ preselectVaultedPaymentMethod: m
71
+ } = v(o), n = l(null), r = l(!1), {
72
+ initDropIn: c,
73
+ paymentMethodRequestable: f,
74
+ requestPaymentMethod: h,
75
+ updateAmount: g
76
+ } = T(o.dropInName);
77
+ return p(u, (e) => {
78
+ g(e);
79
+ }), p(f, (e) => {
80
+ a("transactions-enabled", e);
81
+ }, { immediate: !0 }), M(async () => {
82
+ var e;
83
+ if (((e = n.value) == null ? void 0 : e.innerHTML) === "") {
84
+ r.value = !0;
85
+ try {
86
+ await c({
87
+ amount: u.value,
88
+ authToken: s.value,
89
+ container: n.value,
90
+ googlePayMerchantId: y.value,
91
+ paymentTypes: i.value,
92
+ preselectVaultedPaymentMethod: m.value,
93
+ paypalFlow: d.value
94
+ });
95
+ } catch (t) {
96
+ t instanceof Error ? a("error", t == null ? void 0 : t.message) : a("error", "An error has occured. Please refresh the page and try again.");
97
+ } finally {
98
+ r.value = !1;
99
+ }
100
+ }
101
+ }), {
102
+ container: n,
103
+ updatingPaymentWrapper: r,
104
+ requestPaymentMethod: h
105
+ };
106
+ }
107
+ };
108
+ export {
109
+ k as default
110
+ };