Difference between revisions of "MOR API subscription create"
From Kolmisoft Wiki
Jump to navigationJump to search
(12 intermediate revisions by 7 users not shown) | |||
Line 8: | Line 8: | ||
* Methods: POST, GET(if allowed, not recomended) | * Methods: POST, GET(if allowed, not recomended) | ||
<br><br> | <br><br> | ||
=== | ===Parameters=== | ||
Parameters which are '''included''' into hash: | Parameters which are '''included''' into hash: | ||
* user_id - User ID . '''Required'''. | |||
* service_id - Service ID. '''Required'''. | * service_id - Service ID. '''Required'''. | ||
Parameters which are '''not included''' into hash: | Parameters which are '''not included''' into hash: | ||
* [[MOR API hash construction | hash]] - SHA1 hash constructed using '''API_Secret_Key''' ([[MOR API hash construction | More described in Constructing hash]]). '''Required'''. | * [[MOR API hash construction | hash]] - SHA1 hash constructed using '''API_Secret_Key''' ([[MOR API hash construction | More described in Constructing hash]]). '''Required'''. | ||
* u - username for authentication. '''Required'''. | * u - username for authentication (admin, reseller, accountant). '''Required'''. | ||
* subscription_activation_start - timestamp of Subscription activation start. | * subscription_start_period_day - Start Period on the day, possible values between 1 and 31, default 1. | ||
* subscription_activation_end - timestamp of Subscription activation end. | * subscription_start_period_month - Start Period on the month, possible values between 1 and 12, default 1. | ||
* subscription_charge_balance_on - Charge Balance on, possible values are 1,2,3 (where 1: Period Start, 2: Period End, 3: Every Day), default 1 (daily and one-time fee subscriptions inserted in the database as 3). | |||
* subscription_activation_start - Unix timestamp of Subscription activation start. | |||
* subscription_activation_end - Unix timestamp of Subscription activation end. | |||
* subscription_memo - memo of Subscription. | * subscription_memo - memo of Subscription. | ||
* subscription_until_canceled - subscription is until | * subscription_until_canceled - subscription is until canceled (0 - off, 1 - on, default - off). | ||
* subscription_no_expiration_at_the_end_of_a_month - subscription has no expiration at the end of month. (0 - off, 1 - on, default - off). '''Only for Flat Rate'''. | * subscription_no_expiration_at_the_end_of_a_month - subscription has no expiration at the end of the month. (0 - off, 1 - on, default - off). '''Only for Flat Rate''' and '''Dynamic Flat-Rate'''. | ||
* ignore_balance - for Prepaid user subscription will be applied even if Prepaid User does not have sufficient balance (0 - off, 1 - on, default - off). | |||
* subscription_discount_percent - Subscription Discount Percent. Possible values are from 0 to 100. | |||
* subscription_charge_for_past - Charge for past, possible values are 0, 1 (where 0: no, 1: yes), default 0 | |||
<br><br> | |||
'''NOTE'''. When Flat-Rate Service is subscribed Subscription will be created for a full month. | |||
<br><br> | <br><br> | ||
Line 32: | Line 41: | ||
We send: | We send: | ||
HTML POST: http://<SERVER_IP>/billing/api/subscription_create?u= | HTML POST: http://<SERVER_IP>/billing/api/subscription_create?u=admin&service_id=10&user_id=2&subscription_memo=acc_one&hash=e0f93111f867ca5d424c0f0ebb6b678159086d00 | ||
'''* Note that username are not included in hash''' | '''* Note that username are not included in hash''' | ||
Line 44: | Line 53: | ||
<status> | <status> | ||
<success>Subscription was successfully created</success> | <success>Subscription was successfully created</success> | ||
<id>231</id> | |||
</status> | </status> | ||
</page> | </page> | ||
Line 50: | Line 60: | ||
---- | ---- | ||
'''Errors''' | '''Errors''' | ||
* <error>Access Denied</error> - | * <error>Access Denied</error> - user does not exist or cannot use this functionality. | ||
* <error>You are not authorised to use this functionality</error> - | * <error>You are not authorised to use this functionality</error> - accountant does not have Manage Subscription permission. | ||
* <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>User has insufficient balance</error> - Subscription price is bigger than Subscription User balance. | * <error>User has insufficient balance</error> - Subscription price is bigger than Subscription User balance. | ||
* <error> | * <error>Service was not found</error> - Service with specified service_id was not found. | ||
<br><br> | <br><br> | ||
=See also= | =See also= | ||
* [[MOR API]] | * [[MOR API]] | ||
* [[MOR API subscription delete]] | |||
* [[MOR API Subscriptions get]] | |||
* [[MOR API subscription update]] |
Latest revision as of 08:29, 15 March 2023
Deescription
MOR API Create subscription
Usage
- Call: /api/subscription_create
- Methods: POST, GET(if allowed, not recomended)
Parameters
Parameters which are included into hash:
- user_id - User ID . Required.
- service_id - Service ID. Required.
Parameters which are not included into hash:
- hash - SHA1 hash constructed using API_Secret_Key ( More described in Constructing hash). Required.
- u - username for authentication (admin, reseller, accountant). Required.
- subscription_start_period_day - Start Period on the day, possible values between 1 and 31, default 1.
- subscription_start_period_month - Start Period on the month, possible values between 1 and 12, default 1.
- subscription_charge_balance_on - Charge Balance on, possible values are 1,2,3 (where 1: Period Start, 2: Period End, 3: Every Day), default 1 (daily and one-time fee subscriptions inserted in the database as 3).
- subscription_activation_start - Unix timestamp of Subscription activation start.
- subscription_activation_end - Unix timestamp of Subscription activation end.
- subscription_memo - memo of Subscription.
- subscription_until_canceled - subscription is until canceled (0 - off, 1 - on, default - off).
- subscription_no_expiration_at_the_end_of_a_month - subscription has no expiration at the end of the month. (0 - off, 1 - on, default - off). Only for Flat Rate and Dynamic Flat-Rate.
- ignore_balance - for Prepaid user subscription will be applied even if Prepaid User does not have sufficient balance (0 - off, 1 - on, default - off).
- subscription_discount_percent - Subscription Discount Percent. Possible values are from 0 to 100.
- subscription_charge_for_past - Charge for past, possible values are 0, 1 (where 0: no, 1: yes), default 0
NOTE. When Flat-Rate Service is subscribed Subscription will be created for a full month.
Request
We have service_id = 10, user_id = 2, subscription_memo = acc_one, API Secret Key = 456789.
We send:
HTML POST: http://<SERVER_IP>/billing/api/subscription_create?u=admin&service_id=10&user_id=2&subscription_memo=acc_one&hash=e0f93111f867ca5d424c0f0ebb6b678159086d00
* Note that username are not included in hash
Returns
Success
<?xml version="1.0" encoding="UTF-8"?> <page> <status> <success>Subscription was successfully created</success> <id>231</id> </status> </page>
Errors
- <error>Access Denied</error> - user does not exist or cannot use this functionality.
- <error>You are not authorised to use this functionality</error> - accountant does not have Manage Subscription permission.
- <error>Incorrect hash</error> - Hash was not correct. Check API_Secret_Key and order or params while concatenating hash_string.
- <error>User has insufficient balance</error> - Subscription price is bigger than Subscription User balance.
- <error>Service was not found</error> - Service with specified service_id was not found.