@tonder.io/ionic-lite-sdk 0.0.42-beta.1 → 0.0.42-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.gitlab-ci.yml +28 -28
  2. package/README.md +532 -532
  3. package/dist/classes/BaseInlineCheckout.d.ts +1 -1
  4. package/dist/classes/liteCheckout.d.ts +1 -1
  5. package/dist/data/cardApi.d.ts +3 -3
  6. package/dist/index.js +1 -1
  7. package/dist/types/liteInlineCheckout.d.ts +1 -1
  8. package/jest.config.ts +14 -14
  9. package/package.json +41 -41
  10. package/rollup.config.js +16 -16
  11. package/src/classes/3dsHandler.ts +347 -347
  12. package/src/classes/BaseInlineCheckout.ts +424 -424
  13. package/src/classes/errorResponse.ts +16 -16
  14. package/src/classes/liteCheckout.ts +589 -591
  15. package/src/data/api.ts +20 -20
  16. package/src/data/businessApi.ts +18 -18
  17. package/src/data/cardApi.ts +91 -87
  18. package/src/data/checkoutApi.ts +84 -84
  19. package/src/data/customerApi.ts +31 -31
  20. package/src/data/openPayApi.ts +12 -12
  21. package/src/data/paymentMethodApi.ts +37 -37
  22. package/src/data/skyflowApi.ts +20 -20
  23. package/src/helpers/constants.ts +63 -63
  24. package/src/helpers/mercadopago.ts +15 -15
  25. package/src/helpers/skyflow.ts +91 -91
  26. package/src/helpers/utils.ts +120 -120
  27. package/src/helpers/validations.ts +55 -55
  28. package/src/index.ts +12 -12
  29. package/src/shared/catalog/paymentMethodsCatalog.ts +247 -247
  30. package/src/shared/constants/messages.ts +10 -10
  31. package/src/shared/constants/paymentMethodAPM.ts +63 -63
  32. package/src/shared/constants/tonderUrl.ts +8 -8
  33. package/src/types/card.ts +35 -35
  34. package/src/types/checkout.ts +123 -123
  35. package/src/types/commons.ts +143 -143
  36. package/src/types/customer.ts +22 -22
  37. package/src/types/liteInlineCheckout.ts +216 -216
  38. package/src/types/paymentMethod.ts +23 -23
  39. package/src/types/requests.ts +114 -114
  40. package/src/types/responses.ts +192 -192
  41. package/src/types/skyflow.ts +17 -17
  42. package/src/types/transaction.ts +101 -101
  43. package/src/types/validations.d.ts +11 -11
  44. package/tests/classes/liteCheckout.test.ts +57 -57
  45. package/tests/methods/createOrder.test.ts +141 -141
  46. package/tests/methods/createPayment.test.ts +121 -121
  47. package/tests/methods/customerRegister.test.ts +118 -118
  48. package/tests/methods/getBusiness.test.ts +114 -114
  49. package/tests/methods/getCustomerCards.test.ts +112 -112
  50. package/tests/methods/registerCustomerCard.test.ts +117 -117
  51. package/tests/methods/startCheckoutRouter.test.ts +119 -119
  52. package/tests/methods/startCheckoutRouterFull.test.ts +138 -138
  53. package/tests/utils/defaultMock.ts +21 -21
  54. package/tests/utils/mockClasses.ts +659 -659
  55. package/tsconfig.json +18 -18
@@ -1,216 +1,216 @@
1
- import { IConfigureCheckout, IInlineCheckoutBaseOptions } from "./commons";
2
- import {
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,
20
- } from "./requests";
21
- import {
22
- CreateOrderResponse,
23
- CreatePaymentResponse,
24
- CustomerRegisterResponse,
25
- GetBusinessResponse,
26
- RegisterCustomerCardResponse,
27
- StartCheckoutResponse,
28
- } from "./responses";
29
-
30
- export interface ILiteCheckout {
31
-
32
- /**
33
- * 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.
34
- * @param {import("./index").IConfigureCheckout} data - Configuration data including customer information and potentially other settings.
35
- * @returns {Promise<void>}.
36
- * @public
37
- */
38
- configureCheckout(data: IConfigureCheckout): void;
39
-
40
- /**
41
- * Initializes and prepares the checkout for use.
42
- * This method set up the initial environment.
43
- * @returns {Promise<void>} A promise that resolves when the checkout has been initialized.
44
- * @throws {Error} If there's any problem during the checkout initialization.
45
- * @public
46
- */
47
- injectCheckout(): Promise<void>;
48
-
49
- /**
50
- * Processes a payment.
51
- * @param {import("./index").IProcessPaymentRequest} data - Payment data including customer, cart, and other relevant information.
52
- * @returns {Promise<import("./index").IStartCheckoutResponse>} A promise that resolves with the payment response or 3DS redirect or is rejected with an error.
53
- *
54
- * @throws {Error} Throws an error if the checkout process fails. The error object contains
55
- * additional `details` property with the response from the server if available.
56
- * @property {import("./index").IStartCheckoutErrorResponse} error.details - The response body from the server when an error occurs.
57
- *
58
- * @public
59
- */
60
- payment(data: IProcessPaymentRequest): Promise<IStartCheckoutResponse>;
61
-
62
- /**
63
- * Verifies the 3DS transaction status.
64
- * @returns {Promise<import("./index").ITransaction | import("./index").IStartCheckoutResponse | void>} The result of the 3DS verification and checkout resumption.
65
- * @public
66
- */
67
- verify3dsTransaction(): Promise<ITransaction | IStartCheckoutResponse | void>;
68
-
69
- /**
70
- * Retrieves the list of cards associated with a customer.
71
- * @returns {Promise<import("./index").ICustomerCardsResponse>} A promise that resolves with the customer's card data.
72
- *
73
- * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
74
- *
75
- * @public
76
- */
77
- getCustomerCards(): Promise<ICustomerCardsResponse>;
78
-
79
- /**
80
- * Saves a card to a customer's account. This method can be used to add a new card
81
- * or update an existing one.
82
- * @param {import("./index").ISaveCardRequest} card - The card information to be saved.
83
- * @returns {Promise<import("./index").ISaveCardResponse>} A promise that resolves with the saved card data.
84
- *
85
- * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
86
- *
87
- * @public
88
- */
89
- saveCustomerCard(secureToken: string, card: ISaveCardRequest): Promise<ISaveCardResponse>;
90
-
91
- /**
92
- * Removes a card from a customer's account.
93
- * @param {string} skyflowId - The unique identifier of the card to be deleted.
94
- * @returns {Promise<string>} A promise that resolves when the card is successfully deleted.
95
- *
96
- * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
97
- *
98
- * @public
99
- */
100
- removeCustomerCard(skyflowId: string): Promise<string>;
101
-
102
- /**
103
- * Retrieves the list of available Alternative Payment Methods (APMs).
104
- * @returns {Promise<import("./index").IPaymentMethod[]>} A promise that resolves with the list of APMs.
105
- *
106
- * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
107
- *
108
- * @public
109
- */
110
- getCustomerPaymentMethods(): Promise<IPaymentMethod[]>;
111
-
112
- /**
113
- * @deprecated This method is deprecated and will be removed in a future release.
114
- * It is no longer necessary to use this method, now automatically handled
115
- * during the payment process or when using card management methods.
116
- *
117
- * Retrieves the business information.
118
- * @returns {Promise<import("./index").GetBusinessResponse>} A promise that resolves with the business information.
119
- *
120
- * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
121
- *
122
- * @public
123
- */
124
- getBusiness(): Promise<GetBusinessResponse>;
125
-
126
- /**
127
- * @deprecated This method is deprecated and will be removed in a future release.
128
- * It is no longer necessary to use this method as customer registration is now automatically handled
129
- * during the payment process or when using card management methods.
130
- */
131
- customerRegister(
132
- email: string,
133
- ): Promise<CustomerRegisterResponse | ErrorResponse>;
134
-
135
- /**
136
- * @deprecated This method is deprecated and will be removed in a future release.
137
- * It is no longer necessary to use this method as order creation is now automatically
138
- * handled when making a payment through the `payment` function.
139
- */
140
- createOrder(
141
- orderItems: CreateOrderRequest,
142
- ): Promise<CreateOrderResponse | ErrorResponse>;
143
-
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
- /**
154
- * @deprecated This method is deprecated and will be removed in a future release.
155
- * Use the {@link payment} method
156
- */
157
- startCheckoutRouter(
158
- routerData: StartCheckoutRequest | StartCheckoutIdRequest,
159
- ): Promise<StartCheckoutResponse | ErrorResponse | undefined>;
160
-
161
- /**
162
- * @deprecated This method is deprecated and will be removed in a future release.
163
- * Use the {@link payment} method
164
- */
165
- startCheckoutRouterFull(
166
- routerFullData: StartCheckoutFullRequest,
167
- ): Promise<StartCheckoutResponse | ErrorResponse | undefined>;
168
-
169
- /**
170
- * @deprecated This method is deprecated and will be removed in a future release.
171
- * Use the {@link saveCustomerCard} method
172
- */
173
- registerCustomerCard(
174
- secureToken: string,
175
- customerToken: string,
176
- data: RegisterCustomerCardRequest,
177
- ): Promise<RegisterCustomerCardResponse | ErrorResponse>;
178
-
179
- /**
180
- * @deprecated This method is deprecated and will be removed in a future release.
181
- * Use the {@link removeCustomerCard} method
182
- */
183
- deleteCustomerCard(
184
- customerToken: string,
185
- skyflowId: string,
186
- ): Promise<Boolean | ErrorResponse>;
187
-
188
- /**
189
- * @deprecated This method is deprecated and will be removed in a future release.
190
- * Use the {@link getCustomerPaymentMethods} method
191
- */
192
- getActiveAPMs(): Promise<APM[]>;
193
-
194
- /**
195
- * @deprecated This method is deprecated and will be removed in a future release.
196
- * It is no longer necessary to use this method as card registration or as checkout is now automatically handled
197
- * during the payment process or when using card management methods.
198
- */
199
- getSkyflowTokens({
200
- vault_id,
201
- vault_url,
202
- data,
203
- }: TokensRequest): Promise<any | ErrorResponse>;
204
-
205
- /**
206
- * @deprecated This method is deprecated and will be removed in a future release.
207
- * It is no longer necessary to use this method is now automatically handled
208
- * during the payment process.
209
- */
210
- getOpenpayDeviceSessionID(
211
- merchant_id: string,
212
- public_key: string,
213
- is_sandbox: boolean,
214
- ): Promise<string | ErrorResponse>;
215
- }
216
-
1
+ import { IConfigureCheckout, IInlineCheckoutBaseOptions } from "./commons";
2
+ import {
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,
20
+ } from "./requests";
21
+ import {
22
+ CreateOrderResponse,
23
+ CreatePaymentResponse,
24
+ CustomerRegisterResponse,
25
+ GetBusinessResponse,
26
+ RegisterCustomerCardResponse,
27
+ StartCheckoutResponse,
28
+ } from "./responses";
29
+
30
+ export interface ILiteCheckout {
31
+
32
+ /**
33
+ * 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.
34
+ * @param {import("./index").IConfigureCheckout} data - Configuration data including customer information and potentially other settings.
35
+ * @returns {Promise<void>}.
36
+ * @public
37
+ */
38
+ configureCheckout(data: IConfigureCheckout): void;
39
+
40
+ /**
41
+ * Initializes and prepares the checkout for use.
42
+ * This method set up the initial environment.
43
+ * @returns {Promise<void>} A promise that resolves when the checkout has been initialized.
44
+ * @throws {Error} If there's any problem during the checkout initialization.
45
+ * @public
46
+ */
47
+ injectCheckout(): Promise<void>;
48
+
49
+ /**
50
+ * Processes a payment.
51
+ * @param {import("./index").IProcessPaymentRequest} data - Payment data including customer, cart, and other relevant information.
52
+ * @returns {Promise<import("./index").IStartCheckoutResponse>} A promise that resolves with the payment response or 3DS redirect or is rejected with an error.
53
+ *
54
+ * @throws {Error} Throws an error if the checkout process fails. The error object contains
55
+ * additional `details` property with the response from the server if available.
56
+ * @property {import("./index").IStartCheckoutErrorResponse} error.details - The response body from the server when an error occurs.
57
+ *
58
+ * @public
59
+ */
60
+ payment(data: IProcessPaymentRequest): Promise<IStartCheckoutResponse>;
61
+
62
+ /**
63
+ * Verifies the 3DS transaction status.
64
+ * @returns {Promise<import("./index").ITransaction | import("./index").IStartCheckoutResponse | void>} The result of the 3DS verification and checkout resumption.
65
+ * @public
66
+ */
67
+ verify3dsTransaction(): Promise<ITransaction | IStartCheckoutResponse | void>;
68
+
69
+ /**
70
+ * Retrieves the list of cards associated with a customer.
71
+ * @returns {Promise<import("./index").ICustomerCardsResponse>} A promise that resolves with the customer's card data.
72
+ *
73
+ * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
74
+ *
75
+ * @public
76
+ */
77
+ getCustomerCards(): Promise<ICustomerCardsResponse>;
78
+
79
+ /**
80
+ * Saves a card to a customer's account. This method can be used to add a new card
81
+ * or update an existing one.
82
+ * @param {import("./index").ISaveCardRequest} card - The card information to be saved.
83
+ * @returns {Promise<import("./index").ISaveCardResponse>} A promise that resolves with the saved card data.
84
+ *
85
+ * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
86
+ *
87
+ * @public
88
+ */
89
+ saveCustomerCard(card: ISaveCardRequest): Promise<ISaveCardResponse>;
90
+
91
+ /**
92
+ * Removes a card from a customer's account.
93
+ * @param {string} skyflowId - The unique identifier of the card to be deleted.
94
+ * @returns {Promise<string>} A promise that resolves when the card is successfully deleted.
95
+ *
96
+ * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
97
+ *
98
+ * @public
99
+ */
100
+ removeCustomerCard(skyflowId: string): Promise<string>;
101
+
102
+ /**
103
+ * Retrieves the list of available Alternative Payment Methods (APMs).
104
+ * @returns {Promise<import("./index").IPaymentMethod[]>} A promise that resolves with the list of APMs.
105
+ *
106
+ * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
107
+ *
108
+ * @public
109
+ */
110
+ getCustomerPaymentMethods(): Promise<IPaymentMethod[]>;
111
+
112
+ /**
113
+ * @deprecated This method is deprecated and will be removed in a future release.
114
+ * It is no longer necessary to use this method, now automatically handled
115
+ * during the payment process or when using card management methods.
116
+ *
117
+ * Retrieves the business information.
118
+ * @returns {Promise<import("./index").GetBusinessResponse>} A promise that resolves with the business information.
119
+ *
120
+ * @throws {import("./index").IPublicError} Throws an error object if the operation fails.
121
+ *
122
+ * @public
123
+ */
124
+ getBusiness(): Promise<GetBusinessResponse>;
125
+
126
+ /**
127
+ * @deprecated This method is deprecated and will be removed in a future release.
128
+ * It is no longer necessary to use this method as customer registration is now automatically handled
129
+ * during the payment process or when using card management methods.
130
+ */
131
+ customerRegister(
132
+ email: string,
133
+ ): Promise<CustomerRegisterResponse | ErrorResponse>;
134
+
135
+ /**
136
+ * @deprecated This method is deprecated and will be removed in a future release.
137
+ * It is no longer necessary to use this method as order creation is now automatically
138
+ * handled when making a payment through the `payment` function.
139
+ */
140
+ createOrder(
141
+ orderItems: CreateOrderRequest,
142
+ ): Promise<CreateOrderResponse | ErrorResponse>;
143
+
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
+ /**
154
+ * @deprecated This method is deprecated and will be removed in a future release.
155
+ * Use the {@link payment} method
156
+ */
157
+ startCheckoutRouter(
158
+ routerData: StartCheckoutRequest | StartCheckoutIdRequest,
159
+ ): Promise<StartCheckoutResponse | ErrorResponse | undefined>;
160
+
161
+ /**
162
+ * @deprecated This method is deprecated and will be removed in a future release.
163
+ * Use the {@link payment} method
164
+ */
165
+ startCheckoutRouterFull(
166
+ routerFullData: StartCheckoutFullRequest,
167
+ ): Promise<StartCheckoutResponse | ErrorResponse | undefined>;
168
+
169
+ /**
170
+ * @deprecated This method is deprecated and will be removed in a future release.
171
+ * Use the {@link saveCustomerCard} method
172
+ */
173
+ registerCustomerCard(
174
+ secureToken: string,
175
+ customerToken: string,
176
+ data: RegisterCustomerCardRequest,
177
+ ): Promise<RegisterCustomerCardResponse | ErrorResponse>;
178
+
179
+ /**
180
+ * @deprecated This method is deprecated and will be removed in a future release.
181
+ * Use the {@link removeCustomerCard} method
182
+ */
183
+ deleteCustomerCard(
184
+ customerToken: string,
185
+ skyflowId: string,
186
+ ): Promise<Boolean | ErrorResponse>;
187
+
188
+ /**
189
+ * @deprecated This method is deprecated and will be removed in a future release.
190
+ * Use the {@link getCustomerPaymentMethods} method
191
+ */
192
+ getActiveAPMs(): Promise<APM[]>;
193
+
194
+ /**
195
+ * @deprecated This method is deprecated and will be removed in a future release.
196
+ * It is no longer necessary to use this method as card registration or as checkout is now automatically handled
197
+ * during the payment process or when using card management methods.
198
+ */
199
+ getSkyflowTokens({
200
+ vault_id,
201
+ vault_url,
202
+ data,
203
+ }: TokensRequest): Promise<any | ErrorResponse>;
204
+
205
+ /**
206
+ * @deprecated This method is deprecated and will be removed in a future release.
207
+ * It is no longer necessary to use this method is now automatically handled
208
+ * during the payment process.
209
+ */
210
+ getOpenpayDeviceSessionID(
211
+ merchant_id: string,
212
+ public_key: string,
213
+ is_sandbox: boolean,
214
+ ): Promise<string | ErrorResponse>;
215
+ }
216
+
@@ -1,24 +1,24 @@
1
- export interface IPaymentMethodResponse {
2
- count: number;
3
- next: string | null;
4
- previous: string | null;
5
- results: ITonderPaymentMethod[];
6
- }
7
-
8
- export interface ITonderPaymentMethod {
9
- pk: string;
10
- payment_method: string;
11
- priority: number;
12
- category: string;
13
- unavailable_countries: string[];
14
- status: string;
15
- }
16
-
17
- export interface IPaymentMethod {
18
- id: string;
19
- payment_method: string;
20
- priority: number;
21
- category: string;
22
- icon: string;
23
- label: string;
1
+ export interface IPaymentMethodResponse {
2
+ count: number;
3
+ next: string | null;
4
+ previous: string | null;
5
+ results: ITonderPaymentMethod[];
6
+ }
7
+
8
+ export interface ITonderPaymentMethod {
9
+ pk: string;
10
+ payment_method: string;
11
+ priority: number;
12
+ category: string;
13
+ unavailable_countries: string[];
14
+ status: string;
15
+ }
16
+
17
+ export interface IPaymentMethod {
18
+ id: string;
19
+ payment_method: string;
20
+ priority: number;
21
+ category: string;
22
+ icon: string;
23
+ label: string;
24
24
  }