Notifications
If you'd like to keep track of the status of objects (for example, of payments and refunds), you can subscribe to notifications (webhook, callback) about such events.
Notifications are useful for cases when the API object changes without your participation, for example, if the user needs to confirm the payment, the payment process might take from a few minutes to several hours. Instead of sending periodic GET requests  for the duration of this period, you can just wait for a YooMoney notification to learn about the status.
Available events
Changes in the status of objects are considered events in YooMoney. As soon as an event you're subscribed to occurs, you receive a notification. This notification contains all the information about the object at the moment when its status changed.
There are two types of events to which you can subscribe:
You need to configure notifications to start receiving them. After you receive a notification, you need to confirm that you received it. Learn more about using notifications
Basic events
You can subscribe to notifications about changes in the status of payments and refunds:
EventDescription
payment.waiting_for_capturepayment status changed to
waiting_for_capture
payment.succeededpayment status changed to
succeeded
payment.canceledpayment status changed to
canceled
refund.succeededrefund status changed to
succeeded
Safe deal events
If you use Safe deal, you can also subscribe to notifications about changes in the status of created deals and payouts:
EventDescription
deal.closeddeal status changed to
closed
payout.canceledpayout status changed to
canceled
payout.succeededpayout status changed to
succeeded
Safe deal events are not available to participants of the YooMoney partnership program.
Configuration
If you want to receive notifications from YooMoney, subscribe to them in the Merchant Profile. Specify the URL for notifications and events you want to track in the Integration — HTTP-notifications section.
The HTTPS protocol and TCP port 443 or 8443 must be used in the URL for notifications. Any TLS/SSL certificate is applicable: either self-signed or issued by the certificate authority. Supported TLS/SSL versions: 1.2 or higher.
For partners
If you’re taking part in the YooMoney for Business partnership program, you’ll need to subscribe to notifications via API.
You can only subscribe to basic events, you can't subscribe to Safe deal events.
Create a webhook object  for every event you want to track by specifying the event you want to subscribe to as well as the URL for notifications in the request .
You’ll need to create a separate set of webhooks for each OAuth token.
Example of request for creating webhook object
cURL
PHP
Python
curl https://api.yookassa.ru/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"
}
You can view the list of created webhooks  and remove  the ones you don’t need.
Notifications will only be sent for objects created by your app.
Implementation
After an event you’re subscribed to occurs, a notification will be sent to the URL that you specified during configuration. The notification will contains all the details of the object relevant at the time of the event.
Example of the payment.waiting_for_capture notification body
JSON
{
  "type": "notification",
  "event": "payment.waiting_for_capture",
  "object": {
    "id": "22d6d597-000f-5000-9000-145f6df21d6f",
    "status": "waiting_for_capture",
    "paid": true,
    "amount": {
      "value": "2.00",
      "currency": "RUB"
    },
    "authorization_details": {
      "rrn": "10000000000",
      "auth_code": "000000",
      "three_d_secure": {
        "applied": true
      }
    },
    "created_at": "2018-07-10T14:27:54.691Z",
    "description": "Order No. 72",
    "expires_at": "2018-07-17T14:28:32.484Z",
    "metadata": {},
    "payment_method": {
      "type": "bank_card",
      "id": "22d6d597-000f-5000-9000-145f6df21d6f",
      "saved": false,
      "card": {
        "first6": "555555",
        "last4": "4444",
        "expiry_month": "07",
        "expiry_year": "2021",
        "card_type": "MasterCard",
      "issuer_country": "RU",
      "issuer_name": "Sberbank"
      },
      "title": "Bank card *4444"
    },
    "refundable": false,
    "test": false
  }
}
You will need to confirm that you’ve received the notification. Reply with
200
HTTP code. YooMoney will ignore everything specified in the body or header of the response. Responses containing any other HTTP codes are considered invalid, and YooMoney will continue sending out the notification for the next 24 hours following the moment when the event occurred.
Notification authentication
You can check the authenticity of a notification, for example, by the object status or IP address. This will help you defend yourself against attacks based on fake notifications.
Object status authentication
Check the current status of the object to ensure that the status in the notification is up-to-date.
IP authentication
Check the IP address that the notification was sent from. YooMoney can send notifications from any of the following IP addresses:
  • 185.71.76.0/27
  • 185.71.77.0/27
  • 77.75.153.0/25
  • 77.75.156.11
  • 77.75.156.35
  • 77.75.154.128/25
  • 2a02:5180:0:1509::/64
  • 2a02:5180:0:2655::/64
  • 2a02:5180:0:1533::/64
  • 2a02:5180:0:2669::/64
Processing via SDKs
You can process notifications using our server SDKs:
  1. Obtain data from a POST request made by YooMoney.
  2. Create a notification class object depending on the event.
  3. Obtain the Payment object.
Example of processing notifications using an SDK
PHP
Python
// Obtain data from a POST request made by YooMoney.

<?php
    $source = file_get_contents('php://input');
    $requestBody = json_decode($source, true);
?>

// Create a notification class object depending on the event
// NotificationSucceeded, NotificationWaitingForCapture,
// NotificationCanceled,  NotificationRefundSucceeded

<?php
    use YooKassa\Model\Notification\NotificationSucceeded;
    use YooKassa\Model\Notification\NotificationWaitingForCapture;
    use YooKassa\Model\NotificationEventType;

    try {
      $notification = ($requestBody['event'] === NotificationEventType::PAYMENT_SUCCEEDED)
        ? new NotificationSucceeded($requestBody)
        : new NotificationWaitingForCapture($requestBody);
    } catch (Exception $e) {
        // Processing errors
    }
?>

// Obtain the Payment object

<?php
    $payment = $notification->getObject();
?>
Handling YooMoney widget events
The widget has its own events about which it can send notifications. You can handle these events to interact with the user after the payment is finished or after the pop-up window with the payment form gets closed.

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
Obtaining payment informationUsing SDKsPayment’s lifecycle