npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gamemoney

v9.0.0

Published

GameMoney API wrapper for Node.js

Readme

GameMoney

GameMoney API wrapper for Node.js

Full API documentation here

Installation

$ npm install gamemoney

The package is ESM-only (there is no CommonJS build) and has no runtime dependencies. It requires Node.js >=22.12.0, where ES modules can also be loaded with require().

Usage

Initialization

import fs from 'node:fs'
import { GameMoney } from 'gamemoney'

const gm = new GameMoney({
	project: 42,
	hmacPrivateKey: 'test',

	// Optional. But to make checkouts must be specified
	rsaPrivateKey: {
		key: fs.readFileSync('./private.pem').toString(),
		passphrase: '123', // Optional
	},

	// OR:
	// rsaPrivateKey: Buffer.from(
	// 	process.env.GM_RSA_PRIVATE_KEY ?? '',
	// 	'base64',
	// )

	// Optional. API host from the project settings. Default: https://paygate.gamemoney.com
	apiUrl: 'https://paygate.gamemoney.com',

	// Optional. GameMoney certificate or public key from the project settings,
	// used to verify signatures of responses and notifications.
	// Default: the certificate bundled with the package
	gameMoneyPublicKey: fs.readFileSync('./gm.crt'),

	// Optional. Request timeout in milliseconds. Default: no timeout
	timeout: 30_000,
})

From CommonJS code, via Node's built-in require(esm):

const { GameMoney, verifyRsaSignature } = require('gamemoney')

Errors

  • GameMoneyError: GameMoney responded with "state": "error", the error text is in message.
  • GameMoneyHttpError: GameMoney responded with a non-2xx HTTP status, available in status. Redirects are not followed, so a 3xx response throws it too.
  • TimeoutError: the request did not complete within timeout.
  • TypeError with fetch failed: a network error, the reason is in cause.
  • SyntaxError: the response is not JSON.
  • Error with Response signature mismatch or Wrong rand parameter: the response failed verification and must not be trusted.

Only GameMoneyError means that GameMoney rejected the request. After any other error the request may still have been processed, so check the operation status (for example, with getCheckoutStatus) before retrying. A repeated createCheckout with the same projectId and the same parameters does not create a second payout.

createInvoice resolves with type: 'error' when the payment system declines the payment, the reason is in data.

Dates

Dates are in Moscow time (UTC+3) without an offset: date_create and date_pay in responses and notifications, and start and finish in list requests.

Notifications

GameMoney sends notifications as a form (application/x-www-form-urlencoded), so parse them with express.urlencoded() or a similar parser. All values are strings. Payment and payout notifications are resent for 24 hours until the project responds with HTTP 200 and {"success": "true"}.

A payout created through the API is processed only after the project acknowledges its notification, so answer every payout notification, including the first one with status 0. Set the final webhook URL in the project settings: a redirect (for example, from http to https) can break the delivery.

if (!gm.verifyRsaSignature(notification)) {
	response.send({ success: 'error', error: 'signature mismatch' })
	return
}

response.send({ success: 'true' })

Transfer notifications are answered with the created invoice signed with HMAC, see the example.

Signatures

parametersToString, generateHmacSignature, generateRsaSignature and verifyRsaSignature implement the GameMoney signature algorithm and are exported for custom integrations and tests, for example to sign responses of a GameMoney mock.

Other API methods

Any API method can be called with a signed request:

const response = await gm.request('exchange/rate', { from: 'USD', to: 'RUB' })

Examples

See examples in src/examples directory. They read the credentials from GAMEMONEY_PROJECT_ID, GAMEMONEY_HMAC_PRIVATE_KEY and GAMEMONEY_RSA_PRIVATE_KEY (base64) and can be run directly:

$ node --env-file=.env src/examples/statistics/balance.ts