@tonder.io/ionic-lite-sdk 0.0.32-beta → 0.0.33-beta

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 (34) hide show
  1. package/.gitlab-ci.yml +28 -28
  2. package/README.md +202 -193
  3. package/dist/classes/3dsHandler.d.ts +36 -0
  4. package/dist/classes/liteCheckout.d.ts +13 -4
  5. package/dist/index.js +1 -1
  6. package/dist/types/requests.d.ts +3 -0
  7. package/dist/types/responses.d.ts +1 -0
  8. package/jest.config.ts +14 -14
  9. package/package.json +38 -38
  10. package/rollup.config.js +16 -16
  11. package/src/classes/3dsHandler.ts +254 -0
  12. package/src/classes/errorResponse.ts +16 -16
  13. package/src/classes/liteCheckout.ts +535 -462
  14. package/src/helpers/utils.ts +12 -12
  15. package/src/index.ts +4 -4
  16. package/src/types/commons.ts +62 -62
  17. package/src/types/requests.ts +93 -89
  18. package/src/types/responses.ts +188 -187
  19. package/src/types/skyflow.ts +17 -17
  20. package/tests/classes/liteCheckout.test.ts +57 -57
  21. package/tests/methods/createOrder.test.ts +142 -142
  22. package/tests/methods/createPayment.test.ts +122 -122
  23. package/tests/methods/customerRegister.test.ts +119 -119
  24. package/tests/methods/getBusiness.test.ts +115 -115
  25. package/tests/methods/getCustomerCards.test.ts +117 -117
  26. package/tests/methods/getOpenpayDeviceSessionID.test.ts +94 -94
  27. package/tests/methods/getSkyflowToken.test.ts +154 -154
  28. package/tests/methods/getVaultToken.test.ts +106 -106
  29. package/tests/methods/registerCustomerCard.test.ts +117 -117
  30. package/tests/methods/startCheckoutRouter.test.ts +119 -119
  31. package/tests/methods/startCheckoutRouterFull.test.ts +138 -138
  32. package/tests/utils/defaultMock.ts +20 -20
  33. package/tests/utils/mockClasses.ts +651 -649
  34. package/tsconfig.json +18 -18
@@ -1,649 +1,651 @@
1
- import { Business, OrderItem } from "../../src/types/commons";
2
- import {
3
- CreateOrderRequest,
4
- CreatePaymentRequest,
5
- RegisterCustomerCardRequest,
6
- StartCheckoutRequest,
7
- TokensRequest,
8
- StartCheckoutFullRequest
9
- } from "../../src/types/requests";
10
- import {
11
- CreateOrderResponse,
12
- CreatePaymentResponse,
13
- GetBusinessResponse,
14
- GetCustomerCardsResponse,
15
- RegisterCustomerCardResponse,
16
- StartCheckoutResponse,
17
- CustomerRegisterResponse
18
- } from "../../src/types/responses";
19
-
20
- export class BusinessClass implements Business {
21
- business!: {
22
- pk: number;
23
- name: string;
24
- categories: [{ pk: number; name: string }];
25
- web: string;
26
- logo: string;
27
- full_logo_url: string;
28
- background_color: string;
29
- primary_color: string;
30
- checkout_mode: boolean;
31
- textCheckoutColor: string;
32
- textDetailsColor: string;
33
- checkout_logo: string;
34
- };
35
- openpay_keys!: { merchant_id: string; public_key: string };
36
- fintoc_keys!: { public_key: string };
37
- vault_id!: string;
38
- vault_url!: string;
39
- reference!: number;
40
- is_installments_available!: boolean;
41
-
42
- get mockObject(): GetBusinessResponse {
43
- return {
44
- business: {
45
- pk: 1234, // Número de ejemplo
46
- name: 'Mock Business Name',
47
- categories: [
48
- { pk: 5678, name: 'Mock Category 1' },
49
- { pk: 9012, name: 'Mock Category 2' }
50
- ],
51
- web: 'https://www.mockbusiness.com',
52
- logo: 'assets/images/mock-logo.png',
53
- full_logo_url: 'https://www.mockbusiness.com/logo.png',
54
- background_color: '#f5f5f5',
55
- primary_color: '#007bff',
56
- checkout_mode: true,
57
- textCheckoutColor: '#333333',
58
- textDetailsColor: '#666666',
59
- checkout_logo: 'assets/images/checkout-logo.png',
60
- },
61
- vault_id: 'mock-vault-id-123',
62
- vault_url: 'https://mock-vault.com',
63
- reference: 987654,
64
- is_installments_available: true,
65
- openpay_keys: { merchant_id: "", public_key: "" },
66
- fintoc_keys: { public_key: "" }
67
- }
68
- }
69
- }
70
-
71
- export class OrderClass implements CreateOrderRequest {
72
- business!: string;
73
- client!: string;
74
- billing_address_id!: number | null;
75
- shipping_address_id!: number | null;
76
- amount!: number;
77
- status!: string;
78
- reference!: string;
79
- is_oneclick!: boolean;
80
- items!: OrderItem[];
81
-
82
- get mockObject(): CreateOrderRequest {
83
- return {
84
- business: "The business pk",
85
- client: "Client auth token",
86
- billing_address_id: null,
87
- shipping_address_id: null,
88
- amount: 25,
89
- status: "PENDING",
90
- reference: "XXXXXXX",
91
- is_oneclick: false,
92
- items: [
93
- { ...new OrderItemClass() }
94
- ]
95
- }
96
-
97
- }
98
- }
99
-
100
- export class OrderClassEmptyValues implements CreateOrderRequest {
101
- business!: string;
102
- client!: string;
103
- billing_address_id!: number | null;
104
- shipping_address_id!: number | null;
105
- amount!: number;
106
- status!: string;
107
- reference!: string;
108
- is_oneclick!: boolean;
109
- items!: OrderItem[];
110
-
111
- get mockObject(): CreateOrderRequest {
112
- return {
113
- business: "",
114
- client: "Client auth token",
115
- billing_address_id: 1,
116
- shipping_address_id: 2,
117
- amount: 25,
118
- status: "PENDING",
119
- reference: "",
120
- is_oneclick: false,
121
- items: [
122
- { ...new OrderItemClass() }
123
- ]
124
- }
125
-
126
- }
127
- }
128
-
129
- export class OrderItemClass implements OrderItem {
130
- description!: string;
131
- quantity!: number;
132
- price_unit!: number;
133
- discount!: number;
134
- taxes!: number;
135
- product_reference!: number;
136
- name!: string;
137
- amount_total!: number;
138
-
139
- get mockObject(): OrderItem {
140
- return {
141
- description: "string",
142
- quantity: 0,
143
- price_unit: 0,
144
- discount: 0,
145
- taxes: 0,
146
- product_reference: 0,
147
- name: "string",
148
- amount_total: 0,
149
- }
150
-
151
- }
152
- }
153
-
154
- export class OrderResponseClass implements CreateOrderResponse {
155
- id!: number;
156
- created!: string;
157
- amount!: string;
158
- status!: string;
159
- payment_method?: string | undefined;
160
- reference?: string | undefined;
161
- is_oneclick!: boolean;
162
- items!: [
163
- {
164
- description: string;
165
- product_reference: string;
166
- quantity: string;
167
- price_unit: string;
168
- discount: string;
169
- taxes: string;
170
- amount_total: string;
171
- }
172
- ];
173
- billing_address?: string | undefined;
174
- shipping_address?: string | undefined;
175
- client!: {
176
- email: string;
177
- name: string;
178
- first_name: string;
179
- last_name: string;
180
- client_profile: {
181
- gender: string;
182
- date_birth?: string | undefined;
183
- terms: boolean;
184
- phone: string;
185
- };
186
- };
187
-
188
- get mockObject(): CreateOrderResponse {
189
- return {
190
- id: 12345,
191
- created: '2024-02-01T10:42:00Z',
192
- amount: '123.45',
193
- status: 'APPROVED',
194
- payment_method: 'CREDIT_CARD',
195
- reference: 'PAYMENT_REF_12345',
196
- is_oneclick: true,
197
- items: [
198
- {
199
- description: 'Mock Item 1',
200
- product_reference: 'PRD-123',
201
- quantity: '2',
202
- price_unit: '50.00',
203
- discount: '5.00',
204
- taxes: '10.90',
205
- amount_total: '105.90',
206
- },
207
- {
208
- description: 'Mock Item 2',
209
- product_reference: 'PRD-456',
210
- quantity: '1',
211
- price_unit: '73.45',
212
- discount: '0.00',
213
- taxes: '6.55',
214
- amount_total: '79.00',
215
- },
216
- ],
217
- billing_address: 'Mock Street 123, Mock City',
218
- shipping_address: 'Mock Avenue 456, Mock Town',
219
- client: {
220
- email: 'mockuser@example.com',
221
- name: 'Mock User',
222
- first_name: 'Mock',
223
- last_name: 'User',
224
- client_profile: {
225
- gender: 'M',
226
- date_birth: '1990-01-01',
227
- terms: true,
228
- phone: '+1234567890',
229
- },
230
- },
231
- }
232
- }
233
- }
234
-
235
- export class CreatePaymentRequestClass implements CreatePaymentRequest {
236
- business_pk!: string;
237
- amount!: number;
238
- date!: string;
239
- order_id!: string;
240
- client_id!: number;
241
-
242
- get mockObject(): CreatePaymentRequest {
243
- const now = new Date();
244
- const dateString = now.toISOString();
245
- return {
246
- business_pk: "NNNNNNNNNN",
247
- amount: 25,
248
- date: dateString,
249
- order_id: "XXXXX",
250
- client_id: 1
251
- };
252
- }
253
- }
254
-
255
- export class CreatePaymentResponseClass implements CreatePaymentResponse {
256
- pk!: number;
257
- order?: string | undefined;
258
- amount!: string;
259
- status!: string;
260
- date!: string;
261
- paid_date?: string | undefined;
262
- shipping_address!: {
263
- street: string;
264
- number: string;
265
- suburb: string;
266
- city: { name: string };
267
- state: { name: string; country: { name: string } };
268
- zip_code: string;
269
- };
270
- shipping_address_id?: string | undefined;
271
- billing_address!: {
272
- street: string;
273
- number: string;
274
- suburb: string;
275
- city: { name: string };
276
- state: { name: string; country: { name: string } };
277
- zip_code: string;
278
- };
279
- billing_address_id?: string | undefined;
280
- client?: string | undefined;
281
- customer_order_reference?: string | undefined;
282
-
283
- get mockObject(): CreatePaymentResponse {
284
- return {
285
- pk: 45678,
286
- order: "ORDER-98765",
287
- amount: "250.00",
288
- status: "PENDING",
289
- date: "2024-02-01T14:29:05Z",
290
- paid_date: "",
291
- shipping_address: {
292
- street: "Mock Street 123",
293
- number: "10",
294
- suburb: "Mock Suburb",
295
- city: { name: "Mock City" },
296
- state: { name: "Mock State", country: { name: "Mock Country" } },
297
- zip_code: "12345",
298
- },
299
- shipping_address_id: "",
300
- billing_address: {
301
- street: "Mock Street 456",
302
- number: "20",
303
- suburb: "Mock Suburb 2",
304
- city: { name: "Mock City 2" },
305
- state: { name: "Mock State 2", country: { name: "Mock Country 2" } },
306
- zip_code: "54321",
307
- },
308
- billing_address_id: "",
309
- client: "CLIENT-123",
310
- customer_order_reference: "REF-ABC123",
311
- };
312
- }
313
- }
314
-
315
- export class StartCheckoutRequestClass implements StartCheckoutRequest {
316
- card: any;
317
- name: any;
318
- last_name!: string;
319
- email_client: any;
320
- phone_number: any;
321
- return_url!: string;
322
- id_product!: string;
323
- quantity_product!: number;
324
- id_ship!: string;
325
- instance_id_ship!: string;
326
- amount: any;
327
- title_ship!: string;
328
- description!: string;
329
- device_session_id: any;
330
- token_id!: string;
331
- order_id: any;
332
- business_id: any;
333
- payment_id: any;
334
- source!: string;
335
- currency!: string;
336
- metadata!: string;
337
-
338
- get mockObject(): StartCheckoutRequest {
339
- return {
340
- card: " any",
341
- name: " any",
342
- last_name: " string",
343
- email_client: " any",
344
- phone_number: " any",
345
- return_url: " string",
346
- id_product: " string",
347
- quantity_product: 0,
348
- id_ship: " string",
349
- instance_id_ship: " string",
350
- amount: " any",
351
- title_ship: " string",
352
- description: " string",
353
- device_session_id: " any",
354
- token_id: " string",
355
- order_id: " any",
356
- business_id: " any",
357
- payment_id: " any",
358
- source: " string",
359
- currency: "string",
360
- metadata: "string"
361
- };
362
- }
363
- }
364
-
365
- export class StartCheckoutResponseClass implements StartCheckoutResponse {
366
- status!: number;
367
- message!: string;
368
- psp_response!: {
369
- id: string;
370
- authorization: number;
371
- operation_type: string;
372
- transaction_type: string;
373
- status: string;
374
- conciliated: boolean;
375
- creation_date: string;
376
- operation_date: string;
377
- description: string;
378
- error_message?: string;
379
- order_id?: string;
380
- card: {
381
- type: string;
382
- brand: string;
383
- address?: string;
384
- card_number: string;
385
- holder_name: string;
386
- expiration_year: string;
387
- expiration_month: string;
388
- allows_charges: boolean;
389
- allows_payouts: boolean;
390
- bank_name: string;
391
- points_type: string;
392
- points_card: boolean;
393
- bank_code: number;
394
- };
395
- customer_id: string;
396
- gateway_card_present: string;
397
- amount: number;
398
- fee: {
399
- amount: number;
400
- tax: number;
401
- currency: string;
402
- };
403
- payment_method: {
404
- type: string;
405
- url: string;
406
- };
407
- currency: string;
408
- method: string;
409
- object: string;
410
- };
411
- transaction_status!: string;
412
- transaction_id!: number;
413
- payment_id!: number;
414
- provider!: string;
415
- next_action!: {
416
- redirect_to_url: {
417
- url: string;
418
- return_url: string;
419
- verify_transaction_status_url: string;
420
- };
421
- };
422
- actions!: {
423
- name: string;
424
- url: string;
425
- method: string;
426
- }[];
427
-
428
- get mockObject(): StartCheckoutResponse {
429
- return {
430
- status: 200, // Representa un estado exitoso
431
- message: "Payment processing initiated",
432
- transaction_status: "PENDING",
433
- transaction_id: 1234567890,
434
- payment_id: 9876543210,
435
- provider: "STRIPE",
436
- next_action: {
437
- redirect_to_url: {
438
- url: "https://www.mock-payment-provider.com/checkout",
439
- return_url: "https://your-app.com/payment-confirmation",
440
- verify_transaction_status_url:
441
- "https://api.mock-payment-provider.com/transactions/1234567890/status",
442
- },
443
- },
444
- psp_response: {
445
- id: " string",
446
- authorization: 0,
447
- operation_type: " string",
448
- transaction_type: " string",
449
- status: " string",
450
- conciliated: false,
451
- creation_date: " string",
452
- operation_date: " string",
453
- description: " string",
454
- error_message: " string",
455
- order_id: " string",
456
- card: {
457
- type: " string",
458
- brand: " string",
459
- address: " string",
460
- card_number: " string",
461
- holder_name: " string",
462
- expiration_year: " string",
463
- expiration_month: " string",
464
- allows_charges: false,
465
- allows_payouts: false,
466
- bank_name: " string",
467
- points_type: " string",
468
- points_card: false,
469
- bank_code: 0,
470
- },
471
- customer_id: " string",
472
- gateway_card_present: " string",
473
- amount: 0,
474
- fee: {
475
- amount: 0,
476
- tax: 0,
477
- currency: " string",
478
- },
479
- payment_method: {
480
- type: " string",
481
- url: " string",
482
- },
483
- currency: " string",
484
- method: " string",
485
- object: " string",
486
- },
487
- actions: [
488
- {
489
- name: "Check status",
490
- url: "https://api.mock-payment-provider.com/transactions/1234567890/status",
491
- method: "GET",
492
- },
493
- {
494
- name: "Cancel payment",
495
- url: "https://api.mock-payment-provider.com/transactions/1234567890/cancel",
496
- method: "POST",
497
- },
498
- ],
499
- };
500
- }
501
- }
502
-
503
- export class StartCheckoutFullRequestClass implements StartCheckoutFullRequest {
504
- order!: { items: OrderItem[]; };
505
- return_url!: string;
506
- total!: number;
507
- skyflowTokens!: { cardholder_name: string; card_number: string; cvv: string; expiration_year: string; expiration_month: string; skyflow_id: string; };
508
- customer!: { name: string; lastname: string; email: string; phone: string; };
509
- isSandbox!: boolean;
510
- currency!: string;
511
- metadata!: any;
512
-
513
- get mockObject(): StartCheckoutFullRequest {
514
- return {
515
- order: {
516
- items: [
517
- {
518
- description: "string",
519
- quantity: 25,
520
- price_unit: 25,
521
- discount: 0,
522
- taxes: 0,
523
- product_reference: 25,
524
- name: "Product text",
525
- amount_total: 25
526
- }
527
- ]
528
- },
529
- return_url: "string",
530
- total: 25,
531
- skyflowTokens: {
532
- cardholder_name: "string",
533
- card_number: "string",
534
- cvv: "string",
535
- expiration_year: "string",
536
- expiration_month: "string",
537
- skyflow_id: "string",
538
- },
539
- customer: {
540
- name: "string",
541
- lastname: "string",
542
- email: "string",
543
- phone: "string",
544
- },
545
- isSandbox: true,
546
- currency: "MXN",
547
- metadata: null
548
- };
549
- }
550
- }
551
-
552
- export class TokensRequestClass implements TokensRequest {
553
- vault_id!: string;
554
- vault_url!: string;
555
- data: { [key: string]: any } = {};
556
-
557
- get mockObject(): TokensRequest {
558
- return {
559
- vault_id: "string",
560
- vault_url: "string",
561
- data: {
562
- fields: [],
563
- },
564
- };
565
- }
566
- }
567
-
568
- export class RegisterCustomerCardResponseClass
569
- implements RegisterCustomerCardResponse {
570
- skyflow_id!: string;
571
- user_id!: number;
572
-
573
- get mockObject(): RegisterCustomerCardResponse {
574
- return {
575
- skyflow_id: "string",
576
- user_id: 0,
577
- };
578
- }
579
- }
580
-
581
- export class RegisterCustomerCardRequestClass
582
- implements RegisterCustomerCardRequest {
583
- skyflow_id!: string;
584
-
585
- get mockObject(): RegisterCustomerCardRequest {
586
- return {
587
- skyflow_id: "",
588
- };
589
- }
590
- }
591
-
592
- export class GetCustomerCardsResponseClass implements GetCustomerCardsResponse {
593
- user_id!: number;
594
- cards!: {
595
- fields: {
596
- card_scheme: string;
597
- card_number: string;
598
- cardholder_name: string;
599
- cvv: string;
600
- expiration_month: string;
601
- expiration_year: string;
602
- skyflow_id: string;
603
- };
604
- }[];
605
-
606
- get mockObject(): GetCustomerCardsResponse {
607
- return {
608
- user_id: 0,
609
- cards: [
610
- {
611
- fields: {
612
- card_scheme: "string",
613
- card_number: "string",
614
- cardholder_name: "string",
615
- cvv: "string",
616
- expiration_month: "string",
617
- expiration_year: "string",
618
- skyflow_id: "string",
619
- },
620
- },
621
- ],
622
- };
623
- }
624
- }
625
-
626
- export const OrderEmptyValuesResponse = {
627
- "business": [
628
- "This field may not be blank."
629
- ],
630
- "reference": [
631
- "This field may not be null."
632
- ]
633
- }
634
-
635
- export class CustomerRegisterClass implements CustomerRegisterResponse {
636
- id!: number;
637
- email!: string;
638
- auth_token!: string;
639
- first_name!: string;
640
- last_name!: string;
641
-
642
- get mockObject(): CustomerRegisterResponse {
643
- return {
644
- id: 10,
645
- email: "email@gmail.com",
646
- auth_token: "string"
647
- };
648
- }
649
- }
1
+ import { Business, OrderItem } from "../../src/types/commons";
2
+ import {
3
+ CreateOrderRequest,
4
+ CreatePaymentRequest,
5
+ RegisterCustomerCardRequest,
6
+ StartCheckoutRequest,
7
+ TokensRequest,
8
+ StartCheckoutFullRequest
9
+ } from "../../src/types/requests";
10
+ import {
11
+ CreateOrderResponse,
12
+ CreatePaymentResponse,
13
+ GetBusinessResponse,
14
+ GetCustomerCardsResponse,
15
+ RegisterCustomerCardResponse,
16
+ StartCheckoutResponse,
17
+ CustomerRegisterResponse
18
+ } from "../../src/types/responses";
19
+
20
+ export class BusinessClass implements Business {
21
+ business!: {
22
+ pk: number;
23
+ name: string;
24
+ categories: [{ pk: number; name: string }];
25
+ web: string;
26
+ logo: string;
27
+ full_logo_url: string;
28
+ background_color: string;
29
+ primary_color: string;
30
+ checkout_mode: boolean;
31
+ textCheckoutColor: string;
32
+ textDetailsColor: string;
33
+ checkout_logo: string;
34
+ };
35
+ openpay_keys!: { merchant_id: string; public_key: string };
36
+ fintoc_keys!: { public_key: string };
37
+ vault_id!: string;
38
+ vault_url!: string;
39
+ reference!: number;
40
+ is_installments_available!: boolean;
41
+
42
+ get mockObject(): GetBusinessResponse {
43
+ return {
44
+ business: {
45
+ pk: 1234, // Número de ejemplo
46
+ name: 'Mock Business Name',
47
+ categories: [
48
+ { pk: 5678, name: 'Mock Category 1' },
49
+ { pk: 9012, name: 'Mock Category 2' }
50
+ ],
51
+ web: 'https://www.mockbusiness.com',
52
+ logo: 'assets/images/mock-logo.png',
53
+ full_logo_url: 'https://www.mockbusiness.com/logo.png',
54
+ background_color: '#f5f5f5',
55
+ primary_color: '#007bff',
56
+ checkout_mode: true,
57
+ textCheckoutColor: '#333333',
58
+ textDetailsColor: '#666666',
59
+ checkout_logo: 'assets/images/checkout-logo.png',
60
+ },
61
+ vault_id: 'mock-vault-id-123',
62
+ vault_url: 'https://mock-vault.com',
63
+ reference: 987654,
64
+ is_installments_available: true,
65
+ openpay_keys: { merchant_id: "", public_key: "" },
66
+ fintoc_keys: { public_key: "" }
67
+ }
68
+ }
69
+ }
70
+
71
+ export class OrderClass implements CreateOrderRequest {
72
+ business!: string;
73
+ client!: string;
74
+ billing_address_id!: number | null;
75
+ shipping_address_id!: number | null;
76
+ amount!: number;
77
+ status!: string;
78
+ reference!: string;
79
+ is_oneclick!: boolean;
80
+ items!: OrderItem[];
81
+
82
+ get mockObject(): CreateOrderRequest {
83
+ return {
84
+ business: "The business pk",
85
+ client: "Client auth token",
86
+ billing_address_id: null,
87
+ shipping_address_id: null,
88
+ amount: 25,
89
+ status: "PENDING",
90
+ reference: "XXXXXXX",
91
+ is_oneclick: false,
92
+ items: [
93
+ { ...new OrderItemClass() }
94
+ ]
95
+ }
96
+
97
+ }
98
+ }
99
+
100
+ export class OrderClassEmptyValues implements CreateOrderRequest {
101
+ business!: string;
102
+ client!: string;
103
+ billing_address_id!: number | null;
104
+ shipping_address_id!: number | null;
105
+ amount!: number;
106
+ status!: string;
107
+ reference!: string;
108
+ is_oneclick!: boolean;
109
+ items!: OrderItem[];
110
+
111
+ get mockObject(): CreateOrderRequest {
112
+ return {
113
+ business: "",
114
+ client: "Client auth token",
115
+ billing_address_id: 1,
116
+ shipping_address_id: 2,
117
+ amount: 25,
118
+ status: "PENDING",
119
+ reference: "",
120
+ is_oneclick: false,
121
+ items: [
122
+ { ...new OrderItemClass() }
123
+ ]
124
+ }
125
+
126
+ }
127
+ }
128
+
129
+ export class OrderItemClass implements OrderItem {
130
+ description!: string;
131
+ quantity!: number;
132
+ price_unit!: number;
133
+ discount!: number;
134
+ taxes!: number;
135
+ product_reference!: number;
136
+ name!: string;
137
+ amount_total!: number;
138
+
139
+ get mockObject(): OrderItem {
140
+ return {
141
+ description: "string",
142
+ quantity: 0,
143
+ price_unit: 0,
144
+ discount: 0,
145
+ taxes: 0,
146
+ product_reference: 0,
147
+ name: "string",
148
+ amount_total: 0,
149
+ }
150
+
151
+ }
152
+ }
153
+
154
+ export class OrderResponseClass implements CreateOrderResponse {
155
+ id!: number;
156
+ created!: string;
157
+ amount!: string;
158
+ status!: string;
159
+ payment_method?: string | undefined;
160
+ reference?: string | undefined;
161
+ is_oneclick!: boolean;
162
+ items!: [
163
+ {
164
+ description: string;
165
+ product_reference: string;
166
+ quantity: string;
167
+ price_unit: string;
168
+ discount: string;
169
+ taxes: string;
170
+ amount_total: string;
171
+ }
172
+ ];
173
+ billing_address?: string | undefined;
174
+ shipping_address?: string | undefined;
175
+ client!: {
176
+ email: string;
177
+ name: string;
178
+ first_name: string;
179
+ last_name: string;
180
+ client_profile: {
181
+ gender: string;
182
+ date_birth?: string | undefined;
183
+ terms: boolean;
184
+ phone: string;
185
+ };
186
+ };
187
+
188
+ get mockObject(): CreateOrderResponse {
189
+ return {
190
+ id: 12345,
191
+ created: '2024-02-01T10:42:00Z',
192
+ amount: '123.45',
193
+ status: 'APPROVED',
194
+ payment_method: 'CREDIT_CARD',
195
+ reference: 'PAYMENT_REF_12345',
196
+ is_oneclick: true,
197
+ items: [
198
+ {
199
+ description: 'Mock Item 1',
200
+ product_reference: 'PRD-123',
201
+ quantity: '2',
202
+ price_unit: '50.00',
203
+ discount: '5.00',
204
+ taxes: '10.90',
205
+ amount_total: '105.90',
206
+ },
207
+ {
208
+ description: 'Mock Item 2',
209
+ product_reference: 'PRD-456',
210
+ quantity: '1',
211
+ price_unit: '73.45',
212
+ discount: '0.00',
213
+ taxes: '6.55',
214
+ amount_total: '79.00',
215
+ },
216
+ ],
217
+ billing_address: 'Mock Street 123, Mock City',
218
+ shipping_address: 'Mock Avenue 456, Mock Town',
219
+ client: {
220
+ email: 'mockuser@example.com',
221
+ name: 'Mock User',
222
+ first_name: 'Mock',
223
+ last_name: 'User',
224
+ client_profile: {
225
+ gender: 'M',
226
+ date_birth: '1990-01-01',
227
+ terms: true,
228
+ phone: '+1234567890',
229
+ },
230
+ },
231
+ }
232
+ }
233
+ }
234
+
235
+ export class CreatePaymentRequestClass implements CreatePaymentRequest {
236
+ business_pk!: string;
237
+ amount!: number;
238
+ date!: string;
239
+ order_id!: string;
240
+ client_id!: number;
241
+
242
+ get mockObject(): CreatePaymentRequest {
243
+ const now = new Date();
244
+ const dateString = now.toISOString();
245
+ return {
246
+ business_pk: "NNNNNNNNNN",
247
+ amount: 25,
248
+ date: dateString,
249
+ order_id: "XXXXX",
250
+ client_id: 1
251
+ };
252
+ }
253
+ }
254
+
255
+ export class CreatePaymentResponseClass implements CreatePaymentResponse {
256
+ pk!: number;
257
+ order?: string | undefined;
258
+ amount!: string;
259
+ status!: string;
260
+ date!: string;
261
+ paid_date?: string | undefined;
262
+ shipping_address!: {
263
+ street: string;
264
+ number: string;
265
+ suburb: string;
266
+ city: { name: string };
267
+ state: { name: string; country: { name: string } };
268
+ zip_code: string;
269
+ };
270
+ shipping_address_id?: string | undefined;
271
+ billing_address!: {
272
+ street: string;
273
+ number: string;
274
+ suburb: string;
275
+ city: { name: string };
276
+ state: { name: string; country: { name: string } };
277
+ zip_code: string;
278
+ };
279
+ billing_address_id?: string | undefined;
280
+ client?: string | undefined;
281
+ customer_order_reference?: string | undefined;
282
+
283
+ get mockObject(): CreatePaymentResponse {
284
+ return {
285
+ pk: 45678,
286
+ order: "ORDER-98765",
287
+ amount: "250.00",
288
+ status: "PENDING",
289
+ date: "2024-02-01T14:29:05Z",
290
+ paid_date: "",
291
+ shipping_address: {
292
+ street: "Mock Street 123",
293
+ number: "10",
294
+ suburb: "Mock Suburb",
295
+ city: { name: "Mock City" },
296
+ state: { name: "Mock State", country: { name: "Mock Country" } },
297
+ zip_code: "12345",
298
+ },
299
+ shipping_address_id: "",
300
+ billing_address: {
301
+ street: "Mock Street 456",
302
+ number: "20",
303
+ suburb: "Mock Suburb 2",
304
+ city: { name: "Mock City 2" },
305
+ state: { name: "Mock State 2", country: { name: "Mock Country 2" } },
306
+ zip_code: "54321",
307
+ },
308
+ billing_address_id: "",
309
+ client: "CLIENT-123",
310
+ customer_order_reference: "REF-ABC123",
311
+ };
312
+ }
313
+ }
314
+
315
+ export class StartCheckoutRequestClass implements StartCheckoutRequest {
316
+ card: any;
317
+ name: any;
318
+ last_name!: string;
319
+ email_client: any;
320
+ phone_number: any;
321
+ return_url!: string;
322
+ id_product!: string;
323
+ quantity_product!: number;
324
+ id_ship!: string;
325
+ instance_id_ship!: string;
326
+ amount: any;
327
+ title_ship!: string;
328
+ description!: string;
329
+ device_session_id: any;
330
+ token_id!: string;
331
+ order_id: any;
332
+ business_id: any;
333
+ payment_id: any;
334
+ source!: string;
335
+ currency!: string;
336
+ metadata!: string;
337
+
338
+ get mockObject(): StartCheckoutRequest {
339
+ return {
340
+ card: " any",
341
+ name: " any",
342
+ last_name: " string",
343
+ email_client: " any",
344
+ phone_number: " any",
345
+ return_url: " string",
346
+ id_product: " string",
347
+ quantity_product: 0,
348
+ id_ship: " string",
349
+ instance_id_ship: " string",
350
+ amount: " any",
351
+ title_ship: " string",
352
+ description: " string",
353
+ device_session_id: " any",
354
+ token_id: " string",
355
+ order_id: " any",
356
+ business_id: " any",
357
+ payment_id: " any",
358
+ source: " string",
359
+ currency: "string",
360
+ metadata: "string"
361
+ };
362
+ }
363
+ }
364
+
365
+ export class StartCheckoutResponseClass implements StartCheckoutResponse {
366
+ status!: number;
367
+ message!: string;
368
+ is_route_finished!: Boolean;
369
+ psp_response!: {
370
+ id: string;
371
+ authorization: number;
372
+ operation_type: string;
373
+ transaction_type: string;
374
+ status: string;
375
+ conciliated: boolean;
376
+ creation_date: string;
377
+ operation_date: string;
378
+ description: string;
379
+ error_message?: string;
380
+ order_id?: string;
381
+ card: {
382
+ type: string;
383
+ brand: string;
384
+ address?: string;
385
+ card_number: string;
386
+ holder_name: string;
387
+ expiration_year: string;
388
+ expiration_month: string;
389
+ allows_charges: boolean;
390
+ allows_payouts: boolean;
391
+ bank_name: string;
392
+ points_type: string;
393
+ points_card: boolean;
394
+ bank_code: number;
395
+ };
396
+ customer_id: string;
397
+ gateway_card_present: string;
398
+ amount: number;
399
+ fee: {
400
+ amount: number;
401
+ tax: number;
402
+ currency: string;
403
+ };
404
+ payment_method: {
405
+ type: string;
406
+ url: string;
407
+ };
408
+ currency: string;
409
+ method: string;
410
+ object: string;
411
+ };
412
+ transaction_status!: string;
413
+ transaction_id!: number;
414
+ payment_id!: number;
415
+ provider!: string;
416
+ next_action!: {
417
+ redirect_to_url: {
418
+ url: string;
419
+ return_url: string;
420
+ verify_transaction_status_url: string;
421
+ };
422
+ };
423
+ actions!: {
424
+ name: string;
425
+ url: string;
426
+ method: string;
427
+ }[];
428
+
429
+ get mockObject(): StartCheckoutResponse {
430
+ return {
431
+ status: 200, // Representa un estado exitoso
432
+ message: "Payment processing initiated",
433
+ is_route_finished: false,
434
+ transaction_status: "PENDING",
435
+ transaction_id: 1234567890,
436
+ payment_id: 9876543210,
437
+ provider: "STRIPE",
438
+ next_action: {
439
+ redirect_to_url: {
440
+ url: "https://www.mock-payment-provider.com/checkout",
441
+ return_url: "https://your-app.com/payment-confirmation",
442
+ verify_transaction_status_url:
443
+ "https://api.mock-payment-provider.com/transactions/1234567890/status",
444
+ },
445
+ },
446
+ psp_response: {
447
+ id: " string",
448
+ authorization: 0,
449
+ operation_type: " string",
450
+ transaction_type: " string",
451
+ status: " string",
452
+ conciliated: false,
453
+ creation_date: " string",
454
+ operation_date: " string",
455
+ description: " string",
456
+ error_message: " string",
457
+ order_id: " string",
458
+ card: {
459
+ type: " string",
460
+ brand: " string",
461
+ address: " string",
462
+ card_number: " string",
463
+ holder_name: " string",
464
+ expiration_year: " string",
465
+ expiration_month: " string",
466
+ allows_charges: false,
467
+ allows_payouts: false,
468
+ bank_name: " string",
469
+ points_type: " string",
470
+ points_card: false,
471
+ bank_code: 0,
472
+ },
473
+ customer_id: " string",
474
+ gateway_card_present: " string",
475
+ amount: 0,
476
+ fee: {
477
+ amount: 0,
478
+ tax: 0,
479
+ currency: " string",
480
+ },
481
+ payment_method: {
482
+ type: " string",
483
+ url: " string",
484
+ },
485
+ currency: " string",
486
+ method: " string",
487
+ object: " string",
488
+ },
489
+ actions: [
490
+ {
491
+ name: "Check status",
492
+ url: "https://api.mock-payment-provider.com/transactions/1234567890/status",
493
+ method: "GET",
494
+ },
495
+ {
496
+ name: "Cancel payment",
497
+ url: "https://api.mock-payment-provider.com/transactions/1234567890/cancel",
498
+ method: "POST",
499
+ },
500
+ ],
501
+ };
502
+ }
503
+ }
504
+
505
+ export class StartCheckoutFullRequestClass implements StartCheckoutFullRequest {
506
+ order!: { items: OrderItem[]; };
507
+ return_url!: string;
508
+ total!: number;
509
+ skyflowTokens!: { cardholder_name: string; card_number: string; cvv: string; expiration_year: string; expiration_month: string; skyflow_id: string; };
510
+ customer!: { name: string; lastname: string; email: string; phone: string; };
511
+ isSandbox!: boolean;
512
+ currency!: string;
513
+ metadata!: any;
514
+
515
+ get mockObject(): StartCheckoutFullRequest {
516
+ return {
517
+ order: {
518
+ items: [
519
+ {
520
+ description: "string",
521
+ quantity: 25,
522
+ price_unit: 25,
523
+ discount: 0,
524
+ taxes: 0,
525
+ product_reference: 25,
526
+ name: "Product text",
527
+ amount_total: 25
528
+ }
529
+ ]
530
+ },
531
+ return_url: "string",
532
+ total: 25,
533
+ skyflowTokens: {
534
+ cardholder_name: "string",
535
+ card_number: "string",
536
+ cvv: "string",
537
+ expiration_year: "string",
538
+ expiration_month: "string",
539
+ skyflow_id: "string",
540
+ },
541
+ customer: {
542
+ name: "string",
543
+ lastname: "string",
544
+ email: "string",
545
+ phone: "string",
546
+ },
547
+ isSandbox: true,
548
+ currency: "MXN",
549
+ metadata: null
550
+ };
551
+ }
552
+ }
553
+
554
+ export class TokensRequestClass implements TokensRequest {
555
+ vault_id!: string;
556
+ vault_url!: string;
557
+ data: { [key: string]: any } = {};
558
+
559
+ get mockObject(): TokensRequest {
560
+ return {
561
+ vault_id: "string",
562
+ vault_url: "string",
563
+ data: {
564
+ fields: [],
565
+ },
566
+ };
567
+ }
568
+ }
569
+
570
+ export class RegisterCustomerCardResponseClass
571
+ implements RegisterCustomerCardResponse {
572
+ skyflow_id!: string;
573
+ user_id!: number;
574
+
575
+ get mockObject(): RegisterCustomerCardResponse {
576
+ return {
577
+ skyflow_id: "string",
578
+ user_id: 0,
579
+ };
580
+ }
581
+ }
582
+
583
+ export class RegisterCustomerCardRequestClass
584
+ implements RegisterCustomerCardRequest {
585
+ skyflow_id!: string;
586
+
587
+ get mockObject(): RegisterCustomerCardRequest {
588
+ return {
589
+ skyflow_id: "",
590
+ };
591
+ }
592
+ }
593
+
594
+ export class GetCustomerCardsResponseClass implements GetCustomerCardsResponse {
595
+ user_id!: number;
596
+ cards!: {
597
+ fields: {
598
+ card_scheme: string;
599
+ card_number: string;
600
+ cardholder_name: string;
601
+ cvv: string;
602
+ expiration_month: string;
603
+ expiration_year: string;
604
+ skyflow_id: string;
605
+ };
606
+ }[];
607
+
608
+ get mockObject(): GetCustomerCardsResponse {
609
+ return {
610
+ user_id: 0,
611
+ cards: [
612
+ {
613
+ fields: {
614
+ card_scheme: "string",
615
+ card_number: "string",
616
+ cardholder_name: "string",
617
+ cvv: "string",
618
+ expiration_month: "string",
619
+ expiration_year: "string",
620
+ skyflow_id: "string",
621
+ },
622
+ },
623
+ ],
624
+ };
625
+ }
626
+ }
627
+
628
+ export const OrderEmptyValuesResponse = {
629
+ "business": [
630
+ "This field may not be blank."
631
+ ],
632
+ "reference": [
633
+ "This field may not be null."
634
+ ]
635
+ }
636
+
637
+ export class CustomerRegisterClass implements CustomerRegisterResponse {
638
+ id!: number;
639
+ email!: string;
640
+ auth_token!: string;
641
+ first_name!: string;
642
+ last_name!: string;
643
+
644
+ get mockObject(): CustomerRegisterResponse {
645
+ return {
646
+ id: 10,
647
+ email: "email@gmail.com",
648
+ auth_token: "string"
649
+ };
650
+ }
651
+ }