status->isOpen() && !$config->enabled) { $order = $this->repository->markCanceled($order, RejectionReason::GatewayDisabled); } $code = match ($order->status) { TransactionStatus::Paid => ResultCode::Paid, // Failed — оплата у сервиса прошла, не удалась доставка: новую оплату // по этому заказу не начинаем, повтор Pay URL её доставит. TransactionStatus::Canceled, TransactionStatus::Failed => ResultCode::Rejected, TransactionStatus::New, TransactionStatus::Pending => $notification->getAmount() === null ? ResultCode::WithAmount : ResultCode::AwaitingPayment, }; if ($order->status === TransactionStatus::New) { $order = $this->repository->markPending($order); } $response = new CheckResponse( accountId: $config->accountNumber, transactionId: $notification->getTransactionId(), amount: $order->amount, resultCode: $code, signature: $config->signature(), cms: CmsInfo::getCmsModuleVersion(), ); if (!$order->snapshot->fiscalization) { return $response->toXml(); } try { return $response->toJson($order->snapshot->receipt); } catch (\InvalidArgumentException) { $this->repository->noteError($order, RejectionReason::Receipt); return CallbackResponse::fail(); } } }