Recurring payments
If a user makes a payment via bank card or Yandex.Money wallet, you can save the payment method (with all the payment details) and use it for recurring payments (autopayments). In this case, the user will only need to confirm the first payment, and all subsequent debits will be automatic.
 
Specifics
Recurring payments are only enabled by default in the demo store. If you want to enable them in your real store, contact the Yandex.Checkout manager.
Recurring payments are supported by all integration scenarios, except for Smart payment.
Payment methods that can be used for recurring payments:
  • Yandex.Money wallet;
  • arbitrary bank card, the details of which the user will specify during the payment process (if the user selects a card saved in Google Pay or Apple Pay or linked to wallet, Yandex.Checkout will be unable to save it).
The user can revoke their permission for recurring payments at any time.
 
Procedure
Step 1. Save the payment method by saving a Yandex.Money wallet or user’s bank card in your store. You can do that after a successful payment. After the user allows the means of payment to be saved in your store and confirms the debit, Yandex.Checkout will save the data used for the payment. The payment’s ID will be used as the saved payment method’s ID.
Step 2. Make an autopayment (recurring payment) by initiating the automatic debit from the means of payment saved in the store.
 
Saving the payment method
If you accept payments using the Yandex.Checkout widget, refer to the corresponding instruction for saving the payment method.
To save a payment method, create a payment for a bank card, Yandex.Money wallet, or payment token with the 
true
value of the 
save_payment_method
parameter. After that, proceed in the usual manner.
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": "2.00",
          "currency": "RUB"
        },
        "payment_method_data": {
          "type": "bank_card"
        },
        "confirmation": {
          "type": "redirect",
          "return_url": "https://www.merchant-website.com/return_url"
        },
        "description": "Order No. 72",
        "save_payment_method": "true"
      }'
To get the ID of the saved payment method:
Step 1. Wait until the user confirms the payment, and its status changes to 
succeeded
(or 
waiting_for_capture
if it’s a two-stage payment). You can check the payment status in a notification sent by Yandex.Checkout, or you can send periodic requests for payment information .
Step 2. Make sure the payment method is saved: the 
payment_method.saved
value in the payment object has changed to 
true
.
JSON
{
  "id": "22e18a2f-000f-5000-a000-1db6312b7767",
  "status": "succeeded",
  "paid": true,
  "amount": {
    "value": "2.00",
    "currency": "RUB"
  },
  "authorization_details": {
    "rrn": "10000000000",
    "auth_code": "000000"
  },
  "captured_at": "2018-07-18T17:20:50.825Z",
  "created_at": "2018-07-18T17:18:39.345Z",
  "description": "Order No. 72",
  "metadata": {},
  "payment_method": {
    "type": "bank_card",
    "id": "22e18a2f-000f-5000-a000-1db6312b7767",
    "saved": true,
    "card": {
      "first6": "555555",
      "last4": "4444",
      "expiry_month": "07",
      "expiry_year": "2022",
      "card_type": "MasterCard",
      "issuer_country": "RU",
      "issuer_name": "Sberbank"
    },
    "title": "Bank card *4444"
  },
  "refundable": true,
  "refunded_amount": {
    "value": "0.00",
    "currency": "RUB"
  },
  "recipient": {
    "account_id": "100001",
    "gateway_id": "1000001"
  },
  "test": false
}
Step 3. Save the 
payment_method.id
. You’ll need to use it as the identifier of the saved payment method for subsequent payments.
Done!
Now you can make recurring payments.
 
Processing
Using the saved payment method, you can initiate recurring payments, for example, as a regular charge for a subscription or an instant payment for purchases in your store, without the need to enter payment details.
To make an autopayment, create a payment  with a specified amount, transaction description, and the 
payment_method_id
parameter with the saved payment method ID. Such payments don’t require additional confirmation from the user.
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": "2.00",
          "currency": "RUB"
        },
        "payment_method_id": "<Saved payment method's ID>",
        "description": "Order No. 105"
      }'
After a successful payment, the 
payment_method
object will contain information about the payment details of the saved method used for the payment.
JSON
{
  "id": "255350c9-000f-5000-a000-1f211b3ea0a7",
  "status": "succeeded",
  "paid": true,
  "amount": {
    "value": "2.00",
    "currency": "RUB"
  },
  "authorization_details": {
    "rrn": "10000000000",
    "auth_code": "000000"
  },
  "captured_at": "2018-07-18T17:20:50.825Z",
  "created_at": "2018-07-18T17:18:39.345Z",
  "description": "Order No. 72",
  "metadata": {},
  "payment_method": {
    "type": "bank_card",
    "id": "22e18a2f-000f-5000-a000-1db6312b7767",
    "saved": true,
    "card": {
      "first6": "555555",
      "last4": "4444",
      "expiry_month": "07",
      "expiry_year": "2022",
      "card_type": "MasterCard",
      "issuer_country": "RU",
      "issuer_name": "Sberbank"
    },
    "title": "Bank card *4444"
  },
  "refundable": true,
  "refunded_amount": {
    "value": "0.00",
    "currency": "RUB"
  },
  "recipient": {
    "account_id": "100001",
    "gateway_id": "1000001"
  },
  "test": false
}
If the user revoked their permission for recurring payments from the Yandex.Money wallet, the payment won’t be processed. The 
cancellation_details
object will contain the reason behind the cancellation,
permission_revoked
.
JSON
{
    "id": "24a40656-000f-5000-9000-134108dd5325",
    "status": "canceled",
    "paid": false,
    "amount": {
        "value": "10.00",
        "currency": "RUB"
    },
    "created_at": "2019-06-25T10:08:22.531Z",
    "metadata": {},
    "payment_method": {
        "type": "yandex_money",
        "id": "249ea698-000f-5000-9000-1200128b882c",
        "saved": true
    },
    "recipient": {
        "account_id": "100001",
        "gateway_id": "1000001"
    },
    "refundable": false,
    "test": false,
    "cancellation_details": {
        "party": "yandex_checkout",
        "reason": "permission_revoked"
    }
}
 
See also
Yandex.Chekout widgetPayment processPayment methods