Difference between revisions of "MOR API card by cli update"
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
=Description= | |||
<!---This functionality is available from MOR 12---> | |||
[[MOR API]] Availability to create and update calling cards, including adding and transferring funds, by being identified according the Caller_ID. | |||
<br><br> | |||
=Usage= | |||
* From '''MOR X4''' call: '''/api/card_by_cli_update''' | |||
* For Backwards-compatibility old name 'cc_by_cli' is also usable. Call: '''/api/cc_by_cli''' | |||
* Methods: POST, GET(if allowed, not recomended) | |||
<br><br> | |||
===Parameters=== | |||
Parameters which are '''included''' into hash: | |||
* pin - pin of calling card, if specified amount would be ignored. | |||
* amount - amount to transfer to calling card. | |||
* callerid - Caller ID in MOR database, whose credit notes we want to see. '''Required'''. | |||
* cardgroup_id - cardgroup ID in MOR database. | |||
'''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 for authentication. Username of Calling Cards owner. '''Required'''. | |||
<br><br> | |||
===Request examples=== | |||
HTML POST: http://<SERVER_IP>/billing/api/card_by_cli_update?u=user&callerid=123&cardgroup=3&amount=100&hash=ed9d3657ad490fa2ed860ecc93223d58bf471672 | |||
HTML POST: http://<SERVER_IP>/billing/api/card_by_cli_update?u=user&callerid=123&cardgroup=3&hash=2b76184f5fd39ee4d149d7481c39d57fdc1f7f7a | |||
HTML POST: http://<SERVER_IP>/billing/api/card_by_cli_update?u=user&callerid=123&cardgroup=3&pin=321&hash=71973ad6f8d1f8a52ba17e3a2d3a4e974ac057d2 | |||
'''NOTE that username is not included in hash''' | |||
<br><br> | |||
===Returns=== | |||
'''Success''' | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<page> | |||
<response> | |||
<status>ok</status> | |||
<card> | |||
<id></id> | |||
<cardgroup_id></cardgroup_id> | |||
<balance></balance> | |||
<callerid></callerid> | |||
<pin></pin> | |||
<number></number> | |||
</card> | |||
</response> | |||
</page> | |||
'''Note that user has to be owner of cardgroup that id is supplied.''' | |||
<br><br> | |||
---- | |||
'''Errors''' | |||
''' | |||
* <error>Bad login</error> - User supplied bad login. | |||
* <error>Incorrect hash</error> - Hash was not correct. Check API_Secret_Key and order or params while concatenating hash_string. | |||
* <error>Supplied Cardgroup_id is invalid</error> - user is not the owner of cardgroup or there is no cardgroup at all. | |||
* <error>Failed to make transaction</error> - Something went wrong and transaction could not be completed. | |||
* <error>Card was not found</error> - Card with specified callerid was not found | |||
* <error>Callerid belongs to provider</error> - callerid belongs to provider and you cannot change that using this api method. | |||
* <error>Device allready have such callerid, but you do not have permission to change user's balance</error> - if device with specified callerid was found but device's user A is owned by some user B, you cannot change A's balance. | |||
<br><br> | <br><br> | ||
Line 66: | Line 85: | ||
4. ''Caller_id exists in device'': cards value will be transferred, VAT will not be deducted, from the card found by PIN, to the user of the device and the card will be disabled. | 4. ''Caller_id exists in device'': cards value will be transferred, VAT will not be deducted, from the card found by PIN, to the user of the device and the card will be disabled. | ||
<br><br> | |||
==PIN number supplied== | ==PIN number supplied== | ||
Line 77: | Line 97: | ||
4. ''Caller_id exists in a device'': cards value will be added to the user of the device and the card will be disabled. | 4. ''Caller_id exists in a device'': cards value will be added to the user of the device and the card will be disabled. | ||
<br><br> | |||
[[File: Cc_by_cli.png]] | [[File: Cc_by_cli.png]] | ||
<br><br> | <br><br> | ||
=See also= | =See also= | ||
[[MOR API]] | * [[MOR API]] |
Latest revision as of 04:23, 16 June 2017
Description
MOR API Availability to create and update calling cards, including adding and transferring funds, by being identified according the Caller_ID.
Usage
- From MOR X4 call: /api/card_by_cli_update
- For Backwards-compatibility old name 'cc_by_cli' is also usable. Call: /api/cc_by_cli
- Methods: POST, GET(if allowed, not recomended)
Parameters
Parameters which are included into hash:
- pin - pin of calling card, if specified amount would be ignored.
- amount - amount to transfer to calling card.
- callerid - Caller ID in MOR database, whose credit notes we want to see. Required.
- cardgroup_id - cardgroup ID in MOR database.
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 for authentication. Username of Calling Cards owner. Required.
Request examples
HTML POST: http://<SERVER_IP>/billing/api/card_by_cli_update?u=user&callerid=123&cardgroup=3&amount=100&hash=ed9d3657ad490fa2ed860ecc93223d58bf471672
HTML POST: http://<SERVER_IP>/billing/api/card_by_cli_update?u=user&callerid=123&cardgroup=3&hash=2b76184f5fd39ee4d149d7481c39d57fdc1f7f7a
HTML POST: http://<SERVER_IP>/billing/api/card_by_cli_update?u=user&callerid=123&cardgroup=3&pin=321&hash=71973ad6f8d1f8a52ba17e3a2d3a4e974ac057d2
NOTE that username is not included in hash
Returns
Success
<?xml version="1.0" encoding="UTF-8"?> <page> <response> <status>ok</status> <card> <id></id> <cardgroup_id></cardgroup_id> <balance></balance> <callerid></callerid> <pin></pin> <number></number> </card> </response> </page>
Note that user has to be owner of cardgroup that id is supplied.
Errors
- <error>Bad login</error> - User supplied bad login.
- <error>Incorrect hash</error> - Hash was not correct. Check API_Secret_Key and order or params while concatenating hash_string.
- <error>Supplied Cardgroup_id is invalid</error> - user is not the owner of cardgroup or there is no cardgroup at all.
- <error>Failed to make transaction</error> - Something went wrong and transaction could not be completed.
- <error>Card was not found</error> - Card with specified callerid was not found
- <error>Callerid belongs to provider</error> - callerid belongs to provider and you cannot change that using this api method.
- <error>Device allready have such callerid, but you do not have permission to change user's balance</error> - if device with specified callerid was found but device's user A is owned by some user B, you cannot change A's balance.
API actions according to PIN being or not being supplied
No PIN number supplied
1. Caller_id does not exist in callingcard: a payment of amount of funds will be added to the card, VAT will be deducted, and the card will be marked as sold.
2. Caller_id exists in a card within the cardgroup_id: Value from a calling card found by Caller_id, will be transferred to the card found by PIN, VAT will not be deducted. Caller_id will be associated with the card, which is found by PIN, and that card will be marked as sold. Card found by Caller_id will be disabled.
3. Caller_id exists in another cardgroup_id: Caller_id and balance will be transferred, VAT will not be deducted from the card found by Caller_id to the card found by PIN, Card found by PIN will be marked as sold and the other one will be disabled.
4. Caller_id exists in device: cards value will be transferred, VAT will not be deducted, from the card found by PIN, to the user of the device and the card will be disabled.
PIN number supplied
1. Caller_id does not exist in any calling card: Caller_id will be associated to the new card and it will be marked as sold.
2. Caller_id exists in another card within the same cardgroup_id: a new calling card value will be added to the old card and the new one will be disabled.
3. Caller_id exists in a card within a different cardgroup_id: Caller_id and balance will be transfered from the old card to the new one, new one will be marked as sold and the old one will be disabled.
4. Caller_id exists in a device: cards value will be added to the user of the device and the card will be disabled.