protected function _checkResponse( $response, $invoiceid )
	{
		$responseXSD = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'xsd' . DIRECTORY_SEPARATOR . 'order-response_v1.xsd';

		$dom = new DOMDocument('1.0', 'UTF-8');
		$dom->preserveWhiteSpace = false;

		if ( $dom->loadXML( $response ) !== true ) {
			throw new MShop_Service_Exception(
				sprintf( 'Loading of XML response "%1$s" from delivery provider failed', $response ), parent::ERR_XML );
		}

		if( $dom->schemaValidate( $responseXSD ) !== true ) {
			throw new MShop_Service_Exception(
				sprintf( 'Validation of XML response from delivery provider against schema "%1$s" failed', $responseXSD ), parent::ERR_SCHEMA );
		}

		$xpath = new DOMXPath( $dom );

		$globalStatus = $xpath->query( '/response/error' )->item(0)->nodeValue;
		if( $globalStatus != 0 ) {
			throw new MShop_Service_Exception( sprintf( 'Order data sent to delivery provider was rejected with code "%1$s" according to XML response', $globalStatus ) );
		}

		$orderitemlist = $xpath->query( '/response/orderlist/orderitem' );

		foreach( $orderitemlist as $orderitem )
		{
			$id = $xpath->query( 'id', $orderitem )->item(0)->nodeValue;
			$status = $xpath->query( 'status', $orderitem )->item(0)->nodeValue;

			if( $id != $invoiceid ) {
				throw new MShop_Service_Exception(
					sprintf( 'Order ID "%1$s" in XML response of delivery provider differs from stored invoice ID "%2$s" of the order', $id, $invoiceid ) );
			}

			if( $status != 0 )
			{
				$msg = $xpath->query( 'message', $orderitem )->item(0)->nodeValue;
				throw new MShop_Service_Exception(
					sprintf( 'Order with ID "%1$s" was rejected with code "%2$s": %3$s', $id, $status, $msg ), $status );
			}
		}
	}
protected function _checkResponse( $response, $invoiceid )
	{
		$responseXSD = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'xsd' . DIRECTORY_SEPARATOR . 'order-response_v1.xsd';

		$dom = new DOMDocument('1.0', 'UTF-8');
		$dom->preserveWhiteSpace = false;

		if ( $dom->loadXML( $response ) !== true ) {
			throw new MShop_Service_Exception(
				sprintf( 'Loading of XML response "%1$s" from delivery provider failed', $response ), parent::ERR_XML );
		}

		if( $dom->schemaValidate( $responseXSD ) !== true ) {
			throw new MShop_Service_Exception(
				sprintf( 'Validation of XML response from delivery provider against schema "%1$s" failed', $responseXSD ), parent::ERR_SCHEMA );
		}

		$xpath = new DOMXPath( $dom );

		$globalStatus = $xpath->query( '/response/error' )->item(0)->nodeValue;
		if( $globalStatus != 0 ) {
			throw new MShop_Service_Exception( sprintf( 'Order data sent to delivery provider was rejected with code "%1$s" according to XML response', $globalStatus ) );
		}

		$orderitemlist = $xpath->query( '/response/orderlist/orderitem' );

		foreach( $orderitemlist as $orderitem )
		{
			$id = $xpath->query( 'id', $orderitem )->item(0)->nodeValue;
			$status = $xpath->query( 'status', $orderitem )->item(0)->nodeValue;

			if( $id != $invoiceid ) {
				throw new MShop_Service_Exception(
					sprintf( 'Order ID "%1$s" in XML response of delivery provider differs from stored invoice ID "%2$s" of the order', $id, $invoiceid ) );
			}

			if( $status != 0 )
			{
				$msg = $xpath->query( 'message', $orderitem )->item(0)->nodeValue;
				throw new MShop_Service_Exception(
					sprintf( 'Order with ID "%1$s" was rejected with code "%2$s": %3$s', $id, $status, $msg ), $status );
			}
		}
	}
protected function _checkResponse ( $ response , $ invoiceid ) { $ responseXSD = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'xsd' . DIRECTORY_SEPARATOR . 'order-response_v1.xsd' ; $ dom = new DOMDocument ( '1.0' , 'UTF-8' ) ; $ dom -> preserveWhiteSpace = false ; if ( $ dom -> loadXML ( $ response ) !== true ) { throw new MShop_Service_Exception ( sprintf ( 'Loading of XML response "%1$s" from delivery provider failed' , $ response ) , parent :: ERR_XML ) ; } if ( $ dom -> schemaValidate ( $ responseXSD ) !== true ) { throw new MShop_Service_Exception ( sprintf ( 'Validation of XML response from delivery provider against schema "%1$s" failed' , $ responseXSD ) , parent :: ERR_SCHEMA ) ; } $ xpath = new DOMXPath ( $ dom ) ; $ globalStatus = $ xpath -> query ( '/response/error' ) -> item ( 0 ) -> nodeValue ; if ( $ globalStatus != 0 ) { throw new MShop_Service_Exception ( sprintf ( 'Order data sent to delivery provider was rejected with code "%1$s" according to XML response' , $ globalStatus ) ) ; } $ orderitemlist = $ xpath -> query ( '/response/orderlist/orderitem' ) ; foreach ( $ orderitemlist as $ orderitem ) { $ id = $ xpath -> query ( 'id' , $ orderitem ) -> item ( 0 ) -> nodeValue ; $ status = $ xpath -> query ( 'status' , $ orderitem ) -> item ( 0 ) -> nodeValue ; if ( $ id != $ invoiceid ) { throw new MShop_Service_Exception ( sprintf ( 'Order ID "%1$s" in XML response of delivery provider differs from stored invoice ID "%2$s" of the order' , $ id , $ invoiceid ) ) ; } if ( $ status != 0 ) { $ msg = $ xpath -> query ( 'message' , $ orderitem ) -> item ( 0 ) -> nodeValue ; throw new MShop_Service_Exception ( sprintf ( 'Order with ID "%1$s" was rejected with code "%2$s": %3$s' , $ id , $ status , $ msg ) , $ status ) ; } } }
Check response sent back from the server after the request

@param string $response XML sent back by the server
@param integer $invoiceid Number of the order invoice sent to the fulfillment partner
@throws MShop_Service_Exception If the response is invalid
Check response sent back from the server after the request