Difference between revisions of "M4 API payment create"
From Kolmisoft Wiki
Jump to navigationJump to search
(Created page with '=Description= M2 API Create Payment Create new payment from params. '''User balance will change'''. =Configuration= Go to SETTINGS -> Setup -> Settings->API tab and check '…') |
|||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
=Description= | =Description= | ||
Create Payment | |||
Create new payment from params. '''User balance will change'''. | Create new payment from params. '''User balance will change'''. | ||
Line 10: | Line 10: | ||
* Call: '''/api/payment_create''' | * Call: '''/api/payment_create''' | ||
* Methods: POST, GET(if allowed, not | * Methods: POST, GET(if allowed, not recommended) | ||
<br><br> | <br><br> | ||
=== | ===Parameters=== | ||
Parameters which are '''included''' into hash: | |||
* user_id - User ID in MOR database, whose payment | * user_id - User ID in MOR database, whose payment has to be done. '''Required'''. | ||
* | * amount - amount. '''Required'''. | ||
* | * currency - Currency code. '''Required'''. | ||
* | |||
* | <br> | ||
* | Parameters which are '''not included''' into hash: | ||
* | * amount_in_tax - [0/1] default 0. If value 1, then the amount param is given with tax included. '''Optional'''. | ||
* comment - comment on the payment. '''Optional'''. | |||
* payment_to_provider - [0/1] default 0. If value 0 Payment destination: is Payment from the Client, if value 1 Payment destination: Payment to Provider. '''Optional'''. | |||
* exchange_rate - if a currency is not the default currency then this value is used as an exchange rate. The default value is the default system exchange rate from [[Currencies]]. '''Optional'''. | |||
* u - username (admin/reseller) for authentication. '''Required'''. | * u - username (admin/reseller) for authentication. '''Required'''. | ||
* [[MOR API hash construction | hash]] - SHA1 hash constructed using '''params''' and '''API_Secret_Key''' ([[MOR API hash construction | More described in Constructing hash]]). '''Required''' (if setting '''Disable hash checking''' is not checked). | * [[MOR API hash construction | hash]] - SHA1 hash constructed using '''params''' and '''API_Secret_Key''' ([[MOR API hash construction | More described in Constructing hash]]). '''Required''' (if setting '''Disable hash checking''' is not checked). | ||
<br><br> | <br><br> | ||
Line 29: | Line 34: | ||
We have user_id = 123, API Secret Key = 456789 | We have user_id = 123, API Secret Key = 456789 | ||
We send: | We send: | ||
HTML POST: http://<SERVER_IP>/billing/api/payment_create?u=admin&user_id= | HTML POST: http://<SERVER_IP>/billing/api/payment_create?u=admin&user_id=2&amount=96¤cy=USD&amount_in_tax=1&exchange_rate=0.111&payment_to_provider=1&comment=testest&&hash=687a2cee0a61dee0bffa3bc8837e201a6a31af5d | ||
'''NOTE that username and password are not included in hash''' | '''NOTE that username and password are not included in hash''' | ||
Line 57: | Line 62: | ||
* <error>Bad login</error> - User supplied bad login. | * <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>Incorrect hash</error> - Hash was not correct. Check API_Secret_Key and order or params while concatenating hash_string. | ||
* <error> | * <error>Currency was not foundy</error> - Currency not found in system. | ||
* <error>Access Denied</error> - | * <error>Access Denied</error> - The user was not found or the current user(username (admin/reseller) for authentication) is not an owner of the user for which payment has to be done. | ||
* <error>Amount was not found</error> - Amount was not given. | |||
* <error>Payment was not saved</error> | * <error>Payment was not saved</error> | ||
** <message>Error message</message> | ** <message>Error message</message> | ||
Line 65: | Line 71: | ||
=See also= | =See also= | ||
* [[ | * [[M4 API]] |
Latest revision as of 11:18, 28 November 2022
Description
Create Payment
Create new payment from params. User balance will change.
Configuration
Go to SETTINGS -> Setup -> Settings->API tab and check API allow Payments
Usage
- Call: /api/payment_create
- Methods: POST, GET(if allowed, not recommended)
Parameters
Parameters which are included into hash:
- user_id - User ID in MOR database, whose payment has to be done. Required.
- amount - amount. Required.
- currency - Currency code. Required.
Parameters which are not included into hash:
- amount_in_tax - [0/1] default 0. If value 1, then the amount param is given with tax included. Optional.
- comment - comment on the payment. Optional.
- payment_to_provider - [0/1] default 0. If value 0 Payment destination: is Payment from the Client, if value 1 Payment destination: Payment to Provider. Optional.
- exchange_rate - if a currency is not the default currency then this value is used as an exchange rate. The default value is the default system exchange rate from Currencies. Optional.
- u - username (admin/reseller) for authentication. Required.
- hash - SHA1 hash constructed using params and API_Secret_Key ( More described in Constructing hash). Required (if setting Disable hash checking is not checked).
Request
We have user_id = 123, API Secret Key = 456789 We send:
HTML POST: http://<SERVER_IP>/billing/api/payment_create?u=admin&user_id=2&amount=96¤cy=USD&amount_in_tax=1&exchange_rate=0.111&payment_to_provider=1&comment=testest&&hash=687a2cee0a61dee0bffa3bc8837e201a6a31af5d
NOTE that username and password are not included in hash
Returns
Success
<?xml version="1.0" encoding="UTF-8"?> <page> <response> <status>ok</status> <payment currency="..."> <payment_id>...</payment_id> <tax>...</tax> <amount>...</amount> <gross>...</gross> </payment> </response> </page>
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>Currency was not foundy</error> - Currency not found in system.
- <error>Access Denied</error> - The user was not found or the current user(username (admin/reseller) for authentication) is not an owner of the user for which payment has to be done.
- <error>Amount was not found</error> - Amount was not given.
- <error>Payment was not saved</error>
- <message>Error message</message>