tonder-web-sdk 1.12.0-beta.1 → 1.12.0-beta.10
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/.idea/workspace.xml +38 -32
- package/package.json +1 -1
- package/src/classes/BaseInlineCheckout.js +35 -15
- package/src/classes/LiteInlineCheckout.js +149 -46
- package/src/classes/inlineCheckout.js +30 -10
- package/src/data/apmApi.js +1 -1
- package/src/data/cardApi.js +22 -12
- package/src/data/checkoutApi.js +17 -6
- package/src/data/customerApi.js +1 -1
- package/src/helpers/template.js +5 -4
- package/src/helpers/utils.js +18 -245
- package/src/index-dev.js +3 -2
- package/src/index.js +2 -0
- package/src/shared/catalog/paymentMethodsCatalog.js +247 -0
- package/src/shared/constants/messages.js +10 -0
- package/types/card.ts +33 -0
- package/types/checkout.ts +118 -0
- package/types/common.ts +26 -0
- package/types/customer.ts +11 -0
- package/types/index.d.ts +8 -76
- package/types/inlineCheckout.d.ts +22 -0
- package/types/liteInlineCheckout.d.ts +32 -0
- package/types/paymentMethod.ts +24 -0
- package/types/transaction.ts +101 -0
- package/v1/bundle.min.js +3 -3
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {ICustomer} from "./customer";
|
|
2
|
+
|
|
3
|
+
export interface IStartCheckoutRequestBase {
|
|
4
|
+
name: any;
|
|
5
|
+
last_name: string;
|
|
6
|
+
email_client: any;
|
|
7
|
+
phone_number: any;
|
|
8
|
+
return_url?: string;
|
|
9
|
+
id_product: string;
|
|
10
|
+
quantity_product: number;
|
|
11
|
+
id_ship: string;
|
|
12
|
+
instance_id_ship: string;
|
|
13
|
+
amount: any;
|
|
14
|
+
title_ship: string;
|
|
15
|
+
description: string;
|
|
16
|
+
device_session_id: any;
|
|
17
|
+
token_id: string;
|
|
18
|
+
order_id: any;
|
|
19
|
+
business_id: any;
|
|
20
|
+
payment_id: any;
|
|
21
|
+
source: string;
|
|
22
|
+
browser_info?: any;
|
|
23
|
+
metadata: any;
|
|
24
|
+
currency: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type IStartCheckoutRequestWithCard = IStartCheckoutRequestBase & {
|
|
28
|
+
card: any;
|
|
29
|
+
payment_method?: never;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type IStartCheckoutRequestWithPaymentMethod =
|
|
33
|
+
IStartCheckoutRequestBase & {
|
|
34
|
+
card?: never;
|
|
35
|
+
payment_method: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type IStartCheckoutRequest =
|
|
39
|
+
| IStartCheckoutRequestWithCard
|
|
40
|
+
| IStartCheckoutRequestWithPaymentMethod;
|
|
41
|
+
|
|
42
|
+
export interface IStartCheckoutIdRequest {
|
|
43
|
+
checkout_id: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface IStartCheckoutErrorResponse {
|
|
47
|
+
status: string;
|
|
48
|
+
message: string;
|
|
49
|
+
psp_response: [
|
|
50
|
+
{
|
|
51
|
+
status: number;
|
|
52
|
+
response: Object;
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
checkout_id: string;
|
|
56
|
+
is_route_finished: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface IStartCheckoutResponse {
|
|
60
|
+
status: string;
|
|
61
|
+
message: string;
|
|
62
|
+
psp_response: Record<string, any>;
|
|
63
|
+
checkout_id: string;
|
|
64
|
+
is_route_finished: Boolean;
|
|
65
|
+
transaction_status: string;
|
|
66
|
+
transaction_id: number;
|
|
67
|
+
payment_id: number;
|
|
68
|
+
provider: string;
|
|
69
|
+
next_action: {
|
|
70
|
+
redirect_to_url: {
|
|
71
|
+
url: string;
|
|
72
|
+
return_url: string;
|
|
73
|
+
verify_transaction_status_url: string;
|
|
74
|
+
};
|
|
75
|
+
iframe_resources?: {
|
|
76
|
+
iframe: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
actions: IStartCheckoutActionResponse[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface IStartCheckoutActionResponse {
|
|
83
|
+
name: string;
|
|
84
|
+
url: string;
|
|
85
|
+
method: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
export interface IItem {
|
|
90
|
+
description: string;
|
|
91
|
+
quantity: number;
|
|
92
|
+
price_unit: number;
|
|
93
|
+
discount: number;
|
|
94
|
+
taxes: number;
|
|
95
|
+
product_reference: number;
|
|
96
|
+
name: string;
|
|
97
|
+
amount_total: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface IProcessPaymentRequest {
|
|
101
|
+
customer: ICustomer;
|
|
102
|
+
cart: {
|
|
103
|
+
total: string | number;
|
|
104
|
+
items: IItem[];
|
|
105
|
+
};
|
|
106
|
+
metadata?: Record<string, any>;
|
|
107
|
+
currency?: string;
|
|
108
|
+
payment_method?: string;
|
|
109
|
+
card?: ICardFields | string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface ICardFields {
|
|
113
|
+
card_number: string;
|
|
114
|
+
cvv: string;
|
|
115
|
+
expiration_month: string;
|
|
116
|
+
expiration_year: string;
|
|
117
|
+
cardholder_name: string;
|
|
118
|
+
}
|
package/types/common.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ICustomer } from "./customer";
|
|
2
|
+
|
|
3
|
+
export interface IInlineCheckoutBaseOptions {
|
|
4
|
+
mode?: "production" | "sandbox" | "stage" | "development";
|
|
5
|
+
apiKey: string;
|
|
6
|
+
returnUrl: string;
|
|
7
|
+
callBack?: (response: any) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface IConfigureCheckout {
|
|
11
|
+
customer: ICustomer;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface IApiError {
|
|
15
|
+
code: string;
|
|
16
|
+
body: Record<string, string> | string;
|
|
17
|
+
name: string;
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface IPublicError {
|
|
22
|
+
status: string;
|
|
23
|
+
code: number;
|
|
24
|
+
message: string;
|
|
25
|
+
detail: Record<string, any> | string;
|
|
26
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,79 +1,11 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export * from './card';
|
|
2
|
+
export * from './checkout';
|
|
3
|
+
export * from './common';
|
|
4
|
+
export * from './customer';
|
|
5
|
+
export * from './transaction';
|
|
6
|
+
export * from './paymentMethod';
|
|
7
|
+
export * from './inlineCheckout';
|
|
8
|
+
export * from './liteInlineCheckout';
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
export class LiteInlineCheckout {
|
|
11
|
-
constructor(options: InlineLiteCheckoutOptions);
|
|
12
|
-
configureCheckout(data: { customer?: Customer }): void;
|
|
13
|
-
injectCheckout(): Promise<void>;
|
|
14
|
-
payment(): Promise<void>;
|
|
15
|
-
verify3dsTransaction(): Promise<void>;
|
|
16
|
-
getCustomerCards(authToken: string, businessId: string | number): Promise<CustomerCards>;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Saves a card to a customer's account. This method can be used to add a new card
|
|
20
|
-
* or update an existing one.
|
|
21
|
-
* @param {string} authToken - The customer's authentication token.
|
|
22
|
-
* @param {string} businessId - The business primary key.
|
|
23
|
-
* @param {Object} card - The card information to be saved.
|
|
24
|
-
* @returns {Promise<Object>} A promise that resolves with the saved card data.
|
|
25
|
-
* @public
|
|
26
|
-
*/
|
|
27
|
-
saveCustomerCard(authToken: string, businessId: string, card: { card_number: string; cvv: string; expiration_month: string; expiration_year: string; cardholder_name: string; }): Promise<void>;
|
|
28
|
-
removeCustomerCard(authToken: string, skyflowId: string, businessId: string): Promise<void>;
|
|
29
|
-
getCustomerAPMs(): Promise<void>;
|
|
30
|
-
}
|
|
31
11
|
|
|
32
|
-
|
|
33
|
-
export interface InlineCheckoutOptions {
|
|
34
|
-
mode?: string;
|
|
35
|
-
apiKey: string;
|
|
36
|
-
returnUrl: string;
|
|
37
|
-
renderPaymentButton?: boolean;
|
|
38
|
-
callBack?: (response: any) => void;
|
|
39
|
-
styles?: Record<string, string>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface InlineLiteCheckoutOptions {
|
|
43
|
-
mode?: string;
|
|
44
|
-
apiKey: string;
|
|
45
|
-
returnUrl: string;
|
|
46
|
-
renderPaymentButton?: boolean;
|
|
47
|
-
callBack?: (response: any) => void;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export type Customer = {
|
|
52
|
-
firstName: string;
|
|
53
|
-
lastName: string;
|
|
54
|
-
country: string;
|
|
55
|
-
street: string;
|
|
56
|
-
city: string;
|
|
57
|
-
state: string;
|
|
58
|
-
postCode: string;
|
|
59
|
-
email: string;
|
|
60
|
-
phone: string;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
interface CardFields {
|
|
65
|
-
card_number: string;
|
|
66
|
-
expiration_month: string;
|
|
67
|
-
expiration_year: string;
|
|
68
|
-
skyflow_id: string;
|
|
69
|
-
card_scheme: string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
interface Card {
|
|
73
|
-
fields: CardFields;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
interface CustomerCards {
|
|
77
|
-
user_id: number;
|
|
78
|
-
cards: Card[];
|
|
79
|
-
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {IConfigureCheckout, IInlineCheckoutBaseOptions} from "./common";
|
|
2
|
+
import {IProcessPaymentRequest, IStartCheckoutResponse} from "./checkout";
|
|
3
|
+
import {ITransaction} from "./transaction";
|
|
4
|
+
|
|
5
|
+
export class InlineCheckout {
|
|
6
|
+
constructor(options: IInlineCheckoutOptions);
|
|
7
|
+
|
|
8
|
+
configureCheckout(data: IConfigureCheckout): Promise<void>;
|
|
9
|
+
|
|
10
|
+
injectCheckout(): Promise<void>;
|
|
11
|
+
|
|
12
|
+
payment(data: IProcessPaymentRequest): Promise<IStartCheckoutResponse>;
|
|
13
|
+
|
|
14
|
+
verify3dsTransaction(): Promise<ITransaction | void>;
|
|
15
|
+
|
|
16
|
+
removeCheckout(): void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface IInlineCheckoutOptions extends IInlineCheckoutBaseOptions{
|
|
20
|
+
styles?: Record<string, string>;
|
|
21
|
+
renderPaymentButton?: boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {IConfigureCheckout, IInlineCheckoutBaseOptions} from "./common";
|
|
2
|
+
import {ICustomerCardsResponse, ISaveCardRequest, ISaveCardResponse} from "./card";
|
|
3
|
+
import {IPaymentMethod} from "./paymentMethod";
|
|
4
|
+
import {IProcessPaymentRequest, IStartCheckoutResponse} from "./checkout";
|
|
5
|
+
import {ITransaction} from "./transaction";
|
|
6
|
+
|
|
7
|
+
export class LiteInlineCheckout {
|
|
8
|
+
constructor(options: IInlineLiteCheckoutOptions);
|
|
9
|
+
|
|
10
|
+
configureCheckout(data: IConfigureCheckout): void;
|
|
11
|
+
|
|
12
|
+
injectCheckout(): Promise<void>;
|
|
13
|
+
|
|
14
|
+
payment(data: IProcessPaymentRequest): Promise<IStartCheckoutResponse>;
|
|
15
|
+
|
|
16
|
+
verify3dsTransaction(): Promise<ITransaction | void>;
|
|
17
|
+
|
|
18
|
+
getCustomerCards(): Promise<ICustomerCardsResponse>;
|
|
19
|
+
|
|
20
|
+
saveCustomerCard(
|
|
21
|
+
card: ISaveCardRequest,
|
|
22
|
+
): Promise<ISaveCardResponse>;
|
|
23
|
+
|
|
24
|
+
removeCustomerCard(
|
|
25
|
+
skyflowId: string,
|
|
26
|
+
): Promise<void>;
|
|
27
|
+
|
|
28
|
+
getCustomerPaymentMethods(): Promise<IPaymentMethod[]>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
export interface IInlineLiteCheckoutOptions extends IInlineCheckoutBaseOptions {}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface IPaymentMethodResponse {
|
|
2
|
+
count: number;
|
|
3
|
+
next: string | null;
|
|
4
|
+
previous: string | null;
|
|
5
|
+
results: ITonderPaymentMethod[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ITonderPaymentMethod {
|
|
9
|
+
pk: string;
|
|
10
|
+
payment_method: string;
|
|
11
|
+
priority: number;
|
|
12
|
+
category: string;
|
|
13
|
+
unavailable_countries: string[];
|
|
14
|
+
status: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface IPaymentMethod {
|
|
18
|
+
id: string;
|
|
19
|
+
payment_method: string;
|
|
20
|
+
priority: number;
|
|
21
|
+
category: string;
|
|
22
|
+
icon: string;
|
|
23
|
+
label: string;
|
|
24
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export interface ITransaction {
|
|
2
|
+
id: number;
|
|
3
|
+
provider: string;
|
|
4
|
+
country: string;
|
|
5
|
+
currency_code: string;
|
|
6
|
+
transaction_status: string;
|
|
7
|
+
created: string;
|
|
8
|
+
modified: string;
|
|
9
|
+
operation_date: string;
|
|
10
|
+
transaction_reference: string;
|
|
11
|
+
transaction_type: string;
|
|
12
|
+
status: string;
|
|
13
|
+
amount: string;
|
|
14
|
+
related_transaction_reference?: null | string;
|
|
15
|
+
reason?: null | string;
|
|
16
|
+
is_refunded?: null | boolean;
|
|
17
|
+
is_disputed?: null | boolean;
|
|
18
|
+
number_of_payment_attempts: number;
|
|
19
|
+
card_brand?: null | string;
|
|
20
|
+
number_of_installments: number;
|
|
21
|
+
payment?: {
|
|
22
|
+
id: number;
|
|
23
|
+
created: string;
|
|
24
|
+
modified: string;
|
|
25
|
+
amount: string;
|
|
26
|
+
status: string;
|
|
27
|
+
date: string;
|
|
28
|
+
paid_date: null | string;
|
|
29
|
+
source: null | string;
|
|
30
|
+
customer_order_reference: null | string;
|
|
31
|
+
client: number;
|
|
32
|
+
business: number;
|
|
33
|
+
shipping_address?: null | string;
|
|
34
|
+
billing_address?: null | string;
|
|
35
|
+
order: number;
|
|
36
|
+
};
|
|
37
|
+
checkout: {
|
|
38
|
+
id: string;
|
|
39
|
+
created: string;
|
|
40
|
+
modified: string;
|
|
41
|
+
checkout_data: {
|
|
42
|
+
name: string;
|
|
43
|
+
amount: number;
|
|
44
|
+
source: string;
|
|
45
|
+
id_ship: string;
|
|
46
|
+
currency: string;
|
|
47
|
+
order_id: number;
|
|
48
|
+
token_id: string;
|
|
49
|
+
last_name: string;
|
|
50
|
+
id_product: string;
|
|
51
|
+
ip_address: string;
|
|
52
|
+
payment_id: number;
|
|
53
|
+
return_url: string;
|
|
54
|
+
title_ship: string;
|
|
55
|
+
business_id: number;
|
|
56
|
+
checkout_id: string;
|
|
57
|
+
description: string;
|
|
58
|
+
browser_info: {
|
|
59
|
+
language: string;
|
|
60
|
+
time_zone: number;
|
|
61
|
+
user_agent: string;
|
|
62
|
+
color_depth: number;
|
|
63
|
+
screen_width: number;
|
|
64
|
+
screen_height: number;
|
|
65
|
+
javascript_enabled: boolean;
|
|
66
|
+
};
|
|
67
|
+
email_client: string;
|
|
68
|
+
phone_number: string;
|
|
69
|
+
instance_id_ship: string;
|
|
70
|
+
quantity_product: number;
|
|
71
|
+
device_session_id: null | string;
|
|
72
|
+
number_of_payment_attempts: number;
|
|
73
|
+
};
|
|
74
|
+
number_of_payment_attempts: number;
|
|
75
|
+
tried_psps: string[];
|
|
76
|
+
rejected_transactions: string[];
|
|
77
|
+
routing_step: number;
|
|
78
|
+
route_length: number;
|
|
79
|
+
last_status: string;
|
|
80
|
+
ip_address: string;
|
|
81
|
+
is_dynamic_routing: boolean;
|
|
82
|
+
is_route_finished: boolean;
|
|
83
|
+
business: number;
|
|
84
|
+
payment: number;
|
|
85
|
+
};
|
|
86
|
+
currency: {
|
|
87
|
+
id: number;
|
|
88
|
+
name: string;
|
|
89
|
+
code: string;
|
|
90
|
+
symbol: string;
|
|
91
|
+
country: null | string;
|
|
92
|
+
};
|
|
93
|
+
payment_method?: null | {
|
|
94
|
+
id: number;
|
|
95
|
+
name: string;
|
|
96
|
+
display_name: string;
|
|
97
|
+
category: string;
|
|
98
|
+
is_apm: boolean;
|
|
99
|
+
};
|
|
100
|
+
issuing_country?: null | string;
|
|
101
|
+
}
|