diff --git a/src/Omnipay/WorldpayCGHosted/Message/Notification.php b/src/Omnipay/WorldpayCGHosted/Message/Notification.php index b66a702..c27f818 100644 --- a/src/Omnipay/WorldpayCGHosted/Message/Notification.php +++ b/src/Omnipay/WorldpayCGHosted/Message/Notification.php @@ -3,7 +3,7 @@ namespace Omnipay\WorldpayCGHosted\Message; use DOMDocument; -use Omnipay\Common\Exception\InvalidResponseException; +use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Common\Message\AbstractResponse; /** @@ -28,23 +28,23 @@ class Notification extends AbstractResponse /** @noinspection PhpMissingParentConstructorInspection * @param string $data * @param string $notificationOriginIp - * @throws InvalidResponseException on missing data + * @throws InvalidRequestException on missing or invalid data */ public function __construct($data, $notificationOriginIp) { $this->originIp = $notificationOriginIp; if (empty($data)) { - throw new InvalidResponseException(); + throw new InvalidRequestException('Notification data empty'); } if (!is_string($data)) { - throw new InvalidResponseException('Data must be provided as a string'); + throw new InvalidRequestException('Notification data not a string'); } $responseDom = new DOMDocument; if (!@$responseDom->loadXML($data)) { - throw new InvalidResponseException('Non-XML notification body received'); + throw new InvalidRequestException('Notification data not loaded as XML'); } $document = simplexml_import_dom($responseDom->documentElement); @@ -139,7 +139,8 @@ public function getResponseStatusCode() } /** - * Indicates whether the given origin IP address matches *.worldpay.com based on reverse DNS. + * Indicates whether the given origin IP address matches *.worldpay.com based on reverse DNS, or IP as a fallback + * on containers that can't gethostbyaddr(). * * @return bool */ diff --git a/src/Omnipay/WorldpayCGHosted/Message/Response.php b/src/Omnipay/WorldpayCGHosted/Message/Response.php index 52491bf..e7d4c1b 100755 --- a/src/Omnipay/WorldpayCGHosted/Message/Response.php +++ b/src/Omnipay/WorldpayCGHosted/Message/Response.php @@ -29,7 +29,7 @@ public function __construct(RequestInterface $request, $data) $responseDom = new DOMDocument; if (!@$responseDom->loadXML($data)) { - throw new InvalidResponseException('Non-XML notification response received'); + throw new InvalidResponseException('Non-XML response received'); } $this->data = @simplexml_import_dom( diff --git a/tests/Omnipay/WorldpayCGHosted/Message/NotificationTest.php b/tests/Omnipay/WorldpayCGHosted/Message/NotificationTest.php index 1854f39..9ede692 100644 --- a/tests/Omnipay/WorldpayCGHosted/Message/NotificationTest.php +++ b/tests/Omnipay/WorldpayCGHosted/Message/NotificationTest.php @@ -219,8 +219,8 @@ public function testRefundRequest() } /** - * @expectedException \Omnipay\Common\Exception\InvalidResponseException - * @expectedExceptionMessage Non-XML notification body received + * @expectedException \Omnipay\Common\Exception\InvalidRequestException + * @expectedExceptionMessage Notification data not loaded as XML */ public function testNonXmlResponse() { @@ -251,8 +251,8 @@ public function testUnexpectedXmlBody() } /** - * @expectedException \Omnipay\Common\Exception\InvalidResponseException - * @expectedExceptionMessage Invalid response from payment gateway + * @expectedException \Omnipay\Common\Exception\InvalidRequestException + * @expectedExceptionMessage Notification data empty */ public function testEmptyData() {