Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nowpaymentsio/nowpayments-mass-payments-api-js

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nowpaymentsio/nowpayments-mass-payments-api-js

A library for interacting with the NOWPayments Mass Payments API

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

NOWPayments Mass Payments API

Build Status

A library for interacting with the NOWPayments Mass Payments API.

Installation

Using npm:

$ npm install @nowpaymentsio/nowpayments-mass-payments-api-js

Using unpkg CDN:

<script src="https://unpkg.com/@nowpaymentsio/nowpayments-mass-payments-api-js/dist/nowpayments-mass-payments-api-js.min.js"></script>

Examples

Node JS

const NowPaymentsMPApi = require('@nowpaymentsio/nowpayments-mass-payments-api-js');

const api = new NowPaymentsMPApi({ apiKey: 'your-api-key' }) // your api key
async function logBalance() {
  const { token } = await api.auth({ email: 'your-email', password: 'your-password' })
  const balance = await api.getBalance({ token })
  console.log('Get balance: ', balance)
}
logBalance()

React

import React from 'react'
import NowPaymentsMPApi from '@nowpaymentsio/nowpayments-mass-payments-api-js'

const npApi = new NowPaymentsMPApi({ apiKey: 'your-api-key' }) // your api key

const App = () => {
  const [balance, setBalance] = React.useState()
  React.useEffect(() => {
    async function fetchBalance() {
      const { token } = await npApi.auth({ email: 'your-email', password: 'your-password' })
      const balance = await npApi.getBalance({ token })
      setBalance(balance)
    }
    fetchBalance()
  }, [])

  return (
    <div>
      <h2>Get balance</h2>
      <br />
      {balance && Object.entries(balance).map(([key, value]) => (
        <p key={key}>{key}-{value.amount}</p>
      ))}
    </div>
  )
}

export default App

HTML

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>NOWPayments API - HTML Example</title>
  <script src="https://unpkg.com/@nowpaymentsio/nowpayments-mass-payments-api-js/dist/nowpayments-mass-payments-api-js.min.js"></script>
</head>

<body>
<h4>Get balance</h4>
<script>
  const myParent = document.body;
  const api = new NOWPaymentsMPApiJS({ apiKey: 'your-api-key' })

  async function main() {
    const { token } = await api.auth({ email: 'your-email', password: 'your-password' })
    const balance = await api.getBalance({ token })

    if (Object.keys(balance).length) {
      const span = document.createElement("span")
      span.id = "mySelect"
      myParent.appendChild(span)

      for (const [key, value] of Object.entries(balance)) {
        span.innerHTML = `${key} - ${value.amount}`
      }
    }
  }
  main()
</script>
</body>
</html>

Methods

 

NPApi.auth(params)

Authentication

paramsdefaultrequireddescription
emailnulltrueAccount email
passwordnulltrueAccount password
NPApi.createPayout(params)

This is the method to create a payout

paramsdefaultrequireddescription
withdrawalsnulltrueArray of objects
tokennulltrueAuth token from NPApi.auth()
withdrawals: [
  {
    address: '', // The address where you want to send funds
    currency: '', // Payout currency
    amount: 0 // Amount of the payout. Must not exceed 6 decimals (i.e. 0.123456)
  }
]
NPApi.getPayoutStatus(params)

Get estimated price

paramsdefaultrequireddescription
payout_idnulltruePayout in the request
NPApi.getBalance(params)

Get payment status

paramsdefaultrequireddescription
tokennulltrueAuth token from NPApi.auth()
NPApi.createPayment(params)

Get payout status

paramsdefaultrequireddescription
price_amountnulltrueFiat equivalent of the price to be paid in crypto
price_currencynulltrueFiat currency in which the price_amount is specified (usd, eur, etc)
pay_amountnullfalseAmount that users have to pay for the order stated in crypto
pay_currencynulltrueCrypto currency in which the pay_amount is specified (btc, eth, etc)
ipn_callback_urlnullfalseUrl to receive callbacks, should contain "http" or "https", eg. "https://nowpayments.io"
order_idnullfalseInner store order ID, e.g. "RGDBP-21314"
order_descriptionnullfalseInner store order description, e.g. "Apple Macbook Pro 2019 x 1"
purchase_idnullfalseId of purchase for which you want to create aother
payout_addressnullfalseUsually the funds will go to the address you specify in your Personal account. In case you want to receive funds on another address, you can specify it in this parameter
payout_currencynullfalseCurrency of your external payout_address, required when payout_adress is specified
payout_extra_idnullfalseExtra id or memo or tag for external payout_address
fixed_ratenullfalseBoolean, can be true or false. Required for fixed-rate exchanges

Resources

Keywords

FAQs

Package last updated on 21 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc