@tonder.io/ionic-lite-sdk 0.0.35-beta.3 → 0.0.35-beta.30

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 (52) hide show
  1. package/README.md +425 -114
  2. package/dist/classes/BaseInlineCheckout.d.ts +19 -18
  3. package/dist/classes/errorResponse.d.ts +1 -1
  4. package/dist/classes/liteCheckout.d.ts +11 -42
  5. package/dist/data/businessApi.d.ts +1 -1
  6. package/dist/data/cardApi.d.ts +1 -1
  7. package/dist/data/checkoutApi.d.ts +2 -1
  8. package/dist/data/customerApi.d.ts +1 -1
  9. package/dist/data/paymentMethodApi.d.ts +2 -2
  10. package/dist/helpers/skyflow.d.ts +1 -1
  11. package/dist/index.d.ts +3 -1
  12. package/dist/index.js +1 -1
  13. package/dist/types/card.d.ts +1 -0
  14. package/dist/types/checkout.d.ts +2 -1
  15. package/dist/types/commons.d.ts +8 -3
  16. package/dist/types/customer.d.ts +10 -0
  17. package/dist/types/liteInlineCheckout.d.ts +151 -0
  18. package/dist/types/transaction.d.ts +101 -0
  19. package/package.json +3 -1
  20. package/src/classes/BaseInlineCheckout.ts +67 -41
  21. package/src/classes/errorResponse.ts +1 -1
  22. package/src/classes/liteCheckout.ts +49 -87
  23. package/src/data/businessApi.ts +1 -1
  24. package/src/data/cardApi.ts +1 -5
  25. package/src/data/checkoutApi.ts +3 -6
  26. package/src/data/customerApi.ts +1 -1
  27. package/src/data/paymentMethodApi.ts +2 -2
  28. package/src/helpers/skyflow.ts +1 -1
  29. package/src/helpers/utils.ts +1 -1
  30. package/src/index.ts +9 -1
  31. package/src/types/card.ts +1 -0
  32. package/src/types/checkout.ts +2 -1
  33. package/src/types/commons.ts +104 -99
  34. package/src/types/customer.ts +10 -0
  35. package/src/types/liteInlineCheckout.ts +215 -0
  36. package/src/types/transaction.ts +101 -0
  37. package/tests/classes/liteCheckout.test.ts +2 -2
  38. package/tests/methods/createOrder.test.ts +3 -4
  39. package/tests/methods/createPayment.test.ts +2 -3
  40. package/tests/methods/customerRegister.test.ts +3 -4
  41. package/tests/methods/getBusiness.test.ts +2 -3
  42. package/tests/methods/getCustomerCards.test.ts +2 -3
  43. package/tests/methods/registerCustomerCard.test.ts +2 -2
  44. package/tests/methods/startCheckoutRouter.test.ts +2 -2
  45. package/tests/methods/startCheckoutRouterFull.test.ts +2 -2
  46. package/.idea/aws.xml +0 -17
  47. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  48. package/.idea/prettier.xml +0 -6
  49. package/.idea/vcs.xml +0 -6
  50. package/.idea/workspace.xml +0 -128
  51. package/src/types/index.d.ts +0 -10
  52. package/src/types/liteInlineCheckout.d.ts +0 -191
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,172 +46,466 @@ const liteCheckout = new LiteCheckout({
29
46
  apiKeyTonder
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
- | apiKeyTonder | 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
+ | apiKey | string | Your API key from the Tonder Dashboard |
97
+ | returnUrl | 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
+ ```
55
116
 
56
- const returnUrl = "http://localhost:8100/payment/success";
117
+ ## Payment Data Structure
57
118
 
58
- let checkoutData = {
119
+ When calling the `payment` method, use the following data structure:
120
+
121
+ ### Field Descriptions
122
+
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:
93
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.
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
+ }
274
+
275
+ async injectCheckout(): Promise<void> {
276
+ return await this.liteCheckout.injectCheckout();
277
+ }
103
278
 
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
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>
434
+ ## Deprecated Fields
127
435
 
128
- # Customer Cards(Register)
436
+ The following fields have been deprecated and should no longer be used. Consider using the recommended alternatives:
129
437
 
130
- ## Register customer card
438
+ ### `apiKeyTonder` Property
131
439
 
132
- ```typescript
440
+ - **Deprecated Reason:** The `apiKeyTonder` property in the constructor and `IInlineLiteCheckoutOptions` interface is no longer required.
441
+ - **Alternative:** Use the `apiKey` field.
133
442
 
134
- customer_auth_token: string;
443
+ ### `baseUrlTonder` Property
135
444
 
136
- data: {
137
- skyflow_id: string;
138
- };
445
+ - **Deprecated Reason:** The `baseUrlTonder` property in the constructor and `IInlineLiteCheckoutOptions` interface is no longer required.
446
+ - **Alternative:** Use the `mode` field with `stage` | `development` | `sandbox` | `production` options.
139
447
 
140
- const jsonResponseOrder = await liteCheckout.registerCustomerCard(
141
- customer_auth_token,
142
- data
143
- );
144
- ```
448
+ ### `signal` Property
145
449
 
146
- ## Return register customer card
147
- ```typescript
148
- {
149
- skyflow_id: string;
150
- user_id: number;
151
- }
152
- ```
450
+ - **Deprecated Reason:** The `signal` property in the constructor and `IInlineLiteCheckoutOptions` interface is no longer required.
153
451
 
154
- # Customer Cards(Get)
155
452
 
156
- ## Get customer cards
453
+ ## Deprecated Functions
157
454
 
158
- ```typescript
455
+ The following functions have been deprecated and should no longer be used. Consider using the recommended alternatives:
159
456
 
160
- customer_auth_token: string;
457
+ ### `customerRegister`
161
458
 
162
- query: string = "?ordering=<string>&search=<string>";
459
+ - **Deprecated Reason:** This function is no longer necessary as registration is now automatically handled during payment processing or when using card management methods.
163
460
 
164
- const jsonResponseOrder = await liteCheckout.getCustomerCards(
165
- customer_auth_token,
166
- query
167
- );
168
- ```
461
+ ### `createOrder` and `createPayment`
169
462
 
170
- ## Return get customer cards
171
- ```typescript
172
- {
173
- user_id: number,
174
- cards: [
175
- {
176
- fields: {
177
- card_number: string,
178
- cardholder_name: string,
179
- cvv: string,
180
- expiration_month: string,
181
- expiration_year: string,
182
- skyflow_id: string
183
- }
184
- }
185
- ]
186
- }
187
- ```
463
+ - **Deprecated Reason:** These functions have been replaced by the `payment` function, which now automatically handles order creation and payment processing.
464
+ - **Alternative:** Use the `payment` function.
188
465
 
189
- ## Delete customer card
466
+ ### `startCheckoutRouter` and `startCheckoutRouterFull`
190
467
 
191
- ```typescript
468
+ - **Deprecated Reason:** These functions have been replaced by the `payment` function.
469
+ - **Alternative:** Use the `payment` function.
470
+
471
+ ### `registerCustomerCard`
472
+
473
+ - **Deprecated Reason:** This function has been renamed to `saveCustomerCard` to better align with its purpose. The method's usage has also been updated.
474
+ - **Alternative:** Use the `saveCustomerCard` method and update your implementation to reflect the changes.
475
+
476
+ ### `deleteCustomerCard`
192
477
 
193
- const deleted: boolean = await liteCheckout.deleteCustomerCard(
194
- customer_auth_token,
195
- skyflow_id
196
- );
478
+ - **Deprecated Reason:** This function has been renamed to `removeCustomerCard` to better align with its purpose. The method's usage has also been updated.
479
+ - **Alternative:** Use the `removeCustomerCard` method and update your implementation to reflect the changes.
197
480
 
481
+ ### `getActiveAPMs`
482
+
483
+ - **Deprecated Reason:** This function has been renamed to `getCustomerPaymentMethods` to better align with its purpose. The method's usage has also been updated.
484
+ - **Alternative:** Use the `getCustomerPaymentMethods` method and update your implementation to reflect the changes.
485
+
486
+ ### `getSkyflowTokens`
487
+
488
+ - **Deprecated Reason:** Card registration and checkout are now automatically handled during the payment process or through card management methods, making this method unnecessary.
489
+
490
+ ### `getOpenpayDeviceSessionID`
491
+
492
+ - **Deprecated Reason:** It is no longer necessary to use this method is now automatically handled during the payment process.
493
+
494
+
495
+ ## Notes
496
+
497
+ ### General
498
+
499
+ - Replace `apiKey`, `mode`, `returnUrl` with your actual values.
500
+ - 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.
501
+
502
+ ### Script Dependencies
503
+
504
+ For all implementations, ensure you include the necessary scripts:
505
+
506
+ ```html
507
+ <script src="https://openpay.s3.amazonaws.com/openpay.v1.min.js"></script>
508
+ <script src="https://openpay.s3.amazonaws.com/openpay-data.v1.min.js"></script>
198
509
  ```
199
510
 
200
511
  ## License
@@ -1,34 +1,31 @@
1
1
  import { ThreeDSHandler } from "./3dsHandler";
2
- import { ErrorResponse } from "./errorResponse";
3
- import { Business, ICustomer, IItem, IInlineCheckoutBaseOptions, IConfigureCheckout, IProcessPaymentRequest, IStartCheckoutResponse, StartCheckoutResponse } from "../types";
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";
4
8
  export declare class BaseInlineCheckout {
5
9
  #private;
6
10
  baseUrl: string;
7
- cartTotal: string;
11
+ cartTotal: string | number;
8
12
  process3ds: ThreeDSHandler;
9
13
  mode?: "production" | "sandbox" | "stage" | "development" | undefined;
10
14
  apiKeyTonder: string;
11
- returnUrl: string;
12
- callBack?: ((response: any) => void) | undefined;
15
+ returnUrl?: string;
16
+ callBack?: ((response: IStartCheckoutResponse | Record<string, any>) => void) | undefined;
13
17
  merchantData?: Business;
14
18
  abortController: AbortController;
15
- firstName?: string;
16
- lastName?: string;
17
- country?: string;
18
- address?: string;
19
- city?: string;
20
- state?: string;
21
- postCode?: string;
22
- email?: string;
23
- phone?: string;
24
- customer?: ICustomer;
19
+ customer?: ICustomer | {
20
+ email: string;
21
+ };
25
22
  cartItems?: IItem[];
26
23
  metadata: {};
27
24
  card?: {} | undefined;
28
25
  currency?: string;
29
- constructor({ mode, apiKey, apiKeyTonder, returnUrl, callBack, }: IInlineCheckoutBaseOptions);
26
+ constructor({ mode, apiKey, apiKeyTonder, returnUrl, callBack, baseUrlTonder }: IInlineCheckoutBaseOptions);
30
27
  configureCheckout(data: IConfigureCheckout): void;
31
- verify3dsTransaction(): Promise<false | ErrorResponse | StartCheckoutResponse | undefined>;
28
+ verify3dsTransaction(): Promise<ITransaction | IStartCheckoutResponse | void>;
32
29
  payment(data: IProcessPaymentRequest): Promise<IStartCheckoutResponse>;
33
30
  _initializeCheckout(): Promise<void>;
34
31
  _checkout(data: any): Promise<any>;
@@ -41,5 +38,9 @@ export declare class BaseInlineCheckout {
41
38
  isSandbox?: boolean;
42
39
  }): Promise<any>;
43
40
  _fetchMerchantData(): Promise<Business | undefined>;
44
- _handle3dsRedirect(response: ErrorResponse | StartCheckoutResponse | false | undefined): Promise<false | ErrorResponse | StartCheckoutResponse | undefined>;
41
+ _getCustomerCards(authToken: string, businessId: string | number): Promise<ICustomerCardsResponse>;
42
+ _saveCustomerCard(authToken: string, businessId: string | number, skyflowTokens: ISaveCardSkyflowRequest): Promise<ISaveCardResponse>;
43
+ _removeCustomerCard(authToken: string, businessId: string | number, skyflowId: string): Promise<string>;
44
+ _fetchCustomerPaymentMethods(): Promise<IPaymentMethodResponse>;
45
+ _handle3dsRedirect(response: ITransaction | IStartCheckoutResponse | void): Promise<void | IStartCheckoutResponse | ITransaction>;
45
46
  }
@@ -1,4 +1,4 @@
1
- import { IErrorResponse } from "../types";
1
+ import { IErrorResponse } from "../types/responses";
2
2
  export declare class ErrorResponse implements IErrorResponse {
3
3
  code?: string | undefined;
4
4
  body?: string | undefined;