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