M2 API user balance get

From Kolmisoft Wiki

Jump to: navigation, search


[edit] Description

This feature enables you to check the balance over http.

[edit] Configuration

1. Go to MAINTENANCE –> Settings


2. In API tab check the marked option:


[edit] Usage

  • Methods: POST, GET(if allowed, not recomended)
  • Call: /api/user_balance_get

[edit] Parameters

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.

[edit] Request

We have username=USERNAME, API Secret Key = secret

We send:

HTML POST: http://<SERVER_IP>/billing/api/user_balance_get?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?username=USERNAME&currency={USER|CURRENCY_CODE}&hash=79e75e75f9cd6821e7j5h89f6a45294b45g8u9f5

[edit] Returns

Success returns balance of user.

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

With user_currency = 1 parameter.

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


When hash is incorrect.

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

When user is not found.

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

When feature is off.

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

[edit] See Also

Personal tools


Try M2