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

qiwi-sdk

Package Overview
Dependencies
Maintainers
2
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qiwi-sdk

Typed, Promise based, QIWI API (P2P & Personal) client

  • 1.6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
increased by58.31%
Maintainers
2
Weekly downloads
 
Created
Source

🥝 NodeJS QIWI SDK

license MIT npm GitHub last commit

QIWI SDK

🇬🇧 For english speakers

This document is primarily on Russian, because QIWI Bank (JSC) is Russian bank and mostly russian people interested in this package. Whoever, i added short translations, marked by 🇬🇧 emoji, so you can understand what is going on there.

📕 Содержание / ToC

🇬🇧: Table of Contents

🍬 Почему именно эта библиотека?

🇬🇧: Why use this lib?

  1. Полная поддержка TypeScript
  2. Полностью покрывает Personal и P2P секции QIWI API
  3. Документация прямо в коде, которую отлично подхватывают VSCode и WebStorm

🇬🇧: First-class TS support, Personal & P2P api coverage, In-Code docs that's appear in editor

📦 Установка / Installation

NPM:

npm i -S qiwi-sdk

Yarn:

yarn add qiwi-sdk

✏️ Примеры / Examples

🔎 Получение информации о владельце кошелька

🇬🇧: Getting information about the owner of the wallet

const QIWI = require("qiwi-sdk");

const qp = new QIWI.Personal(process.env.QIWI_TOKEN);

qp.getPersonProfile().then(console.log);

// => { contractInfo: {...}, authInfo: {...}, userInfo: {...} }

💰 Как слить баланс кошелька

🇬🇧: How to steal wallet's balance

⚠️ Если вы делаете это другим людям без их согласия - это противозаконно, я оставляю это тут, потому что это хороший пример комплексного использования API

🇬🇧: If you do this to other people without their consent, it is illegal, I leave it here because it is a good example of complex API use.

const QIWI = require("qiwi-sdk");

const qp = new QIWI.Personal(process.env.QIWI_TOKEN);
const receiver = "+79123456789";
const provider = 99;

async function main() {
  const profile = await qp.getPersonProfile();
  const wallet = profile.authInfo.personId.toString();
  const accounts = await qp.getAccounts(wallet);

  const rubleAccount = accounts.find(
    (accumulator) =>
      accumulator.balance &&
      accumulator.balance.currency === Personal.Currency.RUB
  );

  const commission = await qp.getCommission(
    provider,
    receiver,
    rubleAccount.balance.amount
  );

  const totalToSteal = rubleAccount.balance.amount - commission;

  const payment = await qp.pay(provider, receiver, totalToSteal);

  console.log(payment);
}

main();

🔑 Создание пары ключей для взаимодействия с P2P

🇬🇧: Creating key pair for P2P API

const QIWI = require("qiwi-sdk");

const qp = new QIWI.Personal(process.env.QIWI_TOKEN);

async function main() {
  const profile = await qp.getPersonProfile();
  const wallet = profile.authInfo.personId;

  const [pk, sk] = await qp.createP2PKeyPair("My super pair name");

  // Да, они инвертированы в порядке,
  // так как PublicKey не всегда нужен
  const p2pc = new QIWI.P2P(sk, pk);

  const bill = await p2pc.createBill({
    amount: {
      value: 1000,
      currency: QIWI.P2P.Currency.RUB
    },
    expirationDateTime: QIWI.P2P.formatLifetime(2 /* 2 дня */),
    comment: "Создание сайта"
  });

  console.log(bill.payUrl);
}

main();

🧱 Получение Лимитов (на TypeScript)

🇬🇧: Getting wallet's limits (on TypeScript)

import { Personal } from "qiwi-sdk";

const qp = new Personal(process.env.QIWI_TOKEN);

async function main() {
  const { limits } = await qp.getLimits(process.env.QIWI_WALLET as string, [
    Personal.LimitType.TURNOVER
  ]);

  const [limit] = limits.RU;

  console.log(limit);
  // => { type: "TURNOVER", currency: "RUB", max: 400000, spent: 0, rest: 400000, ... }
}

Интересует приём и отправка P2P платежей по РФ на NodeJS?

У нас есть точно такое-же типизированное SDK для YooMoney 👉 github.com/AlexXanderGrib/yoomoney-sdk

🇬🇧: Have interest in well-done SDK for YooMoney (formerly Yandex.Money)? Check out my other lib

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