Old versions of the API
Help
Sign up for YooMoney
Saving payment methods for recurring payments
Using the YooMoney Checkout Widget, you can save payment methods and use them for recurring payments, for example, as a monthly charge for a subscription.

Recurring payments are only enabled by default in the demo store. If you want to enable them in your real store, contact the YooMoney manager.

If you’re allowed to use autopayments, you can process payments:
Payment with the payment method saved
By saving the payment method, you can save a bank card, YooMoney wallet, Mir Pay, SberPay, T-Pay, or FPS in your store.

If you use the FPS, learn more about processing payments via FPS.

Using the widget, you can process payments and save the payment method unconditionally or conditionally.
Payment method is saved unconditionally when the method is saved by default and the user can’t affect this. The process is as follows:
  1. On your website, you place the warning for the user alerting them that you will save their payment details and explaining how you will use it (for example, the frequency and amounts of your future debits) and how the user can disable recurring charges in your store. On your side, you receive the user’s consent to make autopayments.
  2. The widget displays the payment methods that support unconditional saving to the user and warns that after payment, the payment method will be linked to your store. Upon successful payment, the payment method data will be automatically saved in YooMoney.
Payment methods that support unconditional saving: YooMoney wallet, bank card, Mir Pay, SberPay, T-Pay, FPS.
Example of usage: subscription for regular payments.
Payment with the payment method saved unconditionally
Payment with the payment method saved unconditionally
Payment method is saved conditionally when the method is saved by the user’s request. The process is as follows:
  1. On your website, you let the user know that they can save their payment details and explain how you will use it and how the user can disable the option.
  2. The widget displays all available payment methods to the user. If the user selects a payment method that supports conditional saving, the widget will offer them to save the payment details in your store. If the user agrees, then upon successful payment, the payment method information will be saved in YooMoney, and you will be able to use the saved payment method ID for subsequent payments. If the user refuses, the information will not be saved in the store after the payment.
Payment methods that support conditional saving: YooMoney wallet, bank card.
Example of usage: saving a means of payment in the store to speed up the payment process for subsequent payments with independent implementation of the payment method selection screen.

If you want to use the predesigned selection screen and save only user’s bank cards, use the option to save the user’s bank cards.

Payment with the payment method saved conditionally
Payment with the payment method saved conditionally
Payment with the payment method saved unconditionally
Step 1. Create a payment and specify save_payment_method parameter with the true value.
cURL
PHP
Python
curl https://api.yookassa.ru/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"
        },
        "confirmation": {
          "type": "embedded"
        },
        "capture": true,
        "save_payment_method": true,
        "description": "Order No. 72"
      }'
Step 2. YooMoney will respond with confirmation_token, the token for initializing the widget.
JSON
{
  "id": "25564507-000f-5000-9000-19878c91d156",
  "status": "pending",
  "paid": false,
  "amount": {
    "value": "2.00",
    "currency": "RUB"
  },
  "confirmation": {
    "type": "embedded",
    "confirmation_token": "ct-25564507-000f-5000-9000-19878c91d156"
  },
  "created_at": "2019-11-07T14:59:19.351Z",
  "description": "Order No. 72",
  "metadata": {},
  "recipient": {
    "account_id": "100500",
    "gateway_id": "100700"
  },
  "refundable": false,
  "test": false
}
Step 4. Process the payment in the usual manner.
If the payment is processed successfully, you will receive the saved payment method’s ID.
Payment with the payment method saved conditionally
Step 1. Create a payment (no need to include save_payment_method).
cURL
PHP
Python
curl https://api.yookassa.ru/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"
        },
        "confirmation": {
          "type": "embedded"
        },
        "capture": true,
        "description": "Order No. 72"
      }'
Step 2. YooMoney will respond with confirmation_token, the token for initializing the widget.
JSON
{
  "id": "25564507-000f-5000-9000-19878c91d156",
  "status": "pending",
  "paid": false,
  "amount": {
    "value": "2.00",
    "currency": "RUB"
  },
  "confirmation": {
    "type": "embedded",
    "confirmation_token": "ct-2557c659-000f-5000-9000-12714806d854"
  },
  "created_at": "2019-11-07T14:59:19.351Z",
  "description": "Order No. 72",
  "metadata": {},
  "recipient": {
    "account_id": "100500",
    "gateway_id": "100700"
  },
  "refundable": false,
  "test": false
}
Step 4. Process the payment in the usual manner.
If the payment is processed successfully, you will receive the saved payment method’s ID.
Getting the saved payment method’s ID
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 YooMoney, 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": "25564507-000f-5000-9000-19878c91d156",
  "status": "succeeded",
  "paid": true,
  "amount": {
    "value": "2.00",
    "currency": "RUB"
  },
  "authorization_details": {
    "rrn": "10000000000",
    "auth_code": "000000",
    "three_d_secure": {
      "applied": true
    }
  },
  "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": "25564507-000f-5000-9000-19878c91d156",
    "saved": true,
    "card": {
      "first6": "555555",
      "last4": "4444",
      "expiry_month": "07",
      "expiry_year": "2022",
      "card_type": "Mir",
      "card_product": {
          "code": "MCP",
          "name": "MIR Privilege"
      },
      "issuer_country": "RU",
      "issuer_name": "Sberbank"
    },
    "title": "Bank card *4444"
  },
  "refundable": true,
  "refunded_amount": {
    "value": "0.00",
    "currency": "RUB"
  },
  "recipient": {
    "account_id": "100500",
    "gateway_id": "100700"
  },
  "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. You’ll need to implement payments with a saved payment method independently.
Payments without saving the payment method
You can process payments without saving the payment method. The user can pay via any available payment methods. The method won’t be saved.
To process a payment without saving the payment method:
Step 1. Create a payment and specify the save_payment_method parameter with the false value.
cURL
PHP
Python
curl https://api.yookassa.ru/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"
        },
        "confirmation": {
          "type": "embedded"
        },
        "capture": true,
        "save_payment_method": false,
        "description": "Order No. 72"
      }'
Step 2. YooMoney will respond with confirmation_token, the token for initializing the widget.
JSON
{
  "id": "25564507-000f-5000-9000-19878c91d156",
  "status": "pending",
  "paid": false,
  "amount": {
    "value": "2.00",
    "currency": "RUB"
  },
  "confirmation": {
    "type": "embedded",
    "confirmation_token": "ct-25564507-000f-5000-9000-19878c91d156"
  },
  "created_at": "2019-11-07T14:59:19.351Z",
  "description": "Order No. 72",
  "metadata": {},
  "recipient": {
    "account_id": "100500",
    "gateway_id": "100700"
  },
  "refundable": false,
  "test": false
}
Step 4. Process the payment in the usual manner.
See also
Saving the user’s bank cards
Legal information
Terms and Conditions of the YooMoney ServiceElectronic Document Flow Agreement
+7 (495) 974-35-86
Ask a questionHelp
© 2024, "YooMoney", NBCO LLC