nazarovsa / node-qiwi-api

Node API to work with QIWI Wallet
MIT License
13 stars 12 forks source link
qiwi qiwi-api qiwi-wallet

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:

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:

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:

Transfer to Qiwi wallet

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

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);
})

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:

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:

Get invoices

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

requestOptions includes:

Pay invoice

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

Cancel invoice

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

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:

Check operation commission

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

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

Response contains: