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

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 (55) hide show
  1. package/.gitlab-ci.yml +28 -28
  2. package/README.md +532 -532
  3. package/dist/classes/BaseInlineCheckout.d.ts +1 -1
  4. package/dist/classes/liteCheckout.d.ts +1 -1
  5. package/dist/data/cardApi.d.ts +3 -3
  6. package/dist/index.js +1 -1
  7. package/dist/types/liteInlineCheckout.d.ts +1 -1
  8. package/jest.config.ts +14 -14
  9. package/package.json +41 -41
  10. package/rollup.config.js +16 -16
  11. package/src/classes/3dsHandler.ts +347 -347
  12. package/src/classes/BaseInlineCheckout.ts +424 -424
  13. package/src/classes/errorResponse.ts +16 -16
  14. package/src/classes/liteCheckout.ts +589 -591
  15. package/src/data/api.ts +20 -20
  16. package/src/data/businessApi.ts +18 -18
  17. package/src/data/cardApi.ts +91 -87
  18. package/src/data/checkoutApi.ts +84 -84
  19. package/src/data/customerApi.ts +31 -31
  20. package/src/data/openPayApi.ts +12 -12
  21. package/src/data/paymentMethodApi.ts +37 -37
  22. package/src/data/skyflowApi.ts +20 -20
  23. package/src/helpers/constants.ts +63 -63
  24. package/src/helpers/mercadopago.ts +15 -15
  25. package/src/helpers/skyflow.ts +91 -91
  26. package/src/helpers/utils.ts +120 -120
  27. package/src/helpers/validations.ts +55 -55
  28. package/src/index.ts +12 -12
  29. package/src/shared/catalog/paymentMethodsCatalog.ts +247 -247
  30. package/src/shared/constants/messages.ts +10 -10
  31. package/src/shared/constants/paymentMethodAPM.ts +63 -63
  32. package/src/shared/constants/tonderUrl.ts +8 -8
  33. package/src/types/card.ts +35 -35
  34. package/src/types/checkout.ts +123 -123
  35. package/src/types/commons.ts +143 -143
  36. package/src/types/customer.ts +22 -22
  37. package/src/types/liteInlineCheckout.ts +216 -216
  38. package/src/types/paymentMethod.ts +23 -23
  39. package/src/types/requests.ts +114 -114
  40. package/src/types/responses.ts +192 -192
  41. package/src/types/skyflow.ts +17 -17
  42. package/src/types/transaction.ts +101 -101
  43. package/src/types/validations.d.ts +11 -11
  44. package/tests/classes/liteCheckout.test.ts +57 -57
  45. package/tests/methods/createOrder.test.ts +141 -141
  46. package/tests/methods/createPayment.test.ts +121 -121
  47. package/tests/methods/customerRegister.test.ts +118 -118
  48. package/tests/methods/getBusiness.test.ts +114 -114
  49. package/tests/methods/getCustomerCards.test.ts +112 -112
  50. package/tests/methods/registerCustomerCard.test.ts +117 -117
  51. package/tests/methods/startCheckoutRouter.test.ts +119 -119
  52. package/tests/methods/startCheckoutRouterFull.test.ts +138 -138
  53. package/tests/utils/defaultMock.ts +21 -21
  54. package/tests/utils/mockClasses.ts +659 -659
  55. 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
  });