tonder-web-sdk 1.16.1 → 1.16.3

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 (46) hide show
  1. package/.husky/pre-commit +4 -0
  2. package/.prettierignore +8 -0
  3. package/.prettierrc +10 -0
  4. package/README.md +113 -16
  5. package/eslint.config.mjs +15 -0
  6. package/package.json +20 -4
  7. package/src/classes/3dsHandler.js +58 -62
  8. package/src/classes/BaseInlineCheckout.js +12 -33
  9. package/src/classes/LiteInlineCheckout.js +5 -8
  10. package/src/classes/checkout.js +75 -71
  11. package/src/classes/globalLoader.js +9 -7
  12. package/src/classes/inlineCheckout.js +519 -321
  13. package/src/data/apmApi.js +8 -14
  14. package/src/data/businessApi.js +5 -8
  15. package/src/data/cardApi.js +5 -14
  16. package/src/data/checkoutApi.js +54 -54
  17. package/src/data/customerApi.js +1 -6
  18. package/src/data/index.js +15 -15
  19. package/src/data/openPayApi.js +7 -7
  20. package/src/data/skyflowApi.js +14 -16
  21. package/src/helpers/skyflow.js +132 -123
  22. package/src/helpers/styles.js +56 -27
  23. package/src/helpers/template-skeleton.js +1 -1
  24. package/src/helpers/template.js +971 -610
  25. package/src/helpers/utils.js +152 -58
  26. package/src/helpers/validations.js +34 -35
  27. package/src/index-dev.js +33 -11
  28. package/src/index.html +20 -12
  29. package/src/index.js +19 -13
  30. package/src/shared/catalog/commonLogosCatalog.js +7 -0
  31. package/src/shared/catalog/paymentMethodsCatalog.js +242 -243
  32. package/src/shared/constants/colors.js +15 -0
  33. package/src/shared/constants/displayMode.js +4 -0
  34. package/src/shared/constants/fieldPathNames.js +4 -0
  35. package/src/shared/constants/htmlTonderIds.js +18 -0
  36. package/src/shared/constants/messages.js +10 -9
  37. package/types/card.d.ts +17 -17
  38. package/types/checkout.d.ts +85 -87
  39. package/types/common.d.ts +4 -2
  40. package/types/customer.d.ts +10 -10
  41. package/types/index.d.ts +9 -11
  42. package/types/inlineCheckout.d.ts +81 -61
  43. package/types/liteInlineCheckout.d.ts +78 -83
  44. package/types/paymentMethod.d.ts +17 -17
  45. package/types/transaction.d.ts +94 -94
  46. package/v1/bundle.min.js +3 -3
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx lint-staged
@@ -0,0 +1,8 @@
1
+ # Ignore artifacts:
2
+ build
3
+ coverage
4
+ webpack.config.js
5
+ v1
6
+ README.md
7
+ samples
8
+ cypress
package/.prettierrc ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "singleQuote": false,
3
+ "trailingComma": "all",
4
+ "printWidth": 100,
5
+ "tabWidth": 2,
6
+ "semi": true,
7
+ "bracketSpacing": true,
8
+ "arrowParens": "avoid",
9
+ "endOfLine": "lf"
10
+ }
package/README.md CHANGED
@@ -7,8 +7,10 @@ Tonder SDK helps to integrate the services Tonder offers in your own website
7
7
  1. [Installation](#installation)
8
8
  2. [Usage](#usage)
9
9
  - [InlineCheckout](#inlinecheckout)
10
- - [LiteInlineCheckout](#Liteinlinecheckout)
11
- 3. [Configuration Options](#configuration-options)
10
+ - [LiteCheckout](#litecheckout)
11
+ 3. [Configuration Options](#configuration)
12
+ - [Inline Options](#inline-options)
13
+ - [Lite Options](#lite-options)
12
14
  4. [Styling InlineCheckout](#styling-inlinecheckout)
13
15
  5. [Payment Data Structure](#payment-data-structure)
14
16
  6. [Field Validation Functions](#field-validation-functions)
@@ -148,25 +150,116 @@ const paymentResponse = await LiteInlineCheckout.payment(paymentData);
148
150
  const verificationResult = await LiteInlineCheckout.verify3dsTransaction();
149
151
  ```
150
152
 
151
- ## Configuration Options
153
+ ## Configuration
154
+ ### Inline Options
152
155
 
153
- Both InlineCheckout and LiteInlineCheckout accept the following configuration options:
156
+ | Property | Type | Required | Description | Default | Description |
157
+ |:-------------:|:--------------------:|----------|------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------:|
158
+ | mode | string | Yes | Environment mode for the SDK | stage | Environment mode. Options: 'stage', 'production', 'sandbox'. Default: 'stage' |
159
+ | apiKey | string | Yes | Your Tonder Public API key | | Your API key from the Tonder Dashboard |
160
+ | returnUrl | string | Yes | URL for 3DS redirect completion | | URL where the checkout form is mounted (used for 3DS) |
161
+ | styles | object | No | | | (InlineCheckout only) Custom styles for the checkout interface |
162
+ | customization | CustomizationOptions | No | UI customization options | `{displayMode: 'light',saveCards: {showSaveCardOption: false,showSaved: false,autoSave: false,},paymentButton: {show: false,text: "Pagar",showAmount: true,},cancelButton: {show: false,text: "Cancelar",},paymentMethods: {show: true,},cardForm: {show: true,},showMessages: true,}` | Object to customize the checkout behavior and UI. |
163
+ | callbacks | IInlineCallbacks | No | Payment process callback functions |
164
+ <details>
165
+ <summary>View Interface Definition</summary>
154
166
 
155
- | Property | Type | Description |
156
- |:------------------------------------------:|:-------:|:-------------------------------------------------------------------------------------------------------------------------------------------:|
157
- | mode | string | Environment mode. Options: 'stage', 'production', 'sandbox'. Default: 'stage' |
158
- | apiKey | string | Your API key from the Tonder Dashboard |
159
- | returnUrl | string | URL where the checkout form is mounted (used for 3DS) |
160
- | renderPaymentButton | boolean | View the default Tonder payment button |
161
- | styles | object | (InlineCheckout only) Custom styles for the checkout interface |
162
- | customization | object | Object to customize the checkout behavior and UI. Default value `{saveCards: {showSaved: true, showSaveCardOption: true, autoSave: false}}` |
163
- | customization.saveCards.showSaved | boolean | Show saved cards in the checkout UI. Default value: `true` |
164
- | customization.saveCards.showSaveCardOption | object | Show the option to save the card for future payments. Default value: `true` |
165
- | customization.saveCards.autoSave | object | Automatically save the card without showing the option to the user. Default value: `false` |
167
+ ```typescript
168
+ interface IInlineCheckoutBaseOptions {
169
+ mode?: "production" | "sandbox" | "stage" | "development";
170
+ apiKey: string;
171
+ returnUrl: string;
172
+ callBack?: (response: any) => void;
173
+ }
174
+ interface IInlineCheckoutOptions extends IInlineCheckoutBaseOptions {
175
+ styles?: Record<string, string>;
176
+ customization?: CustomizationOptions;
177
+ callbacks?: IInlineCallbacks;
178
+ }
179
+ ```
180
+ </details>
166
181
 
167
182
  > **Important Note about SaveCard functionality**:
168
183
  > To properly implement the SaveCard feature, you must use a SecureToken. For detailed implementation instructions and best practices, please refer to our official documentation on [How to use SecureToken for secure card saving](https://docs.tonder.io/integration/sdks/secure-token#how-to-use-securetoken-for-secure-card-saving).
169
184
 
185
+ ### Inline Callbacks Structure
186
+
187
+ | Callback | Required | Parameters | Description | Return |
188
+ |------------|----------|------------|--------------------------------------------|---------------|
189
+ | `onCancel` | No | none | Called when user clicked the cancel button | Promise<void> |
190
+ <details>
191
+ <summary>View Interface Definition</summary>
192
+
193
+ ```typescript
194
+ interface IInlineCallbacks extends IBaseCallback {
195
+ onCancel?: () => Promise<void>;
196
+ }
197
+ ```
198
+ </details>
199
+
200
+ ### Inline Customization Options
201
+
202
+ | Option | Type | Default | Description |
203
+ |------------------------------|---------|------------|-------------------------------------------------------------------------------------------|
204
+ | **saveCards** |
205
+ | saveCards.showSaveCardOption | boolean | true | Shows a checkbox allowing users to choose whether to save their card for future purchases |
206
+ | saveCards.showSaved | boolean | true | Displays a list of previously saved cards for the customer |
207
+ | saveCards.autoSave | boolean | false | Automatically saves the card without showing the save option to the user |
208
+ | **paymentButton** |
209
+ | paymentButton.show | boolean | true | Controls the visibility of the payment button |
210
+ | paymentButton.text | string | 'Pagar' | Custom text to display on the payment button |
211
+ | paymentButton.showAmount | boolean | true | Shows the payment amount on the button (e.g., "Pay $100") |
212
+ | **cancelButton** |
213
+ | cancelButton.show | boolean | true | Controls the visibility of the cancel button |
214
+ | cancelButton.text | string | 'Cancelar' | Custom text to display on the cancel button |
215
+ | **paymentMethods** |
216
+ | paymentMethods.show | boolean | true | Controls the visibility of alternative payment methods section |
217
+ | **cardForm** |
218
+ | cardForm.show | boolean | true | Controls the visibility of the card input form |
219
+ | **General** |
220
+ | showMessages | boolean | true | Controls the visibility of error and success messages |
221
+ | displayMode | string | light | Controls the display mode light or dark |
222
+
223
+ <details>
224
+ <summary>View Interface Definition</summary>
225
+
226
+ ```typescript
227
+ export type CustomizationOptions = {
228
+ displayMode?: "light" | "dark";
229
+ saveCards?: {
230
+ showSaveCardOption?: boolean;
231
+ showSaved?: boolean;
232
+ autoSave?: boolean;
233
+ };
234
+ paymentButton?: {
235
+ show?: boolean;
236
+ text?: string;
237
+ showAmount?: boolean;
238
+ };
239
+ cancelButton?: {
240
+ show?: boolean;
241
+ text?: string;
242
+ };
243
+ paymentMethods?: {
244
+ show?: boolean;
245
+ };
246
+ cardForm?: {
247
+ show?: boolean;
248
+ };
249
+ showMessages?: boolean;
250
+ };
251
+ ```
252
+ </details>
253
+
254
+ ## Lite Options
255
+
256
+ | Property | Type | Required | Description | Default | Description |
257
+ |:---------:|:------:|----------|---------------------------------|---------|:-----------------------------------------------------------------------------:|
258
+ | mode | string | Yes | Environment mode for the SDK | stage | Environment mode. Options: 'stage', 'production', 'sandbox'. Default: 'stage' |
259
+ | apiKey | string | Yes | Your Tonder Public API key | | Your API key from the Tonder Dashboard |
260
+ | returnUrl | string | Yes | URL for 3DS redirect completion | | URL where the checkout form is mounted (used for 3DS) |
261
+
262
+
170
263
  ## Styling InlineCheckout
171
264
 
172
265
  You can customize the appearance of InlineCheckout by passing a `styles` object:
@@ -453,7 +546,11 @@ const inlineCheckout = new InlineCheckout({
453
546
  apiKey,
454
547
  returnUrl,
455
548
  styles: customStyles,
456
- renderPaymentButton: true, // activate default Tonder Payment button
549
+ customization: {
550
+ paymentButton: {
551
+ show: true
552
+ }
553
+ }, // activate default Tonder Payment button
457
554
  callBack: (response) => {
458
555
  console.log('Payment response', response)
459
556
  }
@@ -0,0 +1,15 @@
1
+ import eslintConfigPrettier from "eslint-config-prettier";
2
+ import eslintPluginPrettier from "eslint-plugin-prettier";
3
+
4
+ export default [
5
+ eslintConfigPrettier,
6
+ {
7
+ files: ["src/**/*.js"],
8
+ plugins: {
9
+ prettier: eslintPluginPrettier,
10
+ },
11
+ rules: {
12
+ "prettier/prettier": "error",
13
+ },
14
+ },
15
+ ];
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "tonder-web-sdk",
3
- "version": "1.16.1",
3
+ "version": "1.16.3",
4
4
  "description": "tonder sdk for integrations",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
7
7
  "start": "webpack-dev-server",
8
- "build": "webpack --config webpack.config.js --mode production"
8
+ "build": "webpack --config webpack.config.js --mode production",
9
+ "prepare": "husky install",
10
+ "format": "prettier --write .",
11
+ "lint": "eslint 'src/**/*.js'",
12
+ "lint:fix": "eslint 'src/**/*.js' --fix"
9
13
  },
10
14
  "author": "",
11
15
  "types": "types/index.d.ts",
@@ -13,7 +17,8 @@
13
17
  "dependencies": {
14
18
  "accordion-js": "^3.4.0",
15
19
  "crypto-js": "^4.1.1",
16
- "dotenv": "^16.3.1"
20
+ "dotenv": "^16.3.1",
21
+ "lodash.get": "^4.4.2"
17
22
  },
18
23
  "devDependencies": {
19
24
  "@babel/core": "^7.20.12",
@@ -22,12 +27,23 @@
22
27
  "babel-loader": "^9.1.2",
23
28
  "css-loader": "^6.7.3",
24
29
  "cypress": "^13.6.2",
30
+ "eslint": "^9.18.0",
31
+ "eslint-config-prettier": "^10.0.1",
32
+ "eslint-plugin-prettier": "^5.2.3",
25
33
  "html-webpack-plugin": "^5.5.3",
26
- "prettier": "^3.3.3",
34
+ "husky": "^8.0.3",
35
+ "lint-staged": "^15.4.1",
36
+ "prettier": "3.4.2",
27
37
  "style-loader": "^3.3.1",
28
38
  "terser-webpack-plugin": "^5.3.10",
29
39
  "webpack": "^5.75.0",
30
40
  "webpack-cli": "^5.0.1",
31
41
  "webpack-dev-server": "^4.11.1"
42
+ },
43
+ "lint-staged": {
44
+ "**/*.{js,jsx,ts,tsx}": [
45
+ "npm run format",
46
+ "npm run lint:fix"
47
+ ]
32
48
  }
33
49
  }
@@ -1,103 +1,99 @@
1
1
  export class ThreeDSHandler {
2
- constructor({
3
- payload = null,
4
- apiKey,
5
- baseUrl,
6
- }) {
7
- this.baseUrl = baseUrl
8
- this.apiKey = apiKey
9
- this.payload = payload
2
+ constructor({ payload = null, apiKey, baseUrl }) {
3
+ this.baseUrl = baseUrl;
4
+ this.apiKey = apiKey;
5
+ this.payload = payload;
10
6
  }
11
7
 
12
8
  saveVerifyTransactionUrl() {
13
- const url = this.payload?.next_action?.redirect_to_url?.verify_transaction_status_url
9
+ const url = this.payload?.next_action?.redirect_to_url?.verify_transaction_status_url;
14
10
  if (url) {
15
- this.saveUrlWithExpiration(url)
11
+ this.saveUrlWithExpiration(url);
16
12
  } else {
17
- const url = this.payload?.next_action?.iframe_resources?.verify_transaction_status_url
13
+ const url = this.payload?.next_action?.iframe_resources?.verify_transaction_status_url;
18
14
  if (url) {
19
- this.saveUrlWithExpiration(url)
15
+ this.saveUrlWithExpiration(url);
20
16
  } else {
21
- console.log('No verify_transaction_status_url found');
17
+ console.log("No verify_transaction_status_url found");
22
18
  }
23
19
  }
24
20
  }
25
21
 
26
22
  saveUrlWithExpiration(url) {
27
23
  try {
28
- const now = new Date()
24
+ const now = new Date();
29
25
  const item = {
30
26
  url: url,
31
27
  // Expires after 20 minutes
32
- expires: now.getTime() + 20 * 60 * 1000
33
- }
34
- localStorage.setItem('verify_transaction_status', JSON.stringify(item))
28
+ expires: now.getTime() + 20 * 60 * 1000,
29
+ };
30
+ localStorage.setItem("verify_transaction_status", JSON.stringify(item));
35
31
  } catch (error) {
36
- console.log('error: ', error)
32
+ console.log("error: ", error);
37
33
  }
38
34
  }
39
35
 
40
36
  getUrlWithExpiration() {
41
- const item = JSON.parse(localStorage.getItem("verify_transaction_status"))
42
- if (!item) return
37
+ const item = JSON.parse(localStorage.getItem("verify_transaction_status"));
38
+ if (!item) return;
43
39
 
44
- const now = new Date()
40
+ const now = new Date();
45
41
  if (now.getTime() > item.expires) {
46
- this.removeVerifyTransactionUrl()
47
- return null
42
+ this.removeVerifyTransactionUrl();
43
+ return null;
48
44
  } else {
49
- return item.url
45
+ return item.url;
50
46
  }
51
47
  }
52
48
 
53
49
  removeVerifyTransactionUrl() {
54
- localStorage.removeItem("verify_transaction_status")
50
+ localStorage.removeItem("verify_transaction_status");
55
51
  }
56
52
 
57
53
  getVerifyTransactionUrl() {
58
- return localStorage.getItem("verify_transaction_status")
54
+ return localStorage.getItem("verify_transaction_status");
59
55
  }
60
56
 
61
57
  loadIframe() {
62
- const iframe = this.payload?.next_action?.iframe_resources?.iframe
58
+ const iframe = this.payload?.next_action?.iframe_resources?.iframe;
63
59
  if (iframe) {
64
60
  return new Promise((resolve, reject) => {
65
- const iframe = this.payload?.next_action?.iframe_resources?.iframe
61
+ const iframe = this.payload?.next_action?.iframe_resources?.iframe;
66
62
 
67
63
  if (iframe) {
68
64
  // TODO: This is not working for Azul
69
- this.saveVerifyTransactionUrl()
70
- const container = document.createElement('div')
71
- container.innerHTML = iframe
72
- document.body.appendChild(container)
65
+ this.saveVerifyTransactionUrl();
66
+ const container = document.createElement("div");
67
+ container.innerHTML = iframe;
68
+ document.body.appendChild(container);
73
69
 
74
70
  // Create and append the script tag manually
75
- const script = document.createElement('script')
76
- script.textContent = 'document.getElementById("tdsMmethodForm").submit();'
77
- container.appendChild(script)
71
+ const script = document.createElement("script");
72
+ script.textContent = 'document.getElementById("tdsMmethodForm").submit();';
73
+ container.appendChild(script);
78
74
 
79
75
  // Resolve the promise when the iframe is loaded
80
- const iframeElement = document.getElementById('tdsMmethodTgtFrame')
81
- iframeElement.onload = () => resolve(true)
76
+ const iframeElement = document.getElementById("tdsMmethodTgtFrame");
77
+ iframeElement.onload = () => resolve(true);
82
78
  } else {
83
- console.log('No redirection found');
84
- reject(false)
79
+ console.log("No redirection found");
80
+ reject(false);
85
81
  }
86
- })
82
+ });
87
83
  }
88
84
  }
89
85
 
90
86
  getRedirectUrl() {
91
- return this.payload?.next_action?.redirect_to_url?.url
87
+ return this.payload?.next_action?.redirect_to_url?.url;
92
88
  }
93
89
 
94
90
  redirectToChallenge() {
95
- const url = this.getRedirectUrl()
91
+ const url = this.getRedirectUrl();
96
92
  if (url) {
97
- this.saveVerifyTransactionUrl()
93
+ this.saveVerifyTransactionUrl();
98
94
  window.location = url;
99
95
  } else {
100
- console.log('No redirection found');
96
+ console.log("No redirection found");
101
97
  }
102
98
  }
103
99
 
@@ -118,7 +114,7 @@ export class ThreeDSHandler {
118
114
  // TODO: Remove this duplication
119
115
  handleSuccessTransaction(response) {
120
116
  this.removeVerifyTransactionUrl();
121
- console.log('Transacción autorizada');
117
+ console.log("Transacción autorizada");
122
118
  return response;
123
119
  }
124
120
 
@@ -129,22 +125,22 @@ export class ThreeDSHandler {
129
125
 
130
126
  async handle3dsChallenge(response_json) {
131
127
  // Create the form element:
132
- const form = document.createElement('form');
133
- form.name = 'frm';
134
- form.method = 'POST';
128
+ const form = document.createElement("form");
129
+ form.name = "frm";
130
+ form.method = "POST";
135
131
  form.action = response_json.redirect_post_url;
136
132
 
137
133
  // Add hidden fields:
138
- const creqInput = document.createElement('input');
139
- creqInput.type = 'hidden';
140
- creqInput.name = 'creq';
134
+ const creqInput = document.createElement("input");
135
+ creqInput.type = "hidden";
136
+ creqInput.name = "creq";
141
137
  creqInput.value = response_json.creq;
142
138
  form.appendChild(creqInput);
143
139
 
144
140
  if (response_json.term_url) {
145
- const termUrlInput = document.createElement('input');
146
- termUrlInput.type = 'hidden';
147
- termUrlInput.name = 'TermUrl';
141
+ const termUrlInput = document.createElement("input");
142
+ termUrlInput.type = "hidden";
143
+ termUrlInput.name = "TermUrl";
148
144
  termUrlInput.value = response_json.term_url;
149
145
  form.appendChild(termUrlInput);
150
146
  }
@@ -164,7 +160,7 @@ export class ThreeDSHandler {
164
160
  return this.handleSuccessTransaction(response_json);
165
161
  } else {
166
162
  this.handleDeclinedTransaction();
167
- return response_json
163
+ return response_json;
168
164
  }
169
165
  }
170
166
 
@@ -182,22 +178,22 @@ export class ThreeDSHandler {
182
178
  // body: JSON.stringify(data),
183
179
  });
184
180
  if (response.status !== 200) {
185
- console.error('La verificación de la transacción falló.');
181
+ console.error("La verificación de la transacción falló.");
186
182
  this.removeVerifyTransactionUrl();
187
- return response
183
+ return response;
188
184
  }
189
185
 
190
186
  return await this.handleTransactionResponse(response);
191
187
  } catch (error) {
192
- console.error('Error al verificar la transacción:', error);
188
+ console.error("Error al verificar la transacción:", error);
193
189
  this.removeVerifyTransactionUrl();
194
190
  }
195
191
  } else {
196
- console.log('No verify_transaction_status_url found');
192
+ console.log("No verify_transaction_status_url found");
197
193
  }
198
194
  }
199
195
 
200
- setPayload = (payload) => {
201
- this.payload = payload
202
- }
196
+ setPayload = payload => {
197
+ this.payload = payload;
198
+ };
203
199
  }
@@ -35,7 +35,7 @@ export class BaseInlineCheckout {
35
35
  */
36
36
  configureCheckout(data) {
37
37
  if ("secureToken" in data) this.#handleSecureToken(data["secureToken"]);
38
- this.#setCheckoutData(data)
38
+ this.#setCheckoutData(data);
39
39
  }
40
40
 
41
41
  /**
@@ -50,7 +50,7 @@ export class BaseInlineCheckout {
50
50
  this.process3ds.setPayload(resultCheckout);
51
51
  const response = await this.#handle3dsRedirect(resultCheckout);
52
52
  globalLoader.remove();
53
- return response
53
+ return response;
54
54
  }
55
55
 
56
56
  /**
@@ -67,7 +67,7 @@ export class BaseInlineCheckout {
67
67
  payment(data) {
68
68
  return new Promise(async (resolve, reject) => {
69
69
  try {
70
- this.#setCheckoutData(data)
70
+ this.#setCheckoutData(data);
71
71
  const response = await this._checkout(data);
72
72
  this.process3ds.setPayload(response);
73
73
  this.callBack(response);
@@ -90,24 +90,15 @@ export class BaseInlineCheckout {
90
90
  }
91
91
 
92
92
  async _getCustomer(customer, signal) {
93
- return await registerOrFetchCustomer(
94
- this.baseUrl,
95
- this.apiKeyTonder,
96
- customer,
97
- signal,
98
- );
93
+ return await registerOrFetchCustomer(this.baseUrl, this.apiKeyTonder, customer, signal);
99
94
  }
100
95
 
101
96
  async _checkout() {
102
- throw new Error(
103
- "The #checkout method should be implement in child classes.",
104
- );
97
+ throw new Error("The #checkout method should be implement in child classes.");
105
98
  }
106
99
 
107
100
  _setCartTotal(total) {
108
- throw new Error(
109
- "The #setCartTotal method should be implement in child classes.",
110
- );
101
+ throw new Error("The #setCartTotal method should be implement in child classes.");
111
102
  }
112
103
 
113
104
  async _handleCheckout({ card, payment_method, customer }) {
@@ -115,11 +106,7 @@ export class BaseInlineCheckout {
115
106
  const total = Number(this.cartTotal);
116
107
  try {
117
108
  let deviceSessionIdTonder;
118
- if (
119
- !deviceSessionIdTonder &&
120
- openpay_keys.merchant_id &&
121
- openpay_keys.public_key
122
- ) {
109
+ if (!deviceSessionIdTonder && openpay_keys.merchant_id && openpay_keys.public_key) {
123
110
  deviceSessionIdTonder = await getOpenpayDeviceSessionID(
124
111
  openpay_keys.merchant_id,
125
112
  openpay_keys.public_key,
@@ -140,11 +127,7 @@ export class BaseInlineCheckout {
140
127
  is_oneclick: true,
141
128
  items: this.cartItems,
142
129
  };
143
- const jsonResponseOrder = await createOrder(
144
- this.baseUrl,
145
- this.apiKeyTonder,
146
- orderItems,
147
- );
130
+ const jsonResponseOrder = await createOrder(this.baseUrl, this.apiKeyTonder, orderItems);
148
131
 
149
132
  // Create payment
150
133
  const now = new Date();
@@ -210,8 +193,8 @@ export class BaseInlineCheckout {
210
193
  }
211
194
  }
212
195
 
213
- #setCheckoutData(data){
214
- if(!data) return;
196
+ #setCheckoutData(data) {
197
+ if (!data) return;
215
198
  this.#handleCustomer(data.customer);
216
199
  this._setCartTotal(data.cart?.total);
217
200
  this.#setCartItems(data.cart?.items);
@@ -245,11 +228,7 @@ export class BaseInlineCheckout {
245
228
  checkout_id: response?.checkout?.id,
246
229
  };
247
230
  try {
248
- return await startCheckoutRouter(
249
- this.baseUrl,
250
- this.apiKeyTonder,
251
- routerItems,
252
- );
231
+ return await startCheckoutRouter(this.baseUrl, this.apiKeyTonder, routerItems);
253
232
  } catch (error) {
254
233
  // throw error
255
234
  } finally {
@@ -296,7 +275,7 @@ export class BaseInlineCheckout {
296
275
  }
297
276
 
298
277
  async #handle3dsRedirect(response) {
299
- console.log('Handling 3DS redirect...');
278
+ console.log("Handling 3DS redirect...");
300
279
  const iframe = response?.next_action?.iframe_resources?.iframe;
301
280
  const threeDsChallenge = response?.next_action?.three_ds_challenge;
302
281
 
@@ -47,7 +47,7 @@ export class LiteInlineCheckout extends BaseInlineCheckout {
47
47
  );
48
48
  return {
49
49
  ...response,
50
- cards: response.cards.map((ic) => ({
50
+ cards: response.cards.map(ic => ({
51
51
  ...ic,
52
52
  icon: getCardType(ic.fields.card_scheme),
53
53
  })),
@@ -151,8 +151,8 @@ export class LiteInlineCheckout extends BaseInlineCheckout {
151
151
  : [];
152
152
 
153
153
  return apms_results
154
- .filter((apmItem) => apmItem.category.toLowerCase() !== "cards")
155
- .map((apmItem) => {
154
+ .filter(apmItem => apmItem.category.toLowerCase() !== "cards")
155
+ .map(apmItem => {
156
156
  const apm = {
157
157
  id: apmItem.pk,
158
158
  payment_method: apmItem.payment_method,
@@ -178,10 +178,7 @@ export class LiteInlineCheckout extends BaseInlineCheckout {
178
178
  }
179
179
 
180
180
  async _checkout({ card, payment_method }) {
181
- const customer = await this._getCustomer(
182
- this.customer,
183
- this.abortController.signal,
184
- );
181
+ const customer = await this._getCustomer(this.customer, this.abortController.signal);
185
182
  const { vault_id, vault_url } = this.merchantData;
186
183
  let skyflowTokens;
187
184
  if (!payment_method || payment_method !== "" || payment_method === null) {
@@ -193,7 +190,7 @@ export class LiteInlineCheckout extends BaseInlineCheckout {
193
190
  skyflowTokens = await getSkyflowTokens({
194
191
  vault_id: vault_id,
195
192
  vault_url: vault_url,
196
- data: {...card, card_number: card.card_number.replace(/\s+/g, '')},
193
+ data: { ...card, card_number: card.card_number.replace(/\s+/g, "") },
197
194
  baseUrl: this.baseUrl,
198
195
  apiKey: this.apiKeyTonder,
199
196
  });