@tonder.io/ionic-lite-sdk 0.0.35-beta.8 → 0.0.37-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/.gitlab-ci.yml +28 -28
  2. package/README.md +532 -202
  3. package/dist/classes/BaseInlineCheckout.d.ts +21 -19
  4. package/dist/classes/errorResponse.d.ts +1 -1
  5. package/dist/classes/liteCheckout.d.ts +15 -43
  6. package/dist/data/api.d.ts +1 -1
  7. package/dist/data/businessApi.d.ts +1 -1
  8. package/dist/data/cardApi.d.ts +1 -1
  9. package/dist/data/checkoutApi.d.ts +2 -1
  10. package/dist/data/customerApi.d.ts +1 -1
  11. package/dist/data/paymentMethodApi.d.ts +2 -2
  12. package/dist/helpers/skyflow.d.ts +1 -1
  13. package/dist/index.d.ts +2 -1
  14. package/dist/index.js +1 -1
  15. package/dist/types/card.d.ts +1 -0
  16. package/dist/types/checkout.d.ts +7 -1
  17. package/dist/types/commons.d.ts +8 -3
  18. package/dist/types/customer.d.ts +10 -0
  19. package/{src → dist}/types/liteInlineCheckout.d.ts +33 -73
  20. package/dist/types/responses.d.ts +3 -0
  21. package/jest.config.ts +14 -14
  22. package/package.json +41 -38
  23. package/rollup.config.js +16 -16
  24. package/src/classes/3dsHandler.ts +237 -237
  25. package/src/classes/BaseInlineCheckout.ts +385 -356
  26. package/src/classes/errorResponse.ts +16 -16
  27. package/src/classes/liteCheckout.ts +588 -598
  28. package/src/data/api.ts +20 -20
  29. package/src/data/businessApi.ts +18 -18
  30. package/src/data/cardApi.ts +85 -89
  31. package/src/data/checkoutApi.ts +84 -87
  32. package/src/data/customerApi.ts +31 -31
  33. package/src/data/openPayApi.ts +12 -12
  34. package/src/data/paymentMethodApi.ts +37 -37
  35. package/src/data/skyflowApi.ts +20 -20
  36. package/src/helpers/constants.ts +63 -63
  37. package/src/helpers/mercadopago.ts +15 -15
  38. package/src/helpers/skyflow.ts +91 -91
  39. package/src/helpers/utils.ts +120 -120
  40. package/src/helpers/validations.ts +55 -55
  41. package/src/index.ts +12 -10
  42. package/src/shared/catalog/paymentMethodsCatalog.ts +247 -247
  43. package/src/shared/constants/messages.ts +10 -10
  44. package/src/shared/constants/paymentMethodAPM.ts +63 -63
  45. package/src/shared/constants/tonderUrl.ts +8 -8
  46. package/src/types/card.ts +35 -34
  47. package/src/types/checkout.ts +123 -117
  48. package/src/types/commons.ts +130 -125
  49. package/src/types/customer.ts +22 -12
  50. package/src/types/liteInlineCheckout.ts +216 -0
  51. package/src/types/paymentMethod.ts +23 -23
  52. package/src/types/requests.ts +114 -114
  53. package/src/types/responses.ts +193 -189
  54. package/src/types/skyflow.ts +17 -17
  55. package/src/types/transaction.ts +101 -101
  56. package/src/types/validations.d.ts +11 -11
  57. package/tests/classes/liteCheckout.test.ts +57 -57
  58. package/tests/methods/createOrder.test.ts +141 -142
  59. package/tests/methods/createPayment.test.ts +121 -122
  60. package/tests/methods/customerRegister.test.ts +118 -119
  61. package/tests/methods/getBusiness.test.ts +114 -115
  62. package/tests/methods/getCustomerCards.test.ts +112 -113
  63. package/tests/methods/registerCustomerCard.test.ts +117 -117
  64. package/tests/methods/startCheckoutRouter.test.ts +119 -119
  65. package/tests/methods/startCheckoutRouterFull.test.ts +138 -138
  66. package/tests/utils/defaultMock.ts +21 -21
  67. package/tests/utils/mockClasses.ts +659 -659
  68. package/tsconfig.json +18 -18
  69. package/types/classes/liteCheckout.d.ts +29 -0
  70. package/types/classes/liteCheckout.js +225 -0
  71. package/types/classes/liteCheckout.js.map +1 -0
  72. package/types/helpers/utils.d.ts +3 -0
  73. package/types/helpers/utils.js +27 -0
  74. package/types/helpers/utils.js.map +1 -0
  75. package/types/index.d.ts +2 -0
  76. package/types/index.js +6 -0
  77. package/types/index.js.map +1 -0
  78. package/.idea/aws.xml +0 -17
  79. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  80. package/.idea/prettier.xml +0 -6
  81. package/.idea/vcs.xml +0 -6
  82. package/.idea/workspace.xml +0 -133
  83. package/src/types/index.d.ts +0 -10
@@ -1,123 +1,122 @@
1
- import "../utils/defaultMock";
2
- import { LiteCheckout } from "../../src";
3
- import { ErrorResponse } from "../../src/classes/errorResponse";
4
- import { LiteCheckoutConstructor } from "../../src/classes/liteCheckout";
5
- import { IErrorResponse } from "../../src/types/responses";
6
- import { constructorFields } from "../utils/defaultMock";
7
- import { CreatePaymentResponseClass, CreatePaymentRequestClass } from "../utils/mockClasses";
8
-
9
-
10
- declare global {
11
- interface Window {
12
- OpenPay: any;
13
- Skyflow: any;
14
- }
15
- }
16
-
17
- describe("createPayment", () => {
18
- let checkoutConstructor: LiteCheckoutConstructor,
19
- liteCheckout: LiteCheckout,
20
- fetchSpy: jest.SpyInstance,
21
- liteCheckoutSpy: jest.SpyInstance;
22
-
23
- beforeEach(async () => {
24
- window.fetch = jest.fn();
25
-
26
- checkoutConstructor = {
27
- ...constructorFields,
28
- };
29
-
30
- liteCheckout = new LiteCheckout(constructorFields);
31
-
32
- fetchSpy = jest.spyOn(global, "fetch");
33
- });
34
-
35
- afterEach(() => {
36
- jest.restoreAllMocks();
37
- });
38
-
39
- it("createPayment success", async () => {
40
- liteCheckoutSpy = jest.spyOn(liteCheckout, "createPayment");
41
-
42
- fetchSpy.mockImplementation(() =>
43
- Promise.resolve({
44
- json: () => Promise.resolve([{ ...new CreatePaymentResponseClass() }]),
45
- ok: true,
46
- })
47
- );
48
-
49
- const response = await liteCheckout.createPayment({
50
- ...new CreatePaymentRequestClass(),
51
- });
52
-
53
- expect(response).toStrictEqual([{ ...new CreatePaymentResponseClass() }]);
54
- expect(liteCheckoutSpy).toHaveBeenCalled();
55
- expect(liteCheckoutSpy).toHaveBeenCalledWith({
56
- ...new CreatePaymentRequestClass(),
57
- });
58
- });
59
-
60
- it("createPayment empty", async () => {
61
- liteCheckoutSpy = jest.spyOn(liteCheckout, "createPayment");
62
-
63
- fetchSpy.mockImplementation(() =>
64
- Promise.resolve({
65
- json: () => Promise.resolve(),
66
- ok: true,
67
- })
68
- );
69
-
70
- const response = await liteCheckout.createPayment({
71
- ...new CreatePaymentRequestClass(),
72
- });
73
- expect(liteCheckoutSpy).toHaveBeenCalled();
74
- expect(liteCheckoutSpy).toHaveReturned();
75
- expect(response).toBeUndefined();
76
- });
77
-
78
- it("createPayment errorResponse", async () => {
79
- liteCheckoutSpy = jest.spyOn(liteCheckout, "createPayment");
80
-
81
- fetchSpy.mockImplementation(() =>
82
- Promise.resolve({
83
- json: () => Promise.resolve(),
84
- ok: false,
85
- status: 400,
86
- })
87
- );
88
-
89
- let error;
90
-
91
- try {
92
- const response = await liteCheckout.createPayment({
93
- ...new CreatePaymentRequestClass(),
94
- })
95
- } catch (e) {
96
- error = e;
97
- }
98
-
99
- expect(liteCheckoutSpy).toHaveBeenCalled();
100
- expect(error).toBeInstanceOf(ErrorResponse);
101
- });
102
-
103
- it("createPayment errorCatch", async () => {
104
- liteCheckoutSpy = jest.spyOn(liteCheckout, "createPayment");
105
-
106
- fetchSpy.mockRejectedValue("error");
107
-
108
- let error: ErrorResponse;
109
-
110
- try {
111
- const response = (await liteCheckout.createPayment({
112
- ...new CreatePaymentRequestClass(),
113
- })) as ErrorResponse;
114
- } catch (e: any) {
115
- error = e;
116
- expect(error.message).toStrictEqual("error");
117
- expect(error.name).toStrictEqual("catch");
118
- }
119
-
120
- expect(liteCheckoutSpy).toHaveBeenCalled();
121
- expect(liteCheckoutSpy).rejects.toThrow();
122
- });
1
+ import "../utils/defaultMock";
2
+ import { LiteCheckout } from "../../src";
3
+ import { ErrorResponse } from "../../src/classes/errorResponse";
4
+ import { constructorFields } from "../utils/defaultMock";
5
+ import { CreatePaymentResponseClass, CreatePaymentRequestClass } from "../utils/mockClasses";
6
+ import {IInlineLiteCheckoutOptions} from "../../src/types/commons";
7
+
8
+
9
+ declare global {
10
+ interface Window {
11
+ OpenPay: any;
12
+ Skyflow: any;
13
+ }
14
+ }
15
+
16
+ describe("createPayment", () => {
17
+ let checkoutConstructor: IInlineLiteCheckoutOptions,
18
+ liteCheckout: LiteCheckout,
19
+ fetchSpy: jest.SpyInstance,
20
+ liteCheckoutSpy: jest.SpyInstance;
21
+
22
+ beforeEach(async () => {
23
+ window.fetch = jest.fn();
24
+
25
+ checkoutConstructor = {
26
+ ...constructorFields,
27
+ };
28
+
29
+ liteCheckout = new LiteCheckout(constructorFields);
30
+
31
+ fetchSpy = jest.spyOn(global, "fetch");
32
+ });
33
+
34
+ afterEach(() => {
35
+ jest.restoreAllMocks();
36
+ });
37
+
38
+ it("createPayment success", async () => {
39
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "createPayment");
40
+
41
+ fetchSpy.mockImplementation(() =>
42
+ Promise.resolve({
43
+ json: () => Promise.resolve([{ ...new CreatePaymentResponseClass() }]),
44
+ ok: true,
45
+ })
46
+ );
47
+
48
+ const response = await liteCheckout.createPayment({
49
+ ...new CreatePaymentRequestClass(),
50
+ });
51
+
52
+ expect(response).toStrictEqual([{ ...new CreatePaymentResponseClass() }]);
53
+ expect(liteCheckoutSpy).toHaveBeenCalled();
54
+ expect(liteCheckoutSpy).toHaveBeenCalledWith({
55
+ ...new CreatePaymentRequestClass(),
56
+ });
57
+ });
58
+
59
+ it("createPayment empty", async () => {
60
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "createPayment");
61
+
62
+ fetchSpy.mockImplementation(() =>
63
+ Promise.resolve({
64
+ json: () => Promise.resolve(),
65
+ ok: true,
66
+ })
67
+ );
68
+
69
+ const response = await liteCheckout.createPayment({
70
+ ...new CreatePaymentRequestClass(),
71
+ });
72
+ expect(liteCheckoutSpy).toHaveBeenCalled();
73
+ expect(liteCheckoutSpy).toHaveReturned();
74
+ expect(response).toBeUndefined();
75
+ });
76
+
77
+ it("createPayment errorResponse", async () => {
78
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "createPayment");
79
+
80
+ fetchSpy.mockImplementation(() =>
81
+ Promise.resolve({
82
+ json: () => Promise.resolve(),
83
+ ok: false,
84
+ status: 400,
85
+ })
86
+ );
87
+
88
+ let error;
89
+
90
+ try {
91
+ const response = await liteCheckout.createPayment({
92
+ ...new CreatePaymentRequestClass(),
93
+ })
94
+ } catch (e) {
95
+ error = e;
96
+ }
97
+
98
+ expect(liteCheckoutSpy).toHaveBeenCalled();
99
+ expect(error).toBeInstanceOf(ErrorResponse);
100
+ });
101
+
102
+ it("createPayment errorCatch", async () => {
103
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "createPayment");
104
+
105
+ fetchSpy.mockRejectedValue("error");
106
+
107
+ let error: ErrorResponse;
108
+
109
+ try {
110
+ const response = (await liteCheckout.createPayment({
111
+ ...new CreatePaymentRequestClass(),
112
+ })) as ErrorResponse;
113
+ } catch (e: any) {
114
+ error = e;
115
+ expect(error.message).toStrictEqual("error");
116
+ expect(error.name).toStrictEqual("catch");
117
+ }
118
+
119
+ expect(liteCheckoutSpy).toHaveBeenCalled();
120
+ expect(liteCheckoutSpy).rejects.toThrow();
121
+ });
123
122
  });
@@ -1,120 +1,119 @@
1
- import "../utils/defaultMock";
2
- import { LiteCheckout } from "../../src";
3
- import { ErrorResponse } from "../../src/classes/errorResponse";
4
- import { LiteCheckoutConstructor } from "../../src/classes/liteCheckout";
5
- import { IErrorResponse } from "../../src/types/responses";
6
- import { constructorFields } from "../utils/defaultMock";
7
- import { BusinessClass, CustomerRegisterClass } from "../utils/mockClasses";
8
-
9
-
10
- declare global {
11
- interface Window {
12
- OpenPay: any;
13
- Skyflow: any;
14
- }
15
- }
16
-
17
- describe("customerRegister", () => {
18
- let checkoutConstructor: LiteCheckoutConstructor,
19
- liteCheckout: LiteCheckout,
20
- fetchSpy: jest.SpyInstance,
21
- liteCheckoutSpy: jest.SpyInstance;
22
-
23
- beforeEach(async () => {
24
- window.fetch = jest.fn();
25
-
26
- checkoutConstructor = {
27
- ...constructorFields,
28
- };
29
-
30
- liteCheckout = new LiteCheckout(constructorFields);
31
-
32
- fetchSpy = jest.spyOn(global, "fetch");
33
- });
34
-
35
- afterEach(() => {
36
- jest.restoreAllMocks();
37
- });
38
-
39
- it("customerRegister success", async () => {
40
- liteCheckoutSpy = jest.spyOn(liteCheckout, "customerRegister");
41
-
42
- fetchSpy.mockImplementation(() =>
43
- Promise.resolve({
44
- json: () =>
45
- Promise.resolve({
46
- ...new CustomerRegisterClass(),
47
- }),
48
- ok: true,
49
- })
50
- );
51
-
52
- const response = await liteCheckout.customerRegister("email@gmail.com");
53
-
54
- expect(response).toStrictEqual({ ...new CustomerRegisterClass() });
55
- expect(liteCheckoutSpy).toHaveBeenCalled();
56
- expect(liteCheckoutSpy).toHaveBeenCalledWith("email@gmail.com");
57
- });
58
-
59
- it("customerRegister empty", async () => {
60
- liteCheckoutSpy = jest.spyOn(liteCheckout, "customerRegister");
61
-
62
- fetchSpy.mockImplementation(() =>
63
- Promise.resolve({
64
- json: () => Promise.resolve(),
65
- ok: true,
66
- })
67
- );
68
-
69
- const response = await liteCheckout.customerRegister("email@gmail.com");
70
- expect(liteCheckoutSpy).toHaveBeenCalled();
71
- expect(liteCheckoutSpy).toHaveReturned();
72
- expect(response).toBeUndefined();
73
- });
74
-
75
- it("customerRegister errorResponse", async () => {
76
- liteCheckoutSpy = jest.spyOn(liteCheckout, "customerRegister");
77
-
78
- fetchSpy.mockImplementation(() =>
79
- Promise.resolve({
80
- json: () => Promise.resolve(),
81
- ok: false,
82
- status: 400,
83
- })
84
- );
85
-
86
- let error: ErrorResponse;
87
-
88
- try {
89
- const response = await liteCheckout.customerRegister(
90
- "email@gmail.com"
91
- )
92
- } catch (e: any) {
93
- error = e;
94
- expect(error.code).toStrictEqual("400");
95
- expect(error).toBeInstanceOf(ErrorResponse);
96
- }
97
-
98
- });
99
-
100
- it("customerRegister errorCatch", async () => {
101
- liteCheckoutSpy = jest.spyOn(liteCheckout, "customerRegister");
102
-
103
- fetchSpy.mockRejectedValue("error");
104
-
105
- let error: ErrorResponse;
106
-
107
- try {
108
- const response = (await liteCheckout.customerRegister(
109
- "email@gmail.com"
110
- )) as ErrorResponse;
111
- } catch (e: any) {
112
- error = e;
113
- expect(error.message).toStrictEqual("error");
114
- expect(error.name).toStrictEqual("catch");
115
- }
116
-
117
- expect(liteCheckoutSpy).toHaveBeenCalled();
118
- expect(liteCheckoutSpy).rejects.toThrow();
119
- });
1
+ import "../utils/defaultMock";
2
+ import { LiteCheckout } from "../../src";
3
+ import { ErrorResponse } from "../../src/classes/errorResponse";
4
+ import { constructorFields } from "../utils/defaultMock";
5
+ import { CustomerRegisterClass } from "../utils/mockClasses";
6
+ import {IInlineLiteCheckoutOptions} from "../../src/types/commons";
7
+
8
+
9
+ declare global {
10
+ interface Window {
11
+ OpenPay: any;
12
+ Skyflow: any;
13
+ }
14
+ }
15
+
16
+ describe("customerRegister", () => {
17
+ let checkoutConstructor: IInlineLiteCheckoutOptions,
18
+ liteCheckout: LiteCheckout,
19
+ fetchSpy: jest.SpyInstance,
20
+ liteCheckoutSpy: jest.SpyInstance;
21
+
22
+ beforeEach(async () => {
23
+ window.fetch = jest.fn();
24
+
25
+ checkoutConstructor = {
26
+ ...constructorFields,
27
+ };
28
+
29
+ liteCheckout = new LiteCheckout(constructorFields);
30
+
31
+ fetchSpy = jest.spyOn(global, "fetch");
32
+ });
33
+
34
+ afterEach(() => {
35
+ jest.restoreAllMocks();
36
+ });
37
+
38
+ it("customerRegister success", async () => {
39
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "customerRegister");
40
+
41
+ fetchSpy.mockImplementation(() =>
42
+ Promise.resolve({
43
+ json: () =>
44
+ Promise.resolve({
45
+ ...new CustomerRegisterClass(),
46
+ }),
47
+ ok: true,
48
+ })
49
+ );
50
+
51
+ const response = await liteCheckout.customerRegister("email@gmail.com");
52
+
53
+ expect(response).toStrictEqual({ ...new CustomerRegisterClass() });
54
+ expect(liteCheckoutSpy).toHaveBeenCalled();
55
+ expect(liteCheckoutSpy).toHaveBeenCalledWith("email@gmail.com");
56
+ });
57
+
58
+ it("customerRegister empty", async () => {
59
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "customerRegister");
60
+
61
+ fetchSpy.mockImplementation(() =>
62
+ Promise.resolve({
63
+ json: () => Promise.resolve(),
64
+ ok: true,
65
+ })
66
+ );
67
+
68
+ const response = await liteCheckout.customerRegister("email@gmail.com");
69
+ expect(liteCheckoutSpy).toHaveBeenCalled();
70
+ expect(liteCheckoutSpy).toHaveReturned();
71
+ expect(response).toBeUndefined();
72
+ });
73
+
74
+ it("customerRegister errorResponse", async () => {
75
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "customerRegister");
76
+
77
+ fetchSpy.mockImplementation(() =>
78
+ Promise.resolve({
79
+ json: () => Promise.resolve(),
80
+ ok: false,
81
+ status: 400,
82
+ })
83
+ );
84
+
85
+ let error: ErrorResponse;
86
+
87
+ try {
88
+ const response = await liteCheckout.customerRegister(
89
+ "email@gmail.com"
90
+ )
91
+ } catch (e: any) {
92
+ error = e;
93
+ expect(error.code).toStrictEqual("400");
94
+ expect(error).toBeInstanceOf(ErrorResponse);
95
+ }
96
+
97
+ });
98
+
99
+ it("customerRegister errorCatch", async () => {
100
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "customerRegister");
101
+
102
+ fetchSpy.mockRejectedValue("error");
103
+
104
+ let error: ErrorResponse;
105
+
106
+ try {
107
+ const response = (await liteCheckout.customerRegister(
108
+ "email@gmail.com"
109
+ )) as ErrorResponse;
110
+ } catch (e: any) {
111
+ error = e;
112
+ expect(error.message).toStrictEqual("error");
113
+ expect(error.name).toStrictEqual("catch");
114
+ }
115
+
116
+ expect(liteCheckoutSpy).toHaveBeenCalled();
117
+ expect(liteCheckoutSpy).rejects.toThrow();
118
+ });
120
119
  });