{"status":"success","1":{"transaction":"8025400","email":"Не указана","amount":"21.38","currency":"RUB","currency_amount":"20.00","comission_percent":"6.90","comission_fixed":"0.00","amount_profit":"20.00","method":"Не выбран","payment_id":"1618399991","description":"Покупка доступа на 2 дня","date":"2023-03-13 19:40:46","pay_date":"2023-03-13 19:40:46","transaction_status":"0","custom_fields":"null","webhook_status":"0","webhook_amount":"0"}}
if (! isset( transaction_status=0 )) // Вот как тут правильно написать?
{
echo ' Статус транзакции = 0 ';
exit(0);
}
unset( transaction_status=0 ); // И тут аналогично
echo ' Статус транзакции не равен 0 ';
$response = '{"status":"success","1":{"transaction":"8025400","email":"Не указана","amount":"21.38","currency":"RUB","currency_amount":"20.00","comission_percent":"6.90","comission_fixed":"0.00","amount_profit":"20.00","method":"Не выбран","payment_id":"1618399991","description":"Покупка доступа на 2 дня","date":"2023-03-13 19:40:46","pay_date":"2023-03-13 19:40:46","transaction_status":"0","custom_fields":"null","webhook_status":"0","webhook_amount":"0"}}';
$data = json_decode($response, true);
$transaction_status = $data["1"]["transaction_status"];
if ($transaction_status == 0) {
echo 'Статус транзакции = 0';
exit(0);
} else {
echo 'Статус транзакции не равен 0';
}
<?php
$response = '{"status":"success","1":{"transaction":"8025400","email":"Не указана","amount":"21.38","currency":"RUB","currency_amount":"20.00","comission_percent":"6.90","comission_fixed":"0.00","amount_profit":"20.00","method":"Не выбран","payment_id":"1618399991","description":"Покупка доступа на 2 дня","date":"2023-03-13 19:40:46","pay_date":"2023-03-13 19:40:46","transaction_status":"0","custom_fields":"null","webhook_status":"0","webhook_amount":"0"}}';
$data = json_decode($response, true);
$transaction_status = $data["1"]["transaction_status"] ?? -1;
switch ($transaction_status) {
case -1:
echo 'Статус транзакции неизвестен';
exit(0);
case 0:
echo 'Статус транзакции = 0';
exit(0);
default:
echo 'Статус транзакции не равен 0';
}