gamemoney 4.2.0 → 5.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.
Files changed (4) hide show
  1. package/index.d.ts +130 -105
  2. package/index.js +7 -3
  3. package/package.json +16 -16
  4. package/utils.d.ts +6 -6
package/index.d.ts CHANGED
@@ -1,28 +1,28 @@
1
- import { RsaKey, HmacKey } from './utils.js';
1
+ import { type RsaKey, type HmacKey } from './utils.js';
2
2
  export declare enum SignType {
3
3
  'HMAC' = "HMAC",
4
4
  'RSA' = "RSA"
5
5
  }
6
- export interface GenericRequest {
6
+ export type GenericRequest = {
7
7
  [key: string]: any;
8
8
  rand?: string;
9
9
  project: number;
10
10
  signature?: string;
11
- }
12
- export interface GenericResponse {
11
+ };
12
+ export type GenericResponse = {
13
13
  [key: string]: any;
14
14
  state: 'success' | 'error';
15
15
  time: number;
16
16
  error?: string;
17
17
  rand?: string;
18
18
  signature: string;
19
- }
20
- export interface Config {
19
+ };
20
+ export type Config = {
21
21
  rsaPrivateKey?: RsaKey;
22
22
  hmacPrivateKey: HmacKey;
23
23
  project: number;
24
- }
25
- export interface CreateInvoiceRequest {
24
+ };
25
+ export type CreateInvoiceRequest = {
26
26
  [key: string]: any;
27
27
  type: string;
28
28
  user: string;
@@ -37,22 +37,25 @@ export interface CreateInvoiceRequest {
37
37
  user_currency?: string;
38
38
  language?: string;
39
39
  mode?: 'card_direct';
40
- }
41
- export interface CreateInvoiceResponse {
40
+ return_mode?: 'skip';
41
+ recurring?: 'yes';
42
+ recurrent_token?: string;
43
+ };
44
+ export type CreateInvoiceResponse = {
42
45
  invoice: number;
43
46
  type: 'message' | 'redirect' | 'cardrequest' | 'error';
44
47
  data: string;
45
- }
46
- export interface GetInvoiceStatusRequestWithProjectInvoiceId {
48
+ };
49
+ export type GetInvoiceStatusRequestWithProjectInvoiceId = {
47
50
  [key: string]: any;
48
51
  invoice: number;
49
- }
50
- export interface GetInvoiceStatusRequestWithGamemoneyInvoiceId {
52
+ };
53
+ export type GetInvoiceStatusRequestWithGamemoneyInvoiceId = {
51
54
  [key: string]: any;
52
55
  project_invoice: string;
53
- }
54
- export declare type GetInvoiceStatusRequest = GetInvoiceStatusRequestWithProjectInvoiceId | GetInvoiceStatusRequestWithGamemoneyInvoiceId;
55
- export interface GetInvoiceStatusResponse {
56
+ };
57
+ export type GetInvoiceStatusRequest = GetInvoiceStatusRequestWithProjectInvoiceId | GetInvoiceStatusRequestWithGamemoneyInvoiceId;
58
+ export type GetInvoiceStatusResponse = {
56
59
  project: number;
57
60
  invoice: number;
58
61
  status: string;
@@ -62,38 +65,43 @@ export interface GetInvoiceStatusResponse {
62
65
  user: string;
63
66
  type: string;
64
67
  wallet: string;
68
+ comment: string;
65
69
  project_invoice: string;
66
70
  currency_project: string;
67
71
  currency_user: string;
68
72
  date_create: string;
69
73
  date_pay: string;
70
74
  rate?: string;
71
- }
72
- export interface GetInvoiceListRequest {
75
+ recurrent_token?: string;
76
+ reason?: string;
77
+ txid?: string;
78
+ };
79
+ export type GetInvoiceListRequest = {
73
80
  [key: string]: any;
74
81
  start: string;
75
82
  finish: string;
76
- }
77
- export interface GetInvoiceListResponse {
83
+ status?: InvoiceStatus;
84
+ };
85
+ export type GetInvoiceListResponse = {
78
86
  list: GetInvoiceStatusResponse[];
79
87
  is_limit_exceeded: 'yes' | 'no';
80
- }
81
- export interface CancelCheckoutRequest {
88
+ };
89
+ export type CancelCheckoutRequest = {
82
90
  [key: string]: any;
83
91
  projectId: string;
84
- }
85
- export interface GetCheckoutStatusRequest {
92
+ };
93
+ export type GetCheckoutStatusRequest = {
86
94
  [key: string]: any;
87
95
  projectId: string;
88
- }
89
- export interface Refund {
96
+ };
97
+ export type Refund = {
90
98
  id: number;
91
99
  amount: number;
92
100
  net_amount: number;
93
101
  paid_amount: number;
94
102
  comment: string;
95
- }
96
- export interface GetCheckoutStatusResponse {
103
+ };
104
+ export type GetCheckoutStatusResponse = {
97
105
  id: number;
98
106
  project: number;
99
107
  projectId: string;
@@ -105,23 +113,23 @@ export interface GetCheckoutStatusResponse {
105
113
  wallet: string;
106
114
  description: string;
107
115
  comment: string;
108
- redirect_url: string;
109
116
  type: string;
110
117
  currency_project: string;
111
118
  currency_user: string;
112
119
  date_create: string;
113
120
  rate?: string;
114
- refunds: Refund[];
115
- }
116
- export interface GetCheckoutListRequest {
121
+ txid?: string;
122
+ };
123
+ export type GetCheckoutListRequest = {
117
124
  [key: string]: any;
118
125
  start: string;
119
126
  finish: string;
120
- }
121
- export interface GetCheckoutListResponse {
127
+ };
128
+ export type GetCheckoutListResponse = {
122
129
  list: GetCheckoutStatusResponse[];
123
- }
124
- export interface CreateCheckoutRequest {
130
+ is_limit_exceeded: 'yes' | 'no';
131
+ };
132
+ export type CreateCheckoutRequest = {
125
133
  [key: string]: any;
126
134
  projectId: string;
127
135
  user: string;
@@ -132,47 +140,48 @@ export interface CreateCheckoutRequest {
132
140
  type: string;
133
141
  currency?: string;
134
142
  userCurrency?: string;
135
- }
136
- export interface AddCardRequest {
143
+ prepareToken?: string;
144
+ };
145
+ export type AddCardRequest = {
137
146
  [key: string]: any;
138
147
  user: string;
139
148
  redirect: string;
140
- }
141
- export interface AddCardResponse {
149
+ };
150
+ export type AddCardResponse = {
142
151
  url: string;
143
- }
144
- export interface AddTokenCardRequest {
152
+ };
153
+ export type AddTokenCardRequest = {
145
154
  [key: string]: any;
146
155
  user: string;
147
- }
148
- export interface AddTokenCardResponse {
156
+ };
157
+ export type AddTokenCardResponse = {
149
158
  token: string;
150
- }
151
- export interface GetCardListRequest {
159
+ };
160
+ export type GetCardListRequest = {
152
161
  [key: string]: any;
153
162
  user: string;
154
- }
155
- export interface GetCardListResponse {
163
+ };
164
+ export type GetCardListResponse = {
156
165
  pans: string[];
157
- }
158
- export interface GetCardFullListRequest {
166
+ };
167
+ export type GetCardFullListRequest = {
159
168
  [key: string]: any;
160
169
  user: string;
161
- }
162
- export interface GetCardFullListResponse {
170
+ };
171
+ export type GetCardFullListResponse = {
163
172
  cards?: Array<{
164
173
  pan: string;
165
174
  expire_month: string;
166
175
  expire_year: string;
167
176
  cardholder: string;
168
177
  }>;
169
- }
170
- export interface DeleteCardRequest {
178
+ };
179
+ export type DeleteCardRequest = {
171
180
  [key: string]: any;
172
181
  user: string;
173
182
  pan: string;
174
- }
175
- export interface PrepareExchangeRequest {
183
+ };
184
+ export type PrepareExchangeRequest = {
176
185
  [key: string]: any;
177
186
  externalId: string;
178
187
  minAmount: number;
@@ -180,29 +189,38 @@ export interface PrepareExchangeRequest {
180
189
  from: string;
181
190
  to: string;
182
191
  livetime?: number;
183
- }
184
- export interface PrepareExchangeResponse {
192
+ };
193
+ export type PrepareExchangeResponse = {
185
194
  id: number;
186
195
  rate: number;
187
196
  exchanged_amount_from: number;
188
197
  exchanged_amount_to: number;
189
- }
190
- export interface ConvertExchangeRequest {
198
+ };
199
+ export type ConvertExchangeRequest = {
191
200
  [key: string]: any;
192
201
  id: number;
193
202
  amount: number;
194
- }
195
- export interface FastConvertExchangeRequest {
203
+ };
204
+ export type FastConvertExchangeRequest = {
196
205
  [key: string]: any;
197
206
  amount: number;
198
207
  from: string;
199
208
  to: string;
200
- }
201
- export interface FastConvertExchangeResponse {
209
+ };
210
+ export type FastConvertExchangeResponse = {
202
211
  id: number;
203
212
  rate: number;
204
- }
205
- export interface GetExchangeInfoRequest {
213
+ };
214
+ export type GetExchangeRateRequest = {
215
+ [key: string]: any;
216
+ from: string;
217
+ to: string;
218
+ };
219
+ export type GetExchangeRateResponse = {
220
+ buy: number;
221
+ sell: number;
222
+ };
223
+ export type GetExchangeInfoRequest = {
206
224
  [key: string]: any;
207
225
  minAmount: number;
208
226
  maxAmount: number;
@@ -210,18 +228,18 @@ export interface GetExchangeInfoRequest {
210
228
  to: string;
211
229
  livetime?: number;
212
230
  rateType?: 'exchange' | 'invoice' | 'checkout';
213
- }
214
- export interface GetExchangeInfoResponse {
231
+ };
232
+ export type GetExchangeInfoResponse = {
215
233
  rate: number;
216
234
  exchanged_amount_from: number;
217
235
  exchanged_amount_to: number;
218
- }
219
- export interface GetExchangeStatusRequest {
236
+ };
237
+ export type GetExchangeStatusRequest = {
220
238
  [key: string]: any;
221
239
  id?: number;
222
240
  externalId?: string;
223
- }
224
- export interface GetExchangeStatusResponse {
241
+ };
242
+ export type GetExchangeStatusResponse = {
225
243
  id: number;
226
244
  from: string;
227
245
  to: string;
@@ -229,12 +247,12 @@ export interface GetExchangeStatusResponse {
229
247
  amount_from: number;
230
248
  amount_to: number;
231
249
  status: string;
232
- }
233
- export interface GetBalanceStatisticsRequest {
250
+ };
251
+ export type GetBalanceStatisticsRequest = {
234
252
  [key: string]: any;
235
253
  currency: string;
236
- }
237
- export interface GetBalanceStatisticsResponse {
254
+ };
255
+ export type GetBalanceStatisticsResponse = {
238
256
  project: number;
239
257
  currency: string;
240
258
  project_income: number;
@@ -243,24 +261,24 @@ export interface GetBalanceStatisticsResponse {
243
261
  contract_income: number;
244
262
  contract_outcome: number;
245
263
  contract_balance: number;
246
- }
247
- export interface GetDaysBalanceStatisticsRequest {
264
+ };
265
+ export type GetDaysBalanceStatisticsRequest = {
248
266
  [key: string]: any;
249
267
  currency: string;
250
268
  start: string;
251
269
  finish: string;
252
- }
253
- export interface DaysBalance {
270
+ };
271
+ export type DaysBalance = {
254
272
  date: string;
255
273
  income: number;
256
274
  outcome: number;
257
- }
258
- export interface GetDaysBalanceStatisticsResponse {
275
+ };
276
+ export type GetDaysBalanceStatisticsResponse = {
259
277
  project: number;
260
278
  currency: string;
261
279
  days_balance: DaysBalance[];
262
- }
263
- export interface PaySystem {
280
+ };
281
+ export type PaySystem = {
264
282
  type: string;
265
283
  fee: number;
266
284
  fixed_fee: number;
@@ -269,16 +287,15 @@ export interface PaySystem {
269
287
  min_sum?: number;
270
288
  max_sum?: number;
271
289
  terminal?: 'enabled' | 'disabled';
272
- }
273
- export interface GetPayTypesStatisticsResponse {
290
+ };
291
+ export type GetPayTypesStatisticsResponse = {
274
292
  project: number;
275
293
  invoice: PaySystem[];
276
294
  checkout: PaySystem[];
277
- }
278
- export interface CreateTerminalRequest {
295
+ };
296
+ export type CreateTerminalRequest = {
279
297
  [key: string]: any;
280
298
  user: string;
281
- ip: string;
282
299
  amount?: number;
283
300
  comment?: string;
284
301
  success_url?: string;
@@ -289,14 +306,15 @@ export interface CreateTerminalRequest {
289
306
  language?: string;
290
307
  terminal_allow_methods?: string[];
291
308
  terminal_disable_methods?: string[];
292
- }
293
- export interface CreateTerminalResponse {
309
+ };
310
+ export type CreateTerminalResponse = {
294
311
  url: string;
295
- }
296
- export interface InvoiceNotification {
312
+ };
313
+ export type InvoiceStatus = 'New' | 'Processing' | 'Paid' | 'Chargeback' | 'Refund' | 'Chargeback_cancel' | 'Refused';
314
+ export type InvoiceNotification = {
297
315
  project: number;
298
316
  invoice: number;
299
- status: 'New' | 'Processing' | 'Paid' | 'Chargeback' | 'Chargeback_cancel' | 'Refused';
317
+ status: InvoiceStatus;
300
318
  amount: number;
301
319
  net_amount: number;
302
320
  recieved_amount: number;
@@ -309,10 +327,14 @@ export interface InvoiceNotification {
309
327
  project_invoice?: string;
310
328
  currency_project: string;
311
329
  currency_user: string;
330
+ date_create: string;
331
+ date_pay?: string;
332
+ recurrent_token?: string;
312
333
  reason?: string;
334
+ txid?: string;
313
335
  signature: string;
314
- }
315
- export interface CheckoutNotification {
336
+ };
337
+ export type CheckoutNotification = {
316
338
  id: number;
317
339
  project: number;
318
340
  projectId: string;
@@ -328,11 +350,12 @@ export interface CheckoutNotification {
328
350
  type: string;
329
351
  currency_project: string;
330
352
  currency_user: string;
353
+ date_create: string;
354
+ txid?: string;
331
355
  time: string;
332
356
  signature: string;
333
- refunds?: Refund[];
334
- }
335
- export interface TransferNotification {
357
+ };
358
+ export type TransferNotification = {
336
359
  amount: number;
337
360
  currency: string;
338
361
  user: string;
@@ -341,8 +364,8 @@ export interface TransferNotification {
341
364
  time: number;
342
365
  comment: string;
343
366
  signature: string;
344
- }
345
- declare type Payload = Record<string, unknown>;
367
+ };
368
+ type Payload = Record<string, unknown>;
346
369
  export declare class GameMoneyError extends Error {
347
370
  constructor(message: string);
348
371
  }
@@ -357,7 +380,7 @@ export default class GameMoney {
357
380
  createInvoice(body: CreateInvoiceRequest): Promise<CreateInvoiceResponse & GenericResponse>;
358
381
  /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#invoice_status) */
359
382
  getInvoiceStatus(body: GetInvoiceStatusRequest): Promise<GetInvoiceStatusResponse & GenericResponse>;
360
- /** For more details and usage information see [docs](https://cp.gamemoney.com/apidoc#invoice_list) */
383
+ /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#invoice_list) */
361
384
  getInvoiceList(body: GetInvoiceListRequest): Promise<GetInvoiceListResponse & GenericResponse>;
362
385
  /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#checkout_insert) */
363
386
  createCheckout(body: CreateCheckoutRequest): Promise<GenericResponse>;
@@ -365,7 +388,7 @@ export default class GameMoney {
365
388
  cancelCheckout(body: CancelCheckoutRequest): Promise<GenericResponse>;
366
389
  /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#checkout_status) */
367
390
  getCheckoutStatus(body: GetCheckoutStatusRequest): Promise<GetCheckoutStatusResponse & GenericResponse>;
368
- /** For more details and usage information see [docs](https://cp.gamemoney.com/apidoc#checkout_list) */
391
+ /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#checkout_list) */
369
392
  getCheckoutList(body: GetCheckoutListRequest): Promise<GetCheckoutListResponse & GenericResponse>;
370
393
  /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_add) */
371
394
  addCard(body: AddCardRequest): Promise<AddCardResponse & GenericResponse>;
@@ -383,6 +406,8 @@ export default class GameMoney {
383
406
  convertExchange(body: ConvertExchangeRequest): Promise<GenericResponse>;
384
407
  /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_fastconvert) */
385
408
  fastConvertExchange(body: FastConvertExchangeRequest): Promise<FastConvertExchangeResponse & GenericResponse>;
409
+ /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_rate) */
410
+ getExchangeRate(body: GetExchangeRateRequest): Promise<GetExchangeRateResponse & GenericResponse>;
386
411
  /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_info) */
387
412
  getExchangeInfo(body: GetExchangeInfoRequest): Promise<GetExchangeInfoResponse & GenericResponse>;
388
413
  /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_status) */
@@ -393,7 +418,7 @@ export default class GameMoney {
393
418
  getDaysBalanceStatistics(body: GetDaysBalanceStatisticsRequest): Promise<GetDaysBalanceStatisticsResponse & GenericResponse>;
394
419
  /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#stat_paytypes) */
395
420
  getPayTypesStatistics(): Promise<GetPayTypesStatisticsResponse & GenericResponse>;
396
- /** For more details and usage information see [docs](https://cp.gamemoney.com/apidoc#invoice_api_terminal) */
421
+ /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#invoice_api_terminal) */
397
422
  createTerminal(body: CreateTerminalRequest): Promise<CreateTerminalResponse & GenericResponse>;
398
423
  }
399
424
  export {};
package/index.js CHANGED
@@ -66,7 +66,7 @@ export default class GameMoney {
66
66
  async getInvoiceStatus(body) {
67
67
  return this.request('invoice/status', body);
68
68
  }
69
- /** For more details and usage information see [docs](https://cp.gamemoney.com/apidoc#invoice_list) */
69
+ /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#invoice_list) */
70
70
  async getInvoiceList(body) {
71
71
  return this.request('invoice/list', body);
72
72
  }
@@ -82,7 +82,7 @@ export default class GameMoney {
82
82
  async getCheckoutStatus(body) {
83
83
  return this.request('checkout/status', body);
84
84
  }
85
- /** For more details and usage information see [docs](https://cp.gamemoney.com/apidoc#checkout_list) */
85
+ /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#checkout_list) */
86
86
  async getCheckoutList(body) {
87
87
  return this.request('checkout/list', body);
88
88
  }
@@ -118,6 +118,10 @@ export default class GameMoney {
118
118
  async fastConvertExchange(body) {
119
119
  return this.request('exchange/fastconvert', body);
120
120
  }
121
+ /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_rate) */
122
+ async getExchangeRate(body) {
123
+ return this.request('exchange/rate', body);
124
+ }
121
125
  /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_info) */
122
126
  async getExchangeInfo(body) {
123
127
  return this.request('exchange/info', body);
@@ -138,7 +142,7 @@ export default class GameMoney {
138
142
  async getPayTypesStatistics() {
139
143
  return this.request('statistics/paytypes');
140
144
  }
141
- /** For more details and usage information see [docs](https://cp.gamemoney.com/apidoc#invoice_api_terminal) */
145
+ /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#invoice_api_terminal) */
142
146
  async createTerminal(body) {
143
147
  return this.request('terminal/create', body);
144
148
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gamemoney",
3
- "version": "4.2.0",
3
+ "version": "5.0.0",
4
4
  "description": "GameMoney API wrapper for Node.js",
5
5
  "keywords": [
6
6
  "gamemoney",
@@ -62,24 +62,24 @@
62
62
  },
63
63
  "prettier": "@onmoon/prettier-config",
64
64
  "devDependencies": {
65
- "@onmoon/eslint-config": "^1.0.11",
65
+ "@onmoon/eslint-config": "^1.0.12",
66
66
  "@onmoon/prettier-config": "^1.0.2",
67
- "@onmoon/tsconfigs": "^2.0.0",
67
+ "@onmoon/tsconfigs": "^2.0.2",
68
68
  "@types/body-parser": "^1.19.2",
69
- "@types/express": "^4.17.13",
70
- "@types/jest": "^27.5.1",
71
- "@types/node": "^17.0.35",
72
- "@types/uuid": "^8.3.4",
73
- "body-parser": "^1.20.0",
74
- "express": "^4.18.1",
75
- "husky": "^8.0.1",
76
- "lint-staged": "^12.4.1",
77
- "ts-jest": "^28.0.2",
78
- "typescript": "^4.6.4",
79
- "uuid": "^8.3.2",
80
- "xo": "^0.49.0"
69
+ "@types/express": "^4.17.17",
70
+ "@types/jest": "^29.4.0",
71
+ "@types/node": "^18.13.0",
72
+ "@types/uuid": "^9.0.0",
73
+ "body-parser": "^1.20.1",
74
+ "express": "^4.18.2",
75
+ "husky": "^8.0.3",
76
+ "lint-staged": "^13.1.1",
77
+ "ts-jest": "^29.0.5",
78
+ "typescript": "^4.9.5",
79
+ "uuid": "^9.0.0",
80
+ "xo": "^0.53.1"
81
81
  },
82
82
  "dependencies": {
83
- "got": "^12.0.4"
83
+ "got": "^12.5.3"
84
84
  }
85
85
  }
package/utils.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  /// <reference types="node" />
2
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 = {
3
+ export type RsaKey = Parameters<crypto.Sign['sign']>[0];
4
+ export type HmacKey = Parameters<typeof crypto.createHmac>[1];
5
+ type JsonPrimitive = number | number[] | string | string[] | undefined | null;
6
+ type Json = {
7
7
  [key: string]: Json | JsonPrimitive;
8
8
  };
9
- interface Body extends Json {
9
+ type Body = {
10
10
  signature: string;
11
- }
11
+ } & Json;
12
12
  export declare function parametersToString(body: Json): string;
13
13
  export declare function verifyRsaSignature(body: Body): boolean;
14
14
  export declare function generateRsaSignature(body: Json, key: RsaKey): string;