@tonder.io/ionic-lite-sdk 0.0.36-beta.1 → 0.0.38-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.
- package/README.md +427 -116
- package/dist/classes/BaseInlineCheckout.d.ts +47 -0
- package/dist/classes/liteCheckout.d.ts +25 -29
- package/dist/data/businessApi.d.ts +2 -0
- package/dist/data/cardApi.d.ts +4 -0
- package/dist/data/checkoutApi.d.ts +5 -0
- package/dist/data/customerApi.d.ts +2 -0
- package/dist/data/openPayApi.d.ts +1 -0
- package/dist/data/paymentMethodApi.d.ts +5 -0
- package/dist/data/skyflowApi.d.ts +1 -0
- package/dist/helpers/skyflow.d.ts +3 -0
- package/dist/helpers/utils.d.ts +8 -4
- package/dist/helpers/validations.d.ts +6 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/dist/shared/catalog/paymentMethodsCatalog.d.ts +1 -0
- package/dist/shared/constants/messages.d.ts +11 -0
- package/dist/shared/constants/paymentMethodAPM.d.ts +62 -0
- package/dist/shared/constants/tonderUrl.d.ts +7 -0
- package/dist/types/card.d.ts +30 -0
- package/dist/types/checkout.d.ts +109 -0
- package/dist/types/commons.d.ts +42 -0
- package/dist/types/customer.d.ts +22 -0
- package/dist/types/liteInlineCheckout.d.ts +151 -0
- package/dist/types/paymentMethod.d.ts +22 -0
- package/dist/types/requests.d.ts +12 -3
- package/dist/types/transaction.d.ts +101 -0
- package/package.json +4 -1
- package/src/classes/BaseInlineCheckout.ts +387 -0
- package/src/classes/errorResponse.ts +1 -1
- package/src/classes/liteCheckout.ts +372 -356
- package/src/data/businessApi.ts +18 -0
- package/src/data/cardApi.ts +87 -0
- package/src/data/checkoutApi.ts +84 -0
- package/src/data/customerApi.ts +31 -0
- package/src/data/openPayApi.ts +12 -0
- package/src/data/paymentMethodApi.ts +37 -0
- package/src/data/skyflowApi.ts +20 -0
- package/src/helpers/mercadopago.ts +14 -14
- package/src/helpers/skyflow.ts +91 -0
- package/src/helpers/utils.ts +66 -266
- package/src/helpers/validations.ts +55 -0
- package/src/index.ts +9 -1
- package/src/shared/catalog/paymentMethodsCatalog.ts +248 -0
- package/src/shared/constants/messages.ts +11 -0
- package/src/shared/constants/paymentMethodAPM.ts +63 -0
- package/src/shared/constants/tonderUrl.ts +8 -0
- package/src/types/card.ts +35 -0
- package/src/types/checkout.ts +124 -0
- package/src/types/commons.ts +114 -67
- package/src/types/customer.ts +22 -0
- package/src/types/liteInlineCheckout.ts +216 -0
- package/src/types/paymentMethod.ts +24 -0
- package/src/types/requests.ts +12 -3
- package/src/types/transaction.ts +101 -0
- package/src/types/validations.d.ts +11 -0
- package/tests/classes/liteCheckout.test.ts +5 -5
- package/tests/methods/createOrder.test.ts +3 -4
- package/tests/methods/createPayment.test.ts +2 -3
- package/tests/methods/customerRegister.test.ts +3 -4
- package/tests/methods/getBusiness.test.ts +4 -5
- package/tests/methods/getCustomerCards.test.ts +6 -13
- package/tests/methods/registerCustomerCard.test.ts +2 -2
- package/tests/methods/startCheckoutRouter.test.ts +2 -2
- package/tests/methods/startCheckoutRouterFull.test.ts +2 -2
- package/tests/utils/defaultMock.ts +3 -2
- package/tests/utils/mockClasses.ts +7 -4
- package/types/classes/liteCheckout.d.ts +29 -0
- package/types/classes/liteCheckout.js +225 -0
- package/types/classes/liteCheckout.js.map +1 -0
- package/types/helpers/utils.d.ts +3 -0
- package/types/helpers/utils.js +27 -0
- package/types/helpers/utils.js.map +1 -0
- package/types/index.d.ts +2 -0
- package/types/index.js +6 -0
- package/types/index.js.map +1 -0
- package/tests/methods/getOpenpayDeviceSessionID.test.ts +0 -95
- package/tests/methods/getSkyflowToken.test.ts +0 -155
- package/tests/methods/getVaultToken.test.ts +0 -107
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import "../utils/defaultMock";
|
|
2
|
-
import { LiteCheckout } from "../../src";
|
|
3
|
-
import { LiteCheckoutConstructor } from "../../src/classes/liteCheckout";
|
|
4
|
-
import { constructorFields } from "../utils/defaultMock";
|
|
5
|
-
|
|
6
|
-
declare global {
|
|
7
|
-
interface Window {
|
|
8
|
-
OpenPay: any;
|
|
9
|
-
Skyflow: any;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
describe("getVaultToken", () => {
|
|
14
|
-
let checkoutConstructor: LiteCheckoutConstructor,
|
|
15
|
-
liteCheckout: LiteCheckout,
|
|
16
|
-
fetchSpy: jest.SpyInstance,
|
|
17
|
-
liteCheckoutSpy: jest.SpyInstance;
|
|
18
|
-
|
|
19
|
-
beforeEach(async () => {
|
|
20
|
-
window.fetch = jest.fn();
|
|
21
|
-
|
|
22
|
-
checkoutConstructor = {
|
|
23
|
-
...constructorFields,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
liteCheckout = new LiteCheckout(constructorFields);
|
|
27
|
-
|
|
28
|
-
fetchSpy = jest.spyOn(global, "fetch");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
afterEach(() => {
|
|
32
|
-
jest.restoreAllMocks();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("getVaultToken success", async () => {
|
|
36
|
-
liteCheckoutSpy = jest.spyOn(liteCheckout, "getVaultToken");
|
|
37
|
-
|
|
38
|
-
fetchSpy.mockImplementation(() =>
|
|
39
|
-
Promise.resolve({
|
|
40
|
-
json: () => Promise.resolve({ token: "1234" }),
|
|
41
|
-
ok: true,
|
|
42
|
-
})
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const response = await liteCheckout.getVaultToken();
|
|
46
|
-
expect(response).toStrictEqual("1234");
|
|
47
|
-
expect(liteCheckoutSpy).toHaveBeenCalled();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("getVaultToken empty", async () => {
|
|
51
|
-
liteCheckoutSpy = jest.spyOn(liteCheckout, "getVaultToken");
|
|
52
|
-
|
|
53
|
-
fetchSpy.mockImplementation(() =>
|
|
54
|
-
Promise.resolve({
|
|
55
|
-
json: () => Promise.resolve(),
|
|
56
|
-
ok: true,
|
|
57
|
-
})
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
const response = await liteCheckout.getVaultToken();
|
|
61
|
-
expect(liteCheckoutSpy).toHaveBeenCalled();
|
|
62
|
-
expect(liteCheckoutSpy).toHaveReturned();
|
|
63
|
-
expect(response).toBeUndefined();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("getVaultToken errorResponse", async () => {
|
|
67
|
-
liteCheckoutSpy = jest.spyOn(liteCheckout, "getVaultToken");
|
|
68
|
-
|
|
69
|
-
fetchSpy.mockImplementation(() =>
|
|
70
|
-
Promise.resolve({
|
|
71
|
-
json: () => Promise.resolve(),
|
|
72
|
-
ok: false,
|
|
73
|
-
status: 400,
|
|
74
|
-
})
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
try {
|
|
78
|
-
await liteCheckout.getVaultToken();
|
|
79
|
-
} catch (e) {
|
|
80
|
-
const error = e as Error;
|
|
81
|
-
expect(liteCheckoutSpy).toHaveBeenCalled();
|
|
82
|
-
expect(liteCheckoutSpy).rejects.toThrow();
|
|
83
|
-
expect(error.message).toStrictEqual(
|
|
84
|
-
"Failed to retrieve bearer token; HTTPCODE: 400"
|
|
85
|
-
);
|
|
86
|
-
expect(error).toBeInstanceOf(Error);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("getVaultToken errorCatch", async () => {
|
|
91
|
-
liteCheckoutSpy = jest.spyOn(liteCheckout, "getVaultToken");
|
|
92
|
-
|
|
93
|
-
fetchSpy.mockRejectedValue("error");
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
await liteCheckout.getVaultToken();
|
|
97
|
-
} catch (e) {
|
|
98
|
-
const error = e as Error;
|
|
99
|
-
expect(liteCheckoutSpy).toHaveBeenCalled();
|
|
100
|
-
expect(liteCheckoutSpy).rejects.toThrow();
|
|
101
|
-
expect(error.message).toStrictEqual(
|
|
102
|
-
"Failed to retrieve bearer token; error"
|
|
103
|
-
);
|
|
104
|
-
expect(e).toBeInstanceOf(Error);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
});
|