@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,114 +1,114 @@
1
- import "../utils/defaultMock";
2
- import { LiteCheckout } from "../../src";
3
- import { ErrorResponse } from "../../src/classes/errorResponse";
4
- import { constructorFields } from "../utils/defaultMock";
5
- import { BusinessClass } from "../utils/mockClasses";
6
- import {IInlineLiteCheckoutOptions} from "../../src/types/commons";
7
-
8
- declare global {
9
- interface Window {
10
- OpenPay: any;
11
- Skyflow: any;
12
- }
13
- }
14
-
15
- describe("getBusiness", () => {
16
- let checkoutConstructor: IInlineLiteCheckoutOptions,
17
- liteCheckout: LiteCheckout,
18
- fetchSpy: jest.SpyInstance,
19
- liteCheckoutSpy: jest.SpyInstance;
20
-
21
- beforeEach(async () => {
22
- window.fetch = jest.fn();
23
-
24
- checkoutConstructor = {
25
- ...constructorFields,
26
- };
27
-
28
- liteCheckout = new LiteCheckout(constructorFields);
29
-
30
- fetchSpy = jest.spyOn(global, "fetch");
31
- });
32
-
33
- afterEach(() => {
34
- jest.restoreAllMocks();
35
- });
36
-
37
- it("getBusiness success", async () => {
38
- liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
39
-
40
- fetchSpy.mockImplementation(() =>
41
- Promise.resolve({
42
- json: () =>
43
- Promise.resolve({
44
- ...new BusinessClass(),
45
- }),
46
- ok: true,
47
- })
48
- );
49
-
50
- const response = await liteCheckout.getBusiness();
51
-
52
- expect(response).toStrictEqual({ ...new BusinessClass() });
53
- expect(liteCheckoutSpy).toHaveBeenCalled();
54
- });
55
-
56
- it("getBusiness empty", async () => {
57
- liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
58
-
59
- fetchSpy.mockImplementation(() =>
60
- Promise.resolve({
61
- json: () => Promise.resolve(),
62
- ok: true,
63
- })
64
- );
65
-
66
- const response = await liteCheckout.getBusiness();
67
- expect(liteCheckoutSpy).toHaveBeenCalled();
68
- expect(liteCheckoutSpy).toHaveReturned();
69
- expect(response).toBeUndefined();
70
- });
71
-
72
- it("getBusiness errorResponse", async () => {
73
- liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
74
-
75
- fetchSpy.mockImplementation(() =>
76
- Promise.resolve({
77
- json: () => Promise.resolve(),
78
- ok: false,
79
- status: 400,
80
- })
81
- );
82
-
83
- let error: ErrorResponse;
84
-
85
- try {
86
- const response = (await liteCheckout.getBusiness());
87
- } catch (e: any) {
88
- error = e;
89
- expect(error.code).toStrictEqual("400");
90
- expect(error).toBeInstanceOf(ErrorResponse);
91
- }
92
- });
93
-
94
- it("getBusiness errorCatch", async () => {
95
- liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
96
-
97
- fetchSpy.mockRejectedValue("error");
98
-
99
- let error: ErrorResponse;
100
-
101
- try {
102
- const response = (await liteCheckout.getBusiness());
103
- } catch (e: any) {
104
- error = e;
105
- expect(error.message).toStrictEqual("error");
106
- expect(error.name).toStrictEqual("catch");
107
- }
108
-
109
- expect(liteCheckoutSpy).toHaveBeenCalled();
110
- expect(liteCheckoutSpy).rejects.toThrow();
111
- });
112
- });
113
-
114
-
1
+ import "../utils/defaultMock";
2
+ import { LiteCheckout } from "../../src";
3
+ import { ErrorResponse } from "../../src/classes/errorResponse";
4
+ import { constructorFields } from "../utils/defaultMock";
5
+ import { BusinessClass } from "../utils/mockClasses";
6
+ import {IInlineLiteCheckoutOptions} from "../../src/types/commons";
7
+
8
+ declare global {
9
+ interface Window {
10
+ OpenPay: any;
11
+ Skyflow: any;
12
+ }
13
+ }
14
+
15
+ describe("getBusiness", () => {
16
+ let checkoutConstructor: IInlineLiteCheckoutOptions,
17
+ liteCheckout: LiteCheckout,
18
+ fetchSpy: jest.SpyInstance,
19
+ liteCheckoutSpy: jest.SpyInstance;
20
+
21
+ beforeEach(async () => {
22
+ window.fetch = jest.fn();
23
+
24
+ checkoutConstructor = {
25
+ ...constructorFields,
26
+ };
27
+
28
+ liteCheckout = new LiteCheckout(constructorFields);
29
+
30
+ fetchSpy = jest.spyOn(global, "fetch");
31
+ });
32
+
33
+ afterEach(() => {
34
+ jest.restoreAllMocks();
35
+ });
36
+
37
+ it("getBusiness success", async () => {
38
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
39
+
40
+ fetchSpy.mockImplementation(() =>
41
+ Promise.resolve({
42
+ json: () =>
43
+ Promise.resolve({
44
+ ...new BusinessClass(),
45
+ }),
46
+ ok: true,
47
+ })
48
+ );
49
+
50
+ const response = await liteCheckout.getBusiness();
51
+
52
+ expect(response).toStrictEqual({ ...new BusinessClass() });
53
+ expect(liteCheckoutSpy).toHaveBeenCalled();
54
+ });
55
+
56
+ it("getBusiness empty", async () => {
57
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
58
+
59
+ fetchSpy.mockImplementation(() =>
60
+ Promise.resolve({
61
+ json: () => Promise.resolve(),
62
+ ok: true,
63
+ })
64
+ );
65
+
66
+ const response = await liteCheckout.getBusiness();
67
+ expect(liteCheckoutSpy).toHaveBeenCalled();
68
+ expect(liteCheckoutSpy).toHaveReturned();
69
+ expect(response).toBeUndefined();
70
+ });
71
+
72
+ it("getBusiness errorResponse", async () => {
73
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
74
+
75
+ fetchSpy.mockImplementation(() =>
76
+ Promise.resolve({
77
+ json: () => Promise.resolve(),
78
+ ok: false,
79
+ status: 400,
80
+ })
81
+ );
82
+
83
+ let error: ErrorResponse;
84
+
85
+ try {
86
+ const response = (await liteCheckout.getBusiness());
87
+ } catch (e: any) {
88
+ error = e;
89
+ expect(error.code).toStrictEqual("400");
90
+ expect(error).toBeInstanceOf(ErrorResponse);
91
+ }
92
+ });
93
+
94
+ it("getBusiness errorCatch", async () => {
95
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
96
+
97
+ fetchSpy.mockRejectedValue("error");
98
+
99
+ let error: ErrorResponse;
100
+
101
+ try {
102
+ const response = (await liteCheckout.getBusiness());
103
+ } catch (e: any) {
104
+ error = e;
105
+ expect(error.message).toStrictEqual("error");
106
+ expect(error.name).toStrictEqual("catch");
107
+ }
108
+
109
+ expect(liteCheckoutSpy).toHaveBeenCalled();
110
+ expect(liteCheckoutSpy).rejects.toThrow();
111
+ });
112
+ });
113
+
114
+
@@ -1,113 +1,113 @@
1
- import "../utils/defaultMock";
2
- import { LiteCheckout } from "../../src";
3
- import { ErrorResponse } from "../../src/classes/errorResponse";
4
- import { constructorFields } from "../utils/defaultMock";
5
- import { GetCustomerCardsResponseClass } from "../utils/mockClasses";
6
- import {IInlineLiteCheckoutOptions} from "../../src/types/commons";
7
-
8
- declare global {
9
- interface Window {
10
- OpenPay: any;
11
- Skyflow: any;
12
- }
13
- }
14
-
15
- describe("getCustomerCards", () => {
16
- let checkoutConstructor: IInlineLiteCheckoutOptions,
17
- liteCheckout: LiteCheckout,
18
- fetchSpy: jest.SpyInstance,
19
- liteCheckoutSpy: jest.SpyInstance;
20
-
21
- beforeEach(async () => {
22
- window.fetch = jest.fn();
23
-
24
- checkoutConstructor = {
25
- ...constructorFields,
26
- };
27
-
28
- liteCheckout = new LiteCheckout(constructorFields);
29
-
30
- fetchSpy = jest.spyOn(global, "fetch");
31
- });
32
-
33
- afterEach(() => {
34
- jest.restoreAllMocks();
35
- });
36
-
37
- it("getCustomerCards success", async () => {
38
- liteCheckoutSpy = jest.spyOn(liteCheckout, "getCustomerCards");
39
-
40
- fetchSpy.mockImplementation(() =>
41
- Promise.resolve({
42
- json: () =>
43
- Promise.resolve({
44
- ...new GetCustomerCardsResponseClass(),
45
- }),
46
- ok: true,
47
- })
48
- );
49
-
50
- const response = await liteCheckout.getCustomerCards();
51
-
52
- expect(response).toStrictEqual({ ...new GetCustomerCardsResponseClass() });
53
- expect(liteCheckoutSpy).toHaveBeenCalled();
54
- expect(liteCheckoutSpy).toHaveBeenCalledWith("1234", "123456");
55
- });
56
-
57
- it("getCustomerCards empty", async () => {
58
- liteCheckoutSpy = jest.spyOn(liteCheckout, "getCustomerCards");
59
-
60
- fetchSpy.mockImplementation(() =>
61
- Promise.resolve({
62
- json: () => Promise.resolve(),
63
- ok: true,
64
- })
65
- );
66
-
67
- const response = await liteCheckout.getCustomerCards();
68
- expect(liteCheckoutSpy).toHaveBeenCalled();
69
- expect(liteCheckoutSpy).toHaveReturned();
70
- expect(response).toBeUndefined();
71
- });
72
-
73
- it("getCustomerCards errorResponse", async () => {
74
- liteCheckoutSpy = jest.spyOn(liteCheckout, "getCustomerCards");
75
-
76
- fetchSpy.mockImplementation(() =>
77
- Promise.resolve({
78
- json: () => Promise.resolve(),
79
- ok: false,
80
- status: 400,
81
- })
82
- );
83
-
84
- let error: ErrorResponse;
85
-
86
- try {
87
- const response = (await liteCheckout.getCustomerCards());
88
- } catch (e: any) {
89
- error = e;
90
- expect(error.code).toStrictEqual("400");
91
- expect(error).toBeInstanceOf(ErrorResponse);
92
- }
93
- });
94
-
95
- it("getCustomerCards errorCatch", async () => {
96
- liteCheckoutSpy = jest.spyOn(liteCheckout, "getCustomerCards");
97
-
98
- fetchSpy.mockRejectedValue("error");
99
-
100
- let error: ErrorResponse;
101
-
102
- try {
103
- const response = (await liteCheckout.getCustomerCards());
104
- } catch (e: any) {
105
- error = e;
106
- expect(error.message).toStrictEqual("error");
107
- expect(error.name).toStrictEqual("catch");
108
- }
109
-
110
- expect(liteCheckoutSpy).toHaveBeenCalled();
111
- expect(liteCheckoutSpy).rejects.toThrow();
112
- });
1
+ import "../utils/defaultMock";
2
+ import { LiteCheckout } from "../../src";
3
+ import { ErrorResponse } from "../../src/classes/errorResponse";
4
+ import { constructorFields } from "../utils/defaultMock";
5
+ import { GetCustomerCardsResponseClass } from "../utils/mockClasses";
6
+ import {IInlineLiteCheckoutOptions} from "../../src/types/commons";
7
+
8
+ declare global {
9
+ interface Window {
10
+ OpenPay: any;
11
+ Skyflow: any;
12
+ }
13
+ }
14
+
15
+ describe("getCustomerCards", () => {
16
+ let checkoutConstructor: IInlineLiteCheckoutOptions,
17
+ liteCheckout: LiteCheckout,
18
+ fetchSpy: jest.SpyInstance,
19
+ liteCheckoutSpy: jest.SpyInstance;
20
+
21
+ beforeEach(async () => {
22
+ window.fetch = jest.fn();
23
+
24
+ checkoutConstructor = {
25
+ ...constructorFields,
26
+ };
27
+
28
+ liteCheckout = new LiteCheckout(constructorFields);
29
+
30
+ fetchSpy = jest.spyOn(global, "fetch");
31
+ });
32
+
33
+ afterEach(() => {
34
+ jest.restoreAllMocks();
35
+ });
36
+
37
+ it("getCustomerCards success", async () => {
38
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "getCustomerCards");
39
+
40
+ fetchSpy.mockImplementation(() =>
41
+ Promise.resolve({
42
+ json: () =>
43
+ Promise.resolve({
44
+ ...new GetCustomerCardsResponseClass(),
45
+ }),
46
+ ok: true,
47
+ })
48
+ );
49
+
50
+ const response = await liteCheckout.getCustomerCards();
51
+
52
+ expect(response).toStrictEqual({ ...new GetCustomerCardsResponseClass() });
53
+ expect(liteCheckoutSpy).toHaveBeenCalled();
54
+ expect(liteCheckoutSpy).toHaveBeenCalledWith("1234", "123456");
55
+ });
56
+
57
+ it("getCustomerCards empty", async () => {
58
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "getCustomerCards");
59
+
60
+ fetchSpy.mockImplementation(() =>
61
+ Promise.resolve({
62
+ json: () => Promise.resolve(),
63
+ ok: true,
64
+ })
65
+ );
66
+
67
+ const response = await liteCheckout.getCustomerCards();
68
+ expect(liteCheckoutSpy).toHaveBeenCalled();
69
+ expect(liteCheckoutSpy).toHaveReturned();
70
+ expect(response).toBeUndefined();
71
+ });
72
+
73
+ it("getCustomerCards errorResponse", async () => {
74
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "getCustomerCards");
75
+
76
+ fetchSpy.mockImplementation(() =>
77
+ Promise.resolve({
78
+ json: () => Promise.resolve(),
79
+ ok: false,
80
+ status: 400,
81
+ })
82
+ );
83
+
84
+ let error: ErrorResponse;
85
+
86
+ try {
87
+ const response = (await liteCheckout.getCustomerCards());
88
+ } catch (e: any) {
89
+ error = e;
90
+ expect(error.code).toStrictEqual("400");
91
+ expect(error).toBeInstanceOf(ErrorResponse);
92
+ }
93
+ });
94
+
95
+ it("getCustomerCards errorCatch", async () => {
96
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "getCustomerCards");
97
+
98
+ fetchSpy.mockRejectedValue("error");
99
+
100
+ let error: ErrorResponse;
101
+
102
+ try {
103
+ const response = (await liteCheckout.getCustomerCards());
104
+ } catch (e: any) {
105
+ error = e;
106
+ expect(error.message).toStrictEqual("error");
107
+ expect(error.name).toStrictEqual("catch");
108
+ }
109
+
110
+ expect(liteCheckoutSpy).toHaveBeenCalled();
111
+ expect(liteCheckoutSpy).rejects.toThrow();
112
+ });
113
113
  });