Coinpayments-payments
NPM module for acquiring payments from the CoinPayments API without form authentication hassle.
Install
npm install coinpayments-payments
Requirements
This package builds upon the fact that a correct pair of private and public keys are provided. You can generate these Here
Usage
How to initialize the module with the correct data.
const coinPayments = require('coinpayments-payments');
const payment_settings = {
private_key: ""
, public_key: ""
};
const payments = new coinPayments(payment_settings, (err, result) => {
if(err) throw err;
console.log(result);
// Configured successfully
});
Create a transaction
The syntax of creating a transaction. Please note, that the amount is defined in currency_receive (currency1). Remember to specify both the real currency of the transaction, and the currency that will be required to be used. Use the LiteCoin Tesnet (LTCT) for sandbox testing. I suggest doing this by running Electrum LTC with:
electrum --testnet
payments.createTransaction({
amount: 12, // DEFINED IN CURRENCY_RECEIVE
currency_receive: "USD",
currency_send: "LTCT",
buyer_email: ""
}, (err, result) => {
if(err) throw err;
console.log(result);
});
Create a callback/deposit address
By specifying the sending currency, a unique deposit address will be returned to you.
payments.getCallbackAddress("LTCT", (err, result) => {
if(err) throw err;
console.log(result);
});
Author
Knuthy