UNPKG

@an00b1s/gamemoney

Version:
450 lines (449 loc) 14.5 kB
import { type RsaKey, type HmacKey, type Json, type Body } from './utils.js'; export declare enum SignType { 'HMAC' = "HMAC", 'RSA' = "RSA" } export type GenericRequest = { [key: string]: any; rand?: string; project: number; signature?: string; }; export type GenericResponse = { [key: string]: any; state: 'success' | 'error'; time: number; error?: string; rand?: string; signature: string; }; export type Config = { rsaPrivateKey?: RsaKey; hmacPrivateKey: HmacKey; project: number; }; export type 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'; return_mode?: 'skip'; recurring?: 'yes'; recurrent_token?: string; }; export type CreateInvoiceResponse = { invoice: number; type: 'message' | 'redirect' | 'cardrequest' | 'error'; data: string; }; export type GetInvoiceStatusRequestWithProjectInvoiceId = { [key: string]: any; invoice: number; }; export type GetInvoiceStatusRequestWithGamemoneyInvoiceId = { [key: string]: any; project_invoice: string; }; export type GetInvoiceStatusRequest = GetInvoiceStatusRequestWithProjectInvoiceId | GetInvoiceStatusRequestWithGamemoneyInvoiceId; export type GetInvoiceStatusResponse = { project: number; invoice: number; status: string; amount: number; net_amount: number; recieved_amount: number; user: string; type: string; wallet: string; comment: string; project_invoice: string; currency_project: string; currency_user: string; date_create: string; date_pay: string; rate?: string; recurrent_token?: string; reason?: string; txid?: string; }; export type GetInvoiceListRequest = { [key: string]: any; start: string; finish: string; status?: InvoiceStatus; }; export type GetInvoiceListResponse = { list: GetInvoiceStatusResponse[]; is_limit_exceeded: 'yes' | 'no'; }; export type GetCardSessionStatusRequest = Record<string, any> & ({ invoice: string; } | { project_invoice: string; }); export type AddTokenInvoiceRequest = Record<string, any> & { user: string; }; export type AddTokenInvoiceResponse = { token: string; }; export type WaitOrDeclineCardSessionStatusResponse = { status: 'wait' | 'decline'; data: string; }; export type FinishCardSessionStatusResponse = { status: 'finish'; type: 'redirect'; data: string; }; export type GetCardSessionStatusResponse = WaitOrDeclineCardSessionStatusResponse | FinishCardSessionStatusResponse; export type CancelCheckoutRequest = { [key: string]: any; projectId: string; }; export type GetCheckoutStatusRequest = { [key: string]: any; projectId: string; }; export type Refund = { id: number; amount: number; net_amount: number; paid_amount: number; comment: string; }; export type 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; type: string; currency_project: string; currency_user: string; date_create: string; rate?: string; txid?: string; }; export type GetCheckoutListRequest = { [key: string]: any; start: string; finish: string; }; export type GetCheckoutListResponse = { list: GetCheckoutStatusResponse[]; is_limit_exceeded: 'yes' | 'no'; }; export type CreateCheckoutRequest = { [key: string]: any; projectId: string; user: string; ip: string; amount: number; wallet: string; description: string; type: string; currency?: string; userCurrency?: string; prepareToken?: string; }; export type AddCardRequest = { [key: string]: any; user: string; redirect: string; }; export type AddCardResponse = { url: string; }; export type AddTokenCardRequest = { [key: string]: any; user: string; }; export type AddTokenCardResponse = { token: string; }; export type GetCardListRequest = { [key: string]: any; user: string; }; export type GetCardListResponse = { pans: string[]; }; export type GetCardFullListRequest = { [key: string]: any; user: string; }; export type GetCardFullListResponse = { cards?: Array<{ pan: string; expire_month: string; expire_year: string; cardholder: string; }>; }; export type DeleteCardRequest = { [key: string]: any; user: string; pan: string; }; export type PrepareExchangeRequest = { [key: string]: any; externalId: string; minAmount: number; maxAmount: number; from: string; to: string; livetime?: number; }; export type PrepareExchangeResponse = { id: number; rate: number; exchanged_amount_from: number; exchanged_amount_to: number; }; export type ConvertExchangeRequest = { [key: string]: any; id: number; amount: number; }; export type FastConvertExchangeRequest = { [key: string]: any; amount: number; from: string; to: string; }; export type FastConvertExchangeResponse = { id: number; rate: number; }; export type GetExchangeRateRequest = { [key: string]: any; from: string; to: string; }; export type GetExchangeRateResponse = { buy: number; sell: number; }; export type GetExchangeInfoRequest = { [key: string]: any; minAmount: number; maxAmount: number; from: string; to: string; livetime?: number; rateType?: 'exchange' | 'invoice' | 'checkout'; }; export type GetExchangeInfoResponse = { rate: number; exchanged_amount_from: number; exchanged_amount_to: number; }; export type GetExchangeStatusRequest = { [key: string]: any; id?: number; externalId?: string; }; export type GetExchangeStatusResponse = { id: number; from: string; to: string; rate: number; amount_from: number; amount_to: number; status: string; }; export type GetBalanceStatisticsRequest = { [key: string]: any; currency: string; }; export type GetBalanceStatisticsResponse = { project: number; currency: string; project_income: number; project_outcome: number; project_balance: number; contract_income: number; contract_outcome: number; contract_balance: number; }; export type GetDaysBalanceStatisticsRequest = { [key: string]: any; currency: string; start: string; finish: string; }; export type DaysBalance = { date: string; income: number; outcome: number; }; export type GetDaysBalanceStatisticsResponse = { project: number; currency: string; days_balance: DaysBalance[]; }; export type PaySystem = { type: string; fee: number; fixed_fee: number; currency: string; image_url: string; min_sum?: number; max_sum?: number; terminal?: 'enabled' | 'disabled'; }; export type GetPayTypesStatisticsResponse = { project: number; invoice: PaySystem[]; checkout: PaySystem[]; }; export type CreateTerminalRequest = { [key: string]: any; user: 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 type CreateTerminalResponse = { url: string; }; export type InvoiceStatus = 'New' | 'Processing' | 'Paid' | 'Chargeback' | 'Refund' | 'Chargeback_cancel' | 'Refused'; export type InvoiceNotification = { project: string; invoice: string; status: InvoiceStatus; amount: string; net_amount: string; recieved_amount: string; rate?: string; user: string; type: string; wallet: string; comment: string; time: string; project_invoice?: string; currency_project: string; currency_user: string; date_create: string; date_pay?: string; recurrent_token?: string; reason?: string; txid?: string; signature: string; }; export type CheckoutNotification = { id: string; project: string; projectId: string; amount: string; net_amount: string; paid_amount: string; rate?: string; status: string; user: string; wallet: string; description: string; comment: string; type: string; currency_project: string; currency_user: string; date_create: string; txid?: string; time: string; signature: string; }; export type TransferNotification = { amount: string; currency: string; user: string; type: string; ip: string; time: string; comment: string; signature: string; }; 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: Json): string; verifyRsaSignature(body: Body): 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.gmpays.com/apidoc#invoice_list) */ getInvoiceList(body: GetInvoiceListRequest): Promise<GetInvoiceListResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#card_session_status) */ getCardSessionStatus(body: GetCardSessionStatusRequest): Promise<GetCardSessionStatusResponse & GenericResponse>; /** For more details and usage information see [docs](https://cp.gmpays.com/apidoc#invoice_add_token) */ addTokenInvoice(body: AddTokenInvoiceRequest): Promise<AddTokenInvoiceResponse & 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.gmpays.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_rate) */ getExchangeRate(body: GetExchangeRateRequest): Promise<GetExchangeRateResponse & 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.gmpays.com/apidoc#invoice_api_terminal) */ createTerminal(body: CreateTerminalRequest): Promise<CreateTerminalResponse & GenericResponse>; } export {};