1.3.0 • Published 1 month ago

payment-crypto v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

Payment Crypto

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

1.3.0

1 month ago

1.2.0

5 months ago

1.0.1

6 months ago

1.0.0

6 months ago