npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dotred/crypto-pay

v2.3.0

Published

@dotred/crypto-pay - is a wrapper over the Crypto Pay API, which makes it easier to interact with the API

Downloads

53

Readme

@dotred/crypto-pay

  • Crypto Pay is a payment system based on @CryptoBot, which allows you to accept payments
    in cryptocurrency using the API.
  • @dotred/crypto-pay - is a wrapper over the Crypto Pay API, which makes it easier to interact with the API

Updates

2.2.0

  1. Removed: getPayments & confirmPayment.

Documentation

1. Installation

To install the library, you need to run the following commands: Supported node versions: 12.22.7+

  1. if you are use npm -
npm install @dotred/crypto-pay  
  1. if you are use yarn -
yarn add @dotred/crypto-pay  

2. Creating token

First, you need to create your application and get an API token. Open @CryptoBot or @CryptoTestnetBot (for testnet), send a command /pay to create a new app and get API Token.

3. Creating pay-instance

To start interacting with the API, you need to create a pay-instance. To do this, import the standard method from the library and call it by passing the previously received token

CommonJS example

const { Asset, createPayInstance } = require('@dotred/crypto-pay');
const instance = createPayInstance('3323:AAlJ6KtPZCeXz8TVEQNX0lMhAldmclcmtnv', 'test');
const workWithInvoices = async () => {
  await instance.createInvoice({ asset: Asset.BTC, amount: '0.00005', });
  await instance.createInvoice({ asset: Asset.BTC, amount: '0.000045', });
  await instance.createInvoice({ asset: Asset.TON, amount: '12', });
  const invoices = await instance.getInvoices();
  console.log(invoices);
}
workWithInvoices().then().catch();   

TypeScript example

import createPayInstance, { CryptoPay } from '@dotred/crypto-pay';

// You can create instance using function
const instance = createPayInstance('your_token');
// or class
const instance = new CryptoPay('your_token')

// If you want to use Testnet, you must pass the network type as the second parameter 
const instance = createPayInstance('your_token', 'test');   

4. Using example

Let's create some invoices and get only BTC invoices

import createPayInstance, { Asset } from '@dotred/crypto-pay';

const instance = createPayInstance('3138:AAGcw73KFgcqcQ2Sl4sktL2WHuUgAvPpWKh', 'test');
const workWithInvoices = async () => {
  await instance.createInvoice({ asset: Asset.BTC, amount: '0.00005', });
  await instance.createInvoice({ asset: Asset.BTC, amount: '0.000045', });
  await instance.createInvoice({ asset: Asset.TON, amount: '12', });
  const invoices = await instance.getInvoices({ asset: Asset.BTC });
  console.log(invoices);
}

workWithInvoices().then().catch();   

5. API Reference

All methods are asynchronous (exception: createPayInstance)

createPayInstance (Default export)

Use this method to create a new pay-instance. Returns an object containing all the methods listed below

  • token (string)
    Your application token
  • net ("main" | "test")
    Net type. "main" - Mainnet, "test" - "Testnet"

getMe

A simple method for testing your app's authentication token. Requires no parameters. Returns basic information about the app.

createInvoice

Use this method to create a new invoice. Returns object of created invoice.

  • asset (string)
    Currency code. Supported assets: BTC, TON, ETH (only testnet), USDT, USDC, BUSD.

  • amount (string)
    Amount of the invoice in float. For example: 125.50

  • description (string)
    Optional. Description of the invoice. Up to 1024 symbols.

  • paid_btn_name (string) default - callback
    Optional. Paid button name. This button will be shown when your invoice was paid. Supported names: viewItem - View Item
    openChannel - Open Channel
    openBot - Open Bot
    callback - Return

  • paid_btn_url (string)
    Optional but requried when you use paid_btn_name. Paid button URL. You can set any payment success link (for example link on your bot). Start with https or http.

  • payload (string, up to 1kb)
    Optional. Some data. User ID, payment id, or any data you want to attach to the invoice.

getInvoices

Use this method to get invoices of your app. On success, the returns array of invoices.

  • asset (Asset)
    Optional. Currency code. Supported assets: BTC, TON, ETH (only testnet), USDT, USDC, BUSD. Default: all assets.
  • invoice_ids (Array<string | number>)
    Optional. Array of strings, numbers, or numbers and strings together.
  • status (Status)
    Optional. Status of invoices. Available statusses: active or paid. Default: all statusses.
  • offset (number)
    Optional. Offset needed to return a specific subset of invoices. Default 0.
  • count (number)
    Optional. Number of invoices to return. Default 100, max 1000.

getPayments

Use this method to get paid and unconfirmed invoices of your app. On success, the returns array of paid and
unconfirmed
invoices.

  • offset (number)
    Optional. Offset needed to return a specific subset of invoices. Default 0.
  • count (number)
    Optional. Number of invoices to return. Default 100, max 1000.

confirmPayment

Use this method to confirm paid invoice for your app. On success, the return confirmed invoice.

  • invoice_id (number)
    Invoice ID you want to confirm.

getBalance

Use this method to get balance of your app. Returns array of assets.

getExchangeRates

Use this method to get exchange rates of supported currencies. Returns array of currencies.

getCurrencies

Use this method to supported currencies. Returns array of currencies.

6. Types

Asset

enum: BTC, TON, ETH, USDT, USDC, BUSD

Status

enum: ACTIVE, PAID