src/Genesis/API/Response.php
public function parseResponse($response)
    {
        $this->responseRaw = $response;

        try {
            $parser = new \Genesis\Parser('xml');
            $parser->skipRootNode();
            $parser->parseDocument($response);

            $this->responseObj = $parser->getObject();
        } catch (\Exception $e) {
            throw new \Genesis\Exceptions\InvalidResponse(
                $e->getMessage(),
                $e->getCode()
            );
        }

        // Apply per-field transformations
        $this->transform([$this->responseObj]);

        if (isset($this->responseObj->status)) {
            $state = new Constants\Transaction\States($this->responseObj->status);

            if (!$state->isValid()) {
                throw new \Genesis\Exceptions\InvalidArgument(
                    'Unknown transaction status',
                    isset($this->responseObj->code) ? $this->responseObj->code : 0
                );
            }

            if ($state->isError() && !$this->suppressReconciliationException()) {
                throw new \Genesis\Exceptions\ErrorAPI(
                    $this->responseObj->message,
                    isset($this->responseObj->code) ? $this->responseObj->code : 0
                );
            }
        }
    }
public function parseResponse($response)
    {
        $this->responseRaw = $response;

        try {
            $parser = new \Genesis\Parser('xml');
            $parser->skipRootNode();
            $parser->parseDocument($response);

            $this->responseObj = $parser->getObject();
        } catch (\Exception $e) {
            throw new \Genesis\Exceptions\InvalidResponse(
                $e->getMessage(),
                $e->getCode()
            );
        }

        // Apply per-field transformations
        $this->transform([$this->responseObj]);

        if (isset($this->responseObj->status)) {
            $state = new Constants\Transaction\States($this->responseObj->status);

            if (!$state->isValid()) {
                throw new \Genesis\Exceptions\InvalidArgument(
                    'Unknown transaction status',
                    isset($this->responseObj->code) ? $this->responseObj->code : 0
                );
            }

            if ($state->isError() && !$this->suppressReconciliationException()) {
                throw new \Genesis\Exceptions\ErrorAPI(
                    $this->responseObj->message,
                    isset($this->responseObj->code) ? $this->responseObj->code : 0
                );
            }
        }
    }
public function parseResponse ( $ response ) { $ this -> responseRaw = $ response ; try { $ parser = new \ Genesis \ Parser ( 'xml' ) ; $ parser -> skipRootNode ( ) ; $ parser -> parseDocument ( $ response ) ; $ this -> responseObj = $ parser -> getObject ( ) ; } catch ( \ Exception $ e ) { throw new \ Genesis \ Exceptions \ InvalidResponse ( $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } // Apply per-field transformations $ this -> transform ( [ $ this -> responseObj ] ) ; if ( isset ( $ this -> responseObj -> status ) ) { $ state = new Constants \ Transaction \ States ( $ this -> responseObj -> status ) ; if ( ! $ state -> isValid ( ) ) { throw new \ Genesis \ Exceptions \ InvalidArgument ( 'Unknown transaction status' , isset ( $ this -> responseObj -> code ) ? $ this -> responseObj -> code : 0 ) ; } if ( $ state -> isError ( ) && ! $ this -> suppressReconciliationException ( ) ) { throw new \ Genesis \ Exceptions \ ErrorAPI ( $ this -> responseObj -> message , isset ( $ this -> responseObj -> code ) ? $ this -> responseObj -> code : 0 ) ; } } }
Parse Genesis response to stdClass and
apply transformation to known fields

@param string $response

@throws \Genesis\Exceptions\ErrorAPI
@throws \Genesis\Exceptions\InvalidArgument
@throws \Genesis\Exceptions\InvalidResponse
Parse Genesis response to stdClass and apply transformation to known fields