@tonder.io/ionic-lite-sdk 0.0.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 (36) hide show
  1. package/.gitlab-ci.yml +29 -0
  2. package/README.md +496 -0
  3. package/dist/classes/errorResponse.d.ts +9 -0
  4. package/dist/classes/liteCheckout.d.ts +34 -0
  5. package/dist/helpers/utils.d.ts +3 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +1 -0
  8. package/dist/types/commons.d.ts +58 -0
  9. package/dist/types/requests.d.ts +55 -0
  10. package/dist/types/responses.d.ts +177 -0
  11. package/dist/types/skyflow.d.ts +17 -0
  12. package/jest.config.ts +15 -0
  13. package/package.json +34 -0
  14. package/rollup.config.js +17 -0
  15. package/src/classes/errorResponse.ts +17 -0
  16. package/src/classes/liteCheckout.ts +301 -0
  17. package/src/helpers/utils.ts +37 -0
  18. package/src/index.ts +5 -0
  19. package/src/types/commons.ts +61 -0
  20. package/src/types/requests.ts +61 -0
  21. package/src/types/responses.ts +186 -0
  22. package/src/types/skyflow.ts +17 -0
  23. package/tests/classes/liteCheckout.test.ts +57 -0
  24. package/tests/methods/createOrder.test.ts +106 -0
  25. package/tests/methods/createPayment.test.ts +109 -0
  26. package/tests/methods/customerRegister.test.ts +106 -0
  27. package/tests/methods/getBusiness.test.ts +102 -0
  28. package/tests/methods/getCustomerCards.test.ts +105 -0
  29. package/tests/methods/getOpenpayDeviceSessionID.test.ts +95 -0
  30. package/tests/methods/getSkyflowToken.test.ts +137 -0
  31. package/tests/methods/getVaultToken.test.ts +107 -0
  32. package/tests/methods/registerCustomerCard.test.ts +105 -0
  33. package/tests/methods/startCheckoutRouter.test.ts +107 -0
  34. package/tests/utils/defaultMock.ts +21 -0
  35. package/tests/utils/mockClasses.ts +540 -0
  36. package/tsconfig.json +19 -0
@@ -0,0 +1,177 @@
1
+ import { Business } from "./commons";
2
+ export interface IErrorResponse extends Error {
3
+ code?: string;
4
+ body?: string;
5
+ }
6
+ export interface GetBusinessResponse extends Business {
7
+ }
8
+ export type GetVaultTokenResponse = {
9
+ token: string;
10
+ };
11
+ export type CustomerRegisterResponse = {
12
+ id: number | string;
13
+ email: string;
14
+ auth_token: string;
15
+ };
16
+ export type CreateOrderResponse = {
17
+ id: number | string;
18
+ created: string;
19
+ amount: string;
20
+ status: string;
21
+ payment_method?: string;
22
+ reference?: string;
23
+ is_oneclick: boolean;
24
+ items: {
25
+ description: string;
26
+ product_reference: string;
27
+ quantity: string;
28
+ price_unit: string;
29
+ discount: string;
30
+ taxes: string;
31
+ amount_total: string;
32
+ }[];
33
+ billing_address?: string;
34
+ shipping_address?: string;
35
+ client: {
36
+ email: string;
37
+ name: string;
38
+ first_name: string;
39
+ last_name: string;
40
+ client_profile: {
41
+ gender: string;
42
+ date_birth?: string;
43
+ terms: boolean;
44
+ phone: string;
45
+ };
46
+ };
47
+ };
48
+ export type CreatePaymentResponse = {
49
+ pk: number | string;
50
+ order?: string;
51
+ amount: string;
52
+ status: string;
53
+ date: string;
54
+ paid_date?: string;
55
+ shipping_address: {
56
+ street: string;
57
+ number: string;
58
+ suburb: string;
59
+ city: {
60
+ name: string;
61
+ };
62
+ state: {
63
+ name: string;
64
+ country: {
65
+ name: string;
66
+ };
67
+ };
68
+ zip_code: string;
69
+ };
70
+ shipping_address_id?: string;
71
+ billing_address: {
72
+ street: string;
73
+ number: string;
74
+ suburb: string;
75
+ city: {
76
+ name: string;
77
+ };
78
+ state: {
79
+ name: string;
80
+ country: {
81
+ name: string;
82
+ };
83
+ };
84
+ zip_code: string;
85
+ };
86
+ billing_address_id?: string;
87
+ client?: string;
88
+ customer_order_reference?: string;
89
+ };
90
+ export type StartCheckoutResponse = {
91
+ status: number;
92
+ message: string;
93
+ psp_response: {
94
+ id: string;
95
+ authorization: number;
96
+ operation_type: string;
97
+ transaction_type: string;
98
+ status: string;
99
+ conciliated: boolean;
100
+ creation_date: string;
101
+ operation_date: string;
102
+ description: string;
103
+ error_message?: string;
104
+ order_id?: string;
105
+ card: {
106
+ type: string;
107
+ brand: string;
108
+ address?: string;
109
+ card_number: string;
110
+ holder_name: string;
111
+ expiration_year: string;
112
+ expiration_month: string;
113
+ allows_charges: boolean;
114
+ allows_payouts: boolean;
115
+ bank_name: string;
116
+ points_type: string;
117
+ points_card: boolean;
118
+ bank_code: number;
119
+ };
120
+ customer_id: string;
121
+ gateway_card_present: string;
122
+ amount: number;
123
+ fee: {
124
+ amount: number;
125
+ tax: number;
126
+ currency: string;
127
+ };
128
+ payment_method: {
129
+ type: string;
130
+ url: string;
131
+ };
132
+ currency: string;
133
+ method: string;
134
+ object: string;
135
+ };
136
+ transaction_status: string;
137
+ transaction_id: number;
138
+ payment_id: number;
139
+ provider: string;
140
+ next_action: {
141
+ redirect_to_url: {
142
+ url: string;
143
+ return_url: string;
144
+ verify_transaction_status_url: string;
145
+ };
146
+ };
147
+ actions: {
148
+ name: string;
149
+ url: string;
150
+ method: string;
151
+ }[];
152
+ };
153
+ export type TokensResponse = {
154
+ vaultID: string;
155
+ responses: {
156
+ [key: string]: string;
157
+ }[];
158
+ };
159
+ export type GetCustomerCardsResponse = {
160
+ user_id: number;
161
+ cards: {
162
+ records: {
163
+ fields: {
164
+ card_number: string;
165
+ cardholder_name: string;
166
+ cvv: string;
167
+ expiration_month: string;
168
+ expiration_year: string;
169
+ skyflow_id: string;
170
+ };
171
+ }[];
172
+ };
173
+ };
174
+ export type RegisterCustomerCardResponse = {
175
+ skyflow_id: string;
176
+ user_id: number;
177
+ };
@@ -0,0 +1,17 @@
1
+ export type SkyflowRecord = {
2
+ method: string;
3
+ quorum?: boolean;
4
+ tableName: string;
5
+ fields?: {
6
+ [key: string]: string;
7
+ };
8
+ ID?: string;
9
+ tokenization?: boolean;
10
+ batchID?: string;
11
+ redaction?: "DEFAULT" | "REDACTED" | "MASKED" | "PLAIN_TEXT";
12
+ downloadURL?: boolean;
13
+ upsert?: string;
14
+ tokens?: {
15
+ [key: string]: string;
16
+ };
17
+ };
package/jest.config.ts ADDED
@@ -0,0 +1,15 @@
1
+ import type { JestConfigWithTsJest } from 'ts-jest'
2
+
3
+ const jestConfig: JestConfigWithTsJest = {
4
+ testEnvironment: "jsdom",
5
+ preset: 'ts-jest',
6
+ transform: {
7
+ '^.+\\.tsx?$': [
8
+ 'ts-jest',
9
+ {
10
+ },
11
+ ],
12
+ },
13
+ }
14
+
15
+ export default jestConfig
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@tonder.io/ionic-lite-sdk",
3
+ "version": "0.0.3",
4
+ "description": "Tonder ionic lite SDK",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc -noEmit && rollup --config",
9
+ "test": "jest",
10
+ "ts-coverage": "typescript-coverage-report"
11
+ },
12
+ "author": "",
13
+ "license": "ISC",
14
+ "dependencies": {
15
+ "skyflow-js": "^1.34.1",
16
+ "ts-node": "^10.9.2"
17
+ },
18
+ "devDependencies": {
19
+ "@rollup/plugin-terser": "^0.4.4",
20
+ "@rollup/plugin-typescript": "11.1.6",
21
+ "@types/crypto-js": "^4.2.2",
22
+ "@types/jest": "^29.5.11",
23
+ "@types/node": "^20.11.5",
24
+ "jest": "^29.7.0",
25
+ "jest-environment-jsdom": "^29.7.0",
26
+ "jsdom": "^24.0.0",
27
+ "rollup": "4.9.6",
28
+ "ts-jest": "^29.1.2",
29
+ "ts-loader": "^9.5.1",
30
+ "tslib": "^2.6.2",
31
+ "typescript": "^5.3.3",
32
+ "typescript-coverage-report": "^0.8.0"
33
+ }
34
+ }
@@ -0,0 +1,17 @@
1
+ const typescript = require('@rollup/plugin-typescript');
2
+ const terser = require('@rollup/plugin-terser');
3
+
4
+ module.exports = {
5
+ input: './src/index.ts',
6
+ output: {
7
+ dir: 'dist',
8
+ format: 'es',
9
+ plugins: [terser()]
10
+ },
11
+ plugins: [
12
+ typescript({
13
+ exclude: ["tests/**", "jest.config.ts"]
14
+ })
15
+ ],
16
+ external: ["skyflow-js", "crypto-js"]
17
+ };
@@ -0,0 +1,17 @@
1
+ import { IErrorResponse } from "../types/responses";
2
+
3
+ export class ErrorResponse implements IErrorResponse {
4
+ code?: string | undefined;
5
+ body?: string | undefined;
6
+ name!: string;
7
+ message!: string;
8
+ stack?: string | undefined;
9
+
10
+ constructor({ code, body, name, message, stack }: IErrorResponse) {
11
+ this.code = code;
12
+ this.body = body;
13
+ this.name = name;
14
+ this.message = message;
15
+ this.stack = stack;
16
+ }
17
+ }
@@ -0,0 +1,301 @@
1
+ import Skyflow from "skyflow-js";
2
+ import CollectContainer from "skyflow-js/types/core/external/collect/collect-container";
3
+ import CollectElement from "skyflow-js/types/core/external/collect/collect-element";
4
+ import { Business } from "../types/commons";
5
+ import { CreateOrderRequest, CreatePaymentRequest, RegisterCustomerCardRequest, StartCheckoutRequest, TokensRequest } from "../types/requests";
6
+ import { GetBusinessResponse, CustomerRegisterResponse, CreateOrderResponse, CreatePaymentResponse, StartCheckoutResponse, GetVaultTokenResponse, IErrorResponse, GetCustomerCardsResponse, RegisterCustomerCardResponse } from "../types/responses";
7
+ import { ErrorResponse } from "./errorResponse";
8
+
9
+ declare global {
10
+ interface Window {
11
+ OpenPay: any;
12
+ }
13
+ }
14
+
15
+ export type LiteCheckoutConstructor = {
16
+ signal: AbortSignal;
17
+ baseUrlTonder: string;
18
+ apiKeyTonder: string;
19
+ };
20
+
21
+ export class LiteCheckout implements LiteCheckoutConstructor {
22
+ signal: AbortSignal;
23
+ baseUrlTonder: string;
24
+ apiKeyTonder: string;
25
+
26
+ constructor({
27
+ signal,
28
+ baseUrlTonder,
29
+ apiKeyTonder,
30
+ }: LiteCheckoutConstructor) {
31
+ this.baseUrlTonder = baseUrlTonder;
32
+ this.signal = signal;
33
+ this.apiKeyTonder = apiKeyTonder;
34
+ }
35
+
36
+ async getOpenpayDeviceSessionID(
37
+ merchant_id: string,
38
+ public_key: string
39
+ ): Promise<string | ErrorResponse> {
40
+ try {
41
+ let openpay = await window.OpenPay;
42
+ openpay.setId(merchant_id);
43
+ openpay.setApiKey(public_key);
44
+ openpay.setSandboxMode(true);
45
+ return await openpay.deviceData.setup({
46
+ signal: this.signal,
47
+ }) as string;
48
+ } catch (e) {
49
+ throw this.buildErrorResponseFromCatch(e);
50
+ }
51
+ }
52
+
53
+ async getBusiness(): Promise<GetBusinessResponse | ErrorResponse> {
54
+ try {
55
+ const getBusiness = await fetch(
56
+ `${this.baseUrlTonder}/api/v1/payments/business/${this.apiKeyTonder}`,
57
+ {
58
+ headers: {
59
+ Authorization: `Token ${this.apiKeyTonder}`,
60
+ },
61
+ signal: this.signal,
62
+ }
63
+ );
64
+
65
+ if (getBusiness.ok) return (await getBusiness.json()) as Business;
66
+
67
+ return await this.buildErrorResponse(getBusiness);
68
+ } catch (e) {
69
+ return this.buildErrorResponseFromCatch(e);
70
+ }
71
+ }
72
+
73
+ async customerRegister(email: string): Promise<CustomerRegisterResponse | ErrorResponse> {
74
+ try {
75
+ const url = `${this.baseUrlTonder}/api/v1/customer/`;
76
+ const data = { email: email };
77
+ const response = await fetch(url, {
78
+ method: "POST",
79
+ headers: {
80
+ "Content-Type": "application/json",
81
+ Authorization: `Token ${this.apiKeyTonder}`,
82
+ },
83
+ signal: this.signal,
84
+ body: JSON.stringify(data),
85
+ });
86
+
87
+ if (response.ok) return await response.json() as CustomerRegisterResponse;
88
+ return await this.buildErrorResponse(response);
89
+ } catch (e) {
90
+ return this.buildErrorResponseFromCatch(e);
91
+ }
92
+ }
93
+
94
+ async createOrder(orderItems: CreateOrderRequest): Promise<CreateOrderResponse | ErrorResponse> {
95
+ try {
96
+ const url = `${this.baseUrlTonder}/api/v1/orders/`;
97
+ const data = orderItems;
98
+ const response = await fetch(url, {
99
+ method: "POST",
100
+ headers: {
101
+ "Content-Type": "application/json",
102
+ Authorization: `Token ${this.apiKeyTonder}`,
103
+ },
104
+ body: JSON.stringify(data),
105
+ });
106
+ if (response.ok) return await response.json() as CreateOrderResponse;
107
+ return await this.buildErrorResponse(response);
108
+ } catch (e) {
109
+ return this.buildErrorResponseFromCatch(e);
110
+ }
111
+ }
112
+
113
+ async createPayment(paymentItems: CreatePaymentRequest): Promise<CreatePaymentResponse | ErrorResponse> {
114
+ try {
115
+ const url = `${this.baseUrlTonder}/api/v1/business/${paymentItems.business_pk}/payments/`;
116
+ const data = paymentItems;
117
+ const response = await fetch(url, {
118
+ method: "POST",
119
+ headers: {
120
+ "Content-Type": "application/json",
121
+ Authorization: `Token ${this.apiKeyTonder}`,
122
+ },
123
+ body: JSON.stringify(data),
124
+ });
125
+ if (response.ok) return await response.json() as CreatePaymentResponse;
126
+ return await this.buildErrorResponse(response);
127
+ } catch (e) {
128
+ return this.buildErrorResponseFromCatch(e);
129
+ }
130
+ }
131
+
132
+ async startCheckoutRouter(routerData: StartCheckoutRequest): Promise<StartCheckoutResponse | ErrorResponse> {
133
+ try {
134
+ const url = `${this.baseUrlTonder}/api/v1/checkout-router/`;
135
+ const data = routerData;
136
+ const response = await fetch(url, {
137
+ method: "POST",
138
+ headers: {
139
+ "Content-Type": "application/json",
140
+ Authorization: `Token ${this.apiKeyTonder}`,
141
+ },
142
+ body: JSON.stringify(data),
143
+ });
144
+ if (response.ok) return await response.json() as StartCheckoutResponse;
145
+ return await this.buildErrorResponse(response);
146
+ } catch (e) {
147
+ return this.buildErrorResponseFromCatch(e);
148
+ }
149
+ }
150
+
151
+ async getSkyflowTokens({
152
+ vault_id,
153
+ vault_url,
154
+ data,
155
+ }: TokensRequest): Promise<any | ErrorResponse> {
156
+ const skyflow = Skyflow.init({
157
+ vaultID: vault_id,
158
+ vaultURL: vault_url,
159
+ getBearerToken: async () => await this.getVaultToken(),
160
+ options: {
161
+ logLevel: Skyflow.LogLevel.ERROR,
162
+ env: Skyflow.Env.DEV,
163
+ },
164
+ });
165
+
166
+ const collectContainer: CollectContainer = skyflow.container(
167
+ Skyflow.ContainerType.COLLECT
168
+ ) as CollectContainer;
169
+
170
+ const fieldPromises = await this.getFieldsPromise(data, collectContainer);
171
+
172
+ const result = await Promise.all(fieldPromises);
173
+
174
+ const mountFail = result.some((item: boolean) => !item);
175
+
176
+ if (mountFail) {
177
+ return this.buildErrorResponseFromCatch(Error("Ocurrió un error al montar los campos de la tarjeta"));
178
+ } else {
179
+ try {
180
+ const collectResponseSkyflowTonder = await collectContainer.collect() as any;
181
+ if (collectResponseSkyflowTonder) return collectResponseSkyflowTonder["records"][0]["fields"];
182
+ return this.buildErrorResponseFromCatch(Error("Por favor, verifica todos los campos de tu tarjeta"))
183
+ } catch (error) {
184
+ return this.buildErrorResponseFromCatch(error);
185
+ }
186
+ }
187
+ }
188
+
189
+ async getVaultToken(): Promise<string> {
190
+ try {
191
+ const response = await fetch(`${this.baseUrlTonder}/api/v1/vault-token/`, {
192
+ method: "GET",
193
+ headers: {
194
+ Authorization: `Token ${this.apiKeyTonder}`,
195
+ },
196
+ signal: this.signal,
197
+ });
198
+ if (response.ok) return (await response.json() as GetVaultTokenResponse)?.token;
199
+ throw new Error(`HTTPCODE: ${response.status}`)
200
+ } catch (e) {
201
+ throw new Error(`Failed to retrieve bearer token; ${typeof e == "string" ? e : (e as Error).message}`)
202
+ }
203
+ }
204
+
205
+ async getFieldsPromise(data: any, collectContainer: CollectContainer): Promise<Promise<boolean>[]> {
206
+ const fields = await this.getFields(data, collectContainer);
207
+ if (!fields) return [];
208
+
209
+ return fields.map((field: { element: CollectElement, key: string }) => {
210
+ return new Promise((resolve) => {
211
+ const div = document.createElement("div");
212
+ div.hidden = true;
213
+ div.id = `id-${field.key}`;
214
+ document.querySelector(`body`)?.appendChild(div);
215
+ setTimeout(() => {
216
+ field.element.mount(`#id-${field.key}`);
217
+ setInterval(() => {
218
+ if (field.element.isMounted()) {
219
+ const value = data[field.key];
220
+ field.element.update({ value: value });
221
+ return resolve(field.element.isMounted());
222
+ }
223
+ }, 120);
224
+ }, 120);
225
+ });
226
+ })
227
+ }
228
+
229
+ async registerCustomerCard(customerToken: string, data: RegisterCustomerCardRequest): Promise<RegisterCustomerCardResponse | ErrorResponse> {
230
+ try {
231
+ const response = await fetch(`${this.baseUrlTonder}/api/v1/cards/`, {
232
+ method: 'POST',
233
+ headers: {
234
+ 'Authorization': `Token ${customerToken}`,
235
+ 'Content-Type': 'application/json'
236
+ },
237
+ signal: this.signal,
238
+ body: JSON.stringify(data)
239
+ });
240
+
241
+ if (response.ok) return await response.json() as RegisterCustomerCardResponse;
242
+ return await this.buildErrorResponse(response);
243
+ } catch (error) {
244
+ return this.buildErrorResponseFromCatch(error);
245
+ }
246
+ }
247
+
248
+ async getCustomerCards(customerToken: string, query: string = ""): Promise<GetCustomerCardsResponse | ErrorResponse> {
249
+ try {
250
+ const response = await fetch(`${this.baseUrlTonder}/api/v1/cards/${query}`, {
251
+ method: 'GET',
252
+ headers: {
253
+ 'Authorization': `Token ${customerToken}`,
254
+ 'Content-Type': 'application/json'
255
+ },
256
+ signal: this.signal,
257
+ });
258
+
259
+ if (response.ok) return await response.json() as GetCustomerCardsResponse;
260
+ return await this.buildErrorResponse(response);
261
+ } catch (error) {
262
+ return this.buildErrorResponseFromCatch(error);
263
+ }
264
+ }
265
+
266
+ private buildErrorResponseFromCatch(e: any): ErrorResponse {
267
+ return new ErrorResponse({
268
+ code: undefined,
269
+ body: undefined,
270
+ name: typeof e == "string" ? "catch" : (e as Error).name,
271
+ message: typeof e == "string" ? e : (e as Error).message,
272
+ stack: typeof e == "string" ? undefined : (e as Error).stack,
273
+ })
274
+ }
275
+
276
+ private async buildErrorResponse(
277
+ response: Response,
278
+ stack: string | undefined = undefined
279
+ ): Promise<ErrorResponse> {
280
+ return new ErrorResponse({
281
+ code: response.status?.toString?.(),
282
+ body: await response?.json?.(),
283
+ name: response.status?.toString?.(),
284
+ message: await response?.text?.(),
285
+ stack,
286
+ } as IErrorResponse);
287
+ }
288
+
289
+ private async getFields(data: any, collectContainer: CollectContainer): Promise<{ element: CollectElement, key: string }[]> {
290
+ return await Promise.all(
291
+ Object.keys(data).map(async (key) => {
292
+ const cardHolderNameElement = await collectContainer.create({
293
+ table: "cards",
294
+ column: key,
295
+ type: Skyflow.ElementType.INPUT_FIELD,
296
+ });
297
+ return { element: cardHolderNameElement, key: key };
298
+ })
299
+ )
300
+ }
301
+ }
@@ -0,0 +1,37 @@
1
+ export const createObserver = ({ target }: { target: string }): Promise<any> => {
2
+
3
+ return new Promise((resolve, reject) => {
4
+
5
+ let hasChanged = false;
6
+
7
+ // Select the node that will be observed for mutations
8
+ const targetNode: any = document.querySelector(target);
9
+
10
+ // Options for the observer (which mutations to observe)
11
+ const config = { attributes: true, childList: true, subtree: true };
12
+
13
+ // Callback function to execute when mutations are observed
14
+ const callback = (mutationList: any, observer: MutationObserver) => {
15
+ for (const mutation of mutationList) {
16
+ if (mutation.type === "childList") {
17
+ hasChanged = true;
18
+ resolve(mutation)
19
+ }
20
+ }
21
+ };
22
+
23
+ // Create an observer instance linked to the callback function
24
+ const observer = new MutationObserver(callback);
25
+
26
+ // Start observing the target node for configured mutations
27
+ observer.observe(targetNode, config);
28
+
29
+ window.setTimeout(() => {
30
+ if (!hasChanged) {
31
+ reject("Mounting error");
32
+ }
33
+ }, 5000);
34
+
35
+ })
36
+
37
+ }
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { LiteCheckout } from './classes/liteCheckout'
2
+
3
+ export {
4
+ LiteCheckout
5
+ }
@@ -0,0 +1,61 @@
1
+ export type Business = {
2
+ business: {
3
+ pk: number;
4
+ name: string;
5
+ categories: {
6
+ pk: number;
7
+ name: string;
8
+ }[];
9
+ web: string;
10
+ logo: string;
11
+ full_logo_url: string;
12
+ background_color: string;
13
+ primary_color: string;
14
+ checkout_mode: boolean;
15
+ textCheckoutColor: string;
16
+ textDetailsColor: string;
17
+ checkout_logo: string;
18
+ };
19
+ openpay_keys: {
20
+ merchant_id: string;
21
+ public_key: string;
22
+ };
23
+ fintoc_keys: {
24
+ public_key: string;
25
+ };
26
+ vault_id: string;
27
+ vault_url: string;
28
+ reference: number;
29
+ is_installments_available: boolean;
30
+ };
31
+
32
+ export type Customer = {
33
+ firstName: string;
34
+ lastName: string;
35
+ country: string;
36
+ street: string;
37
+ city: string;
38
+ state: string;
39
+ postCode: string;
40
+ email: string;
41
+ phone: string;
42
+ };
43
+
44
+ export type OrderItem = {
45
+ description: string;
46
+ quantity: number;
47
+ price_unit: number;
48
+ discount: number;
49
+ taxes: number;
50
+ product_reference: number;
51
+ name: string;
52
+ amount_total: number;
53
+ };
54
+
55
+ export type PaymentData = {
56
+ customer: Customer;
57
+ cart: {
58
+ total: string | number;
59
+ items: OrderItem[];
60
+ };
61
+ };