src/Amadeus/Client/ResponseHandler/FOP/HandlerCreateFormOfPayment.php
public function analyze(SendResult $response)
    {
        $analyzeResponse = new Result($response);

        $domXpath = $this->makeDomXpath($response->responseXml);

        //General error level in the transmissionError location:
        $errorCodeNodeList = $domXpath->query(self::Q_G_ERR);

        if ($errorCodeNodeList->length > 0) {
            $errorCatNode = $domXpath->query(self::Q_G_CAT)->item(0);
            $analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));

            $code = $errorCodeNodeList->item(0)->nodeValue;
            $errorTextNodeList = $domXpath->query(self::Q_G_MSG);
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);

            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'general');
        }

        //FP level errors via the fopDescription/fpElementError data:
        $errorCodeNodeList = $domXpath->query(self::Q_F_ERR);

        if ($errorCodeNodeList->length > 0) {
            $errorCatNode = $domXpath->query(self::Q_F_CAT)->item(0);
            $analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));

            $code = $errorCodeNodeList->item(0)->nodeValue;
            $errorTextNodeList = $domXpath->query(self::Q_F_MSG);
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);

            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'fp');
        }

        //Deficient FOP level errors:
        $errorCodeNodeList = $domXpath->query(self::Q_D_ERR);

        if ($errorCodeNodeList->length > 0) {
            $errorCatNode = $domXpath->query(self::Q_D_CAT)->item(0);
            $analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));

            $code = $errorCodeNodeList->item(0)->nodeValue;

            $errorTextNodeList = $domXpath->query(self::Q_D_MSG);
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);

            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'deficient_fop');
        }

        //authorization failure:
        $errorCodeNodeList = $domXpath->query(self::Q_A_ERR);

        if ($errorCodeNodeList->length > 0) {
            $errorCatNode = $domXpath->query(self::Q_A_CAT)->item(0);
            $analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));

            $code = $errorCodeNodeList->item(0)->nodeValue;

            $errorTextNodeList = $domXpath->query(self::Q_A_MSG);
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);

            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'authorization_failure');
        }

        return $analyzeResponse;
    }
public function analyze(SendResult $response)
    {
        $analyzeResponse = new Result($response);

        $domXpath = $this->makeDomXpath($response->responseXml);

        //General error level in the transmissionError location:
        $errorCodeNodeList = $domXpath->query(self::Q_G_ERR);

        if ($errorCodeNodeList->length > 0) {
            $errorCatNode = $domXpath->query(self::Q_G_CAT)->item(0);
            $analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));

            $code = $errorCodeNodeList->item(0)->nodeValue;
            $errorTextNodeList = $domXpath->query(self::Q_G_MSG);
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);

            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'general');
        }

        //FP level errors via the fopDescription/fpElementError data:
        $errorCodeNodeList = $domXpath->query(self::Q_F_ERR);

        if ($errorCodeNodeList->length > 0) {
            $errorCatNode = $domXpath->query(self::Q_F_CAT)->item(0);
            $analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));

            $code = $errorCodeNodeList->item(0)->nodeValue;
            $errorTextNodeList = $domXpath->query(self::Q_F_MSG);
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);

            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'fp');
        }

        //Deficient FOP level errors:
        $errorCodeNodeList = $domXpath->query(self::Q_D_ERR);

        if ($errorCodeNodeList->length > 0) {
            $errorCatNode = $domXpath->query(self::Q_D_CAT)->item(0);
            $analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));

            $code = $errorCodeNodeList->item(0)->nodeValue;

            $errorTextNodeList = $domXpath->query(self::Q_D_MSG);
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);

            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'deficient_fop');
        }

        //authorization failure:
        $errorCodeNodeList = $domXpath->query(self::Q_A_ERR);

        if ($errorCodeNodeList->length > 0) {
            $errorCatNode = $domXpath->query(self::Q_A_CAT)->item(0);
            $analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));

            $code = $errorCodeNodeList->item(0)->nodeValue;

            $errorTextNodeList = $domXpath->query(self::Q_A_MSG);
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);

            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'authorization_failure');
        }

        return $analyzeResponse;
    }
public function analyze ( SendResult $ response ) { $ analyzeResponse = new Result ( $ response ) ; $ domXpath = $ this -> makeDomXpath ( $ response -> responseXml ) ; //General error level in the transmissionError location: $ errorCodeNodeList = $ domXpath -> query ( self :: Q_G_ERR ) ; if ( $ errorCodeNodeList -> length > 0 ) { $ errorCatNode = $ domXpath -> query ( self :: Q_G_CAT ) -> item ( 0 ) ; $ analyzeResponse -> setStatus ( $ this -> makeStatusForPotentiallyNonExistent ( $ errorCatNode ) ) ; $ code = $ errorCodeNodeList -> item ( 0 ) -> nodeValue ; $ errorTextNodeList = $ domXpath -> query ( self :: Q_G_MSG ) ; $ message = $ this -> makeMessageFromMessagesNodeList ( $ errorTextNodeList ) ; $ analyzeResponse -> messages [ ] = new Result \ NotOk ( $ code , trim ( $ message ) , 'general' ) ; } //FP level errors via the fopDescription/fpElementError data: $ errorCodeNodeList = $ domXpath -> query ( self :: Q_F_ERR ) ; if ( $ errorCodeNodeList -> length > 0 ) { $ errorCatNode = $ domXpath -> query ( self :: Q_F_CAT ) -> item ( 0 ) ; $ analyzeResponse -> setStatus ( $ this -> makeStatusForPotentiallyNonExistent ( $ errorCatNode ) ) ; $ code = $ errorCodeNodeList -> item ( 0 ) -> nodeValue ; $ errorTextNodeList = $ domXpath -> query ( self :: Q_F_MSG ) ; $ message = $ this -> makeMessageFromMessagesNodeList ( $ errorTextNodeList ) ; $ analyzeResponse -> messages [ ] = new Result \ NotOk ( $ code , trim ( $ message ) , 'fp' ) ; } //Deficient FOP level errors: $ errorCodeNodeList = $ domXpath -> query ( self :: Q_D_ERR ) ; if ( $ errorCodeNodeList -> length > 0 ) { $ errorCatNode = $ domXpath -> query ( self :: Q_D_CAT ) -> item ( 0 ) ; $ analyzeResponse -> setStatus ( $ this -> makeStatusForPotentiallyNonExistent ( $ errorCatNode ) ) ; $ code = $ errorCodeNodeList -> item ( 0 ) -> nodeValue ; $ errorTextNodeList = $ domXpath -> query ( self :: Q_D_MSG ) ; $ message = $ this -> makeMessageFromMessagesNodeList ( $ errorTextNodeList ) ; $ analyzeResponse -> messages [ ] = new Result \ NotOk ( $ code , trim ( $ message ) , 'deficient_fop' ) ; } //authorization failure: $ errorCodeNodeList = $ domXpath -> query ( self :: Q_A_ERR ) ; if ( $ errorCodeNodeList -> length > 0 ) { $ errorCatNode = $ domXpath -> query ( self :: Q_A_CAT ) -> item ( 0 ) ; $ analyzeResponse -> setStatus ( $ this -> makeStatusForPotentiallyNonExistent ( $ errorCatNode ) ) ; $ code = $ errorCodeNodeList -> item ( 0 ) -> nodeValue ; $ errorTextNodeList = $ domXpath -> query ( self :: Q_A_MSG ) ; $ message = $ this -> makeMessageFromMessagesNodeList ( $ errorTextNodeList ) ; $ analyzeResponse -> messages [ ] = new Result \ NotOk ( $ code , trim ( $ message ) , 'authorization_failure' ) ; } return $ analyzeResponse ; }
FOP_CreateFormOfPayment Analyze the result from the message operation and check for any error messages

@param SendResult $response
@return Result
@throws Exception
FOP_CreateFormOfPayment Analyze the result from the message operation and check for any error messages