A node package for MoonPay server-side functions
Set up the MoonPay
class with your secret key.
Note:
You will probably want to load the test key from an environment variable.
const moonPay = new MoonPay('sk_test_...');
Use the moonPay
instance to access our functions.
MoonPay URL utilities are namespaced under the .url
property.
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 },
);
Or, you can verify that a URL is correctly signed.
const isSignatureValid = moonPay.url.isSignatureValid(
'[...]/?apiKey=pk_test_123&signature=someSignature',
);
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 });