Answer the question
In order to leave comments, you need to log in
How to process notifications in Yandex checkout?
Hello, I'm trying to process notifications from Yandex Checkout, the url in the personal account indicated where it should come.
I tried to make a POST request via postman, NULL
came in. I inserted a link from webhook.site into the personal account, everything comes up, but to my host, no (
$source = file_get_contents('php://input');
$requestBody = json_decode($source, true);
var_dump($requestBody);
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) {
// Обработка ошибок при неверных данных
}
$payment = $notification->getObject();
if($payment->getStatus() === PaymentStatus::SUCCEEDED) {
mysqli_query($connection, "UPDATE users SET UserBalance = UserBalance + '".$payment->amount->value."' WHERE UserEmail = '".$payment->description."'");
// Отправка сообщения
$mailTo = "[email protected]"; // Ваш e-mail
$subject = "На сайте совершен платеж"; // Тема сообщения
// Сообщение
$message = "Платеж на сумму: " . $payment->amount->value . "<br/>";
$message .= "Детали платежа: " . $payment->description . "<br/>";
$headers= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf-8\r\n";
$headers .= "From: [email protected] <[email protected]>\r\n";
mail($mailTo, $subject, $message, $headers);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question