Quick start
The partnership program allows you interact with the YooMoney API on behalf of a YooMoney user.
This article will help you accept the first payment in favor of another person in three steps:
  1. Register your app in YooMoney's OAuth server.
  2. Get a payment processing permission from the store.
  3. Make a payment via the YooMoney API.
 
Step 1. Register the app in YooMoney
To interact with YooMoney API, register your app in the YooMoney's OAuth server.
During the registration process:
  • Specify the app’s name (for example, “Test app”), it's description and link to your website.
  • Select using the Callback URL and specify URL for the user redirection.
  • Find the section with the YooMoney API rights and select the payment creation right.
On the following page, you will see your app’s properties. Save the app’s ID (Client ID), and password (Client Secret).
Properties of the created app
 
Step 2. Get a payment processing permission
You will make payments to the YooMoney’s demo store, which requires an OAuth token, the permission for carrying out transactions. The process of OAuth authorization in YooMoney is based on the OAuth 2.0 open protocol.
 
1. Access the demo store
To access the demo store, sign up for YooMoney:
  • sign in to your YooMoney account used for registration in the OAuth server;
  • during the registration process, specify your company’s Taxpayer Identification Number (INN).
You don’t need to enter into a contract and complete the full registration cycle.
Create a demo store in your Merchant Profile.
 
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://yookassa.ru/oauth/v2/authorize
Example of URL for redirecting the user
https://yookassa.ru/oauth/v2/authorize?response_type=code&client_id=<App ID>&state=test-user
Send the 
code
authorization type in the URL for redirection and specify your app’s ID (
client_id
), as well as the ID of the user or session in which the rights are being granted (
state
).
 
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 YooMoney account linked to the YooMoney demo store.
  2. Follow the link you generated on the previous step.
  3. Allow the app to create payments.
  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 authorization 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
http://www.example.com/app?code=rvunUlge6gUMx6TT0UT6ys4y398qqG73KQb1PjXETuX6eiQYJXXi-IrNHe49a9mt&state=test-user
 
4. Obtain an OAuth token
To exchange the authorization code to an OAuth token, send a POST request to the OAuth server and specify the authorization code (
code
parameter), your ID, and the password that your received after the registration in YooMoney's OAuth server.
URL for sending the request:
https://yookassa.ru/oauth/v2/token
The code is valid for 5 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://yookassa.ru/oauth/v2/token \
  -u <App ID>:<App password> \
  -d grant_type=authorization_code \
  -d code=<Authorization code>
In response, the YooMoney’s OAuth server will return the OAuth token in the 
access_token
field. Save it for further interaction with the YooMoney API.
Example of response body with the OAuth token
JSON
{
  "access_token": "AAEAAAAA8cSwPQAAAXUcZAXZ9hmYP3bKvY2r3ALwPYRYhrnOiKDEou9aLKiLYArHj2Tke-syRshb-1TQ1Ns_nQbc",   
  "expires_in": 94607999
}
 
Step 3. Make a payment
 
1. Check the store’s settings
Before using the YooMoney API, you must check the settings of the store you obtained the OAuth token for. The settings affect the number of YooMoney 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://api.yookassa.ru/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,
  "payment_methods": [
    "bank_card",
    "yoo_money"
  ],
  "status": "enabled"
}
 
2. 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://api.yookassa.ru/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"
      }'
Wait for the
succeeded
 payment status: send periodic requests for payment information .
Done!
You made your first payment to YooMoney 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.

Do you have any questions or comments regarding the documentation?

We can set up a call and discuss them: we'll help you solve the problem and you'll help us understand what we need to improve. To do that, share your contact information and select the time.
Yes, I'd like to set up a meeting
 
See also
OAuth authorizationNotificationsPayment processPayment by 54-FZ