@tonder.io/ionic-lite-sdk 0.0.35-beta.7 → 0.0.36-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 (85) hide show
  1. package/.gitlab-ci.yml +28 -28
  2. package/README.md +221 -202
  3. package/dist/classes/errorResponse.d.ts +1 -1
  4. package/dist/classes/liteCheckout.d.ts +32 -56
  5. package/dist/data/api.d.ts +1 -1
  6. package/dist/helpers/utils.d.ts +4 -8
  7. package/dist/index.d.ts +1 -2
  8. package/dist/index.js +1 -1
  9. package/dist/types/commons.d.ts +0 -37
  10. package/dist/types/requests.d.ts +3 -12
  11. package/dist/types/responses.d.ts +3 -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 +237 -237
  16. package/src/classes/errorResponse.ts +16 -16
  17. package/src/classes/liteCheckout.ts +575 -598
  18. package/src/data/api.ts +20 -20
  19. package/src/helpers/constants.ts +63 -63
  20. package/src/helpers/mercadopago.ts +15 -15
  21. package/src/helpers/utils.ts +320 -120
  22. package/src/index.ts +4 -10
  23. package/src/types/commons.ts +83 -125
  24. package/src/types/requests.ts +105 -114
  25. package/src/types/responses.ts +193 -189
  26. package/src/types/skyflow.ts +17 -17
  27. package/tests/classes/liteCheckout.test.ts +57 -57
  28. package/tests/methods/createOrder.test.ts +142 -142
  29. package/tests/methods/createPayment.test.ts +122 -122
  30. package/tests/methods/customerRegister.test.ts +119 -119
  31. package/tests/methods/getBusiness.test.ts +115 -115
  32. package/tests/methods/getCustomerCards.test.ts +119 -113
  33. package/tests/methods/getOpenpayDeviceSessionID.test.ts +95 -0
  34. package/tests/methods/getSkyflowToken.test.ts +155 -0
  35. package/tests/methods/getVaultToken.test.ts +107 -0
  36. package/tests/methods/registerCustomerCard.test.ts +117 -117
  37. package/tests/methods/startCheckoutRouter.test.ts +119 -119
  38. package/tests/methods/startCheckoutRouterFull.test.ts +138 -138
  39. package/tests/utils/defaultMock.ts +20 -21
  40. package/tests/utils/mockClasses.ts +656 -659
  41. package/tsconfig.json +18 -18
  42. package/.idea/aws.xml +0 -17
  43. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  44. package/.idea/prettier.xml +0 -6
  45. package/.idea/vcs.xml +0 -6
  46. package/.idea/workspace.xml +0 -132
  47. package/dist/classes/BaseInlineCheckout.d.ts +0 -45
  48. package/dist/data/businessApi.d.ts +0 -2
  49. package/dist/data/cardApi.d.ts +0 -4
  50. package/dist/data/checkoutApi.d.ts +0 -4
  51. package/dist/data/customerApi.d.ts +0 -2
  52. package/dist/data/openPayApi.d.ts +0 -1
  53. package/dist/data/paymentMethodApi.d.ts +0 -5
  54. package/dist/data/skyflowApi.d.ts +0 -1
  55. package/dist/helpers/skyflow.d.ts +0 -3
  56. package/dist/helpers/validations.d.ts +0 -6
  57. package/dist/shared/catalog/paymentMethodsCatalog.d.ts +0 -1
  58. package/dist/shared/constants/messages.d.ts +0 -11
  59. package/dist/shared/constants/paymentMethodAPM.d.ts +0 -62
  60. package/dist/shared/constants/tonderUrl.d.ts +0 -7
  61. package/dist/types/card.d.ts +0 -29
  62. package/dist/types/checkout.d.ts +0 -103
  63. package/dist/types/customer.d.ts +0 -12
  64. package/dist/types/paymentMethod.d.ts +0 -22
  65. package/src/classes/BaseInlineCheckout.ts +0 -356
  66. package/src/data/businessApi.ts +0 -18
  67. package/src/data/cardApi.ts +0 -89
  68. package/src/data/checkoutApi.ts +0 -87
  69. package/src/data/customerApi.ts +0 -31
  70. package/src/data/openPayApi.ts +0 -12
  71. package/src/data/paymentMethodApi.ts +0 -37
  72. package/src/data/skyflowApi.ts +0 -20
  73. package/src/helpers/skyflow.ts +0 -91
  74. package/src/helpers/validations.ts +0 -55
  75. package/src/shared/catalog/paymentMethodsCatalog.ts +0 -248
  76. package/src/shared/constants/messages.ts +0 -11
  77. package/src/shared/constants/paymentMethodAPM.ts +0 -63
  78. package/src/shared/constants/tonderUrl.ts +0 -8
  79. package/src/types/card.ts +0 -34
  80. package/src/types/checkout.ts +0 -118
  81. package/src/types/customer.ts +0 -12
  82. package/src/types/index.d.ts +0 -10
  83. package/src/types/liteInlineCheckout.d.ts +0 -191
  84. package/src/types/paymentMethod.ts +0 -24
  85. package/src/types/validations.d.ts +0 -11
@@ -1,120 +1,120 @@
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 { 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
+ });
120
120
  });
@@ -1,115 +1,115 @@
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 } from "../utils/mockClasses";
8
-
9
- declare global {
10
- interface Window {
11
- OpenPay: any;
12
- Skyflow: any;
13
- }
14
- }
15
-
16
- describe("getBusiness", () => {
17
- let checkoutConstructor: LiteCheckoutConstructor,
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("getBusiness success", async () => {
39
- liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
40
-
41
- fetchSpy.mockImplementation(() =>
42
- Promise.resolve({
43
- json: () =>
44
- Promise.resolve({
45
- ...new BusinessClass(),
46
- }),
47
- ok: true,
48
- })
49
- );
50
-
51
- const response = await liteCheckout.getBusiness();
52
-
53
- expect(response).toStrictEqual({ ...new BusinessClass() });
54
- expect(liteCheckoutSpy).toHaveBeenCalled();
55
- });
56
-
57
- it("getBusiness empty", async () => {
58
- liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
59
-
60
- fetchSpy.mockImplementation(() =>
61
- Promise.resolve({
62
- json: () => Promise.resolve(),
63
- ok: true,
64
- })
65
- );
66
-
67
- const response = await liteCheckout.getBusiness();
68
- expect(liteCheckoutSpy).toHaveBeenCalled();
69
- expect(liteCheckoutSpy).toHaveReturned();
70
- expect(response).toBeUndefined();
71
- });
72
-
73
- it("getBusiness errorResponse", async () => {
74
- liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
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.getBusiness());
88
- } catch (e: any) {
89
- error = e;
90
- expect(error.code).toStrictEqual("400");
91
- expect(error).toBeInstanceOf(ErrorResponse);
92
- }
93
- });
94
-
95
- it("getBusiness errorCatch", async () => {
96
- liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
97
-
98
- fetchSpy.mockRejectedValue("error");
99
-
100
- let error: ErrorResponse;
101
-
102
- try {
103
- const response = (await liteCheckout.getBusiness());
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
- });
114
-
115
-
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 } from "../utils/mockClasses";
8
+
9
+ declare global {
10
+ interface Window {
11
+ OpenPay: any;
12
+ Skyflow: any;
13
+ }
14
+ }
15
+
16
+ describe("getBusiness", () => {
17
+ let checkoutConstructor: LiteCheckoutConstructor,
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("getBusiness success", async () => {
39
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
40
+
41
+ fetchSpy.mockImplementation(() =>
42
+ Promise.resolve({
43
+ json: () =>
44
+ Promise.resolve({
45
+ ...new BusinessClass(),
46
+ }),
47
+ ok: true,
48
+ })
49
+ );
50
+
51
+ const response = await liteCheckout.getBusiness();
52
+
53
+ expect(response).toStrictEqual({ ...new BusinessClass() });
54
+ expect(liteCheckoutSpy).toHaveBeenCalled();
55
+ });
56
+
57
+ it("getBusiness empty", async () => {
58
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
59
+
60
+ fetchSpy.mockImplementation(() =>
61
+ Promise.resolve({
62
+ json: () => Promise.resolve(),
63
+ ok: true,
64
+ })
65
+ );
66
+
67
+ const response = await liteCheckout.getBusiness();
68
+ expect(liteCheckoutSpy).toHaveBeenCalled();
69
+ expect(liteCheckoutSpy).toHaveReturned();
70
+ expect(response).toBeUndefined();
71
+ });
72
+
73
+ it("getBusiness errorResponse", async () => {
74
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
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.getBusiness()) as IErrorResponse;
88
+ } catch (e: any) {
89
+ error = e;
90
+ expect(error.code).toStrictEqual("400");
91
+ expect(error).toBeInstanceOf(ErrorResponse);
92
+ }
93
+ });
94
+
95
+ it("getBusiness errorCatch", async () => {
96
+ liteCheckoutSpy = jest.spyOn(liteCheckout, "getBusiness");
97
+
98
+ fetchSpy.mockRejectedValue("error");
99
+
100
+ let error: ErrorResponse;
101
+
102
+ try {
103
+ const response = (await liteCheckout.getBusiness()) as ErrorResponse;
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
+ });
114
+
115
+