UNPKG

gamemoney-fix

Version:
400 lines (399 loc) 12.7 kB
import { RsaKey, HmacKey } from './utils.js'; export declare enum SignType { 'HMAC' = "HMAC", 'RSA' = "RSA" } export interface GenericRequest { [key: string]: any; rand?: string; project: number; signature?: string; } export interface GenericResponse { [key: string]: any; state: 'success' | 'error'; time: number; error?: string; rand?: string; signature: string; } export interface Config { rsaPrivateKey?: RsaKey; hmacPrivateKey: HmacKey; project: number; } export interface CreateInvoiceRequest { [key: string]: any; type: string; user: string; ip: string; amount: number; comment?: string; success_url?: string; fail_url?: string; wallet: string; project_invoice?: string; currency?: string; user_currency?: string; language?: string; mode?: 'card_direct'; } export interface CreateInvoiceResponse { invoice: number; type: 'message' | 'redirect' | 'cardrequest' | 'error'; data: string; } export interface GetInvoiceStatusRequestWithProjectInvoiceId { [key: string]: any; invoice: number; } export interface GetInvoiceStatusRequestWithGamemoneyInvoiceId { [key: string]: any; project_invoice: string; } export declare type GetInvoiceStatusRequest = GetInvoiceStatusRequestWithProjectInvoiceId | GetInvoiceStatusRequestWithGamemoneyInvoiceId; export interface GetInvoiceStatusResponse { project: number; invoice: number; status: string; amount: number; net_amount: number; recieved_amount: number; user: string; type: string; wallet: string; project_invoice: string; currency_project: string; currency_user: string; date_create: string; date_pay: string; rate?: string; } export interface GetInvoiceListRequest { [key: string]: any; start: string; finish: string; } export interface GetInvoiceListResponse { list: GetInvoiceStatusResponse[]; is_limit_exceeded: 'yes' | 'no'; } export interface CancelCheckoutRequest { [key: string]: any; projectId: string; } export interface GetCheckoutStatusRequest { [key: string]: any; projectId: string; } export interface Refund { id: number; amount: number; net_amount: number; paid_amount: number; comment: string; } export interface GetCheckoutStatusResponse { id: number; project: number; projectId: string; amount: number; net_amount: number; paid_amount: number; status: number; user: string; wallet: string; description: string; comment: string; redirect_url: string; type: string; currency_project: string; currency_user: string; date_create: string; rate?: string; refunds: Refund[]; } export interface GetCheckoutListRequest { [key: string]: any; start: string; finish: string; } export interface GetCheckoutListResponse { list: GetCheckoutStatusResponse[]; } export interface CreateCheckoutRequest { [key: string]: any; projectId: string; user: string; ip: string; amount: number; wallet: string; description: string; type: string; currency?: string; userCurrency?: string; } export interface AddCardRequest { [key: string]: any; user: string; redirect: string; } export interface AddCardResponse { url: string; } export interface AddTokenCardRequest { [key: string]: any; user: string; } export interface AddTokenCardResponse { token: string; } export interface GetCardListRequest { [key: string]: any; user: string; } export interface GetCardListResponse { pans: string[]; } export interface GetCardFullListRequest { [key: string]: any; user: string; } export interface GetCardFullListResponse { cards?: Array<{ pan: string; expire_month: string; expire_year: string; cardholder: string; }>; } export interface DeleteCardRequest { [key: string]: any; user: string; pan: string; } export interface PrepareExchangeRequest { [key: string]: any; externalId: string; minAmount: number; maxAmount: number; from: string; to: string; livetime?: number; } export interface PrepareExchangeResponse { id: number; rate: number; exchanged_amount_from: number; exchanged_amount_to: number; } export interface ConvertExchangeRequest { [key: string]: any; id: number; amount: number; } export interface FastConvertExchangeRequest { [key: string]: any; amount: number; from: string; to: string; } export interface FastConvertExchangeResponse { id: number; rate: number; } export interface GetExchangeInfoRequest { [key: string]: any; minAmount: number; maxAmount: number; from: string; to: string; livetime?: number; rateType?: 'exchange' | 'invoice' | 'checkout'; } export interface GetExchangeInfoResponse { rate: number; exchanged_amount_from: number; exchanged_amount_to: number; } export interface GetExchangeStatusRequest { [key: string]: any; id?: number; externalId?: string; } export interface GetExchangeStatusResponse { id: number; from: string; to: string; rate: number; amount_from: number; amount_to: number; status: string; } export interface GetBalanceStatisticsRequest { [key: string]: any; currency: string; } export interface GetBalanceStatisticsResponse { project: number; currency: string; project_income: number; project_outcome: number; project_balance: number; contract_income: number; contract_outcome: number; contract_balance: number; } export interface GetDaysBalanceStatisticsRequest { [key: string]: any; currency: string; start: string; finish: string; } export interface DaysBalance { date: string; income: number; outcome: number; } export interface GetDaysBalanceStatisticsResponse { project: number; currency: string; days_balance: DaysBalance[]; } export interface PaySystem { type: string; fee: number; fixed_fee: number; currency: string; image_url: string; min_sum?: number; max_sum?: number; terminal?: 'enabled' | 'disabled'; } export interface GetPayTypesStatisticsResponse { project: number; invoice: PaySystem[]; checkout: PaySystem[]; } export interface CreateTerminalRequest { [key: string]: any; user: string; ip: string; amount?: number; comment?: string; success_url?: string; fail_url?: string; project_invoice?: string; currency?: string; use_user_select_currency?: 'yes' | 'no'; language?: string; terminal_allow_methods?: string[]; terminal_disable_methods?: string[]; } export interface CreateTerminalResponse { url: string; } export interface InvoiceNotification { project: number; invoice: number; status: 'New' | 'Processing' | 'Paid' | 'Chargeback' | 'Chargeback_cancel' | 'Refused'; amount: number; net_amount: number; recieved_amount: number; rate?: number; user: string; type: string; wallet: string; comment: string; time: string; project_invoice?: string; currency_project: string; currency_user: string; reason?: string; signature: string; } export interface CheckoutNotification { id: number; project: number; projectId: string; amount: number; net_amount: number; paid_amount: number; rate?: number; status: string; user: string; wallet: string; description: string; comment: string; type: string; currency_project: string; currency_user: string; time: string; signature: string; refunds?: Refund[]; } export interface TransferNotification { amount: number; currency: string; user: string; type: string; ip: string; time: number; comment: string; signature: string; } declare type Payload = Record<string, unknown>; export declare class GameMoneyError extends Error { constructor(message: string); } export default class GameMoney { private readonly config; private readonly got; constructor(config: Config); request<T extends GenericResponse>(url: string, payload?: Payload, signType?: SignType): Promise<T>; generateHmacSignature(body: any): string; verifyRsaSignature(body: any): boolean; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#invoice_insert_api) */ createInvoice(body: CreateInvoiceRequest): Promise<CreateInvoiceResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#invoice_status) */ getInvoiceStatus(body: GetInvoiceStatusRequest): Promise<GetInvoiceStatusResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gamemoney.com/apidoc#invoice_list) */ getInvoiceList(body: GetInvoiceListRequest): Promise<GetInvoiceListResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#checkout_insert) */ createCheckout(body: CreateCheckoutRequest): Promise<GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#checkout_cancel) */ cancelCheckout(body: CancelCheckoutRequest): Promise<GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#checkout_status) */ getCheckoutStatus(body: GetCheckoutStatusRequest): Promise<GetCheckoutStatusResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gamemoney.com/apidoc#checkout_list) */ getCheckoutList(body: GetCheckoutListRequest): Promise<GetCheckoutListResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_add) */ addCard(body: AddCardRequest): Promise<AddCardResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_add_token) */ addTokenCard(body: AddTokenCardRequest): Promise<AddTokenCardResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_list) */ getCardList(body: GetCardListRequest): Promise<GetCardListResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_fulllist) */ getCardFullList(body: GetCardFullListRequest): Promise<GetCardFullListResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_list) */ deleteCard(body: DeleteCardRequest): Promise<GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_prepare) */ prepareExchange(body: PrepareExchangeRequest): Promise<PrepareExchangeResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_convert) */ convertExchange(body: ConvertExchangeRequest): Promise<GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_fastconvert) */ fastConvertExchange(body: FastConvertExchangeRequest): Promise<FastConvertExchangeResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_info) */ getExchangeInfo(body: GetExchangeInfoRequest): Promise<GetExchangeInfoResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#exchange_status) */ getExchangeStatus(body: GetExchangeStatusRequest): Promise<GetExchangeStatusResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#stat_balance) */ getBalanceStatistics(body: GetBalanceStatisticsRequest): Promise<GetBalanceStatisticsResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#stat_days_balance) */ getDaysBalanceStatistics(body: GetDaysBalanceStatisticsRequest): Promise<GetDaysBalanceStatisticsResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#stat_paytypes) */ getPayTypesStatistics(): Promise<GetPayTypesStatisticsResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gamemoney.com/apidoc#invoice_api_terminal) */ createTerminal(body: CreateTerminalRequest): Promise<CreateTerminalResponse & GenericResponse>; } export {};