<?php

/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 2.0                   # ||
|| # ----------------------------------------- # ||
|| # Copyright 2021 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/

    require_once __DIR__.'yookassa/vendor/autoload.php';
    $source = file_get_contents("php://input");
    $requestBody = json_decode($source,true);
    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
    }
    $payment = $notification->getObject();
    $id = $payment->id;
?>
