117
edits
Changes
no edit summary
==ТерминыTerms==
* '''РеселлерReseller''' – пользователь Ace Stream, которыйuser получилwho праваhas наgot продажуrights платныхto опцийsell paid Ace Stream options
* '''User key''' - Ace Stream user's ID
* '''Option''' - additional service / software service of Ace Stream, which can be activated for a specific user key
* '''App''' - reseller's product (site, mobile or desktop application), which is used to sell options
==How to become a reseller==
* войтиlog наin сайтto site https://accounts.acestream.net подusing своимyour логиномlogin (еслиif уyou васdo нетnot логинаhave the login, необходимоyou have to [https://accounts.acestream.net/register зарегистрироватьсяregister])
* выбратьchoose разделsection [https://accounts.acestream.net/partnership "СотрудничествоPartnership"] вin верхнемa менюtop menu
* click button "Become a reseller"
==API дляfor реселлеровResellers==
API for resellers allows you to activate different additional options for users of your apps.
A common scheme of work of API for resellers looks like this:
* to activate a required option for a user your app (site, mobile or desktop app) sends a request to Ace Stream server, in which specifies user's id, option and activation period
* the cost of specified option for the specified period is charged from your balance in Ace Stream system
* specified option is activated for the user whose id you specified in the request
To work with API you will need the following two identifiers:
* '''API key''' - string, used for reseller's ID in API requests
* '''API secret''' - секретныйsecret ключkey, которыйused используетсяfor дляa цифровойdigital подписиsignature запросовof API requests
You can find these identifiers in section Reseller -> API settings in a left menu. The reseller can change a secret key by themselves (button "Edit API settings").
==Creating apps==
To start working with API for resellers you have to create at least one app. To do this click button "Create a new application" in section Reseller -> Applications in the left menu. After this you will be proposed to fill fields "Name" (mandatory) and "Application's site"(optional).
All your apps can be seen in section Reseller -> Applications in a table with the following fields:
* Name - app's name that you specified when created the app
* APP_ID - app's identifier (it is used in API requests)
* Edit - edit the app (you can change app's name and site)
* OAuth - edit settings OAuth of this app
* API - open API-console of this app
You will need OAuth settings only if you plan to identify users using OAuth2 technology (usually, it is necessary for sites' owners).
API-console allows you to send requests on behalf of your application directly from site. The console is intended primarily to demonstrate the formation of requests to API (each request and response appear in text fields at the bottom of the page).
<span style="color: #a00;">Attention!</span> API-console is not an emulator of requests - all requests are real and are sent to production-servers. It means that when some paid option is activated from console money will be withdrawn from your balance. If you would like to work with API for resellers in a test mode, use [[Reseller_API_Sandbox|sandbox]].
==Options activation reminder==
App engine can notice user about missing options. Notification method depends on API you choose:
* дляmore пользователейabout Engine API описание [[Engine_API#example-missing-option-on-start|здесьhere]]
* дляmore пользователейabout HTTP API описание [[Engine_HTTP_API#stop-notifications|здесьhere]]
==Activation of options for users==
* API key
* APP_ID (идентификаторapplication приложенияidentifier)
* user key
* option ID
* ID of period for which an option has to be activated
If the request was successful a certain amount of money will be charged from reseller's balance, and the option for the requested period will be activated.
If a specified option is already activated at this moment, then validation period of the option will continue for a stated period.
API Key иand APP_ID выyou можетеcan узнатьfind наout сайтеon вthe разделеsite in section [https://accounts.acestream.net/reseller РеселлерReseller].
Identifiers of options and periods are described [[Reseller_API|here]]
As it is seen from the description, to activate options reseller has to know user key. This key can be obtained in two ways: either via OAuth2 protocol, or to create a new key using API for resellers. The first method is more suitable for sites' owners. The second - for apps' developers. Both methods are described below.
==Work scheme for sites' owners==
Sites' owners can get user key using OAuth2 protocol. To do this they have to do the following steps:
* reseller places on his site a button "Log in with Ace Stream"
* after pressing this button everything goes according to OAuth2:
** user is redirected to Ace Stream site
** if he's not registered, he registers
** if he's registered, but not logged in, he logs in
** if user logs in to reseller's site via Ace Stream OAuth2 at the first time, he agrees to provide some of his personal data to reseller's site (email and user key)
** user goes back to reseller's site
** reseller's site receives email and user key according to OAuth2
* now user is authorized at reseller's site, and the reseller has user key, by which he can activate the option for user
More detailed information about OAuth2 is [[OAuth2/en|here]].
==Work scheme for apps' developers==
Apps' developers usually have access to [[Engine_Service_API/en|Engine service API]]. It gives them ability to upload user keys directly to Ace Stream Engine and activate options without direct user intervention.
We propose the following work scheme:
* приложениеapp проверяет,checks активирована лиwhether необходимаяthe опцияrequired уoption пользователяis activated ([[Engine_Service_API#check_user_service|check_user_service]])
* еслиif опцияthe неoption активированаis not activated, приложениеapp creates создаетa новыйnew ключuser пользователяkey ([[Reseller_API#createUserKey|createUserKey]]) иand загружаетuploads егоit вto Ace Stream Engine ([[Engine_Service_API#load_extension|load_extension]])
* приложениеapp активируетactivates нужнуюa опциюrequired дляoption новогоfor ключаa пользователяnew user key ([[Reseller_API#activateService|activateService]])
Described scheme assumes that reseller's app and Ace Stream Engine are run on the same device.