protected function handleQueryResponse(Transaction $transaction, $data)
    {
        $result = $transaction->getResult();
        $parentResult = $transaction->getParent()->getResult();
        $eventResult = null;

        foreach ($data->Results as $event) {
            if ($event->TransAct_ReferenceID === $parentResult->getExternalId()) {
                $eventResult = $event;

                // We don't break in case the transaction has multiple events in the same query-- we want the latest
            }
        }

        $resultType = $parentResult->getStatus()->getValue();

        if (null !== $eventResult) {
            switch ($eventResult->ResultingStatus) {
                case 'Scheduled':
                    $resultType = Result\ResultStatus::PENDING;
                    break;

                case 'Cancelled':
                    $resultType = Result\ResultStatus::CANCELLED;
                    break;

                case 'In-Process':
                    $resultType = Result\ResultStatus::PROCESSED;
                    break;

                case 'Cleared':
                    $resultType = Result\ResultStatus::APPROVED;
                    break;

                case 'Failed Verification':
                case 'Returned-NSF':
                case 'Returned-Other':
                    $resultType = Result\ResultStatus::DECLINED;
                    break;

                case 'Charged Back':
                    $resultType = Result\ResultStatus::CHARGED_BACK;
                    break;

                case 'Merchant Hold':
                case 'Processor Hold':
                    $resultType = Result\ResultStatus::HOLD;
                    break;
            }
        }

        $result->setStatus(new Result\ResultStatus($resultType));
    }