@tonder.io/ionic-lite-sdk 0.0.16 → 0.0.17-beta
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/.gitlab-ci.yml +28 -28
- package/README.md +496 -496
- package/dist/classes/liteCheckout.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/types/requests.d.ts +3 -15
- package/dist/types/responses.d.ts +14 -13
- package/jest.config.ts +14 -14
- package/package.json +38 -38
- package/rollup.config.js +16 -16
- package/src/classes/errorResponse.ts +16 -16
- package/src/classes/liteCheckout.ts +302 -302
- package/src/helpers/utils.ts +37 -37
- package/src/index.ts +4 -4
- package/src/types/commons.ts +61 -61
- package/src/types/requests.ts +60 -60
- package/src/types/responses.ts +185 -185
- package/src/types/skyflow.ts +17 -17
- package/tests/classes/liteCheckout.test.ts +57 -57
- package/tests/methods/createOrder.test.ts +105 -105
- package/tests/methods/createPayment.test.ts +108 -108
- package/tests/methods/customerRegister.test.ts +105 -105
- package/tests/methods/getBusiness.test.ts +102 -102
- package/tests/methods/getCustomerCards.test.ts +104 -104
- package/tests/methods/getOpenpayDeviceSessionID.test.ts +94 -94
- package/tests/methods/getSkyflowToken.test.ts +136 -136
- package/tests/methods/getVaultToken.test.ts +106 -106
- package/tests/methods/registerCustomerCard.test.ts +104 -104
- package/tests/methods/startCheckoutRouter.test.ts +106 -106
- package/tests/utils/defaultMock.ts +20 -20
- package/tests/utils/mockClasses.ts +538 -538
- package/tsconfig.json +18 -18
package/src/helpers/utils.ts
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
export const createObserver = ({ target }: { target: string }): Promise<any> => {
|
|
2
|
-
|
|
3
|
-
return new Promise((resolve, reject) => {
|
|
4
|
-
|
|
5
|
-
let hasChanged = false;
|
|
6
|
-
|
|
7
|
-
// Select the node that will be observed for mutations
|
|
8
|
-
const targetNode: any = document.querySelector(target);
|
|
9
|
-
|
|
10
|
-
// Options for the observer (which mutations to observe)
|
|
11
|
-
const config = { attributes: true, childList: true, subtree: true };
|
|
12
|
-
|
|
13
|
-
// Callback function to execute when mutations are observed
|
|
14
|
-
const callback = (mutationList: any, observer: MutationObserver) => {
|
|
15
|
-
for (const mutation of mutationList) {
|
|
16
|
-
if (mutation.type === "childList") {
|
|
17
|
-
hasChanged = true;
|
|
18
|
-
resolve(mutation)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// Create an observer instance linked to the callback function
|
|
24
|
-
const observer = new MutationObserver(callback);
|
|
25
|
-
|
|
26
|
-
// Start observing the target node for configured mutations
|
|
27
|
-
observer.observe(targetNode, config);
|
|
28
|
-
|
|
29
|
-
window.setTimeout(() => {
|
|
30
|
-
if (!hasChanged) {
|
|
31
|
-
reject("Mounting error");
|
|
32
|
-
}
|
|
33
|
-
}, 5000);
|
|
34
|
-
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
}
|
|
1
|
+
export const createObserver = ({ target }: { target: string }): Promise<any> => {
|
|
2
|
+
|
|
3
|
+
return new Promise((resolve, reject) => {
|
|
4
|
+
|
|
5
|
+
let hasChanged = false;
|
|
6
|
+
|
|
7
|
+
// Select the node that will be observed for mutations
|
|
8
|
+
const targetNode: any = document.querySelector(target);
|
|
9
|
+
|
|
10
|
+
// Options for the observer (which mutations to observe)
|
|
11
|
+
const config = { attributes: true, childList: true, subtree: true };
|
|
12
|
+
|
|
13
|
+
// Callback function to execute when mutations are observed
|
|
14
|
+
const callback = (mutationList: any, observer: MutationObserver) => {
|
|
15
|
+
for (const mutation of mutationList) {
|
|
16
|
+
if (mutation.type === "childList") {
|
|
17
|
+
hasChanged = true;
|
|
18
|
+
resolve(mutation)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Create an observer instance linked to the callback function
|
|
24
|
+
const observer = new MutationObserver(callback);
|
|
25
|
+
|
|
26
|
+
// Start observing the target node for configured mutations
|
|
27
|
+
observer.observe(targetNode, config);
|
|
28
|
+
|
|
29
|
+
window.setTimeout(() => {
|
|
30
|
+
if (!hasChanged) {
|
|
31
|
+
reject("Mounting error");
|
|
32
|
+
}
|
|
33
|
+
}, 5000);
|
|
34
|
+
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LiteCheckout } from './classes/liteCheckout'
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
LiteCheckout
|
|
1
|
+
import { LiteCheckout } from './classes/liteCheckout'
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
LiteCheckout
|
|
5
5
|
}
|
package/src/types/commons.ts
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
export type Business = {
|
|
2
|
-
business: {
|
|
3
|
-
pk: number;
|
|
4
|
-
name: string;
|
|
5
|
-
categories: {
|
|
6
|
-
pk: number;
|
|
7
|
-
name: string;
|
|
8
|
-
}[];
|
|
9
|
-
web: string;
|
|
10
|
-
logo: string;
|
|
11
|
-
full_logo_url: string;
|
|
12
|
-
background_color: string;
|
|
13
|
-
primary_color: string;
|
|
14
|
-
checkout_mode: boolean;
|
|
15
|
-
textCheckoutColor: string;
|
|
16
|
-
textDetailsColor: string;
|
|
17
|
-
checkout_logo: string;
|
|
18
|
-
};
|
|
19
|
-
openpay_keys: {
|
|
20
|
-
merchant_id: string;
|
|
21
|
-
public_key: string;
|
|
22
|
-
};
|
|
23
|
-
fintoc_keys: {
|
|
24
|
-
public_key: string;
|
|
25
|
-
};
|
|
26
|
-
vault_id: string;
|
|
27
|
-
vault_url: string;
|
|
28
|
-
reference: number;
|
|
29
|
-
is_installments_available: boolean;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type Customer = {
|
|
33
|
-
firstName: string;
|
|
34
|
-
lastName: string;
|
|
35
|
-
country: string;
|
|
36
|
-
street: string;
|
|
37
|
-
city: string;
|
|
38
|
-
state: string;
|
|
39
|
-
postCode: string;
|
|
40
|
-
email: string;
|
|
41
|
-
phone: string;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export type OrderItem = {
|
|
45
|
-
description: string;
|
|
46
|
-
quantity: number;
|
|
47
|
-
price_unit: number;
|
|
48
|
-
discount: number;
|
|
49
|
-
taxes: number;
|
|
50
|
-
product_reference: number;
|
|
51
|
-
name: string;
|
|
52
|
-
amount_total: number;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export type PaymentData = {
|
|
56
|
-
customer: Customer;
|
|
57
|
-
cart: {
|
|
58
|
-
total: string | number;
|
|
59
|
-
items: OrderItem[];
|
|
60
|
-
};
|
|
61
|
-
};
|
|
1
|
+
export type Business = {
|
|
2
|
+
business: {
|
|
3
|
+
pk: number;
|
|
4
|
+
name: string;
|
|
5
|
+
categories: {
|
|
6
|
+
pk: number;
|
|
7
|
+
name: string;
|
|
8
|
+
}[];
|
|
9
|
+
web: string;
|
|
10
|
+
logo: string;
|
|
11
|
+
full_logo_url: string;
|
|
12
|
+
background_color: string;
|
|
13
|
+
primary_color: string;
|
|
14
|
+
checkout_mode: boolean;
|
|
15
|
+
textCheckoutColor: string;
|
|
16
|
+
textDetailsColor: string;
|
|
17
|
+
checkout_logo: string;
|
|
18
|
+
};
|
|
19
|
+
openpay_keys: {
|
|
20
|
+
merchant_id: string;
|
|
21
|
+
public_key: string;
|
|
22
|
+
};
|
|
23
|
+
fintoc_keys: {
|
|
24
|
+
public_key: string;
|
|
25
|
+
};
|
|
26
|
+
vault_id: string;
|
|
27
|
+
vault_url: string;
|
|
28
|
+
reference: number;
|
|
29
|
+
is_installments_available: boolean;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type Customer = {
|
|
33
|
+
firstName: string;
|
|
34
|
+
lastName: string;
|
|
35
|
+
country: string;
|
|
36
|
+
street: string;
|
|
37
|
+
city: string;
|
|
38
|
+
state: string;
|
|
39
|
+
postCode: string;
|
|
40
|
+
email: string;
|
|
41
|
+
phone: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type OrderItem = {
|
|
45
|
+
description: string;
|
|
46
|
+
quantity: number;
|
|
47
|
+
price_unit: number;
|
|
48
|
+
discount: number;
|
|
49
|
+
taxes: number;
|
|
50
|
+
product_reference: number;
|
|
51
|
+
name: string;
|
|
52
|
+
amount_total: number;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type PaymentData = {
|
|
56
|
+
customer: Customer;
|
|
57
|
+
cart: {
|
|
58
|
+
total: string | number;
|
|
59
|
+
items: OrderItem[];
|
|
60
|
+
};
|
|
61
|
+
};
|
package/src/types/requests.ts
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { OrderItem } from "./commons";
|
|
2
|
-
import { SkyflowRecord } from "./skyflow";
|
|
3
|
-
|
|
4
|
-
export interface CreateOrderRequest {
|
|
5
|
-
business: string,
|
|
6
|
-
client: string,
|
|
7
|
-
billing_address_id?: string | null,
|
|
8
|
-
shipping_address_id?: string | null,
|
|
9
|
-
amount: number,
|
|
10
|
-
status: string,
|
|
11
|
-
reference: string | number,
|
|
12
|
-
is_oneclick: boolean,
|
|
13
|
-
items: OrderItem[]
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type CreatePaymentRequest = {
|
|
17
|
-
business_pk: string | number,
|
|
18
|
-
amount: number,
|
|
19
|
-
date: string,
|
|
20
|
-
order: string | number
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type StartCheckoutRequest = {
|
|
24
|
-
card: any,
|
|
25
|
-
name: any,
|
|
26
|
-
last_name: string,
|
|
27
|
-
email_client: any,
|
|
28
|
-
phone_number: any,
|
|
29
|
-
return_url?: string,
|
|
30
|
-
id_product: string,
|
|
31
|
-
quantity_product: number,
|
|
32
|
-
id_ship: string,
|
|
33
|
-
instance_id_ship: string,
|
|
34
|
-
amount: any,
|
|
35
|
-
title_ship: string,
|
|
36
|
-
description: string,
|
|
37
|
-
device_session_id: any,
|
|
38
|
-
token_id: string,
|
|
39
|
-
order_id: any,
|
|
40
|
-
business_id: any,
|
|
41
|
-
payment_id: any,
|
|
42
|
-
source: string,
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface VaultRequest extends SkyflowRecord {
|
|
46
|
-
records: SkyflowRecord[],
|
|
47
|
-
continueOnError?: boolean,
|
|
48
|
-
byot?: "DISABLE" | "ENABLE" | "ENABLE_STRICT"
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export type RegisterCustomerCardRequest = {
|
|
52
|
-
skyflow_id: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export type TokensRequest = {
|
|
56
|
-
vault_id: string,
|
|
57
|
-
vault_url: string,
|
|
58
|
-
data: {
|
|
59
|
-
[key: string]: any;
|
|
60
|
-
}
|
|
1
|
+
import { OrderItem } from "./commons";
|
|
2
|
+
import { SkyflowRecord } from "./skyflow";
|
|
3
|
+
|
|
4
|
+
export interface CreateOrderRequest {
|
|
5
|
+
business: string,
|
|
6
|
+
client: string,
|
|
7
|
+
billing_address_id?: string | null,
|
|
8
|
+
shipping_address_id?: string | null,
|
|
9
|
+
amount: number,
|
|
10
|
+
status: string,
|
|
11
|
+
reference: string | number,
|
|
12
|
+
is_oneclick: boolean,
|
|
13
|
+
items: OrderItem[]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type CreatePaymentRequest = {
|
|
17
|
+
business_pk: string | number,
|
|
18
|
+
amount: number,
|
|
19
|
+
date: string,
|
|
20
|
+
order: string | number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type StartCheckoutRequest = {
|
|
24
|
+
card: any,
|
|
25
|
+
name: any,
|
|
26
|
+
last_name: string,
|
|
27
|
+
email_client: any,
|
|
28
|
+
phone_number: any,
|
|
29
|
+
return_url?: string,
|
|
30
|
+
id_product: string,
|
|
31
|
+
quantity_product: number,
|
|
32
|
+
id_ship: string,
|
|
33
|
+
instance_id_ship: string,
|
|
34
|
+
amount: any,
|
|
35
|
+
title_ship: string,
|
|
36
|
+
description: string,
|
|
37
|
+
device_session_id: any,
|
|
38
|
+
token_id: string,
|
|
39
|
+
order_id: any,
|
|
40
|
+
business_id: any,
|
|
41
|
+
payment_id: any,
|
|
42
|
+
source: string,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface VaultRequest extends SkyflowRecord {
|
|
46
|
+
records: SkyflowRecord[],
|
|
47
|
+
continueOnError?: boolean,
|
|
48
|
+
byot?: "DISABLE" | "ENABLE" | "ENABLE_STRICT"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type RegisterCustomerCardRequest = {
|
|
52
|
+
skyflow_id: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type TokensRequest = {
|
|
56
|
+
vault_id: string,
|
|
57
|
+
vault_url: string,
|
|
58
|
+
data: {
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
}
|
|
61
61
|
}
|