Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #18 from comicrelief/GP-1243-notification-validation
Browse files Browse the repository at this point in the history
GP-1243 - type check first so logs on 'empty' Notifications are more specific
  • Loading branch information
adamclark-dev authored Mar 15, 2018
2 parents 05af6eb + 511881c commit 99dab4f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Omnipay/WorldpayCGHosted/Message/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public function __construct($data, $notificationOriginIp)
{
$this->originIp = $notificationOriginIp;

if (empty($data)) {
throw new InvalidRequestException('Notification data empty');
if (!is_string($data)) {
throw new InvalidRequestException(sprintf('Notification data not a string - got %s', gettype($data)));
}

if (!is_string($data)) {
throw new InvalidRequestException('Notification data not a string');
if ($data === '') {
throw new InvalidRequestException('Notification data empty');
}

$responseDom = new DOMDocument;
Expand Down Expand Up @@ -155,7 +155,7 @@ private function originIsValid()
return false;
}

$expectedEnd = 'worldpay.com';
$expectedEnd = 'worldpay.com'; // todo fix me
$expectedPosition = strlen($hostname) - strlen($expectedEnd);

if (strpos($hostname, $expectedEnd) === $expectedPosition) {
Expand Down

0 comments on commit 99dab4f

Please sign in to comment.