tonder-web-sdk 1.12.0-beta.8 → 1.12.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.
@@ -0,0 +1,54 @@
1
+ export function validateCardNumber(cardNumber) {
2
+ const regex = /^\d{12,19}$/;
3
+ return regex.test(cardNumber) && luhnCheck(cardNumber);
4
+ }
5
+
6
+ export function validateCardholderName(name) {
7
+ const regex = /^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/;
8
+ return regex.test(name);
9
+ }
10
+
11
+ export function validateCVV(cvv) {
12
+ const regex = /^\d{3,4}$/;
13
+ return regex.test(cvv);
14
+ }
15
+
16
+ export function validateExpirationDate(expirationDate) {
17
+ const regex = /^(0[1-9]|1[0-2])\/\d{2}$/;
18
+ if (!regex.test(expirationDate)) {
19
+ return false;
20
+ }
21
+ const [month, year] = expirationDate.split('/');
22
+ const currentDate = new Date();
23
+ const expiration = new Date(`20${year}`, month - 1);
24
+ return expiration >= currentDate;
25
+ }
26
+
27
+ export function validateExpirationMonth(month) {
28
+ const regex = /^(0[1-9]|1[0-2])$/;
29
+ return regex.test(month);
30
+ }
31
+
32
+ export function validateExpirationYear(year) {
33
+ const regex = /^\d{2}$/;
34
+ if (!regex.test(year)) {
35
+ return false;
36
+ }
37
+ const currentYear = new Date().getFullYear() % 100;
38
+ return parseInt(year, 10) >= currentYear;
39
+ }
40
+
41
+ const luhnCheck = num => {
42
+ const arr = `${num}`
43
+ .split('')
44
+ .reverse()
45
+ .map(x => Number.parseInt(x));
46
+ const lastDigit = arr.shift();
47
+ let sum = arr.reduce(
48
+ (acc, val, i) =>
49
+ i % 2 !== 0 ? acc + val : acc + ((val *= 2) > 9 ? val - 9 : val),
50
+ 0
51
+ );
52
+ sum += lastDigit;
53
+ return sum % 10 === 0;
54
+ };
package/src/index-dev.js CHANGED
@@ -1,5 +1,7 @@
1
- import { InlineCheckout } from './classes/inlineCheckout'
2
- import {LiteInlineCheckout} from "./classes/LiteInlineCheckout";
1
+ import { InlineCheckout } from "./classes/inlineCheckout";
2
+ import { LiteInlineCheckout } from "./classes/LiteInlineCheckout";
3
+ import { Maskito } from "@maskito/core";
4
+ import { validateCardNumber } from "./helpers/validations";
3
5
 
4
6
  const customStyles = {
5
7
  inputStyles: {
@@ -10,15 +12,15 @@ const customStyles = {
10
12
  color: "#333333",
11
13
  backgroundColor: "#f0f0f0",
12
14
  fontFamily: '"Arial", sans-serif',
13
- fontSize: '14px',
14
- '&::placeholder': {
15
+ fontSize: "14px",
16
+ "&::placeholder": {
15
17
  color: "#888888",
16
18
  },
17
19
  },
18
20
  cardIcon: {
19
- position: 'absolute',
20
- left: '6px',
21
- bottom: 'calc(50% - 12px)',
21
+ position: "absolute",
22
+ left: "6px",
23
+ bottom: "calc(50% - 12px)",
22
24
  },
23
25
  complete: {
24
26
  color: "#4caf50",
@@ -29,39 +31,40 @@ const customStyles = {
29
31
  border: "1px solid #f44336",
30
32
  },
31
33
  global: {
32
- '@import': 'url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;700&display=swap")',
33
- }
34
+ "@import":
35
+ 'url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;700&display=swap")',
36
+ },
34
37
  },
35
38
  labelStyles: {
36
39
  base: {
37
- fontSize: '14px',
38
- fontWeight: 'bold',
40
+ fontSize: "14px",
41
+ fontWeight: "bold",
39
42
  fontFamily: '"Inter", sans-serif',
40
43
  color: "#4a90e2",
41
44
  },
42
45
  },
43
46
  errorTextStyles: {
44
47
  base: {
45
- fontSize: '12px',
46
- fontWeight: '500',
48
+ fontSize: "12px",
49
+ fontWeight: "500",
47
50
  color: "#e74c3c",
48
51
  fontFamily: '"Inter", sans-serif',
49
52
  },
50
53
  },
51
54
  labels: {
52
- nameLabel: 'Nombre de la de Tarjeta',
53
- cardLabel: 'Número de Tarjeta',
54
- cvvLabel: 'Código de Seguridad',
55
- expiryDateLabel: 'Fecha de Expiración',
55
+ nameLabel: "Nombre de la de Tarjeta",
56
+ cardLabel: "Número de Tarjeta",
57
+ cvvLabel: "Código de Seguridad",
58
+ expiryDateLabel: "Fecha de Expiración",
56
59
  },
57
60
  placeholders: {
58
- namePlaceholder: 'Nombre como aparece en la tarjeta',
59
- cardPlaceholder: '0000 0000 0000 0000',
60
- cvvPlaceholder: '123',
61
- expiryMonthPlaceholder: 'Mes',
62
- expiryYearPlaceholder: 'Año'
63
- }
64
- }
61
+ namePlaceholder: "Nombre como aparece en la tarjeta",
62
+ cardPlaceholder: "0000 0000 0000 0000",
63
+ cvvPlaceholder: "123",
64
+ expiryMonthPlaceholder: "Mes",
65
+ expiryYearPlaceholder: "Año",
66
+ },
67
+ };
65
68
 
66
69
  const checkoutData = {
67
70
  customer: {
@@ -75,7 +78,7 @@ const checkoutData = {
75
78
  email: "adrian@email.com",
76
79
  phone: "8161234567",
77
80
  },
78
- currency: 'mxn',
81
+ currency: "mxn",
79
82
  cart: {
80
83
  total: 399,
81
84
  items: [
@@ -89,7 +92,7 @@ const checkoutData = {
89
92
  name: "T-Shirt",
90
93
  amount_total: 399,
91
94
  },
92
- ]
95
+ ],
93
96
  },
94
97
  // card: { "skyflow_id": "53ca875c-16fd-4395-8ac9-c756613dbaf9" },
95
98
  // metadata: {
@@ -97,122 +100,196 @@ const checkoutData = {
97
100
  // }
98
101
  };
99
102
 
100
-
101
-
102
103
  // localhost
103
104
  const apiKey = "11e3d3c3e95e0eaabbcae61ebad34ee5f93c3d27";
104
- const returnUrl = "http://127.0.0.1:8080/"
105
+ const returnUrl = "http://127.0.0.1:8080/";
105
106
  // stage
106
107
  // const apiKey = "8365683bdc33dd6d50fe2397188d79f1a6765852";
107
108
 
108
-
109
109
  const commonConfig = {
110
- mode: 'development',
110
+ mode: "stage",
111
111
  apiKey,
112
- returnUrl: returnUrl+"?mode="+getCheckoutMode(),
113
- styles: customStyles
112
+ returnUrl: returnUrl + "?mode=" + getCheckoutMode(),
113
+ styles: customStyles,
114
114
  };
115
115
 
116
116
  let checkout;
117
117
  let inlineCheckout;
118
118
  let liteInlineCheckout;
119
119
 
120
-
121
120
  function getCheckoutMode() {
122
121
  const urlParams = new URLSearchParams(window.location.search);
123
- return urlParams.get('mode') || 'inline';
122
+ return urlParams.get("mode") || "inline";
124
123
  }
125
124
 
126
125
  function setupInlineCheckout() {
127
- inlineCheckout = new InlineCheckout({...commonConfig});
128
- inlineCheckout.configureCheckout({customer: checkoutData.customer})
126
+ inlineCheckout = new InlineCheckout({
127
+ ...commonConfig,
128
+ customization: {
129
+ saveCards: {
130
+ showSaveCardOption: true, // Usar para mostrar/ocultar el checkbox de guardar tarjeta para futuros pagos
131
+ autoSave: false, // Usar para guardar automáticamente la tarjeta (sin necesidad de mostrar el checkbox)
132
+ showSaved: true // Usar para mostrar/ocultar el listado de tarjetas guardadas
133
+ },
134
+ },
135
+ });
136
+ inlineCheckout.configureCheckout({ customer: checkoutData.customer });
129
137
  inlineCheckout.injectCheckout();
130
138
  // ['Declined', 'Cancelled', 'Failed', 'Success', 'Pending', 'Authorized']
131
- inlineCheckout.verify3dsTransaction().then(response => {
132
- console.log('Verify 3ds response', response)
133
- })
139
+ inlineCheckout.verify3dsTransaction().then((response) => {
140
+ console.log("Verify 3ds response", response);
141
+ });
134
142
 
135
- const payButton = document.getElementById('pay-button');
136
- payButton.addEventListener('click', async function () {
143
+ const payButton = document.getElementById("pay-button");
144
+ payButton.addEventListener("click", async function () {
137
145
  try {
138
- payButton.textContent = 'Procesando...';
146
+ payButton.textContent = "Procesando...";
139
147
  const response = await inlineCheckout.payment(checkoutData);
140
- console.log("Respuesta del pago:", response)
141
- alert('Pago realizado con éxito');
148
+ console.log("Respuesta del pago:", response);
149
+ alert("Pago realizado con éxito");
142
150
  } catch (error) {
143
151
  console.log("Error en el pago:", error.details);
144
- alert('Error al realizar el pago')
152
+ alert("Error al realizar el pago");
145
153
  } finally {
146
- payButton.textContent = 'Pagar';
154
+ payButton.textContent = "Pagar";
147
155
  }
148
156
  });
149
157
  }
150
158
 
151
159
  function setupLiteInlineCheckout() {
152
- liteInlineCheckout = new LiteInlineCheckout(commonConfig);
153
- liteInlineCheckout.configureCheckout({customer: checkoutData.customer})
154
- liteInlineCheckout.injectCheckout().then(() => {});
155
- liteInlineCheckout.verify3dsTransaction().then(response => {
156
- console.log('Verify 3ds response', response)
157
- })
158
-
159
- const liteForm = document.getElementById('lite-payment-form');
160
- liteForm.addEventListener('submit', async function(event) {
160
+ loadMaskitoMask();
161
+ liteInlineCheckout = new LiteInlineCheckout(commonConfig);
162
+ liteInlineCheckout.configureCheckout({ customer: checkoutData.customer });
163
+ liteInlineCheckout.injectCheckout().then(() => {});
164
+ liteInlineCheckout.verify3dsTransaction().then((response) => {
165
+ console.log("Verify 3ds response", response);
166
+ });
167
+
168
+ const liteForm = document.getElementById("lite-payment-form");
169
+ const payButton = document.getElementById("pay-button-lite");
170
+ liteForm.addEventListener("submit", async function (event) {
161
171
  event.preventDefault();
162
172
 
163
173
  const cardData = {
164
- card_number: document.getElementById('card-number').value,
165
- cardholder_name: document.getElementById('card-name').value,
166
- expiration_month: document.getElementById('month').value,
167
- expiration_year: document.getElementById('year').value,
168
- cvv: document.getElementById('cvv').value
174
+ card_number: document.getElementById("card-number").value,
175
+ cardholder_name: document.getElementById("card-name").value,
176
+ expiration_month: document.getElementById("month").value,
177
+ expiration_year: document.getElementById("year").value,
178
+ cvv: document.getElementById("cvv").value,
169
179
  };
170
180
 
171
181
  try {
182
+ payButton.textContent = "Procesando...";
172
183
  const paymentData = {
173
184
  ...checkoutData,
174
- card: cardData
185
+ card: cardData,
175
186
  };
176
187
  const response = await liteInlineCheckout.payment(paymentData);
177
188
  console.log("Respuesta del pago:", response);
178
- alert('Pago realizado con éxito');
189
+ alert("Pago realizado con éxito");
179
190
  } catch (error) {
180
191
  console.error("Error en el pago:", error);
181
- alert('Error al realizar el pago');
192
+ alert("Error al realizar el pago");
193
+ } finally {
194
+ payButton.textContent = "Pagar Ahora";
182
195
  }
183
196
  });
184
197
  }
185
198
 
186
199
  function setupCheckout() {
187
200
  const mode = getCheckoutMode();
188
- document.querySelectorAll('.tab-content').forEach(content => {
189
- content.style.display = 'none';
201
+ document.querySelectorAll(".tab-content").forEach((content) => {
202
+ content.style.display = "none";
190
203
  });
191
204
 
192
- if (mode === 'inline') {
193
- document.getElementById('inline-content').style.display = 'block';
194
- setupInlineCheckout()
195
- }else{
196
- document.getElementById('lite-content').style.display = 'block';
197
- setupLiteInlineCheckout()
205
+ if (mode === "inline") {
206
+ document.getElementById("inline-content").style.display = "block";
207
+ setupInlineCheckout();
208
+ } else {
209
+ document.getElementById("lite-content").style.display = "block";
210
+ setupLiteInlineCheckout();
198
211
  }
199
212
  }
200
213
 
214
+ function loadMaskitoMask() {
215
+ const cardNumberInput = document.getElementById("card-number");
216
+ const monthInput = document.getElementById("month");
217
+ const yearInput = document.getElementById("year");
218
+ const cvvInput = document.getElementById("cvv");
219
+ const nameInput = document.getElementById("card-name");
220
+
221
+ // Definir las opciones para las máscaras
222
+ const cardNumberOptions = {
223
+ mask: [
224
+ ...Array(4).fill(/\d/),
225
+ " ",
226
+ ...Array(4).fill(/\d/),
227
+ " ",
228
+ ...Array(4).fill(/\d/),
229
+ " ",
230
+ ...Array(4).fill(/\d/),
231
+ " ",
232
+ ...Array(3).fill(/\d/),
233
+ ],
234
+ };
235
+
236
+ const monthOptions = {
237
+ mask: [/[0-1]/, /\d/],
238
+ };
239
+
240
+ const yearOptions = {
241
+ mask: [/\d/, /\d/],
242
+ };
243
+
244
+ const nameOptions = {
245
+ mask: /^[a-zA-Z\s]*$/,
246
+ };
247
+
248
+ const cvvOptions = {
249
+ mask: [...Array(3).fill(/\d/)],
250
+ };
251
+
252
+ // Aplicar Maskito a cada campo
253
+ const cardNumberMask = new Maskito(cardNumberInput, cardNumberOptions);
254
+ const monthMask = new Maskito(monthInput, monthOptions);
255
+ const yearMask = new Maskito(yearInput, yearOptions);
256
+ const cvvMask = new Maskito(cvvInput, cvvOptions);
257
+ const nameMask = new Maskito(nameInput, nameOptions);
258
+
259
+ cardNumberInput.addEventListener("input", () => {
260
+ const cardNumber = cardNumberInput.value.replace(/\s+/g, "");
261
+ if (!validateCardNumber(cardNumber)) {
262
+ cardNumberInput.setCustomValidity("Número de tarjeta inválido");
263
+ cardNumberInput.classList.add("invalid");
264
+ } else {
265
+ cardNumberInput.setCustomValidity("");
266
+ cardNumberInput.classList.remove("invalid");
267
+ }
268
+ });
269
+
270
+ window.addEventListener("beforeunload", () => {
271
+ cardNumberMask.destroy();
272
+ monthMask.destroy();
273
+ yearMask.destroy();
274
+ cvvMask.destroy();
275
+ nameMask.destroy();
276
+ });
277
+ }
201
278
  function updateActiveTab() {
202
279
  const mode = getCheckoutMode();
203
- document.querySelectorAll('.tab').forEach(tab => {
204
- tab.classList.remove('active');
280
+ document.querySelectorAll(".tab").forEach((tab) => {
281
+ tab.classList.remove("active");
205
282
  });
206
- document.querySelector(`[data-mode="${mode}"]`).classList.add('active');
283
+ document.querySelector(`[data-mode="${mode}"]`).classList.add("active");
207
284
  }
208
285
 
209
286
  function switchTab(mode) {
210
287
  window.location.href = `${window.location.pathname}?mode=${mode}`;
211
288
  }
212
289
 
213
- document.addEventListener('DOMContentLoaded', function() {
290
+ document.addEventListener("DOMContentLoaded", function () {
214
291
  setupCheckout();
215
292
  updateActiveTab();
216
293
  });
217
294
 
218
- window.switchTab = switchTab;
295
+ window.switchTab = switchTab;
package/src/index.html CHANGED
@@ -109,6 +109,9 @@
109
109
  .input-md {
110
110
  max-width: 100%;
111
111
  }
112
+ .invalid{
113
+ border: 2px solid red !important;
114
+ }
112
115
  </style>
113
116
  </head>
114
117
 
@@ -146,7 +149,7 @@
146
149
  <input class="input-md" type="text" id="cvv" placeholder="123" required>
147
150
  </div>
148
151
  </div>
149
- <button type="submit" class="btn">Pagar Ahora</button>
152
+ <button type="submit" class="btn" id="pay-button-lite">Pagar Ahora</button>
150
153
  </form>
151
154
  </div>
152
155
  <div id="inline-content" class="tab-content">
package/src/index.js CHANGED
@@ -1,9 +1,15 @@
1
1
  import { Checkout } from './classes/checkout'
2
2
  import { InlineCheckout } from './classes/inlineCheckout'
3
3
  import { LiteInlineCheckout } from './classes/LiteInlineCheckout'
4
+ import { validateCVV, validateCardNumber, validateCardholderName, validateExpirationMonth, validateExpirationYear } from "./helpers/validations";
4
5
 
5
6
  export {
6
7
  Checkout,
7
8
  InlineCheckout,
8
- LiteInlineCheckout
9
+ LiteInlineCheckout,
10
+ validateCVV,
11
+ validateCardNumber,
12
+ validateCardholderName,
13
+ validateExpirationMonth,
14
+ validateExpirationYear
9
15
  }
@@ -1,5 +1,6 @@
1
1
  export interface ICard {
2
2
  fields: ICardSkyflowFields;
3
+ icon?: string;
3
4
  }
4
5
 
5
6
  export interface ICardSkyflowFields {
@@ -92,7 +92,7 @@ export interface IItem {
92
92
  price_unit: number;
93
93
  discount: number;
94
94
  taxes: number;
95
- product_reference: number;
95
+ product_reference: string | number;
96
96
  name: string;
97
97
  amount_total: number;
98
98
  }
@@ -8,4 +8,5 @@ export type ICustomer = {
8
8
  postCode?: string;
9
9
  email: string;
10
10
  phone?: string;
11
+ address?: string;
11
12
  };
package/types/index.d.ts CHANGED
@@ -6,6 +6,6 @@ export * from './transaction';
6
6
  export * from './paymentMethod';
7
7
  export * from './inlineCheckout';
8
8
  export * from './liteInlineCheckout';
9
-
9
+ export * from './validations';
10
10
 
11
11
 
@@ -5,18 +5,70 @@ import {ITransaction} from "./transaction";
5
5
  export class InlineCheckout {
6
6
  constructor(options: IInlineCheckoutOptions);
7
7
 
8
- configureCheckout(data: IConfigureCheckout): Promise<void>;
8
+ /**
9
+ * The configureCheckout function allows you to set initial information, such as the customer's email, which is used to retrieve a list of saved cards.
10
+ * @param {import("../types").IConfigureCheckout} data - Configuration data including customer information and potentially other settings.
11
+ * @returns {void}.
12
+ * @public
13
+ */
14
+ configureCheckout(data: IConfigureCheckout): void;
9
15
 
16
+ /**
17
+ * Injects the checkout into the DOM and initializes it.
18
+ * Checks for an existing container and sets up an observer if needed.
19
+ * @returns {void}
20
+ * @public
21
+ */
10
22
  injectCheckout(): Promise<void>;
11
23
 
24
+ /**
25
+ * Processes a payment.
26
+ * @param {import("../types").IProcessPaymentRequest} data - Payment data including customer, cart, and other relevant information.
27
+ * @returns {Promise<import("../types").IStartCheckoutResponse>} A promise that resolves with the payment response or 3DS redirect or is rejected with an error.
28
+ *
29
+ * @throws {Error} Throws an error if the checkout process fails. The error object contains
30
+ * additional `details` property with the response from the server if available.
31
+ * @property {import("../types").IStartCheckoutErrorResponse} error.details - The response body from the server when an error occurs.
32
+ *
33
+ * @public
34
+ */
12
35
  payment(data: IProcessPaymentRequest): Promise<IStartCheckoutResponse>;
13
36
 
37
+ /**
38
+ * Verifies the 3DS transaction status.
39
+ * @returns {Promise<import("../types").ITransaction | void>} The result of the 3DS verification and checkout resumption.
40
+ * @public
41
+ */
14
42
  verify3dsTransaction(): Promise<ITransaction | void>;
15
43
 
44
+ /**
45
+ * Removes the checkout from the DOM and cleans up associated resources.
46
+ *
47
+ * This method performs the following actions:
48
+ * 1. Resets the injection status flags for the checkout, cards, and APMs.
49
+ * 2. Aborts any ongoing requests using the AbortController.
50
+ * 3. Creates a new AbortController for future use.
51
+ * 4. Clears any existing injection intervals.
52
+ *
53
+ * Note: This method should be called when you want to completely remove
54
+ * the checkout from the page and reset its state.
55
+ *
56
+ * @returns {void}
57
+ * @public
58
+ */
16
59
  removeCheckout(): void;
17
60
  }
18
61
 
62
+ export type CustomizationOptions = {
63
+ saveCards?: {
64
+ showSaveCardOption?: boolean;
65
+ showSaved?: boolean;
66
+ autoSave?: boolean;
67
+ }
68
+ }
69
+
19
70
  export interface IInlineCheckoutOptions extends IInlineCheckoutBaseOptions{
20
71
  styles?: Record<string, string>;
21
72
  renderPaymentButton?: boolean;
73
+ customization?: CustomizationOptions;
22
74
  }
@@ -7,32 +7,89 @@ import {ITransaction} from "./transaction";
7
7
  export class LiteInlineCheckout {
8
8
  constructor(options: IInlineLiteCheckoutOptions);
9
9
 
10
+ /**
11
+ * The configureCheckout function allows you to set initial information, such as the customer's email, which is used to retrieve a list of saved cards.
12
+ * @param {import("../types").IConfigureCheckout} data - Configuration data including customer information and potentially other settings.
13
+ * @returns {Promise<void>}.
14
+ * @public
15
+ */
10
16
  configureCheckout(data: IConfigureCheckout): void;
11
17
 
18
+ /**
19
+ * Initializes and prepares the checkout for use.
20
+ * This method set up the initial environment.
21
+ * @returns {Promise<void>} A promise that resolves when the checkout has been initialized.
22
+ * @throws {Error} If there's any problem during the checkout initialization.
23
+ * @public
24
+ */
12
25
  injectCheckout(): Promise<void>;
13
26
 
27
+ /**
28
+ * Processes a payment.
29
+ * @param {import("../types").IProcessPaymentRequest} data - Payment data including customer, cart, and other relevant information.
30
+ * @returns {Promise<import("../types").IStartCheckoutResponse>} A promise that resolves with the payment response or 3DS redirect or is rejected with an error.
31
+ *
32
+ * @throws {Error} Throws an error if the checkout process fails. The error object contains
33
+ * additional `details` property with the response from the server if available.
34
+ * @property {import("../types").IStartCheckoutErrorResponse} error.details - The response body from the server when an error occurs.
35
+ *
36
+ * @public
37
+ */
14
38
  payment(data: IProcessPaymentRequest): Promise<IStartCheckoutResponse>;
15
39
 
40
+ /**
41
+ * Verifies the 3DS transaction status.
42
+ * @returns {Promise<import("../types").ITransaction | void>} The result of the 3DS verification and checkout resumption.
43
+ * @public
44
+ */
16
45
  verify3dsTransaction(): Promise<ITransaction | void>;
17
46
 
18
- getCustomerCards(
19
- authToken: string,
20
- businessId: string | number,
21
- ): Promise<ICustomerCardsResponse>;
47
+ /**
48
+ * Retrieves the list of cards associated with a customer.
49
+ * @returns {Promise<import("../types").ICustomerCardsResponse>} A promise that resolves with the customer's card data.
50
+ *
51
+ * @throws {import("../types").IPublicError} Throws an error object if the operation fails.
52
+ *
53
+ * @public
54
+ */
55
+ getCustomerCards(): Promise<ICustomerCardsResponse>;
22
56
 
57
+ /**
58
+ * Saves a card to a customer's account. This method can be used to add a new card
59
+ * or update an existing one.
60
+ * @param {import("../types").ISaveCardRequest} card - The card information to be saved.
61
+ * @returns {Promise<import("../types").ISaveCardResponse>} A promise that resolves with the saved card data.
62
+ *
63
+ * @throws {import("../types").IPublicError} Throws an error object if the operation fails.
64
+ *
65
+ * @public
66
+ */
23
67
  saveCustomerCard(
24
- authToken: string,
25
- businessId: string,
26
68
  card: ISaveCardRequest,
27
69
  ): Promise<ISaveCardResponse>;
28
70
 
71
+ /**
72
+ * Removes a card from a customer's account.
73
+ * @param {string} skyflowId - The unique identifier of the card to be deleted.
74
+ * @returns {Promise<string>} A promise that resolves when the card is successfully deleted.
75
+ *
76
+ * @throws {import("../types").IPublicError} Throws an error object if the operation fails.
77
+ *
78
+ * @public
79
+ */
29
80
  removeCustomerCard(
30
- authToken: string,
31
81
  skyflowId: string,
32
- businessId: string,
33
82
  ): Promise<void>;
34
83
 
35
- getCustomerAPMs(): Promise<IPaymentMethod[]>;
84
+ /**
85
+ * Retrieves the list of available Alternative Payment Methods (APMs).
86
+ * @returns {Promise<import("../types").IPaymentMethod[]>} A promise that resolves with the list of APMs.
87
+ *
88
+ * @throws {import("../types").IPublicError} Throws an error object if the operation fails.
89
+ *
90
+ * @public
91
+ */
92
+ getCustomerPaymentMethods(): Promise<IPaymentMethod[]>;
36
93
  }
37
94
 
38
95
 
@@ -0,0 +1,11 @@
1
+ export declare function validateCardNumber(cardNumber: string): boolean;
2
+
3
+ export declare function validateCardholderName(name: string): boolean;
4
+
5
+ export declare function validateCVV(cvv: string): boolean;
6
+
7
+ export declare function validateExpirationMonth(month: string): boolean;
8
+
9
+ export declare function validateExpirationYear(year: string): boolean;
10
+
11
+ export declare function validateExpirationDateParts(month: string, year: string): boolean;