Quick start
The Yandex.Checkout API allows accepting online payments in the web and mobile apps. This article will help you accept your first payment, and your customers will be able to access all of the payment methods you’ve implemented.
 Preparation
To start working with Yandex.Checkout, you need to sign up and get access to Merchant Profile. To authenticate requests in the API, you will need a secret key and the Shop ID from the Merchant Profile.
You can make this payment in the demo store. Demo store has its own ID (start with the test_ prefix) and secret key (you can find it in the Merchant Profile). The payment process in the demo store is identical to the actual payment process, except the money is not transferred anywhere. You can only test two payment methods: bank cards and Yandex.Money.
 Step 1. Create a payment
Payment is the main entity of the Yandex.Checkout API. To create a payment, you will need the payment amount and the URL for redirecting the user after they complete the payment. You will also need to send the 
capture
parameter with the 
true
value so that you will receive the money immediately after the payment (if the value is 
false
, the required amount will be held on the user’s account, and you’ll be able to debit it whenever it’s convenient for you).
If you want to add a payment description that’ll be displayed in the Merchant Profile to you, and during the payment to the user, include it in the 
description
parameter. The description must not exceed 128 characters.
Send a request to Yandex.Checkout and include data for creating a payment, data for authentication (Shop ID and secret key) and the idempotence key (any random value).
All requests to the Yandex.Checkout API must be sent from your server. You can use ready-made server SDKs to interact with Yandex.Checkout.
Example of request for payment creation
cURL
PHP
Python
curl https://payment.yandex.net/api/v3/payments \
  -X POST \
  -u <Shop ID>:<Secret Key> \
  -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"
      }'
 Step 2. Redirect the user to the payment page
In the body of the response from Yandex.Checkout, you will receive a created payment object  with the 
pending
status. Redirect the user to the 
confirmation_url
so they could make a payment.
Redirect is the main confirmation scenario for user payments. In some cases, user confirmation is not required or is processed by another scenario.
Example of a created payment object
JSON
{
  "id": "23d93cac-000f-5000-8000-126628f15141",
  "status": "pending",
  "paid": false,
  "amount": {
    "value": "100.00",
    "currency": "RUB"
  },
  "confirmation": {
    "type": "redirect",
    "confirmation_url": "https://money.yandex.ru/api-pages/v2/payment-confirm/epl?orderId=23d93cac-000f-5000-8000-126628f15141"
  },
  "created_at": "2019-01-22T14:30:45.129Z",
  "description": "Order No. 1",
  "metadata": {},
  "recipient": {
    "account_id": "100001",
    "gateway_id": "1000001"
  },
  "refundable": false,
  "test": false
}
If you’re creating a payment for the demo store, use one of the test cards for the payment, for example, 5555555555554444 (use any CVC and future date).
After a successful payment (or if something goes wrong), Yandex.Checkout will return the user to 
return_url
that you specified during payment creation.
 Step 3. Wait for the successful payment completion
Payment can be considered completed once its status changes to 
succeeded
. If the user decides not to proceed with the payment or if something goes wrong, the payment status will change to 
canceled
.
You can check the payment status by subscribing to the notifications from Yandex.Checkout.
You can also track status changes by requesting payment information  with a convenient frequency (for example, after the user returns to 
return_url
). For that, you will need the payment ID (value of the 
id
parameter in the created payment object).
Great, you have accepted your first payment!
In this example, the user selected the payment method and entered the payment details on the Yandex.Checkout’s side. This scenario is called Smart payment. If it doesn’t suit your mode of operation, you can use another integration scenario.
Remember: to accept real payments, you will need to use the ID and secret key of your real store.
 See also
Integration scenariosDeclined paymentsPayment methodsPayment by 54-FZNotifications