@tonder.io/ionic-lite-sdk 0.0.35-beta.0 → 0.0.35-beta.10

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 (43) hide show
  1. package/.idea/prettier.xml +6 -0
  2. package/.idea/workspace.xml +30 -29
  3. package/dist/classes/BaseInlineCheckout.d.ts +7 -8
  4. package/dist/classes/errorResponse.d.ts +1 -1
  5. package/dist/classes/liteCheckout.d.ts +7 -12
  6. package/dist/data/businessApi.d.ts +1 -1
  7. package/dist/data/cardApi.d.ts +1 -1
  8. package/dist/data/checkoutApi.d.ts +1 -2
  9. package/dist/data/customerApi.d.ts +1 -1
  10. package/dist/data/paymentMethodApi.d.ts +1 -1
  11. package/dist/helpers/skyflow.d.ts +2 -2
  12. package/dist/helpers/utils.d.ts +1 -1
  13. package/dist/index.d.ts +2 -1
  14. package/dist/index.js +1 -1
  15. package/dist/types/commons.d.ts +11 -1
  16. package/dist/types/customer.d.ts +10 -0
  17. package/dist/types/requests.d.ts +8 -1
  18. package/dist/types/transaction.d.ts +101 -0
  19. package/package.json +2 -2
  20. package/src/classes/BaseInlineCheckout.ts +345 -303
  21. package/src/classes/errorResponse.ts +1 -1
  22. package/src/classes/liteCheckout.ts +278 -195
  23. package/src/data/businessApi.ts +17 -13
  24. package/src/data/cardApi.ts +70 -63
  25. package/src/data/checkoutApi.ts +75 -59
  26. package/src/data/customerApi.ts +27 -27
  27. package/src/data/openPayApi.ts +12 -7
  28. package/src/data/paymentMethodApi.ts +32 -29
  29. package/src/data/skyflowApi.ts +18 -14
  30. package/src/helpers/mercadopago.ts +14 -14
  31. package/src/helpers/skyflow.ts +36 -30
  32. package/src/helpers/utils.ts +51 -39
  33. package/src/helpers/validations.ts +35 -35
  34. package/src/index.ts +7 -1
  35. package/src/shared/catalog/paymentMethodsCatalog.ts +8 -8
  36. package/src/shared/constants/paymentMethodAPM.ts +59 -59
  37. package/src/shared/constants/tonderUrl.ts +4 -4
  38. package/src/types/commons.ts +11 -1
  39. package/src/types/customer.ts +10 -0
  40. package/src/types/liteInlineCheckout.d.ts +217 -176
  41. package/src/types/requests.ts +8 -1
  42. package/src/types/transaction.ts +101 -0
  43. package/tests/utils/mockClasses.ts +3 -4
@@ -1,183 +1,224 @@
1
- import {IConfigureCheckout, IInlineCheckoutBaseOptions} from "./common";
2
- import {ICustomerCardsResponse, ISaveCardRequest, ISaveCardResponse} from "./card";
3
- import {IPaymentMethod} from "./paymentMethod";
4
- import {IProcessPaymentRequest, IStartCheckoutResponse} from "./checkout";
5
- import {ITransaction} from "./transaction";
6
- import {APM} from "./commons";
7
- import {ErrorResponse} from "../classes/errorResponse";
1
+ import { IConfigureCheckout, IInlineCheckoutBaseOptions } from "./commons";
8
2
  import {
9
- CreateOrderRequest,
10
- CreatePaymentRequest,
11
- RegisterCustomerCardRequest,
12
- StartCheckoutFullRequest,
13
- StartCheckoutIdRequest,
14
- StartCheckoutRequest
3
+ ICustomerCardsResponse,
4
+ ISaveCardRequest,
5
+ ISaveCardResponse,
6
+ } from "./card";
7
+ import { IPaymentMethod } from "./paymentMethod";
8
+ import { IProcessPaymentRequest, IStartCheckoutResponse } from "./checkout";
9
+ import { ITransaction } from "./transaction";
10
+ import { APM } from "./commons";
11
+ import { ErrorResponse } from "../classes/errorResponse";
12
+ import {
13
+ CreateOrderRequest,
14
+ CreatePaymentRequest,
15
+ RegisterCustomerCardRequest,
16
+ StartCheckoutFullRequest,
17
+ StartCheckoutIdRequest,
18
+ StartCheckoutRequest,
19
+ TokensRequest,
15
20
  } from "./requests";
16
21
  import {
17
- CreateOrderResponse,
18
- CreatePaymentResponse, CustomerRegisterResponse, GetBusinessResponse,
19
- RegisterCustomerCardResponse,
20
- StartCheckoutResponse
22
+ CreateOrderResponse,
23
+ CreatePaymentResponse,
24
+ CustomerRegisterResponse,
25
+ GetBusinessResponse,
26
+ RegisterCustomerCardResponse,
27
+ StartCheckoutResponse,
21
28
  } from "./responses";
22
29
 
23
- export class ILiteInlineCheckout {
24
- constructor(options: IInlineLiteCheckoutOptions);
25
-
26
- /**
27
- * 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.
28
- * @param {import("../types").IConfigureCheckout} data - Configuration data including customer information and potentially other settings.
29
- * @returns {Promise<void>}.
30
- * @public
31
- */
32
- configureCheckout(data: IConfigureCheckout): void;
33
-
34
- /**
35
- * Initializes and prepares the checkout for use.
36
- * This method set up the initial environment.
37
- * @returns {Promise<void>} A promise that resolves when the checkout has been initialized.
38
- * @throws {Error} If there's any problem during the checkout initialization.
39
- * @public
40
- */
41
- injectCheckout(): Promise<void>;
42
-
43
- /**
44
- * Processes a payment.
45
- * @param {import("../types").IProcessPaymentRequest} data - Payment data including customer, cart, and other relevant information.
46
- * @returns {Promise<import("../types").IStartCheckoutResponse>} A promise that resolves with the payment response or 3DS redirect or is rejected with an error.
47
- *
48
- * @throws {Error} Throws an error if the checkout process fails. The error object contains
49
- * additional `details` property with the response from the server if available.
50
- * @property {import("../types").IStartCheckoutErrorResponse} error.details - The response body from the server when an error occurs.
51
- *
52
- * @public
53
- */
54
- payment(data: IProcessPaymentRequest): Promise<IStartCheckoutResponse>;
55
-
56
- /**
57
- * Verifies the 3DS transaction status.
58
- * @returns {Promise<import("../types").ITransaction | void>} The result of the 3DS verification and checkout resumption.
59
- * @public
60
- */
61
- verify3dsTransaction(): Promise<ITransaction | void>;
62
-
63
- /**
64
- * Retrieves the list of cards associated with a customer.
65
- * @returns {Promise<import("../types").ICustomerCardsResponse>} A promise that resolves with the customer's card data.
66
- *
67
- * @throws {import("../types").IPublicError} Throws an error object if the operation fails.
68
- *
69
- * @public
70
- */
71
- getCustomerCards(): Promise<ICustomerCardsResponse>;
72
-
73
- /**
74
- * Saves a card to a customer's account. This method can be used to add a new card
75
- * or update an existing one.
76
- * @param {import("../types").ISaveCardRequest} card - The card information to be saved.
77
- * @returns {Promise<import("../types").ISaveCardResponse>} A promise that resolves with the saved card data.
78
- *
79
- * @throws {import("../types").IPublicError} Throws an error object if the operation fails.
80
- *
81
- * @public
82
- */
83
- saveCustomerCard(
84
- card: ISaveCardRequest,
85
- ): Promise<ISaveCardResponse>;
86
-
87
- /**
88
- * Removes a card from a customer's account.
89
- * @param {string} skyflowId - The unique identifier of the card to be deleted.
90
- * @returns {Promise<string>} A promise that resolves when the card is successfully deleted.
91
- *
92
- * @throws {import("../types").IPublicError} Throws an error object if the operation fails.
93
- *
94
- * @public
95
- */
96
- removeCustomerCard(
97
- skyflowId: string,
98
- ): Promise<string>;
99
-
100
- /**
101
- * Retrieves the list of available Alternative Payment Methods (APMs).
102
- * @returns {Promise<import("../types").IPaymentMethod[]>} A promise that resolves with the list of APMs.
103
- *
104
- * @throws {import("../types").IPublicError} Throws an error object if the operation fails.
105
- *
106
- * @public
107
- */
108
- getCustomerPaymentMethods(): Promise<IPaymentMethod[]>;
109
-
110
- /**
111
- * Retrieves the business information.
112
- * @returns {Promise<import("../types").GetBusinessResponse>} A promise that resolves with the business information.
113
- *
114
- * @throws {import("../types").IPublicError} Throws an error object if the operation fails.
115
- *
116
- * @public
117
- */
118
- getBusiness(): Promise<GetBusinessResponse>;
119
-
120
-
121
- // TODO: DEPRECATED
122
- /**
123
- * @deprecated This method is deprecated and will be removed in a future release.
124
- * It is no longer necessary to use this method as customer registration is now automatically handled
125
- * during the payment process or when using card management methods.
126
- */
127
- async customerRegister(email: string): Promise<CustomerRegisterResponse | ErrorResponse>
128
-
129
- // TODO: DEPRECATED
130
- /**
131
- * @deprecated This method is deprecated and will be removed in a future release.
132
- * It is no longer necessary to use this method as order creation is now automatically
133
- * handled when making a payment through the `payment` function.
134
- */
135
- async createOrder(orderItems: CreateOrderRequest): Promise<CreateOrderResponse | ErrorResponse>
136
-
137
- // TODO: DEPRECATED
138
- /**
139
- * @deprecated This method is deprecated and will be removed in a future release.
140
- * It is no longer necessary to use this method as payment creation is now automatically
141
- * handled when making a payment through the `payment` function.
142
- */
143
- async createPayment(paymentItems: CreatePaymentRequest): Promise<CreatePaymentResponse | ErrorResponse>
144
-
145
- // TODO: DEPRECATED
146
- /**
147
- * @deprecated This method is deprecated and will be removed in a future release.
148
- * Use the {@link payment} method
149
- */
150
- async startCheckoutRouter(routerData: StartCheckoutRequest | StartCheckoutIdRequest): Promise<StartCheckoutResponse | ErrorResponse | undefined>
151
-
152
- // TODO: DEPRECATED
153
- /**
154
- * @deprecated This method is deprecated and will be removed in a future release.
155
- * Use the {@link payment} method
156
- */
157
- async startCheckoutRouterFull(routerFullData: StartCheckoutFullRequest): Promise<StartCheckoutResponse | ErrorResponse | undefined>
158
-
159
- // TODO: DEPRECATED
160
- /**
161
- * @deprecated This method is deprecated and will be removed in a future release.
162
- * Use the {@link saveCustomerCard} method
163
- */
164
- async registerCustomerCard(customerToken: string, data: RegisterCustomerCardRequest): Promise<RegisterCustomerCardResponse | ErrorResponse>
165
-
166
-
167
- // TODO: DEPRECATED
168
- /**
169
- * @deprecated This method is deprecated and will be removed in a future release.
170
- * Use the {@link removeCustomerCard} method
171
- */
172
- async deleteCustomerCard(customerToken: string, skyflowId: string = ""): Promise<Boolean | ErrorResponse>
173
-
174
- // TODO: DEPRECATED
175
- /**
176
- * @deprecated This method is deprecated and will be removed in a future release.
177
- * Use the {@link getCustomerPaymentMethods} method
178
- */
179
- async getActiveAPMs(): Promise<APM[]>;
30
+ export class LiteCheckout {
31
+ constructor(options: IInlineLiteCheckoutOptions);
32
+
33
+ /**
34
+ * 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.
35
+ * @param {import("./index").IConfigureCheckout} data - Configuration data including customer information and potentially other settings.
36
+ * @returns {Promise<void>}.
37
+ * @public
38
+ */
39
+ configureCheckout(data: IConfigureCheckout): void;
40
+
41
+ /**
42
+ * Initializes and prepares the checkout for use.
43
+ * This method set up the initial environment.
44
+ * @returns {Promise<void>} A promise that resolves when the checkout has been initialized.
45
+ * @throws {Error} If there's any problem during the checkout initialization.
46
+ * @public
47
+ */
48
+ injectCheckout(): Promise<void>;
49
+
50
+ /**
51
+ * Processes a payment.
52
+ * @param {import("./index").IProcessPaymentRequest} data - Payment data including customer, cart, and other relevant information.
53
+ * @returns {Promise<import("./index").IStartCheckoutResponse>} A promise that resolves with the payment response or 3DS redirect or is rejected with an error.
54
+ *
55
+ * @throws {Error} Throws an error if the checkout process fails. The error object contains
56
+ * additional `details` property with the response from the server if available.
57
+ * @property {import("./index").IStartCheckoutErrorResponse} error.details - The response body from the server when an error occurs.
58
+ *
59
+ * @public
60
+ */
61
+ payment(data: IProcessPaymentRequest): Promise<IStartCheckoutResponse>;
62
+
63
+ /**
64
+ * Verifies the 3DS transaction status.
65
+ * @returns {Promise<import("./index").ITransaction | void>} The result of the 3DS verification and checkout resumption.
66
+ * @public
67
+ */
68
+ verify3dsTransaction(): Promise<ITransaction | void>;
69
+
70
+ /**
71
+ * Retrieves the list of cards associated with a customer.
72
+ * @returns {Promise<import("./index").ICustomerCardsResponse>} A promise that resolves with the customer's card data.
73
+ *
74
+ * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
75
+ *
76
+ * @public
77
+ */
78
+ getCustomerCards(): Promise<ICustomerCardsResponse>;
79
+
80
+ /**
81
+ * Saves a card to a customer's account. This method can be used to add a new card
82
+ * or update an existing one.
83
+ * @param {import("./index").ISaveCardRequest} card - The card information to be saved.
84
+ * @returns {Promise<import("./index").ISaveCardResponse>} A promise that resolves with the saved card data.
85
+ *
86
+ * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
87
+ *
88
+ * @public
89
+ */
90
+ saveCustomerCard(card: ISaveCardRequest): Promise<ISaveCardResponse>;
91
+
92
+ /**
93
+ * Removes a card from a customer's account.
94
+ * @param {string} skyflowId - The unique identifier of the card to be deleted.
95
+ * @returns {Promise<string>} A promise that resolves when the card is successfully deleted.
96
+ *
97
+ * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
98
+ *
99
+ * @public
100
+ */
101
+ removeCustomerCard(skyflowId: string): Promise<string>;
102
+
103
+ /**
104
+ * Retrieves the list of available Alternative Payment Methods (APMs).
105
+ * @returns {Promise<import("./index").IPaymentMethod[]>} A promise that resolves with the list of APMs.
106
+ *
107
+ * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
108
+ *
109
+ * @public
110
+ */
111
+ getCustomerPaymentMethods(): Promise<IPaymentMethod[]>;
112
+
113
+ /**
114
+ * Retrieves the business information.
115
+ * @returns {Promise<import("./index").GetBusinessResponse>} A promise that resolves with the business information.
116
+ *
117
+ * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
118
+ *
119
+ * @public
120
+ */
121
+ getBusiness(): Promise<GetBusinessResponse>;
122
+
123
+ // TODO: DEPRECATED
124
+ /**
125
+ * @deprecated This method is deprecated and will be removed in a future release.
126
+ * It is no longer necessary to use this method as customer registration is now automatically handled
127
+ * during the payment process or when using card management methods.
128
+ */
129
+ customerRegister(
130
+ email: string,
131
+ ): Promise<CustomerRegisterResponse | ErrorResponse>;
132
+
133
+ // TODO: DEPRECATED
134
+ /**
135
+ * @deprecated This method is deprecated and will be removed in a future release.
136
+ * It is no longer necessary to use this method as order creation is now automatically
137
+ * handled when making a payment through the `payment` function.
138
+ */
139
+ createOrder(
140
+ orderItems: CreateOrderRequest,
141
+ ): Promise<CreateOrderResponse | ErrorResponse>;
142
+
143
+ // TODO: DEPRECATED
144
+ /**
145
+ * @deprecated This method is deprecated and will be removed in a future release.
146
+ * It is no longer necessary to use this method as payment creation is now automatically
147
+ * handled when making a payment through the `payment` function.
148
+ */
149
+ createPayment(
150
+ paymentItems: CreatePaymentRequest,
151
+ ): Promise<CreatePaymentResponse | ErrorResponse>;
152
+
153
+ // TODO: DEPRECATED
154
+ /**
155
+ * @deprecated This method is deprecated and will be removed in a future release.
156
+ * Use the {@link payment} method
157
+ */
158
+ startCheckoutRouter(
159
+ routerData: StartCheckoutRequest | StartCheckoutIdRequest,
160
+ ): Promise<StartCheckoutResponse | ErrorResponse | undefined>;
161
+
162
+ // TODO: DEPRECATED
163
+ /**
164
+ * @deprecated This method is deprecated and will be removed in a future release.
165
+ * Use the {@link payment} method
166
+ */
167
+ startCheckoutRouterFull(
168
+ routerFullData: StartCheckoutFullRequest,
169
+ ): Promise<StartCheckoutResponse | ErrorResponse | undefined>;
170
+
171
+ // TODO: DEPRECATED
172
+ /**
173
+ * @deprecated This method is deprecated and will be removed in a future release.
174
+ * Use the {@link saveCustomerCard} method
175
+ */
176
+ registerCustomerCard(
177
+ customerToken: string,
178
+ data: RegisterCustomerCardRequest,
179
+ ): Promise<RegisterCustomerCardResponse | ErrorResponse>;
180
+
181
+ // TODO: DEPRECATED
182
+ /**
183
+ * @deprecated This method is deprecated and will be removed in a future release.
184
+ * Use the {@link removeCustomerCard} method
185
+ */
186
+ deleteCustomerCard(
187
+ customerToken: string,
188
+ skyflowId: string,
189
+ ): Promise<Boolean | ErrorResponse>;
190
+
191
+ // TODO: DEPRECATED
192
+ /**
193
+ * @deprecated This method is deprecated and will be removed in a future release.
194
+ * Use the {@link getCustomerPaymentMethods} method
195
+ */
196
+ getActiveAPMs(): Promise<APM[]>;
197
+
198
+ // TODO: DEPRECATED
199
+ /**
200
+ * @deprecated This method is deprecated and will be removed in a future release.
201
+ * It is no longer necessary to use this method as customer registration is now automatically handled
202
+ * during the payment process or when using card management methods.
203
+ */
204
+ getSkyflowTokens({
205
+ vault_id,
206
+ vault_url,
207
+ data,
208
+ }: TokensRequest): Promise<any | ErrorResponse>;
209
+
210
+ // TODO: DEPRECATED
211
+ /**
212
+ * @deprecated This method is deprecated and will be removed in a future release.
213
+ * It is no longer necessary to use this method is now automatically handled
214
+ * during the payment process.
215
+ */
216
+ getOpenpayDeviceSessionID(
217
+ merchant_id: string,
218
+ public_key: string,
219
+ is_sandbox: boolean,
220
+ ): Promise<string | ErrorResponse>;
180
221
  }
181
222
 
182
-
183
- export interface IInlineLiteCheckoutOptions extends IInlineCheckoutBaseOptions {}
223
+ export interface IInlineLiteCheckoutOptions
224
+ extends IInlineCheckoutBaseOptions {}
@@ -71,7 +71,7 @@ export type RegisterCustomerCardRequest = {
71
71
  skyflow_id: string;
72
72
  }
73
73
 
74
- export type TokensRequest = {
74
+ export type TokensSkyflowRequest = {
75
75
  baseUrl: string;
76
76
  apiKey: string;
77
77
  vault_id: string,
@@ -80,6 +80,13 @@ export type TokensRequest = {
80
80
  [key: string]: any;
81
81
  }
82
82
  }
83
+ export type TokensRequest = {
84
+ vault_id: string,
85
+ vault_url: string,
86
+ data: {
87
+ [key: string]: any;
88
+ }
89
+ }
83
90
 
84
91
  export type StartCheckoutFullRequest = {
85
92
  order: {
@@ -0,0 +1,101 @@
1
+ export interface ITransaction {
2
+ id: number;
3
+ provider: string;
4
+ country: string;
5
+ currency_code: string;
6
+ transaction_status: string;
7
+ created: string;
8
+ modified: string;
9
+ operation_date: string;
10
+ transaction_reference: string;
11
+ transaction_type: string;
12
+ status: string;
13
+ amount: string;
14
+ related_transaction_reference?: null | string;
15
+ reason?: null | string;
16
+ is_refunded?: null | boolean;
17
+ is_disputed?: null | boolean;
18
+ number_of_payment_attempts: number;
19
+ card_brand?: null | string;
20
+ number_of_installments: number;
21
+ payment?: {
22
+ id: number;
23
+ created: string;
24
+ modified: string;
25
+ amount: string;
26
+ status: string;
27
+ date: string;
28
+ paid_date: null | string;
29
+ source: null | string;
30
+ customer_order_reference: null | string;
31
+ client: number;
32
+ business: number;
33
+ shipping_address?: null | string;
34
+ billing_address?: null | string;
35
+ order: number;
36
+ };
37
+ checkout: {
38
+ id: string;
39
+ created: string;
40
+ modified: string;
41
+ checkout_data: {
42
+ name: string;
43
+ amount: number;
44
+ source: string;
45
+ id_ship: string;
46
+ currency: string;
47
+ order_id: number;
48
+ token_id: string;
49
+ last_name: string;
50
+ id_product: string;
51
+ ip_address: string;
52
+ payment_id: number;
53
+ return_url: string;
54
+ title_ship: string;
55
+ business_id: number;
56
+ checkout_id: string;
57
+ description: string;
58
+ browser_info: {
59
+ language: string;
60
+ time_zone: number;
61
+ user_agent: string;
62
+ color_depth: number;
63
+ screen_width: number;
64
+ screen_height: number;
65
+ javascript_enabled: boolean;
66
+ };
67
+ email_client: string;
68
+ phone_number: string;
69
+ instance_id_ship: string;
70
+ quantity_product: number;
71
+ device_session_id: null | string;
72
+ number_of_payment_attempts: number;
73
+ };
74
+ number_of_payment_attempts: number;
75
+ tried_psps: string[];
76
+ rejected_transactions: string[];
77
+ routing_step: number;
78
+ route_length: number;
79
+ last_status: string;
80
+ ip_address: string;
81
+ is_dynamic_routing: boolean;
82
+ is_route_finished: boolean;
83
+ business: number;
84
+ payment: number;
85
+ };
86
+ currency: {
87
+ id: number;
88
+ name: string;
89
+ code: string;
90
+ symbol: string;
91
+ country: null | string;
92
+ };
93
+ payment_method?: null | {
94
+ id: number;
95
+ name: string;
96
+ display_name: string;
97
+ category: string;
98
+ is_apm: boolean;
99
+ };
100
+ issuing_country?: null | string;
101
+ }
@@ -4,9 +4,8 @@ import {
4
4
  CreatePaymentRequest,
5
5
  RegisterCustomerCardRequest,
6
6
  StartCheckoutRequest,
7
- TokensRequest,
8
7
  StartCheckoutFullRequest,
9
- StartCheckoutRequestWithCard
8
+ StartCheckoutRequestWithCard, TokensSkyflowRequest
10
9
  } from "../../src/types/requests";
11
10
  import {
12
11
  CreateOrderResponse,
@@ -556,14 +555,14 @@ export class StartCheckoutFullRequestClass implements StartCheckoutFullRequest {
556
555
  }
557
556
  }
558
557
 
559
- export class TokensRequestClass implements TokensRequest {
558
+ export class TokensRequestClass implements TokensSkyflowRequest {
560
559
  baseUrl!: string;
561
560
  apiKey!: string;
562
561
  vault_id!: string;
563
562
  vault_url!: string;
564
563
  data: { [key: string]: any } = {};
565
564
 
566
- get mockObject(): TokensRequest {
565
+ get mockObject(): TokensSkyflowRequest {
567
566
  return {
568
567
  baseUrl: "",
569
568
  apiKey: "",