Difference between revisions of "MOR API user balance get"

From Kolmisoft Wiki
Jump to navigationJump to search
 
(17 intermediate revisions by 4 users not shown)
Line 1: Line 1:
''This feature is available starting from [[MOR_10_documentation | MOR 10]], but was also backported to [[MOR_9_documentation | MOR 9]]''
<!---This functionality is available from MOR 10, but was also backported to MOR 9--->
 
=Description=
=About=
This feature enables you to check the balance over http.
This feature enables you to check the balance over http.
<br><br>
=Configuration=


==Enable check balance over http feature==
1. Go to '''SETTINGS –> Setup > Settings'''
 
1. Go to '''SETTINGS - Setup -> Settings'''
<br><br>  
<br><br>  
[[File:settings_path.png]]
[[File:settings_path.png]]
<br><br>
<br><br>
2. In Various tab check the marked option:
<!---This functionality is available from MOR 12--->
2. In API tab check the marked option:
<br><br>
<br><br>
[[File:Settings_various_balance_over_http.png]]
[[File:Settings_various_balance_over_http.png]]
<br><br>
<br><br>
==Request==


  HTML POST: http://<SERVER_IP>/billing/api/balance?username=USERNAME
=Usage=
 
* From '''MOR X4''' call: '''/api/user_balance_get'''
* For Backwards-compatibility old name 'balance' is also usable. Call: '''/api/balance'''
* Methods: POST, GET(if allowed, not recomended)
<br><br>
===Parametres===
 
Parameters which are '''included''' into hash(if it is used):
 
* username – username of user whose balance you want to get. '''Required'''.
* currency – currency code or value USER in which case balance will be returned in user's currency. '''Optional'''.
 
'''Note that parameters are shown in the same order as they have to be when generating the hash. Last parameter in a row is API_Secret_Key'''
<br><br>
Parameters which are '''not included''' into hash:
 
* [[MOR API hash construction | hash]] - SHA1 hash constructed using parameters above and API_Secret_Key ([[MOR API hash construction | More described in Constructing hash]]). '''Required'''.
* user_currency = 1 –  in this case balance will be returned in user's currency with name of users currency. '''Optional'''.
<br>
'''NOTE''' Without '''currency''' or '''user_currency''' parameters API request will return Balance in [[Currencies#Default_Currency|Default System Currency]]. If user_currency is used currency parameter will be ignored.
<br><br>
 
===Request===
 
We have username=USERNAME, API Secret Key = secret
 
We send:
 
  HTML POST: http://<SERVER_IP>/billing/api/user_balance_get?u=admin&username=USERNAME&hash=79e75e75f9cd6821e7b661250a45294b4579f262


Optionaly you can specify currency, valid values are USER, in that case balance is returned in user's currency. And currency code(EUR, USD etc.)  
Optionaly you can specify currency, valid values are USER, in that case balance is returned in user's currency. And currency code(EUR, USD etc.)  


  HTML POST: http://<SERVER_IP>/billing/api/balance?username=USERNAME&currency={USER|CURRENCY_CODE}
  HTML POST: http://<SERVER_IP>/billing/api/user_balance_get?u=admin&username=USERNAME&currency={USER|CURRENCY_CODE}&hash=79e75e75f9cd6821e7j5h89f6a45294b45g8u9f5
<br><br>


==Result==
===Returns===


-349282.18
'''Success''' returns balance of user.


returns balance of user.
<?xml version="1.0" encoding="UTF-8"?>
<page>
  <balance> user balance </balance>
</page>


==Erros==
With user_currency = 1 parameter.
<?xml version="1.0" encoding="UTF-8"?>
<page>
  <balance> user balance </balance>
  <currency> user currency </currency>
</page>
 
<br><br>
----
 
'''Errors'''
 
When hash is incorrect.
 
<?xml version="1.0" encoding="UTF-8"?>
<status>
  <error>Incorrect hash</error>
</status>


When user is not found.
When user is not found.
  User not found
  <?xml version="1.0" encoding="UTF-8"?>
<page>
  <error>User was not found</error>
</page>


When feature is off.
When feature is off.
  Feature disabled
  <?xml version="1.0" encoding="UTF-8"?>
<page>
  <error>Feature disabled</error>
</page>
<br><br>


==See Also==
=See Also=


* [[MOR API]]
* [[MOR API]]

Latest revision as of 08:46, 29 June 2016

Description

This feature enables you to check the balance over http.

Configuration

1. Go to SETTINGS –> Setup –> Settings

Settings path.png

2. In API tab check the marked option:

Settings various balance over http.png

Usage

  • From MOR X4 call: /api/user_balance_get
  • For Backwards-compatibility old name 'balance' is also usable. Call: /api/balance
  • Methods: POST, GET(if allowed, not recomended)



Parametres

Parameters which are included into hash(if it is used):

  • username – username of user whose balance you want to get. Required.
  • currency – currency code or value USER in which case balance will be returned in user's currency. Optional.

Note that parameters are shown in the same order as they have to be when generating the hash. Last parameter in a row is API_Secret_Key

Parameters which are not included into hash:

  • hash - SHA1 hash constructed using parameters above and API_Secret_Key ( More described in Constructing hash). Required.
  • user_currency = 1 – in this case balance will be returned in user's currency with name of users currency. Optional.


NOTE Without currency or user_currency parameters API request will return Balance in Default System Currency. If user_currency is used currency parameter will be ignored.

Request

We have username=USERNAME, API Secret Key = secret

We send:

HTML POST: http://<SERVER_IP>/billing/api/user_balance_get?u=admin&username=USERNAME&hash=79e75e75f9cd6821e7b661250a45294b4579f262

Optionaly you can specify currency, valid values are USER, in that case balance is returned in user's currency. And currency code(EUR, USD etc.)

HTML POST: http://<SERVER_IP>/billing/api/user_balance_get?u=admin&username=USERNAME&currency={USER|CURRENCY_CODE}&hash=79e75e75f9cd6821e7j5h89f6a45294b45g8u9f5



Returns

Success returns balance of user.

<?xml version="1.0" encoding="UTF-8"?>
<page>
  <balance> user balance </balance>
</page>

With user_currency = 1 parameter.

<?xml version="1.0" encoding="UTF-8"?>
<page>
  <balance> user balance </balance>
  <currency> user currency </currency>
</page>




Errors

When hash is incorrect.

<?xml version="1.0" encoding="UTF-8"?>
<status>
  <error>Incorrect hash</error>
</status>

When user is not found.

<?xml version="1.0" encoding="UTF-8"?>
<page>
  <error>User was not found</error>
</page>

When feature is off.

<?xml version="1.0" encoding="UTF-8"?>
<page>
  <error>Feature disabled</error>
</page>



See Also