Difference between revisions of "MOR API card from group sell"

From Kolmisoft Wiki
Jump to navigationJump to search
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'This functionality is available from [[MOR 12| MOR 12]]''
=Description=
<!---This functionality is available from MOR 12--->
[[MOR API]] sells Cards from Calling Card Group
<br><br>
=Usage=


* From '''MOR X4''' call: '''/api/card_from_group_sell'''
* For Backwards-compatibility old name 'buy_card_from_callingroup' is also usable. Call: '''/api/buy_card_from_callingroup'''
* Methods: POST, GET(if allowed, not recomended)
<br><br>
===Parametres===


[[MOR API]]
Parameters which are '''included''' into hash:


sells Cards from Calling Card Group
* email - email address, to send information about bought card '''Optional'''.
* id - Calling Card Group ID in MOR database. '''Required'''.
* quantity - default 1. '''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>
<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. '''Required'''.
* number - parameter that indicates which card is sold. If number parameter is send, then quantity parameter will be ignored. '''Optional'''.
* curr - parameter that lets change the currency of cards payment. Default currency is system currency. '''Optional'''.
<br><br>
<br><br>


* Call: /api/buy_card_from_callingroup
===Request===
* Methods: POST, GET(if allowed, not recomended)
 
* Params:
We have id = 6, quantity = 2, API Secret Key = 456789
** id - Calling Card Group ID in MOR database. '''Required'''.
** quantity - default 1. '''Optional'''.
** u - username to login. '''Required'''.
** p - password to login. '''Required'''.
** email - email address, to send information about bought card '''Optional'''.
** [[MOR API hash construction | hash]] - SHA1 hash constructed using '''id''' and  '''quantity''' and '''API_Secret_Key''' ([[MOR API hash construction | More described in Constructing hash]]). '''Required'''.
**


* Returns:
We send:
**Success
HTML POST: http://<SERVER_IP>/billing/api/buy_card_from_callingroup?u=username&id=6&quantity=2&hash=37086d860581fabc278413cd1a417d5c079f6eba
<cards>
  <card>
    <pin>...</pin>
    <number>..</number>
    <balance_without_vat>...</balance_without_vat>
    <currency>...</currency>
  </card>


  <card>
'''NOTE that username are not included in hash'''
    <pin>...</pin>
<br><br>
    <number>...</number>
===Returns===
    <balance_without_vat>...</balance_without_vat>
    <currency>...</currency>
  </card>
</cards>


'''Success'''


** Errors:
<?xml version="1.0" encoding="UTF-8"?>
*** <error>Bad login</error> - User supplied bad login or password.
<page>
*** <error>Incorrect hash</error> - Hash was not correct. Check API_Secret_Key and order or params while concatenating hash_string.
  <cards>
*** <error>Cardgroup was not found</error> - Use correct Calling Card Group ID .
  <card>
*** <error>Free cards was not found/error> - no free cards in Calling Card Group.
    <pin>...</pin>
    <number>..</number>
    <balance_without_vat>...</balance_without_vat>
    <currency>...</currency>
  </card>
  <card>
    <pin>...</pin>
    <number>...</number>
    <balance_without_vat>...</balance_without_vat>
    <currency>...</currency>
  </card>
  </cards>
</page>
<br><br>
<br><br>
----
----
*Example:
 
**We have id = 6, quantity = 2, API Secret Key = 456789
'''Errors'''
**Hash string to be converted: "62456789"
 
**We might send:
* <error>Bad login</error> - User supplied bad login or password.
***/api/buy_card_from_callingroup?id=6&quantity=2&hash=37086d860581fabc278413cd1a417d5c079f6eba&u=admin&p=admin
* <error>Incorrect hash</error> - Hash was not correct. Check API_Secret_Key and order or params while concatenating hash_string.
'''* Note that username and password are not included in hash'''
* <error>Cardgroup was not found</error> - Use correct Calling Card Group ID .
* <error>Free cards was not found</error> - no free cards in Calling Card Group.
* <error>Card is already sold</error> - This card is already sold.
 
<br><br>
 
=See also=
 
* [[MOR API]]

Latest revision as of 13:55, 18 September 2017

Description

MOR API sells Cards from Calling Card Group

Usage

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



Parametres

Parameters which are included into hash:

  • email - email address, to send information about bought card Optional.
  • id - Calling Card Group ID in MOR database. Required.
  • quantity - default 1. 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.
  • u - username for authentication. Required.
  • number - parameter that indicates which card is sold. If number parameter is send, then quantity parameter will be ignored. Optional.
  • curr - parameter that lets change the currency of cards payment. Default currency is system currency. Optional.



Request

We have id = 6, quantity = 2, API Secret Key = 456789

We send:

HTML POST: http://<SERVER_IP>/billing/api/buy_card_from_callingroup?u=username&id=6&quantity=2&hash=37086d860581fabc278413cd1a417d5c079f6eba

NOTE that username are not included in hash

Returns

Success

<?xml version="1.0" encoding="UTF-8"?>
<page>
 <cards>
  <card>
    <pin>...</pin>
    <number>..</number>
    <balance_without_vat>...</balance_without_vat>
    <currency>...</currency>
  </card>
  <card>
    <pin>...</pin>
    <number>...</number>
    <balance_without_vat>...</balance_without_vat>
    <currency>...</currency>
  </card>
 </cards>
</page>




Errors

  • <error>Bad login</error> - User supplied bad login or password.
  • <error>Incorrect hash</error> - Hash was not correct. Check API_Secret_Key and order or params while concatenating hash_string.
  • <error>Cardgroup was not found</error> - Use correct Calling Card Group ID .
  • <error>Free cards was not found</error> - no free cards in Calling Card Group.
  • <error>Card is already sold</error> - This card is already sold.



See also