@tonder.io/ionic-lite-sdk 0.0.36-beta.1 → 0.0.38-beta.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 (79) hide show
  1. package/README.md +427 -116
  2. package/dist/classes/BaseInlineCheckout.d.ts +47 -0
  3. package/dist/classes/liteCheckout.d.ts +25 -29
  4. package/dist/data/businessApi.d.ts +2 -0
  5. package/dist/data/cardApi.d.ts +4 -0
  6. package/dist/data/checkoutApi.d.ts +5 -0
  7. package/dist/data/customerApi.d.ts +2 -0
  8. package/dist/data/openPayApi.d.ts +1 -0
  9. package/dist/data/paymentMethodApi.d.ts +5 -0
  10. package/dist/data/skyflowApi.d.ts +1 -0
  11. package/dist/helpers/skyflow.d.ts +3 -0
  12. package/dist/helpers/utils.d.ts +8 -4
  13. package/dist/helpers/validations.d.ts +6 -0
  14. package/dist/index.d.ts +3 -1
  15. package/dist/index.js +1 -1
  16. package/dist/shared/catalog/paymentMethodsCatalog.d.ts +1 -0
  17. package/dist/shared/constants/messages.d.ts +11 -0
  18. package/dist/shared/constants/paymentMethodAPM.d.ts +62 -0
  19. package/dist/shared/constants/tonderUrl.d.ts +7 -0
  20. package/dist/types/card.d.ts +30 -0
  21. package/dist/types/checkout.d.ts +109 -0
  22. package/dist/types/commons.d.ts +42 -0
  23. package/dist/types/customer.d.ts +22 -0
  24. package/dist/types/liteInlineCheckout.d.ts +151 -0
  25. package/dist/types/paymentMethod.d.ts +22 -0
  26. package/dist/types/requests.d.ts +12 -3
  27. package/dist/types/transaction.d.ts +101 -0
  28. package/package.json +4 -1
  29. package/src/classes/BaseInlineCheckout.ts +387 -0
  30. package/src/classes/errorResponse.ts +1 -1
  31. package/src/classes/liteCheckout.ts +372 -356
  32. package/src/data/businessApi.ts +18 -0
  33. package/src/data/cardApi.ts +87 -0
  34. package/src/data/checkoutApi.ts +84 -0
  35. package/src/data/customerApi.ts +31 -0
  36. package/src/data/openPayApi.ts +12 -0
  37. package/src/data/paymentMethodApi.ts +37 -0
  38. package/src/data/skyflowApi.ts +20 -0
  39. package/src/helpers/mercadopago.ts +14 -14
  40. package/src/helpers/skyflow.ts +91 -0
  41. package/src/helpers/utils.ts +66 -266
  42. package/src/helpers/validations.ts +55 -0
  43. package/src/index.ts +9 -1
  44. package/src/shared/catalog/paymentMethodsCatalog.ts +248 -0
  45. package/src/shared/constants/messages.ts +11 -0
  46. package/src/shared/constants/paymentMethodAPM.ts +63 -0
  47. package/src/shared/constants/tonderUrl.ts +8 -0
  48. package/src/types/card.ts +35 -0
  49. package/src/types/checkout.ts +124 -0
  50. package/src/types/commons.ts +114 -67
  51. package/src/types/customer.ts +22 -0
  52. package/src/types/liteInlineCheckout.ts +216 -0
  53. package/src/types/paymentMethod.ts +24 -0
  54. package/src/types/requests.ts +12 -3
  55. package/src/types/transaction.ts +101 -0
  56. package/src/types/validations.d.ts +11 -0
  57. package/tests/classes/liteCheckout.test.ts +5 -5
  58. package/tests/methods/createOrder.test.ts +3 -4
  59. package/tests/methods/createPayment.test.ts +2 -3
  60. package/tests/methods/customerRegister.test.ts +3 -4
  61. package/tests/methods/getBusiness.test.ts +4 -5
  62. package/tests/methods/getCustomerCards.test.ts +6 -13
  63. package/tests/methods/registerCustomerCard.test.ts +2 -2
  64. package/tests/methods/startCheckoutRouter.test.ts +2 -2
  65. package/tests/methods/startCheckoutRouterFull.test.ts +2 -2
  66. package/tests/utils/defaultMock.ts +3 -2
  67. package/tests/utils/mockClasses.ts +7 -4
  68. package/types/classes/liteCheckout.d.ts +29 -0
  69. package/types/classes/liteCheckout.js +225 -0
  70. package/types/classes/liteCheckout.js.map +1 -0
  71. package/types/helpers/utils.d.ts +3 -0
  72. package/types/helpers/utils.js +27 -0
  73. package/types/helpers/utils.js.map +1 -0
  74. package/types/index.d.ts +2 -0
  75. package/types/index.js +6 -0
  76. package/types/index.js.map +1 -0
  77. package/tests/methods/getOpenpayDeviceSessionID.test.ts +0 -95
  78. package/tests/methods/getSkyflowToken.test.ts +0 -155
  79. package/tests/methods/getVaultToken.test.ts +0 -107
package/README.md CHANGED
@@ -1,6 +1,22 @@
1
1
  # Tonder SDK
2
2
 
3
- Tonder SDK Lite to integrate REST service
3
+ Tonder SDK helps to integrate the services Tonder offers in your own mobile app
4
+
5
+
6
+ ## Table of Contents
7
+
8
+ 1. [Installation](#installation)
9
+ 2. [Usage](#usage)
10
+ 3. [Configuration Options](#configuration-options)
11
+ 4. [Mobile Settings](#mobile-settings)
12
+ 5. [Payment Data Structure](#payment-data-structure)
13
+ 6. [Field Validation Functions](#field-validation-functions)
14
+ 7. [API Reference](#api-reference)
15
+ 8. [Examples](#examples)
16
+ 9. [Deprecated Fields](#deprecated-fields)
17
+ 10. [Deprecated Functions](#deprecated-functions)
18
+ 11. [License](#license)
19
+
4
20
 
5
21
  ## Installation
6
22
 
@@ -16,11 +32,12 @@ Add dependencies to the root of the app (index.html)
16
32
  ```
17
33
 
18
34
  ## Usage
19
- ## Import LiteCheckout class
35
+ LiteCheckout allows you to build a custom checkout interface using Tonder's core functionality
36
+ ### Import LiteCheckout class
20
37
  ```javascript
21
38
  import { LiteCheckout } from "@tonder.io/ionic-lite-sdk"
22
39
  ```
23
- ## Create instance
40
+ ### Create instance
24
41
 
25
42
  ```javascript
26
43
  const liteCheckout = new LiteCheckout({
@@ -29,104 +46,391 @@ const liteCheckout = new LiteCheckout({
29
46
  publicApiKeyTonder
30
47
  })
31
48
 
49
+ // The configureCheckout function allows you to set initial information,
50
+ // such as the customer's email, which is used to retrieve a list of saved cards, save new card, etc.
51
+ inlineCheckout.configureCheckout({ customer: { email: "example@email.com" } });
52
+
53
+ // Initialize the checkout
54
+ await liteCheckout.injectCheckout();
55
+
32
56
  // To verify a 3ds transaction you can use the following method
33
57
  // It should be called after the injectCheckout method
34
58
  // The response status will be one of the following
35
59
  // ['Declined', 'Cancelled', 'Failed', 'Success', 'Pending', 'Authorized']
36
60
 
37
61
  inlineCheckout.verify3dsTransaction().then(response => {
38
- console.log('Verify 3ds response', response)
62
+ console.log('Verify 3ds response', response)
39
63
  })
40
64
  ```
41
65
 
42
- | Property | Type | Description |
43
- |:---------------:|:-------------:|:-----------------------------------------------------------------------:|
44
- | signal | AborSignal | Signal from AbortController instance if it need cancel request |
45
- | baseUrlTonder | string | Live server: http://stage.tonder.io |
46
- | | | Mock Server: https://stoplight.io/mocks/tonder/tonder-api-v1-2/3152148 |
47
- | publicApiKeyTonder | string | You can take this from you Tonder Dashboard |
48
- | | | |
66
+ ```javascript
67
+ // Retrieve customer's saved cards
68
+ const cards = await liteCheckout.getCustomerCards();
69
+ ```
49
70
 
50
- # Class methods
71
+ ```javascript
72
+ // Save a new card
73
+ const newCard = await liteCheckout.saveCustomerCard(cardData);
74
+ ```
51
75
 
52
- # Checkout router
76
+ ```javascript
77
+ // Remove a saved card
78
+ await liteCheckout.removeCustomerCard(cardId);
79
+ ```
53
80
 
54
- ```typescript
81
+ ```javascript
82
+ // Get available payment methods
83
+ const paymentMethods = await liteCheckout.getCustomerPaymentMethods();
84
+ ```
85
+
86
+ ```javascript
87
+ // Process a payment
88
+ const paymentResponse = await liteCheckout.payment(paymentData);
89
+ ```
90
+
91
+ ## Configuration Options
92
+
93
+ | Property | Type | Description |
94
+ |:---------:|:--------:|:--------------------------------------------------------------------------------------------:|
95
+ | mode | string | Environment mode. Options: 'stage', 'production', 'sandbox', 'development'. Default: 'stage' |
96
+ | publicApiKey | string | Your API key from the Tonder Dashboard |
97
+ | returnrl | string | URL where the checkout form is mounted (used for 3DS) |
98
+ | callBack | function | Callback function to be invoked after the payment process ends successfully. |
99
+
100
+ ## Mobile settings
101
+
102
+ <font size="3">If you are deploying to Android, edit your AndroidManifest.xml file to add the Internet permission.</font>
103
+
104
+ ```xml
105
+ <!-- Required to fetch data from the internet. -->
106
+ <uses-permission android:name="android.permission.INTERNET" />
107
+ ```
108
+
109
+ <font size="3">Likewise, if you are deploying to macOS, edit your macos/Runner/DebugProfile.entitlements and macos/Runner/Release.entitlements files to include the network client entitlement.</font>
110
+
111
+ ```xml
112
+ <!-- Required to fetch data from the internet. -->
113
+ <key>com.apple.security.network.client</key>
114
+ <true>
115
+ ```
116
+
117
+ ## Payment Data Structure
118
+
119
+ When calling the `payment` method, use the following data structure:
55
120
 
56
- const returnUrl = "http://localhost:8100/payment/success";
121
+ ### Field Descriptions
57
122
 
58
- let checkoutData = {
123
+ - **customer**: Object containing the customer's personal information to be registered in the transaction.
124
+
125
+ - **cart**: Object containing the total amount and an array of items to be registered in the Tonder order.
126
+
127
+ - **total**: The total amount of the transaction.
128
+ - **items**: An array of objects, each representing a product or service in the order.
129
+ - name: name of the product
130
+ - price_unit: valid float string with the price of the product
131
+ - quantity: valid integer string with the quantity of this product
132
+
133
+ - **currency**: String representing the currency code for the transaction (e.g., "MXN" for Mexican Peso).
134
+
135
+ - **metadata**: Object for including any additional information about the transaction. This can be used for internal references or tracking.
136
+
137
+ - **card**: (for LiteCheckout) Object containing card information. This is used differently depending on whether it's a new card or a saved card:
138
+
139
+ - For a new card: Include `card_number`, `cvv`, `expiration_month`, `expiration_year`, and `cardholder_name`.
140
+ - For a saved card: Include only the `skyflow_id` of the saved card.
141
+ - This is only used when not paying with a payment_method.
142
+
143
+ - **payment_method**: (for LiteCheckout) String indicating the alternative payment method to be used (e.g., "Spei"). This is only used when not paying with a card.
144
+
145
+ ```javascript
146
+ const paymentData = {
59
147
  customer: {
60
- name: "Jhon",
61
- lastname: "Doe",
62
- email: "john.c.calhoun@examplepetstore.com",
63
- phone: "+58452258525"
148
+ firstName: "John",
149
+ lastName: "Doe",
150
+ country: "USA",
151
+ address: "123 Main St",
152
+ city: "Anytown",
153
+ state: "CA",
154
+ postCode: "12345",
155
+ email: "john.doe@example.com",
156
+ phone: "1234567890",
64
157
  },
65
- order: {
158
+ cart: {
159
+ total: "100.00",
66
160
  items: [
67
161
  {
68
- description: "Test product description",
162
+ description: "Product description",
69
163
  quantity: 1,
70
- price_unit: 25,
71
- discount: 1,
72
- taxes: 12,
73
- product_reference: 89456123,
74
- name: "Test product",
75
- amount_total: 25
76
- }
77
- ]
164
+ price_unit: "100.00",
165
+ discount: "0.00",
166
+ taxes: "0.00",
167
+ product_reference: "PROD123",
168
+ name: "Product Name",
169
+ amount_total: "100.00",
170
+ },
171
+ ],
78
172
  },
79
- return_url: returnUrl,
80
- total: 25,
81
- isSandbox: true,
82
- metadata: {},
83
173
  currency: "MXN",
84
- skyflowTokens: {
85
- cardholder_name: "",
86
- card_number: "",
87
- expiration_year: "",
88
- expiration_month: "",
89
- cvv: "",
90
- skyflow_id: ""
91
- }
92
- }
174
+ metadata: {
175
+ order_id: "ORDER123",
176
+ },
177
+ // For a new card:
178
+ card: {
179
+ card_number: "4111111111111111",
180
+ cvv: "123",
181
+ expiration_month: "12",
182
+ expiration_year: "25",
183
+ cardholder_name: "John Doe",
184
+ },
185
+ // card: "skyflow_id" // for a selected saved card.
186
+ // payment_method: "Spei", // For the selected payment method.
187
+ };
188
+ ```
189
+
190
+ ## Field Validation Functions
191
+
192
+ For LiteCheckout implementations, the SDK provides validation functions to ensure the integrity of card data before submitting:
193
+
194
+ - `validateCardNumber(cardNumber)`: Validates the card number using the Luhn algorithm.
195
+ - `validateCardholderName(name)`: Checks if the cardholder name is valid.
196
+ - `validateCVV(cvv)`: Ensures the CVV is in the correct format.
197
+ - `validateExpirationDate(expirationDate)`: Validates the expiration date in MM/YY format.
198
+ - `validateExpirationMonth(month)`: Checks if the expiration month is valid.
199
+ - `validateExpirationYear(year)`: Validates the expiration year.
93
200
 
201
+ Example usage:
202
+
203
+ ```javascript
204
+ import {
205
+ validateCardNumber,
206
+ validateCardholderName,
207
+ validateCVV,
208
+ validateExpirationDate,
209
+ } from "@tonder.io/ionic-lite-sdk";
210
+
211
+ const cardNumber = "4111111111111111";
212
+ const cardholderName = "John Doe";
213
+ const cvv = "123";
214
+ const expirationDate = "12/25";
215
+
216
+ if (
217
+ validateCardNumber(cardNumber) &&
218
+ validateCardholderName(cardholderName) &&
219
+ validateCVV(cvv) &&
220
+ validateExpirationDate(expirationDate)
221
+ ) {
222
+ // Proceed with payment
223
+ } else {
224
+ // Show error message
225
+ }
94
226
  ```
95
227
 
96
- <font size="4">It is required get the skyflow tokens to add it to the checkout router method, the values of the variable skyflowFields come from your html form</font>
228
+
229
+ ## API Reference
230
+
231
+ ### LiteCheckout Methods
232
+
233
+ - `configureCheckout(data)`: Set initial checkout data
234
+ - `injectCheckout()`: Initialize the checkout
235
+ - `getCustomerCards()`: Retrieve saved cards
236
+ - `saveCustomerCard(cardData)`: Save a new card
237
+ - `removeCustomerCard(cardId)`: Remove a saved card
238
+ - `getCustomerPaymentMethods()`: Get available payment methods
239
+ - `payment(data)`: Process a payment
240
+ - `verify3dsTransaction()`: Verify a 3DS transaction
241
+
242
+
243
+ ## Examples
244
+
245
+ Here are examples of how to implement Tonder Lite SDK:
246
+
247
+ ### Angular
248
+
249
+ For Angular, we recommend using a service to manage the Tonder instance:
97
250
 
98
251
  ```typescript
252
+ // tonder.service.ts
253
+ import { Injectable } from "@angular/core";
254
+ import { LiteCheckout } from "@tonder.io/ionic-lite-sdk";
255
+ import {ILiteCheckout} from "@tonder.io/ionic-lite-sdk/dist/types/liteInlineCheckout";
256
+
257
+ @Injectable({
258
+ providedIn: "root",
259
+ })
260
+ export class TonderService {
261
+ private liteCheckout!: ILiteCheckout;
262
+
263
+ constructor(@Inject(Object) private sdkParameters: IInlineLiteCheckoutOptions) {
264
+ this.initializeInlineCheckout();
265
+ }
99
266
 
100
- const merchantData: any = await liteCheckout.getBusiness();
267
+ private initializeInlineCheckout(): void {
268
+ this.liteCheckout = new LiteCheckout({ ...this.sdkParameters });
269
+ }
101
270
 
102
- const { vault_id, vault_url } = merchantData;
271
+ configureCheckout(customerData: IConfigureCheckout): void {
272
+ return this.liteCheckout.configureCheckout({ ...customerData });
273
+ }
103
274
 
104
- const skyflowFields = {
105
- card_number: this.paymentForm.value.cardNumber,
106
- cvv: this.paymentForm.value.cvv,
107
- expiration_month: this.paymentForm.value.month,
108
- expiration_year: this.paymentForm.value.expirationYear,
109
- cardholder_name: this.paymentForm.value.name
275
+ async injectCheckout(): Promise<void> {
276
+ return await this.liteCheckout.injectCheckout();
277
+ }
278
+
279
+ verify3dsTransaction(): Promise<ITransaction | IStartCheckoutResponse | void> {
280
+ return this.liteCheckout.verify3dsTransaction();
281
+ }
282
+
283
+ payment(
284
+ checkoutData: IProcessPaymentRequest,
285
+ ): Promise<IStartCheckoutResponse> {
286
+ return this.inlineCheckout.payment(checkoutData);
287
+ }
288
+
289
+ // Add more functions, for example for lite sdk: get payment methods
290
+
291
+ // getCustomerPaymentMethods(): Promise<IPaymentMethod[]> {
292
+ // return this.liteCheckout.getCustomerPaymentMethods();
293
+ // }
110
294
  }
111
295
 
112
- const skyflowTokens = await liteCheckout.getSkyflowTokens({
113
- vault_id: vault_id,
114
- vault_url: vault_url,
115
- data: skyflowFields
296
+ // checkout.component.ts
297
+ import { Component, OnInit, OnDestroy } from "@angular/core";
298
+ import { TonderService } from "./tonder.service";
299
+
300
+ @Component({
301
+ selector: "app-tonder-checkout",
302
+ template: `
303
+ <div id="container">
304
+ <form [formGroup]="paymentForm">
305
+ <div class="lite-container-tonder">
306
+ <div id="id-name" class="empty-div">
307
+ <label for="name">Namess: </label>
308
+ <input id="name" type="text" formControlName="name">
309
+ </div>
310
+ <div id="id-cardNumber" class="empty-div">
311
+ <label for="cardNumber">Card number: </label>
312
+ <input id="cardNumber" type="text" formControlName="cardNumber">
313
+ </div>
314
+ <div class="collect-row">
315
+ <div class="empty-div">
316
+ <label for="month">Month: </label>
317
+ <input id="month" type="text" formControlName="month">
318
+ </div>
319
+ <div class="expiration-year">
320
+ <label for="expirationYear">Year: </label>
321
+ <input id="expirationYear" type="text" formControlName="expirationYear">
322
+ </div>
323
+ <div class="empty-div">
324
+ <label for="cvv">CVV: </label>
325
+ <input id="cvv" type="text" formControlName="cvv">
326
+ </div>
327
+ </div>
328
+ <div id="msgError">{{ errorMessage }}</div>
329
+ <div id="msgNotification"></div>
330
+ <div class="container-pay-button">
331
+ <button class="lite-pay-button" (click)="onPayment($event)">Pay</button>
332
+ </div>
333
+ </div>
334
+
335
+ </form>
336
+ </div>
337
+ `,
338
+ providers: [
339
+ {
340
+ provide: TonderInlineService,
341
+ // Initialization of the Tonder Lite SDK.
342
+ // Note: Replace these credentials with your own in development/production.
343
+ useFactory: () =>
344
+ new TonderInlineService({
345
+ apiKey: "11e3d3c3e95e0eaabbcae61ebad34ee5f93c3d27",
346
+ returnUrl: "http://localhost:8100/tabs/tab5",
347
+ mode: "stage",
348
+ }),
349
+ },
350
+ ],
116
351
  })
352
+ export class TonderCheckoutComponent implements OnInit, OnDestroy {
353
+ loading = false;
354
+ checkoutData: IProcessPaymentRequest;
355
+ paymentForm = new FormGroup({
356
+ name: new FormControl('Pedro Paramo'),
357
+ cardNumber: new FormControl('4242424242424242'),
358
+ month: new FormControl('12'),
359
+ expirationYear: new FormControl('28'),
360
+ cvv: new FormControl('123')
361
+ });
362
+
363
+ constructor(private tonderService: TonderService) {
364
+ this.checkoutData = {
365
+ customer: {
366
+ firstName: "Jhon",
367
+ lastName: "Doe",
368
+ email: "john.c.calhoun@examplepetstore.com",
369
+ phone: "+58452258525"
370
+ },
371
+ cart: {
372
+ total: 25,
373
+ items: [
374
+ {
375
+ description: "Test product description",
376
+ quantity: 1,
377
+ price_unit: 25,
378
+ discount: 1,
379
+ taxes: 12,
380
+ product_reference: 89456123,
381
+ name: "Test product",
382
+ amount_total: 25
383
+ }
384
+ ]
385
+ },
386
+ metadata: {},
387
+ currency: "MXN"
388
+ }
389
+ }
117
390
 
118
- checkoutData.skyflowTokens = skyflowTokens;
391
+ ngOnInit() {
392
+ this.initCheckout();
393
+ }
119
394
 
120
- const jsonResponseRouter: any = await liteCheckout.startCheckoutRouterFull(
121
- checkoutData
122
- );
395
+ async initCheckout() {
396
+ this.tonderService.configureCheckout({
397
+ customer: { email: "example@email.com" },
398
+ });
399
+ await this.tonderService.injectCheckout();
400
+ this.tonderService.verify3dsTransaction().then((response) => {
401
+ console.log("Verify 3ds response", response);
402
+ });
403
+
404
+ // Calls more functions to get payment methods, saved cards, etc.
405
+ }
123
406
 
407
+ async pay() {
408
+ this.loading = true;
409
+ try {
410
+ const response = await this.tonderService.payment({
411
+ ...this.checkoutData,
412
+ card: { // Card details, if not using a payment method.
413
+ card_number: this.paymentForm.value.cardNumber || "",
414
+ cvv: this.paymentForm.value.cvv || "",
415
+ expiration_month: this.paymentForm.value.month || "",
416
+ expiration_year: this.paymentForm.value.expirationYear || "",
417
+ cardholder_name: this.paymentForm.value.name || ""
418
+ },
419
+ // card: "skyflow_id" // In case a saved card is selected.
420
+ // payment_method: "" // Payment method if not using the card form
421
+ });
422
+ console.log("Payment successful:", response);
423
+ alert("Payment successful");
424
+ } catch (error) {
425
+ console.error("Payment failed:", error);
426
+ alert("Payment failed");
427
+ } finally {
428
+ this.loading = false;
429
+ }
430
+ }
431
+ }
124
432
  ```
125
433
 
126
- <font size="4">Take actions on base to the checkout router response</font>
127
-
128
- # Customer Cards(Register)
129
-
130
434
  ## Request secure token
131
435
 
132
436
  ```typescript
@@ -145,75 +449,82 @@ const jsonResponse = await liteCheckout.getSecureToken(
145
449
  }
146
450
  ```
147
451
 
452
+ ## Deprecated Fields
453
+
454
+ The following fields have been deprecated and should no longer be used. Consider using the recommended alternatives:
455
+
148
456
  ## Register customer card
457
+ ### `apiKeyTonder` Property
149
458
 
150
- ```typescript
459
+ - **Deprecated Reason:** The `apiKeyTonder` property in the constructor and `IInlineLiteCheckoutOptions` interface is no longer required.
460
+ - **Alternative:** Use the `apiKey` field.
151
461
 
152
- customer_auth_token: string;
462
+ ### `baseUrlTonder` Property
153
463
 
154
- data: {
155
- skyflow_id: string;
156
- };
464
+ - **Deprecated Reason:** The `baseUrlTonder` property in the constructor and `IInlineLiteCheckoutOptions` interface is no longer required.
465
+ - **Alternative:** Use the `mode` field with `stage` | `development` | `sandbox` | `production` options.
157
466
 
158
- const jsonResponseOrder = await liteCheckout.registerCustomerCard(
159
- secureToken
160
- customer_auth_token,
161
- data
162
- );
163
- ```
467
+ ### `signal` Property
164
468
 
165
- ## Return register customer card
166
- ```typescript
167
- {
168
- skyflow_id: string;
169
- user_id: number;
170
- }
171
- ```
469
+ - **Deprecated Reason:** The `signal` property in the constructor and `IInlineLiteCheckoutOptions` interface is no longer required.
172
470
 
173
- # Customer Cards(Get)
174
471
 
175
- ## Get customer cards
472
+ ## Deprecated Functions
176
473
 
177
- ```typescript
474
+ The following functions have been deprecated and should no longer be used. Consider using the recommended alternatives:
178
475
 
179
- customer_auth_token: string;
476
+ ### `customerRegister`
180
477
 
181
- query: string = "?ordering=<string>&search=<string>";
478
+ - **Deprecated Reason:** This function is no longer necessary as registration is now automatically handled during payment processing or when using card management methods.
182
479
 
183
- const jsonResponseOrder = await liteCheckout.getCustomerCards(
184
- customer_auth_token,
185
- query
186
- );
187
- ```
480
+ ### `createOrder` and `createPayment`
188
481
 
189
- ## Return get customer cards
190
- ```typescript
191
- {
192
- user_id: number,
193
- cards: [
194
- {
195
- fields: {
196
- card_number: string,
197
- cardholder_name: string,
198
- cvv: string,
199
- expiration_month: string,
200
- expiration_year: string,
201
- skyflow_id: string
202
- }
203
- }
204
- ]
205
- }
206
- ```
482
+ - **Deprecated Reason:** These functions have been replaced by the `payment` function, which now automatically handles order creation and payment processing.
483
+ - **Alternative:** Use the `payment` function.
207
484
 
208
- ## Delete customer card
485
+ ### `startCheckoutRouter` and `startCheckoutRouterFull`
209
486
 
210
- ```typescript
487
+ - **Deprecated Reason:** These functions have been replaced by the `payment` function.
488
+ - **Alternative:** Use the `payment` function.
211
489
 
212
- const deleted: boolean = await liteCheckout.deleteCustomerCard(
213
- customer_auth_token,
214
- skyflow_id
215
- );
490
+ ### `registerCustomerCard`
491
+
492
+ - **Deprecated Reason:** This function has been renamed to `saveCustomerCard` to better align with its purpose. The method's usage has also been updated.
493
+ - **Alternative:** Use the `saveCustomerCard` method and update your implementation to reflect the changes.
494
+
495
+ ### `deleteCustomerCard`
216
496
 
497
+ - **Deprecated Reason:** This function has been renamed to `removeCustomerCard` to better align with its purpose. The method's usage has also been updated.
498
+ - **Alternative:** Use the `removeCustomerCard` method and update your implementation to reflect the changes.
499
+
500
+ ### `getActiveAPMs`
501
+
502
+ - **Deprecated Reason:** This function has been renamed to `getCustomerPaymentMethods` to better align with its purpose. The method's usage has also been updated.
503
+ - **Alternative:** Use the `getCustomerPaymentMethods` method and update your implementation to reflect the changes.
504
+
505
+ ### `getSkyflowTokens`
506
+
507
+ - **Deprecated Reason:** Card registration and checkout are now automatically handled during the payment process or through card management methods, making this method unnecessary.
508
+
509
+ ### `getOpenpayDeviceSessionID`
510
+
511
+ - **Deprecated Reason:** It is no longer necessary to use this method is now automatically handled during the payment process.
512
+
513
+
514
+ ## Notes
515
+
516
+ ### General
517
+
518
+ - Replace `apiKey`, `mode`, `returnUrl` with your actual values.
519
+ - Remember to use the `configureCheckout` function after creating an instance of `LiteCheckout`. This ensures that functions such as payment processing, saving cards, deleting cards, and others work correctly.
520
+
521
+ ### Script Dependencies
522
+
523
+ For all implementations, ensure you include the necessary scripts:
524
+
525
+ ```html
526
+ <script src="https://openpay.s3.amazonaws.com/openpay.v1.min.js"></script>
527
+ <script src="https://openpay.s3.amazonaws.com/openpay-data.v1.min.js"></script>
217
528
  ```
218
529
 
219
530
  ## License
@@ -0,0 +1,47 @@
1
+ import { ThreeDSHandler } from "./3dsHandler";
2
+ import { Business, IConfigureCheckout, IInlineCheckoutBaseOptions } from "../types/commons";
3
+ import { ICustomer } from "../types/customer";
4
+ import { IItem, IProcessPaymentRequest, IStartCheckoutResponse } from "../types/checkout";
5
+ import { ICustomerCardsResponse, ISaveCardResponse, ISaveCardSkyflowRequest } from "../types/card";
6
+ import { IPaymentMethodResponse } from "../types/paymentMethod";
7
+ import { ITransaction } from "../types/transaction";
8
+ export declare class BaseInlineCheckout {
9
+ #private;
10
+ baseUrl: string;
11
+ cartTotal: string | number;
12
+ process3ds: ThreeDSHandler;
13
+ mode?: "production" | "sandbox" | "stage" | "development" | undefined;
14
+ apiKeyTonder: string;
15
+ returnUrl?: string;
16
+ callBack?: ((response: IStartCheckoutResponse | Record<string, any>) => void) | undefined;
17
+ merchantData?: Business;
18
+ abortController: AbortController;
19
+ customer?: ICustomer | {
20
+ email: string;
21
+ };
22
+ cartItems?: IItem[];
23
+ metadata: {};
24
+ card?: {} | undefined;
25
+ currency?: string;
26
+ constructor({ mode, apiKey, apiKeyTonder, returnUrl, callBack, baseUrlTonder }: IInlineCheckoutBaseOptions);
27
+ configureCheckout(data: IConfigureCheckout): void;
28
+ verify3dsTransaction(): Promise<ITransaction | IStartCheckoutResponse | void>;
29
+ payment(data: IProcessPaymentRequest): Promise<IStartCheckoutResponse>;
30
+ _initializeCheckout(): Promise<void>;
31
+ _checkout(data: any): Promise<any>;
32
+ _setCartTotal(total: string | number): void;
33
+ _getCustomer(signal?: AbortSignal | null): Promise<Record<string, any>>;
34
+ _handleCheckout({ card, payment_method, customer, isSandbox, returnUrl: returnUrlData }: {
35
+ card?: string;
36
+ payment_method?: string;
37
+ customer: Record<string, any>;
38
+ isSandbox?: boolean;
39
+ returnUrl?: string;
40
+ }): Promise<any>;
41
+ _fetchMerchantData(): Promise<Business | undefined>;
42
+ _getCustomerCards(authToken: string, businessId: string | number): Promise<ICustomerCardsResponse>;
43
+ _saveCustomerCard(authToken: string, secureToken: string, businessId: string | number, skyflowTokens: ISaveCardSkyflowRequest): Promise<ISaveCardResponse>;
44
+ _removeCustomerCard(authToken: string, businessId: string | number, skyflowId: string): Promise<string>;
45
+ _fetchCustomerPaymentMethods(): Promise<IPaymentMethodResponse>;
46
+ _handle3dsRedirect(response: ITransaction | IStartCheckoutResponse | void): Promise<void | IStartCheckoutResponse | ITransaction>;
47
+ }