tonder-web-sdk 1.16.3 → 1.16.6-beta.DEV-1433.2

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 (106) hide show
  1. package/README.md +22 -25
  2. package/package.json +10 -3
  3. package/types/common.d.ts +4 -0
  4. package/v1/bundle.min.js +1 -18
  5. package/.env-example +0 -1
  6. package/.husky/pre-commit +0 -4
  7. package/.prettierignore +0 -8
  8. package/.prettierrc +0 -10
  9. package/cypress/e2e/1-getting-started/todo.cy.js +0 -143
  10. package/cypress/e2e/2-advanced-examples/actions.cy.js +0 -299
  11. package/cypress/e2e/2-advanced-examples/aliasing.cy.js +0 -39
  12. package/cypress/e2e/2-advanced-examples/assertions.cy.js +0 -176
  13. package/cypress/e2e/2-advanced-examples/connectors.cy.js +0 -98
  14. package/cypress/e2e/2-advanced-examples/cookies.cy.js +0 -118
  15. package/cypress/e2e/2-advanced-examples/cypress_api.cy.js +0 -185
  16. package/cypress/e2e/2-advanced-examples/files.cy.js +0 -85
  17. package/cypress/e2e/2-advanced-examples/location.cy.js +0 -32
  18. package/cypress/e2e/2-advanced-examples/misc.cy.js +0 -104
  19. package/cypress/e2e/2-advanced-examples/navigation.cy.js +0 -56
  20. package/cypress/e2e/2-advanced-examples/network_requests.cy.js +0 -163
  21. package/cypress/e2e/2-advanced-examples/querying.cy.js +0 -114
  22. package/cypress/e2e/2-advanced-examples/spies_stubs_clocks.cy.js +0 -201
  23. package/cypress/e2e/2-advanced-examples/storage.cy.js +0 -110
  24. package/cypress/e2e/2-advanced-examples/traversal.cy.js +0 -121
  25. package/cypress/e2e/2-advanced-examples/utilities.cy.js +0 -108
  26. package/cypress/e2e/2-advanced-examples/viewport.cy.js +0 -58
  27. package/cypress/e2e/2-advanced-examples/waiting.cy.js +0 -30
  28. package/cypress/e2e/2-advanced-examples/window.cy.js +0 -22
  29. package/cypress/fixtures/example.json +0 -5
  30. package/cypress/support/commands.js +0 -25
  31. package/cypress/support/e2e.js +0 -20
  32. package/cypress.config.js +0 -9
  33. package/eslint.config.mjs +0 -15
  34. package/index.js.example +0 -50
  35. package/samples/react/README.md +0 -70
  36. package/samples/react/build/asset-manifest.json +0 -16
  37. package/samples/react/build/favicon.ico +0 -0
  38. package/samples/react/build/index.html +0 -1
  39. package/samples/react/build/logo192.png +0 -0
  40. package/samples/react/build/logo512.png +0 -0
  41. package/samples/react/build/manifest.json +0 -25
  42. package/samples/react/build/robots.txt +0 -3
  43. package/samples/react/build/static/css/main.073c9b0a.css +0 -2
  44. package/samples/react/build/static/css/main.073c9b0a.css.map +0 -1
  45. package/samples/react/build/static/js/787.b83ed06f.chunk.js +0 -2
  46. package/samples/react/build/static/js/787.b83ed06f.chunk.js.map +0 -1
  47. package/samples/react/build/static/js/main.0a848807.js +0 -3
  48. package/samples/react/build/static/js/main.0a848807.js.LICENSE.txt +0 -39
  49. package/samples/react/build/static/js/main.0a848807.js.map +0 -1
  50. package/samples/react/build/static/media/sdk-icons.b491623214b2af4cccdb.png +0 -0
  51. package/samples/react/package-lock.json +0 -28973
  52. package/samples/react/package.json +0 -44
  53. package/samples/react/public/favicon.ico +0 -0
  54. package/samples/react/public/index.html +0 -43
  55. package/samples/react/public/logo192.png +0 -0
  56. package/samples/react/public/logo512.png +0 -0
  57. package/samples/react/public/manifest.json +0 -25
  58. package/samples/react/public/robots.txt +0 -3
  59. package/samples/react/src/App.css +0 -38
  60. package/samples/react/src/App.js +0 -22
  61. package/samples/react/src/App.test.js +0 -8
  62. package/samples/react/src/assets/img/sdk-icons.png +0 -0
  63. package/samples/react/src/components/Cart.js +0 -29
  64. package/samples/react/src/components/ProductCard.js +0 -27
  65. package/samples/react/src/context/CartContext.js +0 -116
  66. package/samples/react/src/index.css +0 -13
  67. package/samples/react/src/index.js +0 -17
  68. package/samples/react/src/logo.svg +0 -1
  69. package/samples/react/src/reportWebVitals.js +0 -13
  70. package/samples/react/src/screens/Checkout.js +0 -82
  71. package/samples/react/src/screens/Store.js +0 -21
  72. package/samples/react/src/setupTests.js +0 -5
  73. package/samples/react/src/storeProducts.js +0 -30
  74. package/src/classes/3dsHandler.js +0 -199
  75. package/src/classes/BaseInlineCheckout.js +0 -303
  76. package/src/classes/LiteInlineCheckout.js +0 -217
  77. package/src/classes/checkout.js +0 -129
  78. package/src/classes/globalLoader.js +0 -31
  79. package/src/classes/inlineCheckout.js +0 -713
  80. package/src/data/apmApi.js +0 -38
  81. package/src/data/businessApi.js +0 -16
  82. package/src/data/cardApi.js +0 -134
  83. package/src/data/checkoutApi.js +0 -92
  84. package/src/data/customerApi.js +0 -32
  85. package/src/data/index.js +0 -17
  86. package/src/data/openPayApi.js +0 -16
  87. package/src/data/skyflowApi.js +0 -16
  88. package/src/helpers/skyflow.js +0 -370
  89. package/src/helpers/styles.js +0 -90
  90. package/src/helpers/template-skeleton.js +0 -59
  91. package/src/helpers/template.js +0 -1104
  92. package/src/helpers/utils.js +0 -257
  93. package/src/helpers/validations.js +0 -53
  94. package/src/index-dev.js +0 -329
  95. package/src/index.html +0 -180
  96. package/src/index.js +0 -21
  97. package/src/shared/catalog/commonLogosCatalog.js +0 -7
  98. package/src/shared/catalog/paymentMethodsCatalog.js +0 -246
  99. package/src/shared/constants/colors.js +0 -15
  100. package/src/shared/constants/displayMode.js +0 -4
  101. package/src/shared/constants/fieldPathNames.js +0 -4
  102. package/src/shared/constants/htmlTonderIds.js +0 -18
  103. package/src/shared/constants/messages.js +0 -11
  104. package/src/shared/constants/paymentMethodAPM.js +0 -63
  105. package/src/shared/constants/tonderUrl.js +0 -8
  106. package/webpack.config.js +0 -77
@@ -1,129 +0,0 @@
1
- import { AES } from "crypto-js";
2
-
3
- export class Checkout {
4
- constructor({
5
- apiKey,
6
- type = "payment",
7
- backgroundColor = "#141414",
8
- color = "#EBEBEB",
9
- cb = () => {},
10
- url = "http://checkout.tonder.io/#/",
11
- }) {
12
- this.url = url;
13
- this.apiKey = apiKey;
14
- this.type = type;
15
- this.backgroundColor = backgroundColor;
16
- this.color = color;
17
- this.params = "";
18
- this.order = {};
19
- this.buttonText = "Proceder al pago";
20
- this.cb = cb;
21
-
22
- window.addEventListener("message", this.receiveMessage.bind(this), false);
23
- }
24
- generateButton = buttonText => {
25
- this.buttonText = buttonText ? buttonText : this.buttonText;
26
- this.tonderButton = document.createElement("button");
27
- this.tonderButton.innerHTML = this.buttonText;
28
- this.stylishButton(this.tonderButton);
29
- this.tonderButton.onclick = this.openCheckout;
30
- };
31
- getButton = ({ buttonText }) => {
32
- this.generateButton(buttonText);
33
- return this.tonderButton;
34
- };
35
- mountButton = ({ buttonText }) => {
36
- this.generateButton(buttonText);
37
- const entryPoint = document.getElementById("tonder-checkout");
38
- try {
39
- entryPoint.innerHTML = "";
40
- entryPoint.append(this.tonderButton);
41
- } catch (error) {
42
- console.error(error);
43
- }
44
- };
45
- stylishButton = element => {
46
- element.style.backgroundColor = this.backgroundColor;
47
- element.style.color = this.color;
48
- element.style.display = "flex";
49
- element.style.justifyContent = "center";
50
- element.style.border = "none";
51
- element.style.padding = "1rem";
52
- element.style.borderRadius = "10px";
53
- element.style.fontSize = "1rem";
54
- element.style.width = "100%";
55
- element.style.boxShadow = "0 3px 6px 0 rgba(0,0,0,0.16)";
56
- };
57
- setOrder = ({ products, email, shippingCost }) => {
58
- let _order = {};
59
- if (products) _order.products = products;
60
- if (email) _order.email = email;
61
- if (shippingCost) _order.shippingCost = shippingCost;
62
- this.order = { ...this.order, ..._order };
63
- return this.order;
64
- };
65
- openTabListener = (tab, button) => {
66
- const tabInterval = setInterval(() => {
67
- if (tab.closed) {
68
- clearInterval(tabInterval);
69
- button.disabled = false;
70
- button.innerHTML = this.buttonText;
71
- }
72
- }, 500);
73
- };
74
- openCheckout = () => {
75
- const queryString = this.getUrlParams();
76
- const encrypted = AES.encrypt(queryString, "url-params-encrypt").toString();
77
- const encodedURL = encodeURIComponent(encrypted);
78
- this.params = "?" + encodedURL;
79
- const newWindow = window.open(
80
- this.url + this.params,
81
- "_blank",
82
- `width=1200,height=$800,left=0,top=0`,
83
- );
84
- this.tonderButton.disabled = true;
85
- this.tonderButton.innerHTML = `
86
- <div class="loader"></div>
87
- <style>
88
- .loader {
89
- border: 4px solid ${this.color};
90
- border-radius: 50%;
91
- border-top: 4px solid ${this.backgroundColor};
92
- width: 0.625rem;
93
- height: 0.625rem;
94
- -webkit-animation: spin 2s linear infinite; /* Safari */
95
- animation: spin 2s linear infinite;
96
- }
97
-
98
- /* Safari */
99
- @-webkit-keyframes spin {
100
- 0% { -webkit-transform: rotate(0deg); }
101
- 100% { -webkit-transform: rotate(360deg); }
102
- }
103
-
104
- @keyframes spin {
105
- 0% { transform: rotate(0deg); }
106
- 100% { transform: rotate(360deg); }
107
- }
108
- </style>
109
- `;
110
- this.openTabListener(newWindow, this.tonderButton);
111
- };
112
- getUrlParams = () => {
113
- const params = { apiKey: this.apiKey, ...this.order, type: this.type };
114
- if (params.products) {
115
- params.products = JSON.stringify(params.products);
116
- }
117
- const queryString = new URLSearchParams(params).toString();
118
- return queryString;
119
- };
120
- receiveMessage(event) {
121
- // Parse data if it is possible, in case of error it will return the raw data.
122
- try {
123
- const data = JSON.parse(event.data);
124
- this.cb(data);
125
- } catch (error) {
126
- this.cb(event.data);
127
- }
128
- }
129
- }
@@ -1,31 +0,0 @@
1
- import { cardTemplateSkeleton } from "../helpers/template-skeleton.js";
2
- import { HTML_IDS } from "../shared/constants/htmlTonderIds";
3
-
4
- class GlobalLoader {
5
- constructor() {
6
- this.requestCount = 0;
7
- }
8
-
9
- show() {
10
- this.requestCount++;
11
- const checkoutContainer = document.querySelector(`#${HTML_IDS.globalLoader}`);
12
- if (checkoutContainer) {
13
- checkoutContainer.innerHTML = cardTemplateSkeleton;
14
- checkoutContainer.style.display = "block";
15
- }
16
- }
17
-
18
- remove() {
19
- this.requestCount--;
20
- if (this.requestCount <= 0) {
21
- this.requestCount = 0;
22
- const loaders = document.querySelectorAll(`#${HTML_IDS.globalLoader}`);
23
-
24
- loaders.forEach(loader => {
25
- loader.style.display = "none";
26
- });
27
- }
28
- }
29
- }
30
-
31
- export const globalLoader = new GlobalLoader();