CoiniJS is an npm client for interacting with the Coini cryptocurrency payment service API. It allows you to easily perform operations such as creating payment orders and listing supported cryptocurrencies.
To install CoiniJS in your project, run:
npm install coinijs
First, import CoiniJS and create a new instance of the client with your API key:
const CoiniClient = require('coinijs');
const client = new CoiniClient('your_api_key_here', 'sandbox'); // Use 'production' for the production environment
To create a new payment order:
async function createOrder() {
try {
const order = await client.createOrder({
amount: 100,
currency: 'PEN',
transaction: {
customer: {
name: 'John Doe',
email: 'john.doe@example.com'
},
networkId: 1,
cryptoId: 2
},
metadata: {
description: 'Cryptocurrency course purchase',
order: 'order-123',
hash: 'hash-123'
}
});
console.log(order);
} catch (error) {
console.error(error);
}
}
createOrder();
To get a list of supported cryptocurrencies and networks:
async function listCryptocurrencies() {
try {
const cryptocurrencies = await client.getCryptocurrencies();
console.log(cryptocurrencies);
} catch (error) {
console.error(error);
}
}
listCryptocurrencies();
createOrder(orderData)
Creates a new payment order.
orderData
must be an object containingamount
,currency
,transaction
andmetadata
getCryptocurrencies()
Returns a list of the cryptocurrencies and networks supported by Coini.
Contributions to the project are welcome. Please check out the open issues on GitHub or open a new one to discuss changes or report bugs.
This project is licensed under the MIT License - see the LICENSE.md file for details.