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

qiwi-sdk

v4.1.4

Published

⭐ QIWI SDK for node: P2P Payments & Wallet management

Downloads

5,573

Readme

QIWI SDK

QIWI SDK for node: P2P Payments & Wallet management

Test Status Downloads last commit codecov GitHub qiwi-sdk Known Vulnerabilities Quality npm license MIT Size Codacy Badge

👅 Язык

👉 Документация на Русском 🇷🇺 👈

Language: Русский | English

🍬 Why use this lib?

  1. Full. Covers the following APIs: Wallet Personal, P2P Payments;
  2. Simple. All methods are named as in QIWI documentation and collected into subclasses. All methods have JSDoc comments. Lot of examples.
  3. Reliable. The library is written in TypeScript and covered by tests.
  4. Secure. The library has only 1 dependency (axios) and is constantly scanned by Code QL and Snyk for vulnerabilities.
  5. Compatible. Code from version 1.1.0 (18 Jan. 2020) will work on version 4.0.0 (26 May 2022) with little changes. Also qiwi-sdk provides classes to make migration from similar libs effortless.

Language: Русский | English

Documentation

  1. Installation
  2. Import
  3. API Overview
  4. API Reference
  5. Examples

📦 Installation

  • Using npm
    npm i qiwi-sdk
  • Using Yarn
    yarn add qiwi-sdk
  • Using pnpm
    pnpm add qiwi-sdk

Language: Русский | English

🛠️ Usage

Import

From the library you can import all the APIs separately, because use cases are different.

  • CommonJS (default for Node JS)

    const { P2p, Wallet, Detector } = require("qiwi-sdk");
  • TypeScript or ES Modules

    import { P2p, Wallet, Detector } from "qiwi-sdk";

Documentation

👉 View API Reference 👈

The table shows the currently implemented APIs.

Class (Legacy v2) is a compatible class only for those who are upgrading from version 2. The rest are advised to use the new version of the API - Class v3.

API Overview

| Class (v3) | ~~Class (Legacy v2)~~ | Documentation by QIWI | Recommended var name | | ------------------------------------------------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------- | --------------------- | | Wallet | Personal | https://developer.qiwi.com/en/qiwi-wallet-personal | wallet (or qiwi) | | P2p | P2P | https://developer.qiwi.com/en/p2p-payments | p2p | | P2p | - | https://developer.qiwi.com/en/bill-payments | p2p (or payments) | | Detector | DetectorCompat | https://developer.qiwi.com/en/qiwi-wallet-personal/#search-providers | detector |

To see detailed documentation on a class, click on its name.

Migration

  1. Migration from version 2 to 3;
  2. Migration from version 1 to 2 (just in case);
  3. Migration from node-qiwi;
  4. Migration from @qiwi/bill-payments-node-js-sdk.

Instantiation

const { Wallet, P2p, Detector } = require("qiwi-sdk");

const wallet = new Wallet({
  token: process.env.QIWI_TOKEN,
  walletId: process.env.QIWI_WALLET
});

const p2p = new P2p({
  secretKey: process.env.QIWI_SECRET_KEY,
  publicKey: process.env.QIWI_PUBLIC_KEY
});

const detect = new Detector();

Environment variables

The following environment variables were used in this example. It's recommended to store all data for API access in environment variables or in another protected place, but not in the code.

| Name | Type | Description | | ------------------------------------- | ---------------------------- | ------------------------------------------------------------ | | QIWI_TOKEN | String(32 chars) - Hex | Qiwi token got on https://qiwi.com/api | | QIWI_WALLET | String(10-16 chars) - Digits | Wallet's phone number | | QIWI_SECRET_KEY и QIWI_PUBLIC_KEY | Strings | Key pair created on https://qiwi.com/p2p-admin/transfers/api |

Examples

Getting info about wallet

const wallet = Wallet.create(process.env.QIWI_TOKEN);

wallet.personProfile.getCurrent().then(console.log);
// => { contractInfo: {...}, authInfo: {...}, userInfo: {...} }

Sending payment

const wallet = Wallet.create(process.env.QIWI_TOKEN);

// 100 RUB from RUB account to QIWI (99) `79123456789` including commission
// All above can be configured
wallet.payments.quickPay({
  amount: 100,
  account: "79123456789"
});

Using P2P

const p2p = P2p.create(process.env.QIWI_SECRET_KEY);

p2p.bills
  .create({
    amount: {
      value: 1000,
      currency: P2p.Currency.RUB
    },
    successUrl: "https://youtu.be/dQw4w9WgXcQ"
  })
  .then(console.log);

// => { payUrl: 'https://oplata.qiwi.com/...' }

Using Proxy

const { SocksProxyAgent } = require("socks-proxy-agent");

const wallet = Wallet.create(process.env.QIWI_TOKEN);
wallet.agent = new SocksProxyAgent("socks://login:password@host:port");

// do work here

// Remember to dispose agent
wallet.agent = undefined;

Express integration

const p2p = P2p.create(process.env.QIWI_SECRET_KEY);
const app = express();

app.post(
  "/webhook/qiwi",
  p2p.notificationMiddleware({}, (req, res) => {
    // Bill body
    console.log(req.body);

    // { "siteId": "9hh4jb-00", "billId": "cc961e8d-d4d6-4f02-b737-2297e51fb48e", ... }
  })
);

app.use((error, req, res, next) => {
  if (error instanceof P2pBillNotificationError) {
    // Somebody sent invalid notification
    console.log(error);
  }

  return next();
});

Full examples

  1. 🥝 Getting info about wallet
  2. 📬 Sending payment
  3. 🛠️ Using P2P api
  4. 🔐 Getting wallet limits (using ESM)
  5. 🤖 Telegram bot with direct payments (by wallet phone number)
  6. 🖥️ Shop on Express
  7. 🌐 Using proxy

Language: Русский | English

🎩 About the Project

License

Distributed under the MIT License. See LICENSE.txt for more information.

FOSSA Status

Contributing

  1. ⁉️ Do not hesitate to create Issues
  2. 🛠️ If you want to contribute to code, follow CONTRIBUTING.md
  3. 💸 Also please donate 👉 https://qiwi.com/n/ALEXXGRIB
  4. 🌟 Or give this repo a star, if you liked this lib

Support

You can write issue, or if i am slow to answer it, you can DM me in

Telegram: @AlexXanderGrib

💜 YooMoney package

Interested in P2P acquiring in Russia?

Check out my other SDK for YooMoney (formerly Yandex.Money) 👉 github.com/AlexXanderGrib/yoomoney-sdk

Language: Русский | English