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

node-qiwi-api

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-qiwi-api - npm Package Compare versions

Comparing version 2.0.0-beta.0 to 2.0.0-beta.1

15

CHANGELOG.md

@@ -5,8 +5,12 @@ 2.0.0

---------------------
* getAccounts - get wallet accounts
* createAccount - create account in new currency by alias
* setDefaultAccount - set default account
* getPossibleAccountAliases - get possible account aliases
* getIdentificationData - get wallet identification data
* identifyWallet - identify wallet
* getCrossRates - get exchange rates
* getTransactionInfo - get information about transaction
* getReceipt - get receipt of transaction
* checkOnlineCommission - get information about future operation commission
* getReceipt - get receipt of transaction
* identifyWallet - identify wallet

@@ -19,5 +23,10 @@ Update

* getOperationStatistics - update path to v2
* getOperationHistory and getOperationStatistics - now accepts wallet into arguments and not calling getAccountInfo anymore
Rename
---------------------
* getOperationStats -> getOperationStatistics
* getOperationStats -> getOperationStatistics
Remove
---------------------
* getBalance - now you can get same data from getAccounts

@@ -9,3 +9,23 @@ var request = require("request");

module.exports = function Qiwi(token) {
/**
* Api url
*/
apiUri = "https://edge.qiwi.com";
/**
* Access token
*/
token = token;
/**
* Headers
*/
headers = {
'Accept': 'application/json',
'content-type': 'application/json',
'Authorization': 'Bearer ' + token
}
/**
* Allowable recepients

@@ -41,21 +61,2 @@ */

/**
* Access token
*/
this.token = token;
/**
* Headers
*/
this.headers = {
'Accept': 'application/json',
'content-type': 'application/json',
'Authorization': 'Bearer ' + this.token
}
/**
* Api url
*/
this.apiUri = "https://edge.qiwi.com";
/**
* Transaction type

@@ -80,3 +81,3 @@ */

* @link https://developer.qiwi.com/ru/qiwi-wallet-personal/index.html#ident_data
* @param {string} wallet wallet number without plus (+) and with prefix, as example: 79991234567
* @param {string} wallet Wallet number without plus (+) and with prefix, as example: 79991234567
* @param {function(err,data)} callback

@@ -86,4 +87,4 @@ */

var options = {
url: `${this.apiUri}/identification/v1/persons/${wallet}/identification`,
headers: this.headers,
url: `${apiUri}/identification/v1/persons/${wallet}/identification`,
headers: headers,
json: true

@@ -100,3 +101,3 @@ };

* @link https://developer.qiwi.com/ru/qiwi-wallet-personal/index.html#ident
* @param {string} wallet wallet number without plus (+) and with prefix, as example: 79991234567
* @param {string} wallet Wallet number without plus (+) and with prefix, as example: 79991234567
* @param {{birthDate:string, firstName:string, middleName:string, lastName:string, passport:string, inn:string, snils:string, oms:string}} requestOptions

@@ -107,4 +108,4 @@ * @param {function(err,data)} callback

var options = {
url: `${this.apiUri}/identification/v1/persons/${wallet}/identification`,
headers: this.headers,
url: `${apiUri}/identification/v1/persons/${wallet}/identification`,
headers: headers,
body: requestOptions,

@@ -120,10 +121,11 @@ json: true

/**
* Get information about current account
* @link
* Get accounts of wallet
* @link https://developer.qiwi.com/ru/qiwi-wallet-personal/index.html#balances_list
* @param {string} wallet Wallet number without plus (+) and with prefix, as example: 79991234567
* @param {function(err,data)} callback
*/
this.getAccountInfo = function (callback) {
this.getAccounts = function (wallet, callback) {
var options = {
url: `${this.apiUri}/person-profile/v1/profile/current`,
headers: this.headers,
url: `${apiUri}/funding-sources/v2/persons/${wallet}/accounts`,
headers: headers,
json: true

@@ -138,10 +140,72 @@ };

/**
* Get information about account balance
* Creates new account by alias
* @link https://developer.qiwi.com/ru/qiwi-wallet-personal/index.html#balance_create
* @param {string} wallet Wallet number without plus (+) and with prefix, as example: 79991234567
* @param {string} accountAlias Alias of account name
* @param {function(err,data)} callback
*/
this.createAccount = function (wallet, accountAlias, callback) {
var options = {
url: `${apiUri}/funding-sources/v2/persons/${wallet}/accounts`,
headers: headers,
body: {
alias: accountAlias
},
json: true
};
request.post(options, (error, response) => {
process204result(error, response, callback);
});
}
/**
* Sets default account
* @link https://developer.qiwi.com/ru/qiwi-wallet-personal/index.html#default_balance
* @param {string} wallet Wallet number without plus (+) and with prefix, as example: 79991234567
* @param {string} accountAlias Alias of account name
* @param {function(err,data)} callback
*/
this.setDefaultAccount = function (wallet, accountAlias, callback) {
var options = {
url: `${apiUri}/funding-sources/v2/persons/${wallet}/accounts/${accountAlias}`,
headers: headers,
body: {
defaultAccount: true
},
json: true
};
request.patch(options, (error, response) => {
process204result(error, response, callback);
});
}
/**
* Get possible aliases of account
* @link https://developer.qiwi.com/ru/qiwi-wallet-personal/index.html#funding_offer
* @param {string} wallet Wallet number without plus (+) and with prefix, as example: 79991234567
* @param {function(err,data)} callback
*/
this.getPossibleAccountAliases = function (wallet, callback) {
var options = {
url: `${apiUri}/funding-sources/v2/persons/${wallet}/accounts/offer`,
headers: headers,
json: true
};
request.get(options, (error, response) => {
processRequestCallback(error, response.body, callback);
});
}
/**
* Get information about current account
* @link
* @param {function(err,data)} callback
*/
this.getBalance = function (callback) {
this.getAccountInfo = function (callback) {
var options = {
url: `${this.apiUri}/funding-sources/v1/accounts/current`,
headers: this.headers,
url: `${apiUri}/person-profile/v1/profile/current`,
headers: headers,
json: true

@@ -157,26 +221,17 @@ };

* Get operation history
* @link
* @link https://developer.qiwi.com/ru/qiwi-wallet-personal/index.html#payments_list
* @param {string} wallet Wallet number without plus (+) and with prefix, as example: 79991234567
* @param {{rows:number, operation:string, sources:string, startDate:Date, endDate:Date, nextTxnDate:Date, nextTxnId:number}} requestOptions
* @param {function(err,data)} callback
*/
this.getOperationHistory = function (requestOptions, callback) {
this.getAccountInfo((err, data) => {
if (err != null) {
return callback(err, null);
}
this.getOperationHistory = function (wallet, requestOptions, callback) {
var options = {
url: `${apiUri}/payment-history/v2/persons/${wallet}/payments`,
headers: headers,
qs: requestOptions,
json: true
};
if (data == null) {
return callback(new Error("Can not retrieve account info"), null);
}
var options = {
url: `${this.apiUri}/payment-history/v2/persons/${data.authInfo.personId}/payments`,
headers: this.headers,
qs: requestOptions,
json: true
};
request.get(options, (error, response) => {
processRequestCallback(error, response.body, callback);
});
request.get(options, (error, response) => {
processRequestCallback(error, response.body, callback);
});

@@ -187,28 +242,17 @@ }

* Get statistics for operations
* @link
* @link https://developer.qiwi.com/ru/qiwi-wallet-personal/index.html#stat
* @param {string} wallet Wallet number without plus (+) and with prefix, as example: 79991234567
* @param {{operation:string, sources:string, startDate:Date, endDate:Date}} requestOptions
* @param {function(err,data)} callback
*/
this.getOperationStatistics = function (requestOptions, callback) {
this.getAccountInfo((err, data) => {
if (err != null) {
callback(err, null);
return;
}
this.getOperationStatistics = function (wallet, requestOptions, callback) {
var options = {
url: `${apiUri}/payment-history/v2/persons/${wallet}/payments/total`,
headers: headers,
qs: requestOptions,
json: true
};
if (data == null) {
callback(new Error("Can not retrieve account info"), null);
return;
}
var options = {
url: `${this.apiUri}/payment-history/v2/persons/${data.authInfo.personId}/payments/total`,
headers: this.headers,
qs: requestOptions,
json: true
};
request.get(options, (error, response) => {
processRequestCallback(error, response.body, callback);
});
request.get(options, (error, response) => {
processRequestCallback(error, response.body, callback);
});

@@ -226,4 +270,4 @@ }

var options = {
url: `${this.apiUri}/payment-history/v2/transactions/${transactionId}`,
headers: this.headers,
url: `${apiUri}/payment-history/v2/transactions/${transactionId}`,
headers: headers,
json: true

@@ -246,4 +290,4 @@ };

var options = {
url: `${this.apiUri}/payment-history/v1/transactions/${transactionId}/cheque/file`,
headers: this.headers,
url: `${apiUri}/payment-history/v1/transactions/${transactionId}/cheque/file`,
headers: headers,
qs: requestOptions,

@@ -266,4 +310,4 @@ json: true

var options = {
url: `${this.apiUri}/sinap/terms/99/payments`,
headers: this.headers,
url: `${apiUri}/sinap/terms/99/payments`,
headers: headers,
body: {

@@ -304,4 +348,4 @@ id: (1000 * Date.now()).toString(),

var options = {
url: `${this.apiUri}/sinap/terms/${data.message}/payments`,
headers: this.headers,
url: `${apiUri}/sinap/terms/${data.message}/payments`,
headers: headers,
body: {

@@ -345,4 +389,4 @@ id: (1000 * Date.now()).toString(),

var options = {
url: `${this.apiUri}/sinap/terms/${data.message}/payments`,
headers: this.headers,
url: `${apiUri}/sinap/terms/${data.message}/payments`,
headers: headers,
body: {

@@ -382,4 +426,4 @@ id: (1000 * Date.now()).toString(),

var options = {
url: `${this.apiUri}/sinap/terms/${recipient}/payments`,
headers: this.headers,
url: `${apiUri}/sinap/terms/${recipient}/payments`,
headers: headers,
body: {

@@ -418,3 +462,3 @@ id: (1000 * Date.now()).toString(),

var options = {
url: `${this.apiUri}/sinap/providers/${recipient}/form`,
url: `${apiUri}/sinap/providers/${recipient}/form`,
json: true

@@ -437,3 +481,3 @@ };

var options = {
url: `${this.apiUri}/sinap/providers/${recipient}/onlineCommission`,
url: `${apiUri}/sinap/providers/${recipient}/onlineCommission`,
body: {

@@ -470,3 +514,3 @@ account: requestOptions.account,

url: 'https://qiwi.com/mobile/detect.action',
headers: this.headers,
headers: headers,
qs: {

@@ -491,3 +535,3 @@ phone: phone

url: 'https://qiwi.com/card/detect.action',
headers: this.headers,
headers: headers,
qs: {

@@ -511,4 +555,4 @@ cardNumber: cardNumber

var options = {
url: `${this.apiUri}/sinap/crossRates`,
headers: this.headers,
url: `${apiUri}/sinap/crossRates`,
headers: headers,
json: true

@@ -529,4 +573,4 @@ };

var options = {
url: `${this.apiUri}/payment-notifier/v1/hooks`,
headers: this.headers,
url: `${apiUri}/payment-notifier/v1/hooks`,
headers: headers,
qs: {

@@ -552,4 +596,4 @@ hookType: 1,

var options = {
url: `${this.apiUri}/payment-notifier/v1/hooks/${hookId}`,
headers: this.headers,
url: `${apiUri}/payment-notifier/v1/hooks/${hookId}`,
headers: headers,
json: true

@@ -570,4 +614,4 @@ };

var options = {
url: `${this.apiUri}/payment-notifier/v1/hooks/${hookId}/key`,
headers: this.headers,
url: `${apiUri}/payment-notifier/v1/hooks/${hookId}/key`,
headers: headers,
json: true

@@ -588,4 +632,4 @@ };

var options = {
url: `${this.apiUri}/payment-notifier/v1/hooks/${hookId}/newkey`,
headers: this.headers,
url: `${apiUri}/payment-notifier/v1/hooks/${hookId}/newkey`,
headers: headers,
json: true

@@ -606,4 +650,4 @@ };

var options = {
url: `${this.apiUri}/payment-notifier/v1/hooks/active`,
headers: this.headers,
url: `${apiUri}/payment-notifier/v1/hooks/active`,
headers: headers,
json: true

@@ -623,4 +667,4 @@ };

var options = {
url: `${this.apiUri}/payment-notifier/v1/hooks/test`,
headers: this.headers,
url: `${apiUri}/payment-notifier/v1/hooks/test`,
headers: headers,
json: true

@@ -650,2 +694,11 @@ };

/**
* Process request response witch returns 204 (NoContent)
* @param {*} error
* @param {*} response
* @param {*} callback
*/
function process204result(error, response, callback) {
callback(error, { success: response.statusCode != undefined && response.statusCode == 204 })
}
}

2

package.json
{
"name": "node-qiwi-api",
"version": "2.0.0-beta.0",
"version": "2.0.0-beta.1",
"main": "./lib/index.js",

@@ -5,0 +5,0 @@ "dependencies": {

@@ -29,6 +29,7 @@ node-qiwi-api

}
console.log(info);
console.log(data);
})
```
**wallet** - wallet number without plus (+) and with prefix (79991234567)
```
Identify wallet

@@ -41,3 +42,3 @@ ----------------

}
console.log(info);
console.log(data);
})

@@ -60,30 +61,79 @@ ```

```js
wallet.getAccountInfo((err, info) => {
wallet.getAccountInfo((err, data) => {
if(err) {
/*hanle error*/
}
console.log(info);
console.log(data);
})
```
Balance
Get accounts
----------------
```js
wallet.getBalance((err, balance) => {
wallet.getAccounts(wallet, (err, data) => {
if(err) {
/*hanle error*/
}
console.log(balance);
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
```js
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
```js
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
```js
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
----------------
```js
wallet.getOperationHistory(requestOptions, (err, operations) => {
wallet.getOperationHistory(wallet, requestOptions, (err, data) => {
if(err) {
/*hanle error*/
}
console.log(operations);
console.log(data);
})
```
**wallet** - wallet number without plus (+) and with prefix (79991234567)
requestOptions includes:

@@ -109,9 +159,11 @@ * **rows** - Amount of payments in response. Integer from 1 to 50. Required.

```js
wallet.getOperationStatistics(requestOptions, (err, stats) => {
wallet.getOperationStatistics(wallet, requestOptions, (err, data) => {
if(err) {
/*hanle error*/
}
console.log(stats);
console.log(data);
})
```
**wallet** - wallet number without plus (+) and with prefix (79991234567)
requestOptions: **operation, sources, startDate, endDate** - Parameters are similar to **getOperationHistory**.

@@ -127,3 +179,3 @@

}
console.log(stats);
console.log(data);
})

@@ -140,3 +192,3 @@ ```

}
console.log(stats);
console.log(data);
})

@@ -250,2 +302,3 @@ ```

* **recipient** - Allowable values stored in wallet.recipients
Response contains:

@@ -252,0 +305,0 @@ * **bound** - Payment amount, starting from which the condition applies

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