tonder-web-sdk 1.16.1 → 1.16.6-beta.DEV-1433.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 (105) hide show
  1. package/README.md +134 -40
  2. package/package.json +29 -6
  3. package/types/card.d.ts +17 -17
  4. package/types/checkout.d.ts +85 -87
  5. package/types/common.d.ts +8 -2
  6. package/types/customer.d.ts +10 -10
  7. package/types/index.d.ts +9 -11
  8. package/types/inlineCheckout.d.ts +81 -61
  9. package/types/liteInlineCheckout.d.ts +78 -83
  10. package/types/paymentMethod.d.ts +17 -17
  11. package/types/transaction.d.ts +94 -94
  12. package/v1/bundle.min.js +1 -18
  13. package/.env-example +0 -1
  14. package/cypress/e2e/1-getting-started/todo.cy.js +0 -143
  15. package/cypress/e2e/2-advanced-examples/actions.cy.js +0 -299
  16. package/cypress/e2e/2-advanced-examples/aliasing.cy.js +0 -39
  17. package/cypress/e2e/2-advanced-examples/assertions.cy.js +0 -176
  18. package/cypress/e2e/2-advanced-examples/connectors.cy.js +0 -98
  19. package/cypress/e2e/2-advanced-examples/cookies.cy.js +0 -118
  20. package/cypress/e2e/2-advanced-examples/cypress_api.cy.js +0 -185
  21. package/cypress/e2e/2-advanced-examples/files.cy.js +0 -85
  22. package/cypress/e2e/2-advanced-examples/location.cy.js +0 -32
  23. package/cypress/e2e/2-advanced-examples/misc.cy.js +0 -104
  24. package/cypress/e2e/2-advanced-examples/navigation.cy.js +0 -56
  25. package/cypress/e2e/2-advanced-examples/network_requests.cy.js +0 -163
  26. package/cypress/e2e/2-advanced-examples/querying.cy.js +0 -114
  27. package/cypress/e2e/2-advanced-examples/spies_stubs_clocks.cy.js +0 -201
  28. package/cypress/e2e/2-advanced-examples/storage.cy.js +0 -110
  29. package/cypress/e2e/2-advanced-examples/traversal.cy.js +0 -121
  30. package/cypress/e2e/2-advanced-examples/utilities.cy.js +0 -108
  31. package/cypress/e2e/2-advanced-examples/viewport.cy.js +0 -58
  32. package/cypress/e2e/2-advanced-examples/waiting.cy.js +0 -30
  33. package/cypress/e2e/2-advanced-examples/window.cy.js +0 -22
  34. package/cypress/fixtures/example.json +0 -5
  35. package/cypress/support/commands.js +0 -25
  36. package/cypress/support/e2e.js +0 -20
  37. package/cypress.config.js +0 -9
  38. package/index.js.example +0 -50
  39. package/samples/react/README.md +0 -70
  40. package/samples/react/build/asset-manifest.json +0 -16
  41. package/samples/react/build/favicon.ico +0 -0
  42. package/samples/react/build/index.html +0 -1
  43. package/samples/react/build/logo192.png +0 -0
  44. package/samples/react/build/logo512.png +0 -0
  45. package/samples/react/build/manifest.json +0 -25
  46. package/samples/react/build/robots.txt +0 -3
  47. package/samples/react/build/static/css/main.073c9b0a.css +0 -2
  48. package/samples/react/build/static/css/main.073c9b0a.css.map +0 -1
  49. package/samples/react/build/static/js/787.b83ed06f.chunk.js +0 -2
  50. package/samples/react/build/static/js/787.b83ed06f.chunk.js.map +0 -1
  51. package/samples/react/build/static/js/main.0a848807.js +0 -3
  52. package/samples/react/build/static/js/main.0a848807.js.LICENSE.txt +0 -39
  53. package/samples/react/build/static/js/main.0a848807.js.map +0 -1
  54. package/samples/react/build/static/media/sdk-icons.b491623214b2af4cccdb.png +0 -0
  55. package/samples/react/package-lock.json +0 -28973
  56. package/samples/react/package.json +0 -44
  57. package/samples/react/public/favicon.ico +0 -0
  58. package/samples/react/public/index.html +0 -43
  59. package/samples/react/public/logo192.png +0 -0
  60. package/samples/react/public/logo512.png +0 -0
  61. package/samples/react/public/manifest.json +0 -25
  62. package/samples/react/public/robots.txt +0 -3
  63. package/samples/react/src/App.css +0 -38
  64. package/samples/react/src/App.js +0 -22
  65. package/samples/react/src/App.test.js +0 -8
  66. package/samples/react/src/assets/img/sdk-icons.png +0 -0
  67. package/samples/react/src/components/Cart.js +0 -29
  68. package/samples/react/src/components/ProductCard.js +0 -27
  69. package/samples/react/src/context/CartContext.js +0 -116
  70. package/samples/react/src/index.css +0 -13
  71. package/samples/react/src/index.js +0 -17
  72. package/samples/react/src/logo.svg +0 -1
  73. package/samples/react/src/reportWebVitals.js +0 -13
  74. package/samples/react/src/screens/Checkout.js +0 -82
  75. package/samples/react/src/screens/Store.js +0 -21
  76. package/samples/react/src/setupTests.js +0 -5
  77. package/samples/react/src/storeProducts.js +0 -30
  78. package/src/classes/3dsHandler.js +0 -203
  79. package/src/classes/BaseInlineCheckout.js +0 -324
  80. package/src/classes/LiteInlineCheckout.js +0 -220
  81. package/src/classes/checkout.js +0 -125
  82. package/src/classes/globalLoader.js +0 -29
  83. package/src/classes/inlineCheckout.js +0 -515
  84. package/src/data/apmApi.js +0 -44
  85. package/src/data/businessApi.js +0 -19
  86. package/src/data/cardApi.js +0 -143
  87. package/src/data/checkoutApi.js +0 -92
  88. package/src/data/customerApi.js +0 -37
  89. package/src/data/index.js +0 -17
  90. package/src/data/openPayApi.js +0 -16
  91. package/src/data/skyflowApi.js +0 -18
  92. package/src/helpers/skyflow.js +0 -361
  93. package/src/helpers/styles.js +0 -61
  94. package/src/helpers/template-skeleton.js +0 -59
  95. package/src/helpers/template.js +0 -743
  96. package/src/helpers/utils.js +0 -163
  97. package/src/helpers/validations.js +0 -54
  98. package/src/index-dev.js +0 -307
  99. package/src/index.html +0 -172
  100. package/src/index.js +0 -15
  101. package/src/shared/catalog/paymentMethodsCatalog.js +0 -247
  102. package/src/shared/constants/messages.js +0 -10
  103. package/src/shared/constants/paymentMethodAPM.js +0 -63
  104. package/src/shared/constants/tonderUrl.js +0 -8
  105. package/webpack.config.js +0 -77
@@ -1,44 +0,0 @@
1
- {
2
- "name": "sdk-test",
3
- "version": "0.1.0",
4
- "private": true,
5
- "homepage": "https://fuentesc91.github.io/react-example-use-tonder-sdk",
6
- "dependencies": {
7
- "@testing-library/jest-dom": "^5.16.5",
8
- "@testing-library/react": "^13.4.0",
9
- "@testing-library/user-event": "^13.5.0",
10
- "react": "^18.2.0",
11
- "react-dom": "^18.2.0",
12
- "react-scripts": "5.0.1",
13
- "web-vitals": "^2.1.4"
14
- },
15
- "scripts": {
16
- "predeploy": "npm run build",
17
- "deploy": "gh-pages -d build",
18
- "start": "react-scripts start",
19
- "build": "react-scripts build",
20
- "test": "react-scripts test",
21
- "eject": "react-scripts eject"
22
- },
23
- "eslintConfig": {
24
- "extends": [
25
- "react-app",
26
- "react-app/jest"
27
- ]
28
- },
29
- "browserslist": {
30
- "production": [
31
- ">0.2%",
32
- "not dead",
33
- "not op_mini all"
34
- ],
35
- "development": [
36
- "last 1 chrome version",
37
- "last 1 firefox version",
38
- "last 1 safari version"
39
- ]
40
- },
41
- "devDependencies": {
42
- "gh-pages": "^5.0.0"
43
- }
44
- }
Binary file
@@ -1,43 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <meta name="theme-color" content="#000000" />
8
- <meta
9
- name="description"
10
- content="Web site created using create-react-app"
11
- />
12
- <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
- <!--
14
- manifest.json provides metadata used when your web app is installed on a
15
- user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
- -->
17
- <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
- <!--
19
- Notice the use of %PUBLIC_URL% in the tags above.
20
- It will be replaced with the URL of the `public` folder during the build.
21
- Only files inside the `public` folder can be referenced from the HTML.
22
-
23
- Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
- work correctly both with client-side routing and a non-root public URL.
25
- Learn how to configure a non-root public URL by running `npm run build`.
26
- -->
27
- <title>React App</title>
28
- </head>
29
- <body>
30
- <noscript>You need to enable JavaScript to run this app.</noscript>
31
- <div id="root"></div>
32
- <!--
33
- This HTML file is a template.
34
- If you open it directly in the browser, you will see an empty page.
35
-
36
- You can add webfonts, meta tags, or analytics to this file.
37
- The build step will place the bundled scripts into the <body> tag.
38
-
39
- To begin the development, run `npm start` or `yarn start`.
40
- To create a production bundle, use `npm run build` or `yarn build`.
41
- -->
42
- </body>
43
- </html>
Binary file
Binary file
@@ -1,25 +0,0 @@
1
- {
2
- "short_name": "React App",
3
- "name": "Create React App Sample",
4
- "icons": [
5
- {
6
- "src": "favicon.ico",
7
- "sizes": "64x64 32x32 24x24 16x16",
8
- "type": "image/x-icon"
9
- },
10
- {
11
- "src": "logo192.png",
12
- "type": "image/png",
13
- "sizes": "192x192"
14
- },
15
- {
16
- "src": "logo512.png",
17
- "type": "image/png",
18
- "sizes": "512x512"
19
- }
20
- ],
21
- "start_url": ".",
22
- "display": "standalone",
23
- "theme_color": "#000000",
24
- "background_color": "#ffffff"
25
- }
@@ -1,3 +0,0 @@
1
- # https://www.robotstxt.org/robotstxt.html
2
- User-agent: *
3
- Disallow:
@@ -1,38 +0,0 @@
1
- .App {
2
- text-align: center;
3
- }
4
-
5
- .App-logo {
6
- height: 40vmin;
7
- pointer-events: none;
8
- }
9
-
10
- @media (prefers-reduced-motion: no-preference) {
11
- .App-logo {
12
- animation: App-logo-spin infinite 20s linear;
13
- }
14
- }
15
-
16
- .App-header {
17
- background-color: #282c34;
18
- min-height: 100vh;
19
- display: flex;
20
- flex-direction: column;
21
- align-items: center;
22
- justify-content: center;
23
- font-size: calc(10px + 2vmin);
24
- color: white;
25
- }
26
-
27
- .App-link {
28
- color: #61dafb;
29
- }
30
-
31
- @keyframes App-logo-spin {
32
- from {
33
- transform: rotate(0deg);
34
- }
35
- to {
36
- transform: rotate(360deg);
37
- }
38
- }
@@ -1,22 +0,0 @@
1
-
2
- import './App.css';
3
- import { CartProvider } from './context/CartContext';
4
-
5
- import Store from './screens/Store';
6
- import Cart from './components/Cart';
7
- import { Checkout } from './screens/Checkout';
8
-
9
- function App() {
10
-
11
- return (
12
- <div className="App">
13
- <CartProvider>
14
- <Store/>
15
- <Cart/>
16
- <Checkout />
17
- </CartProvider>
18
- </div>
19
- );
20
- }
21
-
22
- export default App;
@@ -1,8 +0,0 @@
1
- import { render, screen } from '@testing-library/react';
2
- import App from './App';
3
-
4
- test('renders learn react link', () => {
5
- render(<App />);
6
- const linkElement = screen.getByText(/learn react/i);
7
- expect(linkElement).toBeInTheDocument();
8
- });
@@ -1,29 +0,0 @@
1
- import React, { useContext } from 'react'
2
-
3
- import { CartContext } from '../context/CartContext'
4
-
5
- const Cart = () => {
6
- const cart = useContext(CartContext)
7
-
8
- return (
9
- <>
10
- <h3>Cart</h3>
11
- <div>
12
- { cart.items.map((product, index) => {
13
- return (
14
- <div key={index}>
15
- <div>{product.title}</div>
16
- <div>{product.price}</div>
17
- <div>{product.quantity}</div>
18
- </div>
19
- )
20
- })}
21
- <div>
22
- Total: <span id="cart-total">{cart.getTotalCost()}</span>
23
- </div>
24
- </div>
25
- </>
26
- )
27
- }
28
-
29
- export default Cart
@@ -1,27 +0,0 @@
1
- import React, { useContext } from 'react'
2
-
3
- import { CartContext } from '../context/CartContext'
4
- import { getProductData } from '../storeProducts'
5
-
6
- const ProductCard = (props) => {
7
- const { productData } = props
8
- const product = getProductData(productData.id)
9
-
10
- const cart = useContext(CartContext)
11
-
12
- return (
13
- <div>
14
- <div>
15
- { product.title }
16
- </div>
17
- { product.price }
18
- <button
19
- onClick={() => cart.addOneToCart(product.id)}
20
- >
21
- Add
22
- </button>
23
- </div>
24
- )
25
- }
26
-
27
- export default ProductCard
@@ -1,116 +0,0 @@
1
- import { createContext, useState } from "react";
2
- import { getProductData } from "../storeProducts";
3
-
4
-
5
- export const CartContext = createContext({
6
- items: [],
7
- getProductQuantity: () => {},
8
- addOneToCart: () => {},
9
- removeOneFromCart: () => {},
10
- deleteFromCart: () => {},
11
- getTotalCost: () => {}
12
- });
13
-
14
- export function CartProvider({children}) {
15
- const [cartProducts, setCartProducts] = useState([]);
16
-
17
- function getProductQuantity(id) {
18
- const quantity = cartProducts.find(product => product.id === id)?.quantity;
19
-
20
- if (quantity === undefined) {
21
- return 0;
22
- }
23
-
24
- return quantity;
25
- }
26
-
27
- function addOneToCart(id) {
28
- const quantity = getProductQuantity(id);
29
- const product = getProductData(id)
30
-
31
- if (quantity === 0) { // product is not in cart
32
- setCartProducts(
33
- [
34
- ...cartProducts,
35
- {
36
- ...product,
37
- quantity: 1
38
- }
39
- ]
40
- )
41
- } else { // product is in cart
42
- setCartProducts(
43
- cartProducts.map(
44
- _product =>
45
- _product.id === id // if condition
46
- ? { ...product, quantity: _product.quantity + 1 } // if statement is true
47
- : _product // if statement is false
48
- )
49
- )
50
- }
51
- }
52
-
53
- function removeOneFromCart(id) {
54
- const quantity = getProductQuantity(id);
55
-
56
- if(quantity === 1) {
57
- deleteFromCart(id);
58
- } else {
59
- setCartProducts(
60
- cartProducts.map(
61
- product =>
62
- product.id === id // if condition
63
- ? { ...product, quantity: product.quantity - 1 } // if statement is true
64
- : product // if statement is false
65
- )
66
- )
67
- }
68
- }
69
-
70
- function deleteFromCart(id) {
71
- // [] if an object meets a condition, add the object to array
72
- // [product1, product2, product3]
73
- // [product1, product3]
74
- setCartProducts(
75
- cartProducts =>
76
- cartProducts.filter(currentProduct => {
77
- return currentProduct.id !== id;
78
- })
79
- )
80
- }
81
-
82
- function getTotalCost() {
83
- var formatter = new Intl.NumberFormat('es-MX', {
84
- style: 'currency',
85
- currency: 'MXN'
86
- });
87
- let totalCost = 0;
88
- cartProducts.forEach((cartItem) => {
89
- totalCost += (cartItem.price * cartItem.quantity);
90
- });
91
- return formatter.format(totalCost);
92
- }
93
-
94
- const contextValue = {
95
- items: cartProducts,
96
- getProductQuantity,
97
- addOneToCart,
98
- removeOneFromCart,
99
- deleteFromCart,
100
- getTotalCost,
101
- }
102
-
103
- return (
104
- <CartContext.Provider value={contextValue}>
105
- {children}
106
- </CartContext.Provider>
107
- )
108
- }
109
-
110
- export default CartProvider;
111
-
112
-
113
- // CODE DOWN HERE
114
-
115
- // Context (cart, addToCart, removeCart)
116
- // Provider -> gives your React app access to all the things in your context
@@ -1,13 +0,0 @@
1
- body {
2
- margin: 0;
3
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4
- 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5
- sans-serif;
6
- -webkit-font-smoothing: antialiased;
7
- -moz-osx-font-smoothing: grayscale;
8
- }
9
-
10
- code {
11
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12
- monospace;
13
- }
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import ReactDOM from 'react-dom/client';
3
- import './index.css';
4
- import App from './App';
5
- import reportWebVitals from './reportWebVitals';
6
-
7
- const root = ReactDOM.createRoot(document.getElementById('root'));
8
- root.render(
9
- <React.StrictMode>
10
- <App />
11
- </React.StrictMode>
12
- );
13
-
14
- // If you want to start measuring performance in your app, pass a function
15
- // to log results (for example: reportWebVitals(console.log))
16
- // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17
- reportWebVitals();
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
@@ -1,13 +0,0 @@
1
- const reportWebVitals = onPerfEntry => {
2
- if (onPerfEntry && onPerfEntry instanceof Function) {
3
- import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4
- getCLS(onPerfEntry);
5
- getFID(onPerfEntry);
6
- getFCP(onPerfEntry);
7
- getLCP(onPerfEntry);
8
- getTTFB(onPerfEntry);
9
- });
10
- }
11
- };
12
-
13
- export default reportWebVitals;
@@ -1,82 +0,0 @@
1
- import React, { useState, useEffect } from 'react'
2
- import { InlineCheckout } from 'tonder-web-sdk'
3
-
4
- import sdkIcons from "../assets/img/sdk-icons.png";
5
-
6
- export const Checkout = () => {
7
- const [selectedOption, setSelectedOption] = useState(null);
8
- const [optionHidden, setOptionHidden] = useState(true);
9
-
10
- useEffect(()=>{
11
- const form = document.querySelector("#payment-form");
12
- const apiKey = "d34a419991e0bd53ed5cae7faf979b3263afabf5";
13
- const totalElement = document.querySelector("#cart-total");
14
- const returnUrl = window.location.href
15
- const inlineCheckout = new InlineCheckout({
16
- form: form,
17
- apiKey: apiKey,
18
- totalElementId: totalElement,
19
- returnUrl: returnUrl
20
- });
21
- inlineCheckout.injectCheckout();
22
- return () => inlineCheckout.removeCheckout()
23
- }, [])
24
-
25
- const checkoutStyle = {
26
- marginTop: "2rem",
27
- overflow: "hidden",
28
- transition: "max-height 0.3s",
29
- };
30
- const hiddenStyle = { maxHeight: optionHidden ? "0px" : "1000px" };
31
-
32
- const onRadioChange = (event) => {
33
- setSelectedOption(event.target.value);
34
- if (event.target.value === "1") {
35
- setOptionHidden(false);
36
- } else {
37
- setOptionHidden(true);
38
- }
39
- };
40
-
41
- return (
42
- <>
43
- <h3>{selectedOption}</h3>
44
- <form id="payment-form">
45
- <div
46
- style={{
47
- display: "flex",
48
- flexDirection: "column",
49
- marginBottom: "2rem",
50
- }}
51
- >
52
- <div style={{ display: 'flex', alignItems: 'center', justifyContent: "center" }}>
53
- <input
54
- onChange={onRadioChange}
55
- name="payment"
56
- type="radio"
57
- id="tonder-pay"
58
- value="1"
59
- />
60
- <label htmlFor="tonder-pay">
61
- Pago con tarjeta de crédito/débito
62
- </label>
63
- <img style={{ width: "150px", marginLeft: "0.5rem" }} src={sdkIcons} alt="" />
64
- </div>
65
- <div style={{ ...checkoutStyle, ...hiddenStyle }} id="tonder-checkout">
66
- </div>
67
- {/* <p>{checkoutResponse?.data?.status}</p> */}
68
- </div>
69
- <div style={{ marginTop: "2rem" }}>
70
- <input
71
- onChange={onRadioChange}
72
- name="payment"
73
- type="radio"
74
- id="other"
75
- value="2"
76
- />
77
- <label htmlFor="other">Otra opcion</label>
78
- </div>
79
- </form>
80
- </>
81
- );
82
- };
@@ -1,21 +0,0 @@
1
- import React from 'react'
2
-
3
- import ProductCard from '../components/ProductCard'
4
- import { productsArray } from '../storeProducts'
5
-
6
- const Store = () => {
7
- return (
8
- <>
9
- {productsArray.map((product, index) => {
10
- return (
11
- <ProductCard
12
- key={index}
13
- productData={product}
14
- />
15
- )
16
- })}
17
- </>
18
- )
19
- }
20
-
21
- export default Store
@@ -1,5 +0,0 @@
1
- // jest-dom adds custom jest matchers for asserting on DOM nodes.
2
- // allows you to do things like:
3
- // expect(element).toHaveTextContent(/react/i)
4
- // learn more: https://github.com/testing-library/jest-dom
5
- import '@testing-library/jest-dom';
@@ -1,30 +0,0 @@
1
- const productsArray = [
2
- {
3
- id: "price_1LnUTFDM1jwCEz8OGoOSXiSM",
4
- title: "Banana",
5
- price: 5.99
6
- },
7
- {
8
- id: "price_1LnUTxDM1jwCEz8OAqHYTwKQ",
9
- title: "Carrot",
10
- price: 9.99
11
- },
12
- {
13
- id: "price_1LnUUoDM1jwCEz8OvxIcJ7to",
14
- title: "Apple",
15
- price: 40.99
16
- }
17
- ];
18
-
19
- function getProductData(id) {
20
- let productData = productsArray.find(product => product.id === id);
21
-
22
- if (productData === undefined) {
23
- console.log("Product data does not exist for ID: " + id);
24
- return undefined;
25
- }
26
-
27
- return productData;
28
- }
29
-
30
- export { productsArray, getProductData };