node-qiwi-api

2.2.1 • Public • Published

node-qiwi-api

npm npm npm

Official documentation for Qiwi api.

Get started

Firstly, get access token at Qiwi.

npm install node-qiwi-api

You can use callback and promise based api.

Initialise new wallet instance with your access token:

var callbackQiwi = require('node-qiwi-api').callbackApi;
var asyncQiwi = require('node-qiwi-api').asyncApi;

var callbackWallet = new callbackQiwi(token);
var asyncWallet = new asyncQiwi(token);

Now you can get information about your wallet and make money transfers.

Next examples presented for callback api.

Identification data

wallet.getIdentificationData(wallet, (err, data) => {
  if(err) {
    /*hanle error*/
  }
  console.log(data);
})

wallet - wallet number without plus (+) and with prefix (79991234567)

Identify wallet

wallet.identifyWallet(wallet, requestOptions, (err, data) => {
  if(err) {
    /*hanle error*/
  }
  console.log(data);
})

wallet - wallet number without plus (+) and with prefix (79991234567)

requestOptions includes:

  • birthDate - Date of birth (YYYY-MM-DD)
  • firstName - First name
  • middleName - Middle name
  • lastName - Last name
  • passport - Serial and number of passport
  • snils - SNILS number
  • inn - INN number
  • oms - OMS number

Information about account

wallet.getAccountInfo((err, data) => {
  if(err) {
    /*hanle error*/
  }
  console.log(data);
})

Get accounts

wallet.getAccounts(wallet, (err, data) => {
  if(err) {
    /*hanle error*/
  }
  console.log(data);
})

wallet - wallet number without plus (+) and with prefix (79991234567)

Get possible account aliases

Return possible for creation at your wallet account aliases

wallet.getPossibleAccountAliases(wallet, (err, data) => {
  if(err) {
    /*hanle error*/
  }
  console.log(data);
})

wallet - wallet number without plus (+) and with prefix (79991234567)

Create account

Create account in new currency

wallet.createAccount(wallet, accountAlias, (err, data) => {
  if(err) {
    /*hanle error*/
  }
  console.log(data);
})

wallet - wallet number without plus (+) and with prefix (79991234567) accountAlias - Account alias, possible values: qw_wallet_rub, qw_wallet_kzt, qw_wallet_usd, qw_wallet_eur

If call was successfull as data you will have { success: true }, else { success: false }

Set default account

Set default account for all operations

wallet.setDefaultAccount(wallet, accountAlias, (err, data) => {
  if(err) {
    /*hanle error*/
  }
  console.log(data);
})

wallet - wallet number without plus (+) and with prefix (79991234567) accountAlias - Account alias, possible values: qw_wallet_rub, qw_wallet_kzt, qw_wallet_usd, qw_wallet_eur

If call was successfull as data you will have { success: true }, else { success: false }

Operation history

wallet.getOperationHistory(wallet, requestOptions, (err, data) => {
  if(err) {
    /*hanle error*/
  }
  console.log(data);
})

wallet - wallet number without plus (+) and with prefix (79991234567)

requestOptions includes:

  • rows - Amount of payments in response. Integer from 1 to 50. Required.
  • operation - Operation type. ALL - all operations, IN - incoming only, OUT - outgoing only, QIWI_CARD - just payments by QIWI cards (QVC, QVP). Default - ALL
  • sources - Payment source. Array of values. Allowable values: QW_RUB - ruble account of wallet, QW_USD - usd account of wallet, QW_EUR - euro account of wallet, CARD - added and not added to wallet cards, MK - account of mobile operator. If not presented, you will receive info from all sources
  • startDate - Start date (YYYY-MM-ddThh:mm:ssZ). By default equals yesterday date. Use only with endDate
  • endDate - End date (YYYY-MM-ddThh:mm:ssZ). By default equals current date. Use only with startDate
  • nextTxnDate - Transaction date (YYYY-MM-ddThh:mm:ssZ), (see nextTxnDate in response). Use only with nextTxnId
  • nextTxnId - Previous transaction number (see nextTxnId in response). Use only with nextTxnDate Maximum interval between startDate and endDate - 90 days.

As example - information about 25 outgoing payments can be get by next way:

wallet.getOperationHistory({rows: 25, operation: "OUT"}, (err, operations) => {
  /* some code */
})

Operations statistics

If you want to see statistics for summs of payments by period of time use this method. Example:

wallet.getOperationStatistics(wallet, requestOptions, (err, data) => {
  if(err) {
    /*hanle error*/
  }
  console.log(data);
})

wallet - wallet number without plus (+) and with prefix (79991234567)

requestOptions: operation, sources, startDate, endDate - Parameters are similar to getOperationHistory.

Get transaction info

Example:

wallet.getTransactionInfo(transactionId, (err, data) => {
  if(err) {
    /*hanle error*/
  }
  console.log(data);
})

Get transaction receipt

Example:

wallet.getReceipt(transactionId, requestOptions, (err, data) => {
  if(err) {
    /*hanle error*/
  }
  console.log(data);
})

requestOptions includes:

  • type - Transaction type from getOperationHistory
  • format - File format, see wallet.receiptFormat

Transfer to Qiwi wallet

wallet.toWallet({ amount: '0.01', comment: 'test', account: '+79261234567' }, (err, data) => {
  if(err) {
    /* handle err*/
    }
  console.log(data);
})
  • amount - Ammount of money
  • comment - Commentary for payment.
  • account - Receiver phone number (with international prefix)

Transfer to mobile phone

Similar to "transfer to qiwi wallet", but number without international prefix:

wallet.toMobilePhone({ amount: '0.01', comment: 'test', account: '9261234567' }, (err, data) => {
  if(err) {
    /* handle err*/
    }
  console.log(data);
})

Transfer to card

Similar to other transfers, but account is card number:

wallet.toCard({ amount: '0.01', comment: 'test', account: '5213********0000' }, (err, data) => {
  if(err) {
    /* handle err*/
    }
  console.log(data);
})

Transfer to bank account

wallet.toBank({ amount: '0.01', account: '5213********0000', account_type: '1', exp_date: 'MMYY' }, recipient, (err, data) => {
  if(err) {
    /* handle err*/
    }
  console.log(data);
})
  • ammount - Ammount of money
  • account - Receiver card/account number
  • account_type - Type of bank identificator.
    • for Alfa-bank (Альфа-Банк) - 1
    • for OTP Bank (АО ОТП БАНК) - 1
    • for Rosselhozbank (АО РОССЕЛЬХОЗБАНК) - 5
    • for Russian Standard (Русский Стандарт) - 1
    • for VTB (ВТБ ПАО) - 5
    • for Promsvyazbank (Промсвязьбанк) - 7
    • for Sberbank (ПАО Сбербанк) - 5
    • for Renessans Credit (Ренессанс Кредит) - 1
    • for Moscow Credit Bank (ПАО Московский кредитный банк) - 5
  • exp_date - Card expiration date (MMYY), as examlpe: 0218 - february 2018. Only for card transfer.
  • recipient -
    • 464 - Alfa-bank (Альфа-Банка)
    • 466 - Tinkoff Bank (Тинькофф Банк)
    • 804 - OTP Bank (АО ОТП БАНК)
    • 810 - Rosselhozbank (АО РОССЕЛЬХОЗБАНК)
    • 815 - Russian Standard (Русский Стандарт)
    • 816 - VTB (ВТБ ПАО)
    • 821 - Promsvyazbank (Промсвязьбанк)
    • 870 - Sberbank (ПАО Сбербанк)
    • 881 - Renessans Credit (Ренессанс Кредит)
    • 1135 - Moscow Credit Bank (ПАО Московский кредитный банк)

Get currency exchange rates

wallet.getCrossRates((err, data) => {
  if(err) {
    /* handle err*/
    }
  console.log(data);
})

Transfer by requisites

wallet.toCard(requestOptions, (err, data) => {
  if(err) {
    /* handle err*/
    }
  console.log(data);
})

requestOptions includes:

  • amount - Amount of money
  • account - Receiver account number
  • bankName - Receiver bank name
  • bik - Receiver bank bik
  • city - Receiver city
  • organizationName - Receiver organization name
  • inn - Receiver organization inn
  • kpp - Receiver organization kpp
  • nds - 'НДС не облагается' or 'В т.ч. НДС'
  • purpose - Purpose of payment
  • urgent - 0 or 1. Urgent pay need 10 minutes to complete. Available from 9.00 AM to 8.30 PM (09.00 - 20.30) by Moscow time (GMT+3). Service fee - 25 rubles
  • senderName - Sender name
  • senderMiddleName - Sender middle name
  • senderLastName - Sender last name

Convert currency at you wallet

wallet.convertCurrency({amount: 10, currency: wallet.currencyCode.KZT, account:'+79991234567'}, (err, data) => {
  if(err) {
    /* handle err*/
    }
  console.log(data);
})

requestOptions includes:

  • account - Phone number with plus and international prefix, as example +79991234567
  • currency - Currency code - 3 number by ISO-4217 (see wallet.currencyCode)
  • amount - Amount of money for calculate commission
  • comment - Commentary for payment.

Get invoices

wallet.getInvoices(requestOptions, (err, data) => {
  if(err) {
    /* handle err*/
    }
  console.log(data);
})

requestOptions includes:

  • rows - Amount of payments in response. Integer from 1 to 50. Required.
  • from - Date from
  • to - Date to
  • nextId - If present, method will return invoices from this id
  • nextDate - If present, method will return invoices created before this time

Pay invoice

wallet.payInvoice(invoiceId, currency, (err, data) => {
  if(err) {
    /* handle err*/
    }
  console.log(data);
})
  • invoiceId - Invoice id from getInvoices (bills[].id)
  • currency - Currency from getInvoices (bills[].sum.currency)

Cancel invoice

wallet.cancelInvoice(invoiceId, (err, data) => {
  if(err) {
    /* handle err*/
    }
  console.log(data);
})
  • invoiceId - Invoice id from getInvoices (bills[].id)

Check commission rates

wallet.checkOnlineCommission(recipient, requestOptions, (err, data) => {
  if(err) {
    /* handle err*/
    }
  console.log(data);
})

recipient - Allowable values stored in wallet.recipients

requestOptions includes:

  • account - Phone number with international prefix or card/account number, as example 79991234567
  • amount - Amount of money for calculate commission

Check operation commission

wallet.checkCommission(recipient, (err, data) => {
  if(err) {
    /* handle err*/
    }
  console.log(data);
})

data.content.terms.commission.ranges[i]:

  • recipient - Allowable values stored in wallet.recipients

Response contains:

  • bound - Payment amount, starting from which the condition applies
  • rate - Commission (absolute multiplier)
  • fixed - Fixed amount of commission

Readme

Keywords

Package Sidebar

Install

npm i node-qiwi-api

Weekly Downloads

50

Version

2.2.1

License

MIT

Unpacked Size

69.1 kB

Total Files

7

Last publish

Collaborators

  • insight.appdev