Quick start
The partnership program allows you interact with the Yandex.Checkout API on behalf of a Yandex.Checkout user.
This article will help you accept the first payment in favor of another person in four steps:
  1. Become a Yandex.Checkout partner.
  2. Register your app in Yandex.OAuth.
  3. Get a payment processing permission from the store.
  4. Make a payment via the Yandex.Checkout API.
 Step 1. Become a Yandex.Checkout partner
Join the Yandex.Checkout partnership program: invite new users to Yandex.Checkout and get a percentage of their turnover.
Send a request for registration to agents@yamoney.ru to join the partnership program. In the request, tell us about your company and which Yandex.Checkout features you want to use. The Yandex.Checkout manager will contact you with the further instructions.
Registration requires a Yandex login.
 Step 2. Register the app in Yandex.OAuth
To interact with the OAuth server, register your app in Yandex.OAuth:
  1. Sign in to your Yandex account used for registration in the partnership program.
  2. Click the Create new client button on the Yandex.OAuth page.
    App registration
  3. On the following page, specify the app’s name (for example, “Test app”).
  4. Select Web services in the Platforms section and specify the Callback URL. If you don’t have one, use the URL for development offered by Yandex.OAuth.
  5. Find the section with the Yandex Payout Solution rights in the Permissions section and select the Creation of Yandex.Checkout payments right.
    The set of rights for interacting with Yandex.Checkout is available only to those who’ve joined the partnership program.
  6. Click the Create app button.
On the following page, you will see your app’s properties. Save the app’s ID, password, and Callback URL.
Properties of the created app
 Step 3. Get a payment processing permission
You will make payments to the Yandex.Checkout’s demo store, which requires an OAuth token, the permission for carrying out transactions. The process of OAuth authorization in Yandex.Checkout is based on the OAuth 2.0 open protocol.
 1. Access the demo store
To access the demo store, sign up for Yandex.Checkout:
  • sign in to your Yandex account used for registration in the partnership program;
  • during the registration process, specify your company’s Taxpayer Identification Number (INN);
  • select the API (for self-made websites) integration method in the settings.
You don’t need to enter into a contract and complete the full registration cycle.
 2. Create the URL for redirection
The user will be able to grant the rights to a store after you redirect them to the OAuth server:
https://oauth.yandex.com/authorize
Example of URL for redirecting the user
https://oauth.yandex.com/authorize?response_type=code&client_id=<App ID>&device_id=123456&state=test-user
Send the 
code
confirmation type in the URL for redirection and specify your app’s ID (
client_id
), unique shop ID you’re requesting access for (
device_id
), as well as the ID of the user or session in which the rights are being granted (
state
).
Please note:
  • Shop ID (
    device_id
    ) allows creating tokens if the user has several stores connected to Yandex.Checkout. You can use any unique value with the length of 6 to 50 characters that includes only printable ASCII characters (with codes from 32 to 126).
  • User or session ID (
    state
    ) is returned in the response from the Yandex’s OAuth server.
More about the parameters of the URL for confirmation
 3. Provide the app with the access to demo store
Allow the app to create payments for the demo store:
  1. Sign in to your Yandex account linked to the Yandex.Checkout demo store.
  2. Follow the link you generated on the previous step.
  3. Allow the app to create payments.
    Granting rights to the app
  4. Select the store that you allow to create payments and grant access to it.
    Selecting the store
Afterwards, the OAuth server will redirect you to Callback URL that you specified during the app registration. The link will include the confirmation code and the ID of the user that granted you the rights (
state
value that you specified in the request).
Example of the URL you will be redirected to in case of success
https://oauth.yandex.com/verification_code?state=test-user&code=6404702
 4. Obtain an OAuth token
To exchange the confirmation code to an OAuth token, send a POST request to the Yandex’s OAuth server and specify the confirmation code (
code
parameter), your ID, and the password that your received after the registration in Yandex.OAuth.
URL for sending the request:
https://oauth.yandex.com/token
The code is valid for 10 minutes. You must exchange it to an OAuth token within this period, otherwise you will have to request it again.
Example of request
cURL
curl https://oauth.yandex.ru/token \
  -u <App ID>:<App password> \
  -d grant_type=authorization_code \
  -d code=<Authorization code>
In response, the Yandex’s OAuth server will return the OAuth token in the 
access_token
field. Save it for further interaction with the Yandex.Checkout API.
Example of response body with the OAuth token
JSON
{
  "token_type": "bearer",
  "access_token": "AQAAAACy1C6ZAAAAfa6vDLuItEy8pg-iIpnDxIs",
  "expires_in": 124234123534,
  "refresh_token": "1:GN686QVt0mmakDd9:A4pYuW9LGk0_UnlrMIWklkAuJkUWbq27loFekJVmSYrdfzdePBy7:A-2dHOmBxiXgajnD-kYOwQ"
}
 Step 4. Make a payment
 1. Check the store’s settings
Before using the Yandex.Checkout API, you must check the settings of the store you obtained the OAuth token for. The settings affect the number of Yandex.Checkout options available for you. For example, if it’s the demo store, you’ll be able to make only test payments.
To check the settings, send the request for obtaining the store information  with the OAuth token.
Example of request
cURL
PHP
Python
curl https://payment.yandex.net/api/v3/me \
  -H 'Authorization: Bearer <oauth_token>'
Store settings 
will be returned in response.
Example of the response body
JSON
{
  "account_id": "123",
  "test": true,
  "fiscalization_enabled": false
}
 2. Subscribe to notifications (optional)
You can subscribe to notifications from Yandex.Checkout: specify the 
payment.succeeded
event in the request  (payment status changed to 
succeeded
) and the URL for notifications.
URL for notifications must start with https.
Minimum version of SSL/TLS is TLS v1.2
Example of request for creating webhook object
cURL
PHP
Python
curl https://payment.yandex.net/api/v3/webhooks \
  -X POST \
  -H 'Authorization: Bearer <oauth_token>' \
  -H 'Idempotence-Key: <Idempotence Key>' \
  -H 'Content-Type: application/json' \
  -d '{
        "event": "payment.succeeded",
        "url": "https://www.merchant-website.com/notification_url"
      }'
Example of the response body
JSON
{
  "id": "wh-e44e8088-bd73-43b1-959a-954f3a7d0c54",
  "event": "payment.succeeded",
  "url": "https://www.merchant-website.com/notification_url"
}
 3. Make a test payment
Make your first payment to the demo store. Use Quick start for creating payments. Specify the OAuth token instead of Shop ID and secret key.
Example of request for payment creation
cURL
PHP
Python
curl https://payment.yandex.net/api/v3/payments \
  -X POST \
  -H 'Authorization: Bearer <oauth_token>' \
  -H 'Idempotence-Key: <Idempotence Key>' \
  -H 'Content-Type: application/json' \
  -d '{
        "amount": {
          "value": "100.00",
          "currency": "RUB"
        },
        "capture": true,
        "confirmation": {
          "type": "redirect",
          "return_url": "https://www.merchant-website.com/return_url"
        },
        "description": "Order No. 1"
      }'
If you’ve subscribed to notifications, Yandex.Checkout will notify you when the payment status changes to 
succeeded
.
Done!
You made your first payment to Yandex.Checkout on behalf of a store. Now you can expand the set of rights for your app, implement another payment scenario, or support payment by 54-FZ.
In the demo store, you can only test two payment methods.
 See also
OAuth authorizationNotificationsPayment processPayment by 54-FZ