@moonpay/moonpay-node
TypeScript icon, indicating that this package has built-in type declarations

0.2.5 • Public • Published

@moonpay/moonpay-node

A node package for MoonPay server-side functions

Setup

Set up the MoonPay class with your secret key.

Note: ⚠️ NEVER use your secret key in client side code. ⚠️

You will probably want to load the test key from an environment variable.

const moonPay = new MoonPay('sk_test_...');

Usage

Use the moonPay instance to access our functions.

URL utilities

MoonPay URL utilities are namespaced under the .url property.

Signing your URL

If you include the walletAddress or walletAddresses query param, you'll need to sign the URL.

const signature = moonPay.url.generateSignature(
  'https://buy.moonpay.com/?apiKey=pk_test_123&walletAddress=...',
);

Or, return the signed URL, using the returnFullURL option.

const signedURL = moonPay.url.generateSignature(
  'https://buy.moonpay.com/?apiKey=pk_test_123&walletAddress=...',
  { returnFullURL: true },
);

Verifying a signature

Or, you can verify that a URL is correctly signed.

const isSignatureValid = moonPay.url.isSignatureValid(
  '[...]/?apiKey=pk_test_123&signature=someSignature',
);

Generating a signed URL

You can also have us generate the full, signed URL, based on some input parameters.

const params = {
  apiKey: 'pk_test_123',
  baseCurrencyCode: 'GBP',
};

const url = moonPay.url.generate({ flow: 'buy', params });

/@moonpay/moonpay-node/

    Package Sidebar

    Install

    npm i @moonpay/moonpay-node

    Weekly Downloads

    617

    Version

    0.2.5

    License

    MIT

    Unpacked Size

    68.9 kB

    Total Files

    6

    Last publish

    Collaborators

    • moonpay-engineering
    • moonpay-security
    • sbsto
    • ihell
    • tomislavhrenmp
    • npmitservices
    • jpulsifer-moonpay
    • vfaramond