@yosle/tropipayjs 0.2.1 → 0.2.2
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 +27 -0
- package/api/TropipayAPI.d.ts +31 -4
- package/index.d.ts +41 -104
- package/index.js +99 -81
- package/interfaces/index.d.ts +10 -35
- package/interfaces/paymentlink/index.d.ts +3 -1
- package/package.json +5 -2
- package/paymentcard/paymentcard.spec.d.ts +1 -0
- package/src/api/TropipayAPI.ts +129 -30
- package/src/depositAccount/depositAccounts.ts +5 -5
- package/src/index.ts +1 -0
- package/src/interfaces/index.ts +212 -264
- package/src/interfaces/paymentlink/index.d.ts +32 -33
- package/src/interfaces/paymentlink/index.ts +3 -1
- package/src/paymentcard/PaymentCard.ts +4 -4
- package/src/utils/TropipayUtils.ts +1 -40
- package/utils/TropipayUtils.d.ts +1 -14
- package/accounts/accounts.d.ts +0 -52
- package/src/accounts/accounts.ts +0 -86
package/src/interfaces/index.ts
CHANGED
|
@@ -1,264 +1,212 @@
|
|
|
1
|
-
import { ServerMode } from "../constants/TropipayConstants";
|
|
2
|
-
|
|
3
|
-
export type AccountBalance = {
|
|
4
|
-
balance: number;
|
|
5
|
-
pendingIn: number;
|
|
6
|
-
pendingOut: number;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export interface TropipayConfig {
|
|
10
|
-
clientId: string;
|
|
11
|
-
clientSecret: string;
|
|
12
|
-
scopes?: string[];
|
|
13
|
-
serverMode?: ServerMode;
|
|
14
|
-
// Custom tropipay environment for testing
|
|
15
|
-
customTropipayUrl?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type TropipayCredentials = { clientId: string; clientSecret: string };
|
|
19
|
-
export type HookEventType =
|
|
20
|
-
| "transaction_completed"
|
|
21
|
-
| "transaction_charged"
|
|
22
|
-
| "transaction_guarded"
|
|
23
|
-
| "user_signup"
|
|
24
|
-
| "user_kyc"
|
|
25
|
-
| "payment_in_state_change"
|
|
26
|
-
| "payment_out_state_change"
|
|
27
|
-
| "beneficiary_added"
|
|
28
|
-
| "beneficiary_updated"
|
|
29
|
-
| "beneficiary_deleted"
|
|
30
|
-
| "transaction_new"
|
|
31
|
-
| "transaction_preauthorized"
|
|
32
|
-
| "transaction_pendingin"
|
|
33
|
-
| "transaction_processing"
|
|
34
|
-
| "transaction_error"
|
|
35
|
-
| "transaction_bloqued"
|
|
36
|
-
| "transaction_guarded_send"
|
|
37
|
-
| "transaction_guarded_mediation"
|
|
38
|
-
| "user_after_update"
|
|
39
|
-
| "user_after_create"
|
|
40
|
-
| "userDetail_after_create"
|
|
41
|
-
| "userDetail_after_update"
|
|
42
|
-
| "tpv_callback_ok"
|
|
43
|
-
| "fraud_state_on_change";
|
|
44
|
-
|
|
45
|
-
export type HookTargetType = "web" | "email";
|
|
46
|
-
export interface UserHook {
|
|
47
|
-
event: HookEventType;
|
|
48
|
-
target: string;
|
|
49
|
-
value: string;
|
|
50
|
-
}
|
|
51
|
-
export interface UserHookSubscribed extends UserHook {
|
|
52
|
-
createdAt: string;
|
|
53
|
-
updatedAt: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface UserHook {
|
|
57
|
-
event: HookEventType;
|
|
58
|
-
target: string;
|
|
59
|
-
value: string;
|
|
60
|
-
}
|
|
61
|
-
export interface UserHookSubscribed extends UserHook {
|
|
62
|
-
createdAt: string;
|
|
63
|
-
updatedAt: string;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
state:
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
isRisky: boolean;
|
|
214
|
-
currentCurrency: string | null;
|
|
215
|
-
createdAt: string;
|
|
216
|
-
updatedAt: string;
|
|
217
|
-
isFavorite: boolean;
|
|
218
|
-
position: any;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
export type Deposit = {
|
|
222
|
-
id: number;
|
|
223
|
-
accountNumber: string;
|
|
224
|
-
alias: string;
|
|
225
|
-
swift: string;
|
|
226
|
-
type: number;
|
|
227
|
-
country: number | null;
|
|
228
|
-
firstName: string;
|
|
229
|
-
default: null;
|
|
230
|
-
state: number;
|
|
231
|
-
userId: string;
|
|
232
|
-
countryDestinationId: number;
|
|
233
|
-
lastName: string;
|
|
234
|
-
documentNumber: number;
|
|
235
|
-
userRelationTypeId: number;
|
|
236
|
-
city: string;
|
|
237
|
-
postalCode: string;
|
|
238
|
-
address: string;
|
|
239
|
-
phone: string;
|
|
240
|
-
checked: boolean;
|
|
241
|
-
province: string;
|
|
242
|
-
beneficiaryType: number;
|
|
243
|
-
relatedUserId: null | string;
|
|
244
|
-
currency: string;
|
|
245
|
-
correspondent?: any;
|
|
246
|
-
location: any;
|
|
247
|
-
office: any;
|
|
248
|
-
officeValue: any;
|
|
249
|
-
paymentType: number;
|
|
250
|
-
paymentEntityBeneficiaryId: number;
|
|
251
|
-
paymentEntityAccountId: number;
|
|
252
|
-
verified: any;
|
|
253
|
-
paymentEntityInfo: any;
|
|
254
|
-
documentTypeId: any;
|
|
255
|
-
documentExpirationDate: Date;
|
|
256
|
-
createdAt: Date;
|
|
257
|
-
updatedAt: Date;
|
|
258
|
-
countryDestination: Country;
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
export type AccountDeposits = {
|
|
262
|
-
count: number;
|
|
263
|
-
rows: Deposit[];
|
|
264
|
-
};
|
|
1
|
+
import { ServerMode } from "../constants/TropipayConstants";
|
|
2
|
+
|
|
3
|
+
export type AccountBalance = {
|
|
4
|
+
balance: number;
|
|
5
|
+
pendingIn: number;
|
|
6
|
+
pendingOut: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export interface TropipayConfig {
|
|
10
|
+
clientId: string;
|
|
11
|
+
clientSecret: string;
|
|
12
|
+
scopes?: string[];
|
|
13
|
+
serverMode?: ServerMode;
|
|
14
|
+
// Custom tropipay environment for testing
|
|
15
|
+
customTropipayUrl?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type TropipayCredentials = { clientId: string; clientSecret: string };
|
|
19
|
+
export type HookEventType =
|
|
20
|
+
| "transaction_completed"
|
|
21
|
+
| "transaction_charged"
|
|
22
|
+
| "transaction_guarded"
|
|
23
|
+
| "user_signup"
|
|
24
|
+
| "user_kyc"
|
|
25
|
+
| "payment_in_state_change"
|
|
26
|
+
| "payment_out_state_change"
|
|
27
|
+
| "beneficiary_added"
|
|
28
|
+
| "beneficiary_updated"
|
|
29
|
+
| "beneficiary_deleted"
|
|
30
|
+
| "transaction_new"
|
|
31
|
+
| "transaction_preauthorized"
|
|
32
|
+
| "transaction_pendingin"
|
|
33
|
+
| "transaction_processing"
|
|
34
|
+
| "transaction_error"
|
|
35
|
+
| "transaction_bloqued"
|
|
36
|
+
| "transaction_guarded_send"
|
|
37
|
+
| "transaction_guarded_mediation"
|
|
38
|
+
| "user_after_update"
|
|
39
|
+
| "user_after_create"
|
|
40
|
+
| "userDetail_after_create"
|
|
41
|
+
| "userDetail_after_update"
|
|
42
|
+
| "tpv_callback_ok"
|
|
43
|
+
| "fraud_state_on_change";
|
|
44
|
+
|
|
45
|
+
export type HookTargetType = "web" | "email";
|
|
46
|
+
export interface UserHook {
|
|
47
|
+
event: HookEventType;
|
|
48
|
+
target: string;
|
|
49
|
+
value: string;
|
|
50
|
+
}
|
|
51
|
+
export interface UserHookSubscribed extends UserHook {
|
|
52
|
+
createdAt: string;
|
|
53
|
+
updatedAt: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface UserHook {
|
|
57
|
+
event: HookEventType;
|
|
58
|
+
target: string;
|
|
59
|
+
value: string;
|
|
60
|
+
}
|
|
61
|
+
export interface UserHookSubscribed extends UserHook {
|
|
62
|
+
createdAt: string;
|
|
63
|
+
updatedAt: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface PaymentLinkPayload {
|
|
67
|
+
reference: string;
|
|
68
|
+
concept: string;
|
|
69
|
+
favorite: boolean;
|
|
70
|
+
amount: number;
|
|
71
|
+
currency: string;
|
|
72
|
+
description: string;
|
|
73
|
+
singleUse: boolean;
|
|
74
|
+
reasonId: number;
|
|
75
|
+
expirationDays: number;
|
|
76
|
+
lang: string;
|
|
77
|
+
urlSuccess: string;
|
|
78
|
+
urlFailed: string;
|
|
79
|
+
urlNotification: string;
|
|
80
|
+
serviceDate: string;
|
|
81
|
+
client?: {
|
|
82
|
+
name?: string;
|
|
83
|
+
lastName?: string;
|
|
84
|
+
address?: string;
|
|
85
|
+
phone?: string;
|
|
86
|
+
email?: string;
|
|
87
|
+
countryId?: number;
|
|
88
|
+
countryIso?: string;
|
|
89
|
+
city: string;
|
|
90
|
+
postCode: string;
|
|
91
|
+
termsAndConditions: boolean;
|
|
92
|
+
} | null;
|
|
93
|
+
directPayment: boolean;
|
|
94
|
+
paymentMethods?: string[];
|
|
95
|
+
imageBase?: string;
|
|
96
|
+
saveToken?: boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface PaymentLink extends PaymentLinkPayload {
|
|
100
|
+
expirationDate: string;
|
|
101
|
+
hasClient: boolean;
|
|
102
|
+
updatedAt: string;
|
|
103
|
+
createdAt: string;
|
|
104
|
+
qrImage: string;
|
|
105
|
+
shortUrl: string;
|
|
106
|
+
paymentUrl: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface MediationPaymentCardConfig {
|
|
110
|
+
amount: number;
|
|
111
|
+
currency: "EUR" | "USD";
|
|
112
|
+
concept: string;
|
|
113
|
+
description: string;
|
|
114
|
+
reference: string;
|
|
115
|
+
singleUse: boolean;
|
|
116
|
+
lang: string;
|
|
117
|
+
productUrl?: string;
|
|
118
|
+
buyer: null | any;
|
|
119
|
+
seller: {
|
|
120
|
+
sellerId?: number;
|
|
121
|
+
type?: number;
|
|
122
|
+
email?: string;
|
|
123
|
+
};
|
|
124
|
+
feePercent?: number;
|
|
125
|
+
feeFixed?: number;
|
|
126
|
+
sendMail: boolean;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export type LoginResponse = {
|
|
130
|
+
access_token: string;
|
|
131
|
+
refresh_token: string;
|
|
132
|
+
token_type: "Bearer";
|
|
133
|
+
expires_in: number;
|
|
134
|
+
scope: string;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export type LoginError = {
|
|
138
|
+
error: string;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export type Country = {
|
|
142
|
+
id: number;
|
|
143
|
+
name: string;
|
|
144
|
+
sepaZone: boolean;
|
|
145
|
+
state: number;
|
|
146
|
+
slug: string;
|
|
147
|
+
slugn: number;
|
|
148
|
+
callingCode: number;
|
|
149
|
+
isDestination: boolean;
|
|
150
|
+
isRisky: boolean;
|
|
151
|
+
currentCurrency: string | null;
|
|
152
|
+
createdAt: string;
|
|
153
|
+
updatedAt: string;
|
|
154
|
+
isFavorite: boolean;
|
|
155
|
+
position: any;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export type Deposit = {
|
|
159
|
+
id: number;
|
|
160
|
+
accountNumber: string;
|
|
161
|
+
alias: string;
|
|
162
|
+
swift: string;
|
|
163
|
+
type: number;
|
|
164
|
+
country: number | null;
|
|
165
|
+
firstName: string;
|
|
166
|
+
default: null;
|
|
167
|
+
state: number;
|
|
168
|
+
userId: string;
|
|
169
|
+
countryDestinationId: number;
|
|
170
|
+
lastName: string;
|
|
171
|
+
documentNumber: number;
|
|
172
|
+
userRelationTypeId: number;
|
|
173
|
+
city: string;
|
|
174
|
+
postalCode: string;
|
|
175
|
+
address: string;
|
|
176
|
+
phone: string;
|
|
177
|
+
checked: boolean;
|
|
178
|
+
province: string;
|
|
179
|
+
beneficiaryType: number;
|
|
180
|
+
relatedUserId: null | string;
|
|
181
|
+
currency: string;
|
|
182
|
+
correspondent?: any;
|
|
183
|
+
location: any;
|
|
184
|
+
office: any;
|
|
185
|
+
officeValue: any;
|
|
186
|
+
paymentType: number;
|
|
187
|
+
paymentEntityBeneficiaryId: number;
|
|
188
|
+
paymentEntityAccountId: number;
|
|
189
|
+
verified: any;
|
|
190
|
+
paymentEntityInfo: any;
|
|
191
|
+
documentTypeId: any;
|
|
192
|
+
documentExpirationDate: Date;
|
|
193
|
+
createdAt: Date;
|
|
194
|
+
updatedAt: Date;
|
|
195
|
+
countryDestination: Country;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export type AccountDeposits = {
|
|
199
|
+
count: number;
|
|
200
|
+
rows: Deposit[];
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export type RefundResponse = {
|
|
204
|
+
id: number;
|
|
205
|
+
orderCode: string;
|
|
206
|
+
amount: number;
|
|
207
|
+
currency: string;
|
|
208
|
+
state: string;
|
|
209
|
+
type: string;
|
|
210
|
+
createdAt: string;
|
|
211
|
+
completedAt: string;
|
|
212
|
+
};
|
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
export interface PaymentLinkPayload {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
paymentMethods?: string[];
|
|
2
|
+
reference: string;
|
|
3
|
+
concept: string;
|
|
4
|
+
favorite: boolean;
|
|
5
|
+
amount: number;
|
|
6
|
+
currency: string;
|
|
7
|
+
description: string;
|
|
8
|
+
singleUse: boolean;
|
|
9
|
+
reasonId: number;
|
|
10
|
+
expirationDays: number;
|
|
11
|
+
lang: string;
|
|
12
|
+
urlSuccess: string;
|
|
13
|
+
urlFailed: string;
|
|
14
|
+
urlNotification: string;
|
|
15
|
+
serviceDate: string;
|
|
16
|
+
client: {
|
|
17
|
+
name: string;
|
|
18
|
+
lastName: string;
|
|
19
|
+
address: string;
|
|
20
|
+
phone: string;
|
|
21
|
+
email: string;
|
|
22
|
+
countryId: number;
|
|
23
|
+
termsAndConditions: boolean;
|
|
24
|
+
};
|
|
25
|
+
directPayment: boolean;
|
|
26
|
+
paymentMethods?: string[];
|
|
28
27
|
}
|
|
29
28
|
export interface PaymentLink extends PaymentLinkPayload {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
expirationDate: string;
|
|
30
|
+
hasClient: boolean;
|
|
31
|
+
updatedAt: string;
|
|
32
|
+
createdAt: string;
|
|
33
|
+
qrImage: string;
|
|
34
|
+
shortUrl: string;
|
|
35
|
+
paymentUrl: string;
|
|
37
36
|
}
|
|
@@ -50,7 +50,6 @@ enum Reasons {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export interface PaymentLinkPayload {
|
|
53
|
-
accountId: number;
|
|
54
53
|
reference: string;
|
|
55
54
|
concept: string;
|
|
56
55
|
favorite: boolean;
|
|
@@ -65,6 +64,9 @@ export interface PaymentLinkPayload {
|
|
|
65
64
|
urlFailed: string;
|
|
66
65
|
urlNotification: string;
|
|
67
66
|
serviceDate: string;
|
|
67
|
+
/**
|
|
68
|
+
* fgfsgdfgdfgd
|
|
69
|
+
*/
|
|
68
70
|
client?: {
|
|
69
71
|
name: string;
|
|
70
72
|
lastName: string;
|
|
@@ -20,7 +20,7 @@ export default class PaymentCard {
|
|
|
20
20
|
}
|
|
21
21
|
try {
|
|
22
22
|
const paylink = await this.tropipay.request.post(
|
|
23
|
-
"/api/
|
|
23
|
+
"/api/v2/paymentcards",
|
|
24
24
|
payload,
|
|
25
25
|
{
|
|
26
26
|
headers: {
|
|
@@ -46,7 +46,7 @@ export default class PaymentCard {
|
|
|
46
46
|
}
|
|
47
47
|
try {
|
|
48
48
|
const paymentcards = await this.tropipay.request.get(
|
|
49
|
-
`/api/
|
|
49
|
+
`/api/v2/paymentcards`,
|
|
50
50
|
{
|
|
51
51
|
headers: {
|
|
52
52
|
"Content-Type": "application/json",
|
|
@@ -74,7 +74,7 @@ export default class PaymentCard {
|
|
|
74
74
|
}
|
|
75
75
|
try {
|
|
76
76
|
const paymentcard = await this.tropipay.request.get(
|
|
77
|
-
`/api/
|
|
77
|
+
`/api/v2/paymentcards/${id}`,
|
|
78
78
|
{
|
|
79
79
|
headers: {
|
|
80
80
|
"Content-Type": "application/json",
|
|
@@ -103,7 +103,7 @@ export default class PaymentCard {
|
|
|
103
103
|
}
|
|
104
104
|
try {
|
|
105
105
|
const paymentcard = await this.tropipay.request.delete(
|
|
106
|
-
`/api/
|
|
106
|
+
`/api/v2/paymentcards/`,
|
|
107
107
|
{
|
|
108
108
|
headers: {
|
|
109
109
|
"Content-Type": "application/json",
|
|
@@ -11,9 +11,7 @@ export class ServerSideUtils {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @deprecated This method is deprecated and will be removed in future versions.
|
|
16
|
-
* Use the `verifySignatureV3` method from the `ServerSideUtils` class instead.
|
|
14
|
+
* Verify Topipay's signature on webhooks.
|
|
17
15
|
* @param credentials Credential object or Tropipay instance
|
|
18
16
|
* @param {String} originalCurrencyAmount
|
|
19
17
|
* @param bankOrderCode
|
|
@@ -125,41 +123,4 @@ export class ServerSideUtils {
|
|
|
125
123
|
throw new Error(`Error checking base64 image`);
|
|
126
124
|
}
|
|
127
125
|
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Verify Topipay's signature on API V3 webhooks.
|
|
131
|
-
* @param {string} originalCurrencyAmount
|
|
132
|
-
* @param {string} bankOrderCode
|
|
133
|
-
* @param {string} signature signaturev3 field to be verified
|
|
134
|
-
* @returns {boolean}
|
|
135
|
-
*/
|
|
136
|
-
public static verifySignatureV3(
|
|
137
|
-
credentials:
|
|
138
|
-
| {
|
|
139
|
-
clientId: string;
|
|
140
|
-
clientSecret: string;
|
|
141
|
-
}
|
|
142
|
-
| Tropipay,
|
|
143
|
-
originalCurrencyAmount: string,
|
|
144
|
-
bankOrderCode: string,
|
|
145
|
-
signature: string
|
|
146
|
-
): boolean {
|
|
147
|
-
const sha1Secret = crypto
|
|
148
|
-
.createHash("sha1")
|
|
149
|
-
.update(credentials.clientSecret)
|
|
150
|
-
.digest("hex");
|
|
151
|
-
|
|
152
|
-
const dataToHash =
|
|
153
|
-
bankOrderCode +
|
|
154
|
-
credentials.clientId +
|
|
155
|
-
sha1Secret +
|
|
156
|
-
originalCurrencyAmount;
|
|
157
|
-
|
|
158
|
-
const localSignature = crypto
|
|
159
|
-
.createHash("sha256")
|
|
160
|
-
.update(dataToHash)
|
|
161
|
-
.digest("hex");
|
|
162
|
-
|
|
163
|
-
return localSignature === signature;
|
|
164
|
-
}
|
|
165
126
|
}
|
package/utils/TropipayUtils.d.ts
CHANGED
|
@@ -3,9 +3,7 @@ export declare class ServerSideUtils {
|
|
|
3
3
|
private tropipay;
|
|
4
4
|
constructor(tropipayInstance: Tropipay);
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @deprecated This method is deprecated and will be removed in future versions.
|
|
8
|
-
* Use the `verifySignatureV3` method from the `ServerSideUtils` class instead.
|
|
6
|
+
* Verify Topipay's signature on webhooks.
|
|
9
7
|
* @param credentials Credential object or Tropipay instance
|
|
10
8
|
* @param {String} originalCurrencyAmount
|
|
11
9
|
* @param bankOrderCode
|
|
@@ -44,15 +42,4 @@ export declare class ServerSideUtils {
|
|
|
44
42
|
* @return {Promise<string>} the valid base64 image
|
|
45
43
|
*/
|
|
46
44
|
static isValidImage(base64Image: string): boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Verify Topipay's signature on API V3 webhooks.
|
|
49
|
-
* @param {string} originalCurrencyAmount
|
|
50
|
-
* @param {string} bankOrderCode
|
|
51
|
-
* @param {string} signature signaturev3 field to be verified
|
|
52
|
-
* @returns {boolean}
|
|
53
|
-
*/
|
|
54
|
-
static verifySignatureV3(credentials: {
|
|
55
|
-
clientId: string;
|
|
56
|
-
clientSecret: string;
|
|
57
|
-
} | Tropipay, originalCurrencyAmount: string, bankOrderCode: string, signature: string): boolean;
|
|
58
45
|
}
|