@kiva/kv-shop 1.3.2 → 1.4.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 (56) hide show
  1. package/dist/basket.cjs +44 -15
  2. package/dist/basket.d.ts +4 -4
  3. package/dist/basket.js +5 -8
  4. package/dist/basketCredits.cjs +197 -0
  5. package/dist/basketCredits.d.ts +18 -0
  6. package/dist/basketCredits.js +12 -0
  7. package/dist/basketItems.cjs +70 -33
  8. package/dist/basketItems.d.ts +11 -1
  9. package/dist/basketItems.js +5 -3
  10. package/dist/basketTotals.cjs +228 -0
  11. package/dist/basketTotals.d.ts +37 -0
  12. package/dist/basketTotals.js +12 -0
  13. package/dist/basketVerification.cjs +41 -0
  14. package/dist/basketVerification.d.ts +10 -0
  15. package/dist/basketVerification.js +8 -0
  16. package/dist/checkoutStatus.cjs +110 -0
  17. package/dist/checkoutStatus.d.ts +20 -0
  18. package/dist/checkoutStatus.js +10 -0
  19. package/dist/{chunk-B7RLQXI6.js → chunk-2NC7LGGO.js} +14 -12
  20. package/dist/{chunk-IYCMZ5WV.js → chunk-4ODZGLWK.js} +21 -0
  21. package/dist/chunk-AI6E33YE.js +33 -0
  22. package/dist/chunk-CBJJUUVR.js +121 -0
  23. package/dist/chunk-DZGZX4F6.js +45 -0
  24. package/dist/chunk-EJ5NGYPO.js +145 -0
  25. package/dist/chunk-FCAOCO7O.js +17 -0
  26. package/dist/chunk-JBQ2KNMP.js +50 -0
  27. package/dist/{chunk-SLMBU6L7.js → chunk-JXQPCEKG.js} +9 -2
  28. package/dist/{chunk-TIASV6B2.js → chunk-KV4SOUVF.js} +1 -1
  29. package/dist/chunk-LZ4UMRCV.js +16 -0
  30. package/dist/chunk-MRCBNXPS.js +35 -0
  31. package/dist/chunk-PC4WUPYU.js +78 -0
  32. package/dist/chunk-TPJPGUO7.js +12 -0
  33. package/dist/components/KvPaymentSelect.vue +8 -1
  34. package/dist/index.cjs +489 -56
  35. package/dist/index.d.ts +12 -5
  36. package/dist/index.js +55 -21
  37. package/dist/oneTimeCheckout.cjs +396 -9
  38. package/dist/oneTimeCheckout.d.ts +11 -10
  39. package/dist/oneTimeCheckout.js +10 -5
  40. package/dist/shopError.cjs +21 -0
  41. package/dist/shopError.d.ts +2 -0
  42. package/dist/shopError.js +1 -1
  43. package/dist/shopQueries.cjs +248 -0
  44. package/dist/shopQueries.d.ts +8 -0
  45. package/dist/shopQueries.js +13 -0
  46. package/dist/subscriptionCheckout.cjs +21 -0
  47. package/dist/subscriptionCheckout.js +2 -2
  48. package/dist/useBraintreeDropIn.cjs +29 -1
  49. package/dist/useBraintreeDropIn.d.ts +9 -9
  50. package/dist/useBraintreeDropIn.js +2 -2
  51. package/dist/validatePreCheckout.cjs +210 -0
  52. package/dist/validatePreCheckout.d.ts +22 -0
  53. package/dist/validatePreCheckout.js +13 -0
  54. package/package.json +3 -3
  55. package/dist/chunk-M4CJOCIQ.js +0 -26
  56. package/dist/chunk-NC7RAUNV.js +0 -66
@@ -1,26 +0,0 @@
1
- // src/oneTimeCheckout.ts
2
- import { gql } from "@apollo/client/core";
3
- async function executeOneTimeCheckout({ apollo }) {
4
- }
5
- async function waitOnTransaction({ apollo, transactionId }) {
6
- const result = await apollo.query({
7
- query: gql`
8
- query checkoutStatus($transactionId: String!, $visitorId: string) {
9
- checkoutStatus(transactionId: $transactionId, visitorId: $visitorId) {
10
- errorCode
11
- errorMessage
12
- status
13
- transactionId
14
- }
15
- }
16
- `,
17
- variables: {
18
- transactionId
19
- }
20
- });
21
- }
22
-
23
- export {
24
- executeOneTimeCheckout,
25
- waitOnTransaction
26
- };
@@ -1,66 +0,0 @@
1
- import {
2
- createBasket,
3
- getBasketID,
4
- hasBasketExpired
5
- } from "./chunk-B7RLQXI6.js";
6
- import {
7
- ShopError,
8
- parseShopError
9
- } from "./chunk-IYCMZ5WV.js";
10
-
11
- // src/basketItems.ts
12
- import { gql } from "@apollo/client/core";
13
- import numeral from "numeral";
14
- async function callShopMutation(apollo, mutation, variables, maxretries = 2) {
15
- try {
16
- const result = await apollo.mutate({
17
- mutation,
18
- variables: {
19
- ...variables,
20
- basketId: getBasketID()
21
- }
22
- });
23
- if (result?.errors?.length) {
24
- const basketErrors = result?.errors.filter((err) => hasBasketExpired(err));
25
- if (basketErrors.length) {
26
- if (maxretries > 0) {
27
- await createBasket(apollo);
28
- return callShopMutation(apollo, mutation, variables, maxretries - 1);
29
- }
30
- throw basketErrors[0];
31
- }
32
- const otherErrors = result?.errors?.filter((err) => !hasBasketExpired(err));
33
- if (otherErrors.length) {
34
- throw otherErrors[0];
35
- }
36
- }
37
- return result?.data;
38
- } catch (e) {
39
- if (e instanceof ShopError) {
40
- throw e;
41
- }
42
- throw parseShopError(e);
43
- }
44
- }
45
- async function setTipDonation({ amount, apollo }) {
46
- const donationAmount = numeral(amount).format("0.00");
47
- const data = await callShopMutation(apollo, gql`mutation setTipDonation($price: Money!, $basketId: String) {
48
- shop (basketId: $basketId) {
49
- id
50
- updateDonation (donation: {
51
- price: $price,
52
- isTip: true
53
- })
54
- {
55
- id
56
- price
57
- isTip
58
- }
59
- }
60
- }`, { price: donationAmount });
61
- return data?.shop?.updateDonation;
62
- }
63
-
64
- export {
65
- setTipDonation
66
- };