gamemoney 2.0.0 → 4.0.0
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/index.d.ts +395 -0
- package/index.js +138 -0
- package/package.json +59 -22
- package/utils.d.ts +17 -0
- package/utils.js +51 -0
- package/LICENSE +0 -21
- package/README.md +0 -105
- package/dist/index.d.ts +0 -249
- package/dist/index.js +0 -82
- package/dist/index.js.map +0 -1
- package/dist/request.d.ts +0 -18
- package/dist/request.js +0 -52
- package/dist/request.js.map +0 -1
- package/dist/utils.d.ts +0 -11
- package/dist/utils.js +0 -64
- package/dist/utils.js.map +0 -1
- package/tsconfig.json +0 -22
- package/tslint.json +0 -18
package/index.d.ts
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { RsaKey, HmacKey } from './utils.js';
|
|
2
|
+
export declare enum SignType {
|
|
3
|
+
'HMAC' = "HMAC",
|
|
4
|
+
'RSA' = "RSA"
|
|
5
|
+
}
|
|
6
|
+
export interface GenericRequest {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
rand?: string;
|
|
9
|
+
project: number;
|
|
10
|
+
signature?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface GenericResponse {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
state: 'success' | 'error';
|
|
15
|
+
time: number;
|
|
16
|
+
error?: string;
|
|
17
|
+
rand?: string;
|
|
18
|
+
signature: string;
|
|
19
|
+
}
|
|
20
|
+
export interface Config {
|
|
21
|
+
rsaPrivateKey?: RsaKey;
|
|
22
|
+
hmacPrivateKey: HmacKey;
|
|
23
|
+
project: number;
|
|
24
|
+
}
|
|
25
|
+
export interface CreateInvoiceRequest {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
type: string;
|
|
28
|
+
user: string;
|
|
29
|
+
ip: string;
|
|
30
|
+
amount: number;
|
|
31
|
+
comment?: string;
|
|
32
|
+
success_url?: string;
|
|
33
|
+
fail_url?: string;
|
|
34
|
+
wallet: string;
|
|
35
|
+
project_invoice?: string;
|
|
36
|
+
currency?: string;
|
|
37
|
+
user_currency?: string;
|
|
38
|
+
language?: string;
|
|
39
|
+
mode?: 'card_direct';
|
|
40
|
+
}
|
|
41
|
+
export interface CreateInvoiceResponse {
|
|
42
|
+
invoice: number;
|
|
43
|
+
type: 'message' | 'redirect' | 'cardrequest' | 'error';
|
|
44
|
+
data: string;
|
|
45
|
+
}
|
|
46
|
+
export interface GetInvoiceStatusRequestWithProjectInvoiceId {
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
invoice: number;
|
|
49
|
+
}
|
|
50
|
+
export interface GetInvoiceStatusRequestWithGamemoneyInvoiceId {
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
project_invoice: string;
|
|
53
|
+
}
|
|
54
|
+
export declare type GetInvoiceStatusRequest = GetInvoiceStatusRequestWithProjectInvoiceId | GetInvoiceStatusRequestWithGamemoneyInvoiceId;
|
|
55
|
+
export interface GetInvoiceStatusResponse {
|
|
56
|
+
project: number;
|
|
57
|
+
invoice: number;
|
|
58
|
+
status: string;
|
|
59
|
+
amount: number;
|
|
60
|
+
net_amount: number;
|
|
61
|
+
recieved_amount: number;
|
|
62
|
+
user: string;
|
|
63
|
+
type: string;
|
|
64
|
+
wallet: string;
|
|
65
|
+
project_invoice: string;
|
|
66
|
+
currency_project: string;
|
|
67
|
+
currency_user: string;
|
|
68
|
+
date_create: string;
|
|
69
|
+
date_pay: string;
|
|
70
|
+
rate?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface GetInvoiceListRequest {
|
|
73
|
+
[key: string]: any;
|
|
74
|
+
start: string;
|
|
75
|
+
finish: string;
|
|
76
|
+
}
|
|
77
|
+
export interface GetInvoiceListResponse {
|
|
78
|
+
list: GetInvoiceStatusResponse[];
|
|
79
|
+
is_limit_exceeded: 'yes' | 'no';
|
|
80
|
+
}
|
|
81
|
+
export interface CancelCheckoutRequest {
|
|
82
|
+
[key: string]: any;
|
|
83
|
+
projectId: string;
|
|
84
|
+
}
|
|
85
|
+
export interface GetCheckoutStatusRequest {
|
|
86
|
+
[key: string]: any;
|
|
87
|
+
projectId: string;
|
|
88
|
+
}
|
|
89
|
+
export interface Refund {
|
|
90
|
+
id: number;
|
|
91
|
+
amount: number;
|
|
92
|
+
net_amount: number;
|
|
93
|
+
paid_amount: number;
|
|
94
|
+
comment: string;
|
|
95
|
+
}
|
|
96
|
+
export interface GetCheckoutStatusResponse {
|
|
97
|
+
id: number;
|
|
98
|
+
project: number;
|
|
99
|
+
projectId: string;
|
|
100
|
+
amount: number;
|
|
101
|
+
net_amount: number;
|
|
102
|
+
paid_amount: number;
|
|
103
|
+
status: number;
|
|
104
|
+
user: string;
|
|
105
|
+
wallet: string;
|
|
106
|
+
description: string;
|
|
107
|
+
comment: string;
|
|
108
|
+
redirect_url: string;
|
|
109
|
+
type: string;
|
|
110
|
+
currency_project: string;
|
|
111
|
+
currency_user: string;
|
|
112
|
+
date_create: string;
|
|
113
|
+
rate?: string;
|
|
114
|
+
refunds: Refund[];
|
|
115
|
+
}
|
|
116
|
+
export interface GetCheckoutListRequest {
|
|
117
|
+
[key: string]: any;
|
|
118
|
+
start: string;
|
|
119
|
+
finish: string;
|
|
120
|
+
}
|
|
121
|
+
export interface GetCheckoutListResponse {
|
|
122
|
+
list: GetCheckoutStatusResponse[];
|
|
123
|
+
}
|
|
124
|
+
export interface CreateCheckoutRequest {
|
|
125
|
+
[key: string]: any;
|
|
126
|
+
projectId: string;
|
|
127
|
+
user: string;
|
|
128
|
+
ip: string;
|
|
129
|
+
amount: number;
|
|
130
|
+
wallet: string;
|
|
131
|
+
description: string;
|
|
132
|
+
type: string;
|
|
133
|
+
currency?: string;
|
|
134
|
+
userCurrency?: string;
|
|
135
|
+
}
|
|
136
|
+
export interface AddCardRequest {
|
|
137
|
+
[key: string]: any;
|
|
138
|
+
user: string;
|
|
139
|
+
redirect: string;
|
|
140
|
+
}
|
|
141
|
+
export interface AddCardResponse {
|
|
142
|
+
url: string;
|
|
143
|
+
}
|
|
144
|
+
export interface AddTokenCardRequest {
|
|
145
|
+
[key: string]: any;
|
|
146
|
+
user: string;
|
|
147
|
+
}
|
|
148
|
+
export interface AddTokenCardResponse {
|
|
149
|
+
token: string;
|
|
150
|
+
}
|
|
151
|
+
export interface GetCardListRequest {
|
|
152
|
+
[key: string]: any;
|
|
153
|
+
user: string;
|
|
154
|
+
}
|
|
155
|
+
export interface GetCardListResponse {
|
|
156
|
+
pans: string[];
|
|
157
|
+
}
|
|
158
|
+
export interface GetCardFullListRequest {
|
|
159
|
+
[key: string]: any;
|
|
160
|
+
user: string;
|
|
161
|
+
}
|
|
162
|
+
export interface GetCardFullListResponse {
|
|
163
|
+
cards?: Array<{
|
|
164
|
+
pan: string;
|
|
165
|
+
expire_month: string;
|
|
166
|
+
expire_year: string;
|
|
167
|
+
cardholder: string;
|
|
168
|
+
}>;
|
|
169
|
+
}
|
|
170
|
+
export interface DeleteCardRequest {
|
|
171
|
+
[key: string]: any;
|
|
172
|
+
user: string;
|
|
173
|
+
pan: string;
|
|
174
|
+
}
|
|
175
|
+
export interface PrepareExchangeRequest {
|
|
176
|
+
[key: string]: any;
|
|
177
|
+
externalId: string;
|
|
178
|
+
minAmount: number;
|
|
179
|
+
maxAmount: number;
|
|
180
|
+
from: string;
|
|
181
|
+
to: string;
|
|
182
|
+
livetime?: number;
|
|
183
|
+
}
|
|
184
|
+
export interface PrepareExchangeResponse {
|
|
185
|
+
id: number;
|
|
186
|
+
rate: number;
|
|
187
|
+
exchanged_amount_from: number;
|
|
188
|
+
exchanged_amount_to: number;
|
|
189
|
+
}
|
|
190
|
+
export interface ConvertExchangeRequest {
|
|
191
|
+
[key: string]: any;
|
|
192
|
+
id: number;
|
|
193
|
+
amount: number;
|
|
194
|
+
}
|
|
195
|
+
export interface FastConvertExchangeRequest {
|
|
196
|
+
[key: string]: any;
|
|
197
|
+
amount: number;
|
|
198
|
+
from: string;
|
|
199
|
+
to: string;
|
|
200
|
+
}
|
|
201
|
+
export interface FastConvertExchangeResponse {
|
|
202
|
+
id: number;
|
|
203
|
+
rate: number;
|
|
204
|
+
}
|
|
205
|
+
export interface GetExchangeInfoRequest {
|
|
206
|
+
[key: string]: any;
|
|
207
|
+
minAmount: number;
|
|
208
|
+
maxAmount: number;
|
|
209
|
+
from: string;
|
|
210
|
+
to: string;
|
|
211
|
+
livetime?: number;
|
|
212
|
+
rateType?: 'exchange' | 'invoice' | 'checkout';
|
|
213
|
+
}
|
|
214
|
+
export interface GetExchangeInfoResponse {
|
|
215
|
+
rate: number;
|
|
216
|
+
exchanged_amount_from: number;
|
|
217
|
+
exchanged_amount_to: number;
|
|
218
|
+
}
|
|
219
|
+
export interface GetExchangeStatusRequest {
|
|
220
|
+
[key: string]: any;
|
|
221
|
+
id?: number;
|
|
222
|
+
externalId?: string;
|
|
223
|
+
}
|
|
224
|
+
export interface GetExchangeStatusResponse {
|
|
225
|
+
id: number;
|
|
226
|
+
from: string;
|
|
227
|
+
to: string;
|
|
228
|
+
rate: number;
|
|
229
|
+
amount_from: number;
|
|
230
|
+
amount_to: number;
|
|
231
|
+
status: string;
|
|
232
|
+
}
|
|
233
|
+
export interface GetBalanceStatisticsRequest {
|
|
234
|
+
[key: string]: any;
|
|
235
|
+
currency: string;
|
|
236
|
+
}
|
|
237
|
+
export interface GetBalanceStatisticsResponse {
|
|
238
|
+
project: number;
|
|
239
|
+
currency: string;
|
|
240
|
+
project_income: number;
|
|
241
|
+
project_outcome: number;
|
|
242
|
+
project_balance: number;
|
|
243
|
+
contract_income: number;
|
|
244
|
+
contract_outcome: number;
|
|
245
|
+
contract_balance: number;
|
|
246
|
+
}
|
|
247
|
+
export interface GetDaysBalanceStatisticsRequest {
|
|
248
|
+
[key: string]: any;
|
|
249
|
+
currency: string;
|
|
250
|
+
start: string;
|
|
251
|
+
finish: string;
|
|
252
|
+
}
|
|
253
|
+
export interface DaysBalance {
|
|
254
|
+
date: string;
|
|
255
|
+
income: number;
|
|
256
|
+
outcome: number;
|
|
257
|
+
}
|
|
258
|
+
export interface GetDaysBalanceStatisticsResponse {
|
|
259
|
+
project: number;
|
|
260
|
+
currency: string;
|
|
261
|
+
days_balance: DaysBalance[];
|
|
262
|
+
}
|
|
263
|
+
export interface PaySystem {
|
|
264
|
+
type: string;
|
|
265
|
+
fee: number;
|
|
266
|
+
fixed_fee: number;
|
|
267
|
+
currency: string;
|
|
268
|
+
image_url: string;
|
|
269
|
+
min_sum?: number;
|
|
270
|
+
max_sum?: number;
|
|
271
|
+
terminal?: 'enabled' | 'disabled';
|
|
272
|
+
}
|
|
273
|
+
export interface GetPayTypesStatisticsResponse {
|
|
274
|
+
project: number;
|
|
275
|
+
invoice: PaySystem[];
|
|
276
|
+
checkout: PaySystem[];
|
|
277
|
+
}
|
|
278
|
+
export interface CreateTerminalRequest {
|
|
279
|
+
[key: string]: any;
|
|
280
|
+
user: string;
|
|
281
|
+
ip: string;
|
|
282
|
+
amount?: number;
|
|
283
|
+
comment?: string;
|
|
284
|
+
success_url?: string;
|
|
285
|
+
fail_url?: string;
|
|
286
|
+
project_invoice?: string;
|
|
287
|
+
currency?: string;
|
|
288
|
+
use_user_select_currency?: 'yes' | 'no';
|
|
289
|
+
language?: string;
|
|
290
|
+
terminal_allow_methods?: string[];
|
|
291
|
+
terminal_disable_methods?: string[];
|
|
292
|
+
}
|
|
293
|
+
export interface CreateTerminalResponse {
|
|
294
|
+
url: string;
|
|
295
|
+
}
|
|
296
|
+
export interface InvoiceNotification {
|
|
297
|
+
project: number;
|
|
298
|
+
invoice: number;
|
|
299
|
+
status: 'New' | 'Processing' | 'Paid' | 'Chargeback' | 'Chargeback_cancel' | 'Refused';
|
|
300
|
+
amount: number;
|
|
301
|
+
net_amount: number;
|
|
302
|
+
recieved_amount: number;
|
|
303
|
+
rate?: number;
|
|
304
|
+
user: string;
|
|
305
|
+
type: string;
|
|
306
|
+
wallet: string;
|
|
307
|
+
comment: string;
|
|
308
|
+
time: string;
|
|
309
|
+
project_invoice?: string;
|
|
310
|
+
currency_project: string;
|
|
311
|
+
currency_user: string;
|
|
312
|
+
reason?: string;
|
|
313
|
+
signature: string;
|
|
314
|
+
}
|
|
315
|
+
export interface CheckoutNotification {
|
|
316
|
+
id: number;
|
|
317
|
+
project: number;
|
|
318
|
+
projectId: string;
|
|
319
|
+
amount: number;
|
|
320
|
+
net_amount: number;
|
|
321
|
+
paid_amount: number;
|
|
322
|
+
rate?: number;
|
|
323
|
+
status: string;
|
|
324
|
+
user: string;
|
|
325
|
+
wallet: string;
|
|
326
|
+
description: string;
|
|
327
|
+
comment: string;
|
|
328
|
+
type: string;
|
|
329
|
+
currency_project: string;
|
|
330
|
+
currency_user: string;
|
|
331
|
+
time: string;
|
|
332
|
+
signature: string;
|
|
333
|
+
}
|
|
334
|
+
export interface TransferNotification {
|
|
335
|
+
amount: number;
|
|
336
|
+
currency: string;
|
|
337
|
+
user: string;
|
|
338
|
+
type: string;
|
|
339
|
+
ip: string;
|
|
340
|
+
time: number;
|
|
341
|
+
comment: string;
|
|
342
|
+
signature: string;
|
|
343
|
+
}
|
|
344
|
+
declare type Payload = Record<string, unknown>;
|
|
345
|
+
export default class GameMoney {
|
|
346
|
+
private readonly config;
|
|
347
|
+
private readonly got;
|
|
348
|
+
constructor(config: Config);
|
|
349
|
+
request<T extends GenericResponse>(url: string, payload?: Payload, signType?: SignType): Promise<T>;
|
|
350
|
+
generateHmacSignature(body: any): string;
|
|
351
|
+
verifyRsaSignature(body: any): boolean;
|
|
352
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#invoice_insert_api) */
|
|
353
|
+
createInvoice(body: CreateInvoiceRequest): Promise<CreateInvoiceResponse & GenericResponse>;
|
|
354
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#invoice_status) */
|
|
355
|
+
getInvoiceStatus(body: GetInvoiceStatusRequest): Promise<GetInvoiceStatusResponse & GenericResponse>;
|
|
356
|
+
/** For more details and usage information see [docs](https://cp.gamemoney.com/apidoc#invoice_list) */
|
|
357
|
+
getInvoiceList(body: GetInvoiceListRequest): Promise<GetInvoiceListResponse & GenericResponse>;
|
|
358
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#checkout_insert) */
|
|
359
|
+
createCheckout(body: CreateCheckoutRequest): Promise<GenericResponse>;
|
|
360
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#checkout_cancel) */
|
|
361
|
+
cancelCheckout(body: CancelCheckoutRequest): Promise<GenericResponse>;
|
|
362
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#checkout_status) */
|
|
363
|
+
getCheckoutStatus(body: GetCheckoutStatusRequest): Promise<GetCheckoutStatusResponse & GenericResponse>;
|
|
364
|
+
/** For more details and usage information see [docs](https://cp.gamemoney.com/apidoc#checkout_list) */
|
|
365
|
+
getCheckoutList(body: GetCheckoutListRequest): Promise<GetCheckoutListResponse & GenericResponse>;
|
|
366
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_add) */
|
|
367
|
+
addCard(body: AddCardRequest): Promise<AddCardResponse & GenericResponse>;
|
|
368
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_add_token) */
|
|
369
|
+
addTokenCard(body: AddTokenCardRequest): Promise<AddTokenCardResponse & GenericResponse>;
|
|
370
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_list) */
|
|
371
|
+
getCardList(body: GetCardListRequest): Promise<GetCardListResponse & GenericResponse>;
|
|
372
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_fulllist) */
|
|
373
|
+
getCardFullList(body: GetCardFullListRequest): Promise<GetCardFullListResponse & GenericResponse>;
|
|
374
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_list) */
|
|
375
|
+
deleteCard(body: DeleteCardRequest): Promise<GenericResponse>;
|
|
376
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_prepare) */
|
|
377
|
+
prepareExchange(body: PrepareExchangeRequest): Promise<PrepareExchangeResponse & GenericResponse>;
|
|
378
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_convert) */
|
|
379
|
+
convertExchange(body: ConvertExchangeRequest): Promise<GenericResponse>;
|
|
380
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_fastconvert) */
|
|
381
|
+
fastConvertExchange(body: FastConvertExchangeRequest): Promise<FastConvertExchangeResponse & GenericResponse>;
|
|
382
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_info) */
|
|
383
|
+
getExchangeInfo(body: GetExchangeInfoRequest): Promise<GetExchangeInfoResponse & GenericResponse>;
|
|
384
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_status) */
|
|
385
|
+
getExchangeStatus(body: GetExchangeStatusRequest): Promise<GetExchangeStatusResponse & GenericResponse>;
|
|
386
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#stat_balance) */
|
|
387
|
+
getBalanceStatistics(body: GetBalanceStatisticsRequest): Promise<GetBalanceStatisticsResponse & GenericResponse>;
|
|
388
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#stat_days_balance) */
|
|
389
|
+
getDaysBalanceStatistics(body: GetDaysBalanceStatisticsRequest): Promise<GetDaysBalanceStatisticsResponse & GenericResponse>;
|
|
390
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#stat_paytypes) */
|
|
391
|
+
getPayTypesStatistics(): Promise<GetPayTypesStatisticsResponse & GenericResponse>;
|
|
392
|
+
/** For more details and usage information see [docs](https://cp.gamemoney.com/apidoc#invoice_api_terminal) */
|
|
393
|
+
createTerminal(body: CreateTerminalRequest): Promise<CreateTerminalResponse & GenericResponse>;
|
|
394
|
+
}
|
|
395
|
+
export {};
|
package/index.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import got from 'got';
|
|
2
|
+
import { generateRsaSignature, generateHmacSignature, getRandomString, verifyRsaSignature, } from './utils.js';
|
|
3
|
+
export var SignType;
|
|
4
|
+
(function (SignType) {
|
|
5
|
+
SignType["HMAC"] = "HMAC";
|
|
6
|
+
SignType["RSA"] = "RSA";
|
|
7
|
+
})(SignType || (SignType = {}));
|
|
8
|
+
export default class GameMoney {
|
|
9
|
+
config;
|
|
10
|
+
got = got.extend({
|
|
11
|
+
prefixUrl: 'https://paygate.gamemoney.com',
|
|
12
|
+
responseType: 'json',
|
|
13
|
+
});
|
|
14
|
+
constructor(config) {
|
|
15
|
+
this.config = config;
|
|
16
|
+
}
|
|
17
|
+
async request(url, payload = {}, signType = SignType.HMAC) {
|
|
18
|
+
const form = {
|
|
19
|
+
rand: getRandomString(20),
|
|
20
|
+
project: this.config.project,
|
|
21
|
+
...payload,
|
|
22
|
+
};
|
|
23
|
+
if (signType === SignType.RSA) {
|
|
24
|
+
if (!this.config.rsaPrivateKey) {
|
|
25
|
+
throw new Error("To make requests with RSA sign type, 'rsaPrivateKey' must be provided");
|
|
26
|
+
}
|
|
27
|
+
form.signature = generateRsaSignature(form, this.config.rsaPrivateKey);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
form.signature = generateHmacSignature(form, this.config.hmacPrivateKey);
|
|
31
|
+
}
|
|
32
|
+
const response = await this.got.post({
|
|
33
|
+
url,
|
|
34
|
+
form,
|
|
35
|
+
resolveBodyOnly: true,
|
|
36
|
+
});
|
|
37
|
+
if (!verifyRsaSignature(response)) {
|
|
38
|
+
throw new Error('Response signature mismatch');
|
|
39
|
+
}
|
|
40
|
+
if (form.rand !== response.rand) {
|
|
41
|
+
throw new Error(`Wrong rand parameter: ${response.rand}`);
|
|
42
|
+
}
|
|
43
|
+
if (response.state === 'error') {
|
|
44
|
+
throw new Error(response.error);
|
|
45
|
+
}
|
|
46
|
+
return response;
|
|
47
|
+
}
|
|
48
|
+
generateHmacSignature(body) {
|
|
49
|
+
return generateHmacSignature(body, this.config.hmacPrivateKey);
|
|
50
|
+
}
|
|
51
|
+
verifyRsaSignature(body) {
|
|
52
|
+
return verifyRsaSignature(body);
|
|
53
|
+
}
|
|
54
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#invoice_insert_api) */
|
|
55
|
+
async createInvoice(body) {
|
|
56
|
+
return this.request('invoice/', body);
|
|
57
|
+
}
|
|
58
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#invoice_status) */
|
|
59
|
+
async getInvoiceStatus(body) {
|
|
60
|
+
return this.request('invoice/status', body);
|
|
61
|
+
}
|
|
62
|
+
/** For more details and usage information see [docs](https://cp.gamemoney.com/apidoc#invoice_list) */
|
|
63
|
+
async getInvoiceList(body) {
|
|
64
|
+
return this.request('invoice/list', body);
|
|
65
|
+
}
|
|
66
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#checkout_insert) */
|
|
67
|
+
async createCheckout(body) {
|
|
68
|
+
return this.request('checkout/insert', body, SignType.RSA);
|
|
69
|
+
}
|
|
70
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#checkout_cancel) */
|
|
71
|
+
async cancelCheckout(body) {
|
|
72
|
+
return this.request('checkout/cancel', body);
|
|
73
|
+
}
|
|
74
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#checkout_status) */
|
|
75
|
+
async getCheckoutStatus(body) {
|
|
76
|
+
return this.request('checkout/status', body);
|
|
77
|
+
}
|
|
78
|
+
/** For more details and usage information see [docs](https://cp.gamemoney.com/apidoc#checkout_list) */
|
|
79
|
+
async getCheckoutList(body) {
|
|
80
|
+
return this.request('checkout/list', body);
|
|
81
|
+
}
|
|
82
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_add) */
|
|
83
|
+
async addCard(body) {
|
|
84
|
+
return this.request('card/add', body);
|
|
85
|
+
}
|
|
86
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_add_token) */
|
|
87
|
+
async addTokenCard(body) {
|
|
88
|
+
return this.request('card/addtoken', body);
|
|
89
|
+
}
|
|
90
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_list) */
|
|
91
|
+
async getCardList(body) {
|
|
92
|
+
return this.request('card/list', body);
|
|
93
|
+
}
|
|
94
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_fulllist) */
|
|
95
|
+
async getCardFullList(body) {
|
|
96
|
+
return this.request('card/fulllist', body);
|
|
97
|
+
}
|
|
98
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_list) */
|
|
99
|
+
async deleteCard(body) {
|
|
100
|
+
return this.request('card/delete', body);
|
|
101
|
+
}
|
|
102
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_prepare) */
|
|
103
|
+
async prepareExchange(body) {
|
|
104
|
+
return this.request('exchange/prepare', body);
|
|
105
|
+
}
|
|
106
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_convert) */
|
|
107
|
+
async convertExchange(body) {
|
|
108
|
+
return this.request('exchange/convert', body);
|
|
109
|
+
}
|
|
110
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_fastconvert) */
|
|
111
|
+
async fastConvertExchange(body) {
|
|
112
|
+
return this.request('exchange/fastconvert', body);
|
|
113
|
+
}
|
|
114
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_info) */
|
|
115
|
+
async getExchangeInfo(body) {
|
|
116
|
+
return this.request('exchange/info', body);
|
|
117
|
+
}
|
|
118
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_status) */
|
|
119
|
+
async getExchangeStatus(body) {
|
|
120
|
+
return this.request('exchange/status', body);
|
|
121
|
+
}
|
|
122
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#stat_balance) */
|
|
123
|
+
async getBalanceStatistics(body) {
|
|
124
|
+
return this.request('statistics/balance', body);
|
|
125
|
+
}
|
|
126
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#stat_days_balance) */
|
|
127
|
+
async getDaysBalanceStatistics(body) {
|
|
128
|
+
return this.request('statistics/days_balance_project', body);
|
|
129
|
+
}
|
|
130
|
+
/** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#stat_paytypes) */
|
|
131
|
+
async getPayTypesStatistics() {
|
|
132
|
+
return this.request('statistics/paytypes');
|
|
133
|
+
}
|
|
134
|
+
/** For more details and usage information see [docs](https://cp.gamemoney.com/apidoc#invoice_api_terminal) */
|
|
135
|
+
async createTerminal(body) {
|
|
136
|
+
return this.request('terminal/create', body);
|
|
137
|
+
}
|
|
138
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gamemoney",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "GameMoney API wrapper for Node.js",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"prepublish": "npm run lint && npm run test && npm run build",
|
|
9
|
-
"lint": "tslint 'src/**/*.ts' -t codeFrame",
|
|
10
|
-
"test": "mocha -r ts-node/register src/**/*.spec.ts",
|
|
11
|
-
"build": "tsc"
|
|
12
|
-
},
|
|
13
5
|
"keywords": [
|
|
14
6
|
"gamemoney",
|
|
7
|
+
"gmpays",
|
|
15
8
|
"gm",
|
|
16
9
|
"merchant"
|
|
17
10
|
],
|
|
@@ -23,26 +16,70 @@
|
|
|
23
16
|
"author": {
|
|
24
17
|
"name": "Maxim Makarov",
|
|
25
18
|
"email": "maxpain177@gmail.com",
|
|
26
|
-
"url": "
|
|
19
|
+
"url": "https://maxpain.pro"
|
|
27
20
|
},
|
|
28
21
|
"license": "MIT",
|
|
29
22
|
"repository": {
|
|
30
23
|
"type": "git",
|
|
31
24
|
"url": "https://github.com/gamemoney-ps/gamemoney-node-sdk"
|
|
32
25
|
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": "./index.js",
|
|
30
|
+
"types": "./index.d.ts"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"prebuild": "rm -rf .build",
|
|
35
|
+
"build": "tsc",
|
|
36
|
+
"postbuild": "cp -r package*.json .npmignore ./src/certs .build",
|
|
37
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
38
|
+
"lint": "xo",
|
|
39
|
+
"lint:fix": "xo --fix"
|
|
40
|
+
},
|
|
41
|
+
"lint-staged": {
|
|
42
|
+
"*.ts": "xo --fix"
|
|
43
|
+
},
|
|
44
|
+
"jest": {
|
|
45
|
+
"testMatch": [
|
|
46
|
+
"**/*.test.ts"
|
|
47
|
+
],
|
|
48
|
+
"preset": "ts-jest/presets/default-esm",
|
|
49
|
+
"globals": {
|
|
50
|
+
"ts-jest": {
|
|
51
|
+
"useESM": true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"moduleNameMapper": {
|
|
55
|
+
"^(\\.{1,2}/.*)\\.js$": "$1"
|
|
56
|
+
},
|
|
57
|
+
"maxConcurrency": 50
|
|
58
|
+
},
|
|
59
|
+
"xo": {
|
|
60
|
+
"extends": "@onmoon",
|
|
61
|
+
"prettier": true
|
|
62
|
+
},
|
|
63
|
+
"prettier": "@onmoon/prettier-config",
|
|
33
64
|
"devDependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"@types/
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
65
|
+
"@onmoon/eslint-config": "^1.0.8",
|
|
66
|
+
"@onmoon/prettier-config": "^1.0.2",
|
|
67
|
+
"@onmoon/tsconfigs": "^1.0.5",
|
|
68
|
+
"@types/body-parser": "^1.19.2",
|
|
69
|
+
"@types/express": "^4.17.13",
|
|
70
|
+
"@types/jest": "^27.4.0",
|
|
71
|
+
"@types/node": "^17.0.10",
|
|
72
|
+
"@types/uuid": "^8.3.4",
|
|
73
|
+
"body-parser": "^1.19.1",
|
|
74
|
+
"express": "^4.17.2",
|
|
75
|
+
"husky": "^7.0.4",
|
|
76
|
+
"lint-staged": "^12.2.1",
|
|
77
|
+
"ts-jest": "^27.1.3",
|
|
78
|
+
"typescript": "^4.5.4",
|
|
79
|
+
"uuid": "^8.3.2",
|
|
80
|
+
"xo": "^0.47.0"
|
|
43
81
|
},
|
|
44
82
|
"dependencies": {
|
|
45
|
-
"
|
|
46
|
-
"request-promise-native": "^1.0.7"
|
|
83
|
+
"got": "^12.0.1"
|
|
47
84
|
}
|
|
48
|
-
}
|
|
85
|
+
}
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import crypto from 'node:crypto';
|
|
3
|
+
export declare type RsaKey = Parameters<crypto.Sign['sign']>[0];
|
|
4
|
+
export declare type HmacKey = Parameters<typeof crypto.createHmac>[1];
|
|
5
|
+
declare type JsonPrimitive = number | number[] | string | string[] | undefined | null;
|
|
6
|
+
declare type Json = {
|
|
7
|
+
[key: string]: Json | JsonPrimitive;
|
|
8
|
+
};
|
|
9
|
+
interface Body extends Json {
|
|
10
|
+
signature: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function parametersToString(body: Json): string;
|
|
13
|
+
export declare function verifyRsaSignature(body: Body): boolean;
|
|
14
|
+
export declare function generateRsaSignature(body: Json, key: RsaKey): string;
|
|
15
|
+
export declare function generateHmacSignature(body: Json, key: HmacKey): string;
|
|
16
|
+
export declare function getRandomString(length: number): string;
|
|
17
|
+
export {};
|