payment-crypto
v1.5.0
Published
Crypto Pay API
Downloads
30
Readme
Introduction
This simple module is based on Crypto Pay API for easy use.
Crypto Pay is a payment system based on Crypto Bot that allows you to accept payments in crypto and transfer coins to users using this module.
Installation
Installation from npm
npm i payment-crypto
Installation from yarn
in the future
Setup
Importing
CommonJS. For the use of async
functions in the main scope, try this:
const PaymentCrypto = require('payment-crypto');
(async () => {
// async functions
})();
ES6. Supports the use of async
functions in main scope:
import PaymentCrypto from 'payment-crypto';
// async functions
To use ES6, add to package.json
:
"type": "module"
Authorization
First, you need to create a new app and get API token. Open @CryptoBot, go to Crypto Pay and tap Create App to get API Token.
const token = '1234:TOKEN'; // replace with your token
const payment = new PaymentCrypto(token);
Authorization in testnet
Getting testnet token is similar to the mainnet. Open @CryptoTestnetBot, go to Crypto Pay and tap Create App to get API Token.
const token = '1234:TOKEN'; // replace with your testnet token
const payment = new PaymentCrypto(token, {
mode: 'testnet',
});
Example
This is a small ES6 example with which you can easily start using payment-crypto.
import PaymentCrypto from 'payment-crypto';
const token = '1234:TOKEN'; // replace with your testnet token
const payment = new PaymentCrypto(token, {
mode: 'testnet',
});
const me = await payment.getMe();
console.log(me);
You can find more examples here.
Useful links
- Documentation
- Examples
- Official reference
- crypto-pay-api by Foile
payment-crypto
- Crypto Pay news channel
- Crypto Pay discussion chat