Answer the question
In order to leave comments, you need to log in
Why, after a successful payment for Yukassa, an error is generated when receiving a Notification?
what is the error please
string(0) ""
Fatal error: Uncaught TypeError: Argument 1 passed to YandexCheckout\Model\Notification\NotificationWaitingForCapture::__construct() must be of the type array, null given, called in /var/www/u0015789/data/www/ddeducate.ru/pay.php on line 52 and defined in /var/www/u0015789/data/www/ddeducate.ru/lib/Model/Notification/NotificationWaitingForCapture.php:72 Stack trace: #0 /var/www/u0015789/data/www/ddeducate.ru/pay.php(52): YandexCheckout\Model\Notification\NotificationWaitingForCapture->__construct(NULL) #1 {main} thrown in /var/www/u0015789/data/www/ddeducate.ru/lib/Model/Notification/NotificationWaitingForCapture.php on line 72
<form id="kassa-form" class='dar-kassa' action="/payac.php" method="POST">
<label for="">ФИО: </label>
<input class='' type="fio" name="fio" required placeholder="Ваше ФИО"><br>
<label for="">E-mail: </label>
<input class='' type="email" name="email" required placeholder="Ваш E-mail"><br>
<input class='dar-oplata-kassa-button' type="submit" name="submit" value="Оплатить">
</form>
<?Php
session_start();
include_once( 'connect_db.php' );
require __DIR__ . '/lib/autoload.php';
use YandexCheckout\Client;
$sum = 3500;
$fio = $_POST['fio'];
$email = $_POST["email"];
$_SESSION['em'] = $email;
?>
<?Php
if( !empty($sum) && !empty($fio) && !empty($email)) {
$description = 'ФИО: '.$fio.'<br>E-mail: '.$email;
$client = new Client();
$client->setAuth('11111', 'sfjiesifjiejfejfisefjeoifjseoifjseif');
$payment = $client->createPayment(
array(
'amount' => array(
'value' => $sum,
'currency' => 'RUB',
),
'confirmation' => array(
'type' => 'redirect',
'return_url' => 'https://ddeducate.ru/pay.php',
),
'capture' => true,
'description' => $description,
),
uniqid('', true)
);
header('Location: '. $payment["confirmation"]["confirmation_url"]);
?>
<p>Сейчас вы будете перенаправлены на страницу оплаты, если этого не произошло нажмите на ссылку ниже:</p>
<p><a href="<?=$payment["confirmation"]["confirmation_url"];?>">Оплатить</a></p>
<?Php } else { ?>
<p>Произошла ошибка. Попробуйте еще раз.</p>
<?}?>
require __DIR__ . '/lib/autoload.php';
// Получите данные из POST-запроса от Яндекс.Кассы
$source = file_get_contents('php://input');
$requestBody = json_decode($source, true);
var_dump($source);
// Создайте объект класса уведомлений в зависимости от события
// NotificationSucceeded, NotificationWaitingForCapture,
// NotificationCanceled, NotificationRefundSucceeded
use YandexCheckout\Model\Notification\NotificationSucceeded;
use YandexCheckout\Model\Notification\NotificationWaitingForCapture;
use YandexCheckout\Model\NotificationEventType;
use YandexCheckout\Model\PaymentStatus;
try {
$notification = ($requestBody['event'] === NotificationEventType::PAYMENT_SUCCEEDED)
? new NotificationSucceeded($requestBody)
: new NotificationWaitingForCapture($requestBody);
} catch (Exception $e) {
// Обработка ошибок при неверных данных
}
// Получите объект платежа
$payment = $notification->getObject();
if($payment->getStatus() === PaymentStatus::SUCCEEDED) {
$emm = $_SESSION['em'];
sendMessageEmail( $emm );
unset( $_SESSION['em'] );
header("Location: https://t.me/joinchat");
}
Answer the question
In order to leave comments, you need to log in
If you start with the simplest, then I would look here -
<input class='' type="fio" name="fio" required placeholder="Ваше ФИО"><br>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question