@tonder.io/ionic-lite-sdk 0.0.35-beta.8 → 0.0.37-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 (83) hide show
  1. package/.gitlab-ci.yml +28 -28
  2. package/README.md +532 -202
  3. package/dist/classes/BaseInlineCheckout.d.ts +21 -19
  4. package/dist/classes/errorResponse.d.ts +1 -1
  5. package/dist/classes/liteCheckout.d.ts +15 -43
  6. package/dist/data/api.d.ts +1 -1
  7. package/dist/data/businessApi.d.ts +1 -1
  8. package/dist/data/cardApi.d.ts +1 -1
  9. package/dist/data/checkoutApi.d.ts +2 -1
  10. package/dist/data/customerApi.d.ts +1 -1
  11. package/dist/data/paymentMethodApi.d.ts +2 -2
  12. package/dist/helpers/skyflow.d.ts +1 -1
  13. package/dist/index.d.ts +2 -1
  14. package/dist/index.js +1 -1
  15. package/dist/types/card.d.ts +1 -0
  16. package/dist/types/checkout.d.ts +7 -1
  17. package/dist/types/commons.d.ts +8 -3
  18. package/dist/types/customer.d.ts +10 -0
  19. package/{src → dist}/types/liteInlineCheckout.d.ts +33 -73
  20. package/dist/types/responses.d.ts +3 -0
  21. package/jest.config.ts +14 -14
  22. package/package.json +41 -38
  23. package/rollup.config.js +16 -16
  24. package/src/classes/3dsHandler.ts +237 -237
  25. package/src/classes/BaseInlineCheckout.ts +385 -356
  26. package/src/classes/errorResponse.ts +16 -16
  27. package/src/classes/liteCheckout.ts +588 -598
  28. package/src/data/api.ts +20 -20
  29. package/src/data/businessApi.ts +18 -18
  30. package/src/data/cardApi.ts +85 -89
  31. package/src/data/checkoutApi.ts +84 -87
  32. package/src/data/customerApi.ts +31 -31
  33. package/src/data/openPayApi.ts +12 -12
  34. package/src/data/paymentMethodApi.ts +37 -37
  35. package/src/data/skyflowApi.ts +20 -20
  36. package/src/helpers/constants.ts +63 -63
  37. package/src/helpers/mercadopago.ts +15 -15
  38. package/src/helpers/skyflow.ts +91 -91
  39. package/src/helpers/utils.ts +120 -120
  40. package/src/helpers/validations.ts +55 -55
  41. package/src/index.ts +12 -10
  42. package/src/shared/catalog/paymentMethodsCatalog.ts +247 -247
  43. package/src/shared/constants/messages.ts +10 -10
  44. package/src/shared/constants/paymentMethodAPM.ts +63 -63
  45. package/src/shared/constants/tonderUrl.ts +8 -8
  46. package/src/types/card.ts +35 -34
  47. package/src/types/checkout.ts +123 -117
  48. package/src/types/commons.ts +130 -125
  49. package/src/types/customer.ts +22 -12
  50. package/src/types/liteInlineCheckout.ts +216 -0
  51. package/src/types/paymentMethod.ts +23 -23
  52. package/src/types/requests.ts +114 -114
  53. package/src/types/responses.ts +193 -189
  54. package/src/types/skyflow.ts +17 -17
  55. package/src/types/transaction.ts +101 -101
  56. package/src/types/validations.d.ts +11 -11
  57. package/tests/classes/liteCheckout.test.ts +57 -57
  58. package/tests/methods/createOrder.test.ts +141 -142
  59. package/tests/methods/createPayment.test.ts +121 -122
  60. package/tests/methods/customerRegister.test.ts +118 -119
  61. package/tests/methods/getBusiness.test.ts +114 -115
  62. package/tests/methods/getCustomerCards.test.ts +112 -113
  63. package/tests/methods/registerCustomerCard.test.ts +117 -117
  64. package/tests/methods/startCheckoutRouter.test.ts +119 -119
  65. package/tests/methods/startCheckoutRouterFull.test.ts +138 -138
  66. package/tests/utils/defaultMock.ts +21 -21
  67. package/tests/utils/mockClasses.ts +659 -659
  68. package/tsconfig.json +18 -18
  69. package/types/classes/liteCheckout.d.ts +29 -0
  70. package/types/classes/liteCheckout.js +225 -0
  71. package/types/classes/liteCheckout.js.map +1 -0
  72. package/types/helpers/utils.d.ts +3 -0
  73. package/types/helpers/utils.js +27 -0
  74. package/types/helpers/utils.js.map +1 -0
  75. package/types/index.d.ts +2 -0
  76. package/types/index.js +6 -0
  77. package/types/index.js.map +1 -0
  78. package/.idea/aws.xml +0 -17
  79. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  80. package/.idea/prettier.xml +0 -6
  81. package/.idea/vcs.xml +0 -6
  82. package/.idea/workspace.xml +0 -133
  83. package/src/types/index.d.ts +0 -10
@@ -1,125 +1,130 @@
1
- import {ICustomer} from "./customer";
2
-
3
- export type Business = {
4
- business: {
5
- pk: number;
6
- name: string;
7
- categories: {
8
- pk: number;
9
- name: string;
10
- }[];
11
- web: string;
12
- logo: string;
13
- full_logo_url: string;
14
- background_color: string;
15
- primary_color: string;
16
- checkout_mode: boolean;
17
- textCheckoutColor: string;
18
- textDetailsColor: string;
19
- checkout_logo: string;
20
- };
21
- openpay_keys: {
22
- merchant_id: string;
23
- public_key: string;
24
- };
25
- fintoc_keys: {
26
- public_key: string;
27
- };
28
- mercado_pago: {
29
- active: boolean;
30
- };
31
- vault_id: string;
32
- vault_url: string;
33
- reference: number;
34
- is_installments_available: boolean;
35
- };
36
-
37
- export type Customer = {
38
- firstName: string;
39
- lastName: string;
40
- country: string;
41
- street: string;
42
- city: string;
43
- state: string;
44
- postCode: string;
45
- email: string;
46
- phone: string;
47
- };
48
-
49
- export type OrderItem = {
50
- description: string;
51
- quantity: number;
52
- price_unit: number;
53
- discount: number;
54
- taxes: number;
55
- product_reference: number;
56
- name: string;
57
- amount_total: number;
58
- };
59
-
60
- export type PaymentData = {
61
- customer: Customer;
62
- currency: string;
63
- cart: {
64
- total: string | number;
65
- items: OrderItem[];
66
- };
67
- };
68
-
69
- export type TonderAPM = {
70
- pk: string;
71
- payment_method: string;
72
- priority: number;
73
- category: string;
74
- unavailable_countries: string[];
75
- status: string;
76
- }
77
-
78
- export type APM = {
79
- id: string;
80
- payment_method: string;
81
- priority: number;
82
- category: string;
83
- icon: string;
84
- label: string;
85
- }
86
-
87
-
88
- export interface IConfigureCheckout {
89
- customer: ICustomer;
90
- }
91
-
92
- export interface IInlineCheckoutBaseOptions {
93
- mode?: "production" | "sandbox" | "stage" | "development";
94
- /**
95
- * @deprecated This property is deprecated and will be removed in a future release.
96
- * `baseUrlTonder` is no longer required.
97
- */
98
- baseUrlTonder?: string;
99
- /**
100
- * @deprecated This property is deprecated and will be removed in a future release.
101
- * Use `apiKey` instead, as `apiKeyTonder` is no longer required.
102
- */
103
- apiKeyTonder?: string;
104
- /**
105
- * @deprecated This property is deprecated and will be removed in a future release.
106
- * `signal` is no longer required.
107
- */
108
- signal?: AbortSignal;
109
- apiKey: string;
110
- returnUrl: string;
111
- callBack?: (response: any) => void;
112
- }
113
- export interface IApiError {
114
- code: string;
115
- body: Record<string, string> | string;
116
- name: string;
117
- message: string;
118
- }
119
-
120
- export interface IPublicError {
121
- status: string;
122
- code: number;
123
- message: string;
124
- detail: Record<string, any> | string;
125
- }
1
+ import { ICustomer } from "./customer";
2
+ import {IStartCheckoutResponse} from "./checkout";
3
+
4
+ export type Business = {
5
+ business: {
6
+ pk: number;
7
+ name: string;
8
+ categories: {
9
+ pk: number;
10
+ name: string;
11
+ }[];
12
+ web: string;
13
+ logo: string;
14
+ full_logo_url: string;
15
+ background_color: string;
16
+ primary_color: string;
17
+ checkout_mode: boolean;
18
+ textCheckoutColor: string;
19
+ textDetailsColor: string;
20
+ checkout_logo: string;
21
+ };
22
+ openpay_keys: {
23
+ merchant_id: string;
24
+ public_key: string;
25
+ };
26
+ fintoc_keys: {
27
+ public_key: string;
28
+ };
29
+ mercado_pago: {
30
+ active: boolean;
31
+ };
32
+ vault_id: string;
33
+ vault_url: string;
34
+ reference: number;
35
+ is_installments_available: boolean;
36
+ };
37
+
38
+ export type Customer = {
39
+ firstName: string;
40
+ lastName: string;
41
+ country: string;
42
+ street: string;
43
+ city: string;
44
+ state: string;
45
+ postCode: string;
46
+ email: string;
47
+ phone: string;
48
+ };
49
+
50
+ export type OrderItem = {
51
+ description: string;
52
+ quantity: number;
53
+ price_unit: number;
54
+ discount: number;
55
+ taxes: number;
56
+ product_reference: number;
57
+ name: string;
58
+ amount_total: number;
59
+ };
60
+
61
+ export type PaymentData = {
62
+ customer: Customer;
63
+ currency: string;
64
+ cart: {
65
+ total: string | number;
66
+ items: OrderItem[];
67
+ };
68
+ };
69
+
70
+ export type TonderAPM = {
71
+ pk: string;
72
+ payment_method: string;
73
+ priority: number;
74
+ category: string;
75
+ unavailable_countries: string[];
76
+ status: string;
77
+ };
78
+
79
+ export type APM = {
80
+ id: string;
81
+ payment_method: string;
82
+ priority: number;
83
+ category: string;
84
+ icon: string;
85
+ label: string;
86
+ };
87
+
88
+ export interface IConfigureCheckout {
89
+ customer: ICustomer | { email: string };
90
+ }
91
+
92
+ export interface IInlineCheckoutBaseOptions {
93
+ mode?: "production" | "sandbox" | "stage" | "development";
94
+ /**
95
+ * @deprecated This property is deprecated and will be removed in a future release.
96
+ * `baseUrlTonder` is no longer required.
97
+ */
98
+ baseUrlTonder?: string;
99
+ /**
100
+ * @deprecated This property is deprecated and will be removed in a future release.
101
+ * Use `apiKey` instead, as `apiKeyTonder` is no longer required.
102
+ */
103
+ apiKeyTonder?: string;
104
+ /**
105
+ * @deprecated This property is deprecated and will be removed in a future release.
106
+ * `signal` is no longer required.
107
+ */
108
+ signal?: AbortSignal;
109
+ apiKey: string;
110
+ returnUrl?: string;
111
+ callBack?: (response: IStartCheckoutResponse | Record<string, any>) => void;
112
+ }
113
+
114
+ export interface IInlineLiteCheckoutOptions
115
+ extends IInlineCheckoutBaseOptions {}
116
+
117
+
118
+ export interface IApiError {
119
+ code: string;
120
+ body: Record<string, string> | string;
121
+ name: string;
122
+ message: string;
123
+ }
124
+
125
+ export interface IPublicError {
126
+ status: string;
127
+ code: number;
128
+ message: string;
129
+ detail: Record<string, any> | string;
130
+ }
@@ -1,12 +1,22 @@
1
- export type ICustomer = {
2
- firstName: string;
3
- lastName: string;
4
- country?: string;
5
- street?: string;
6
- city?: string;
7
- state?: string;
8
- postCode?: string;
9
- email: string;
10
- phone?: string;
11
- address?: string;
12
- };
1
+ export type ICustomer = {
2
+ /**
3
+ * @deprecated This property is deprecated and will be removed in a future release.
4
+ * Use `firstName` instead, as `name` is no longer required.
5
+ */
6
+ name?: string;
7
+ /**
8
+ * @deprecated This property is deprecated and will be removed in a future release.
9
+ * Use `lastName` instead, as `lastname` is no longer required.
10
+ */
11
+ lastname?: string;
12
+ firstName: string;
13
+ lastName: string;
14
+ country?: string;
15
+ street?: string;
16
+ city?: string;
17
+ state?: string;
18
+ postCode?: string;
19
+ email: string;
20
+ phone?: string;
21
+ address?: string;
22
+ };
@@ -0,0 +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(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
  }