Difference between revisions of "MOR API user balance update"

From Kolmisoft Wiki
Jump to navigationJump to search
 
(16 intermediate revisions by 4 users not shown)
Line 1: Line 1:
''This functionality is available from [[MOR 10 documentation | MOR 10]]''
=Description=
<!---This functionality is available from MOR 10--->
[[MOR API]] for user balance update.  This method increases/decreases users balance with specified amount of money.
<br><br>
=Usage=
 
* From '''MOR X4''' call: '''/api/user_balance_update'''
* For Backwards-compatibility old name 'user_balance_change' is also usable. Call: '''/api/user_balance_change'''
* Methods: POST, GET(if allowed, not recomended)
<br><br>
===Parametres===
 
Parameters which are '''included''' into hash:
 
* user_id - Users ID in MOR database, whose balance we want to change. '''Required'''.
* balance - new user balance. '''Required'''.
 
'''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'''.
* u - username to login. '''Required'''. (The user which changes balance: admin/reseller, not the user himself!)
<br><br>
 
===Request===
 
We have user_id = 123, API Secret Key = 456789, balance = 100


HTML POST: http://<SERVER IP>/billing/api/user_balance_update?u=username&user_id=123&balance=100&hash=b1bef44691c237b574263e09b2838ad1e658e507


[[MOR API]]
'''* Note that username and password are not included in hash'''
<br><br>
===Returns===


Login and change user balance.
'''Success'''


<page>
  <page>
    <status>User balance updated</status>
    <user>
      <username> username </username>
      <id> user_id </id>
      <balance> new balance </balance>
    </user>
  </page>
</page>
<br><br>
<br><br>
----
----
'''Errors'''
User was not found using user_id. Use correct user_id.
<?xml version="1.0" encoding="UTF-8"?>
<page>
  <error>User was not found</error>
</page>
Hash was not correct. Check API_Secret_Key and order or params while concatenating hash_string.
<?xml version="1.0" encoding="UTF-8"?>
<status>
  <error>Incorrect hash</error>
</status>
User not loged in the system. Check username and password.
<?xml version="1.0" encoding="UTF-8"?>
<page>
  <error>Bad login</error>
</page>
Params balance is not correct or user is not saved. Check balance param.
<?xml version="1.0" encoding="UTF-8"?>
<page>
  <error>User balance not updated</error>
</page>
<br><br>
<br><br>
===Additional notes===


* Call: /api/change_user_balance
*If the balance is changed during the call, price for the call will be deducted from new balance, because balance is deducted at the end of call.
* Methods: POST, GET(if allowed, not recomended)
*User Balance changes will not be shown in Payments. Use [http://wiki.kolmisoft.com/index.php/MOR_API_payment_create API Payment Create].
* Params:
<br><br>
** user_id - Users ID in MOR database, whose balance we want to change. '''Required'''.
 
** u - username to login. '''Required'''.
=See also=
** p - password to login. '''Required'''.
 
** balance - new user balance. '''Required'''.
* [[MOR API]]
** [[MOR API hash construction | hash]] - SHA1 hash constructed using params and API_Secret_Key ([[MOR API hash construction | More described in Constructing hash]]). '''Required'''.
* Returns:
** Errors:
*** <error>User was not found</error> - User was not found using user_id. Use correct user_id.
*** <error>Incorrect hash</error> - Hash was not correct. Check API_Secret_Key and order or params while concatenating hash_string.
*** <error>Bad login</error> - User not loged in the system. Check username and password.
*** <error>User balance not updated</error> - Params balance is not correct or user is not saved. Check balance param.

Latest revision as of 11:03, 6 November 2015

Description

MOR API for user balance update. This method increases/decreases users balance with specified amount of money.

Usage

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



Parametres

Parameters which are included into hash:

  • user_id - Users ID in MOR database, whose balance we want to change. Required.
  • balance - new user balance. Required.

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.
  • u - username to login. Required. (The user which changes balance: admin/reseller, not the user himself!)



Request

We have user_id = 123, API Secret Key = 456789, balance = 100

HTML POST: http://<SERVER IP>/billing/api/user_balance_update?u=username&user_id=123&balance=100&hash=b1bef44691c237b574263e09b2838ad1e658e507

* Note that username and password are not included in hash

Returns

Success

<page>
  <page>
    <status>User balance updated</status>
    <user>
      <username> username </username>
      <id> user_id </id>
      <balance> new balance </balance>
    </user>
  </page>
</page>




Errors

User was not found using user_id. Use correct user_id.

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

Hash was not correct. Check API_Secret_Key and order or params while concatenating hash_string.

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

User not loged in the system. Check username and password.

<?xml version="1.0" encoding="UTF-8"?>
<page>
  <error>Bad login</error>
</page>

Params balance is not correct or user is not saved. Check balance param.

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



Additional notes

  • If the balance is changed during the call, price for the call will be deducted from new balance, because balance is deducted at the end of call.
  • User Balance changes will not be shown in Payments. Use API Payment Create.



See also