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

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