From 3ff44d4b48ed13ad12d52228b980dbb0079ff612 Mon Sep 17 00:00:00 2001 From: Jason Judge Date: Thu, 23 Aug 2018 20:29:19 +0100 Subject: [PATCH] Remove some old Guzzle references. Omnipay 3.x is now PSR-7 for responses and Symfony for server requests. --- src/Helper.php | 31 +++++++++------------------- src/Message/AbstractNotification.php | 6 +++--- src/Traits/HasCompleteResponse.php | 2 +- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/Helper.php b/src/Helper.php index 9471fed..c946811 100644 --- a/src/Helper.php +++ b/src/Helper.php @@ -7,7 +7,6 @@ */ use Symfony\Component\HttpFoundation\Request; -use Guzzle\Http\Message\Response; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use SimpleXMLElement; @@ -20,30 +19,25 @@ class Helper * as XML in a header line or XML in the request body. * All of these methods are used in various places. * XML data is parsed into a flat array. - * Supports Guzzle sewrver request/response, but be - * switched to PSR-7 messages in Omnipay 3.x versions. * - * @param Request|Response|TBC $httpMessage a Guzzle HTTP server request or HTTP response, or a PSR-7 message (TODO) + * @param Request|ResponseInterface $httpMessage a HTTP server request or a PSR-7 message * @return array the data as a flat array */ public static function extractMessageData($httpMessage) { - // Guzzle 3 Response or PSR-7 response. - // The assumption for now is that it will always be XML. + // The assumption for now is that a syncronous response will always be XML. - if ($httpMessage instanceof Response || $httpMessage instanceof ResponseInterface) { + if ($httpMessage instanceof ResponseInterface) { $xmlString = (string)$httpMessage->getBody(); $xmlString = simplexml_load_string($xmlString); return static::parseXmlElement($xmlString); } - // Guzzle 3 ServerRequest. - // CHECKME: when coult this also be a ServerRequestInterface? - + // Incoming server request. // The results could be sent by GET or POST. It's an account // option, or an overriding request option. - // Could also be XML in a header or the body. + // Could also be XML in a header field or the body. if ($httpMessage instanceof Request) { if (static::getMethod($httpMessage) === 'POST') { @@ -70,21 +64,16 @@ public static function extractMessageData($httpMessage) // Fall back to standard GET query or POST form parameters. - return static::getFormData($httpMessage); + if (static::getMethod($httpMessage) === 'POST') { + return $httpMessage->request->all(); + } else { + return $httpMessage->query->all(); + } } return []; } - public static function getFormData($httpMessage) - { - if (static::getMethod($httpMessage) === 'POST') { - return $httpMessage->request->all(); - } else { - return $httpMessage->query->all(); - } - } - public static function getMethod($httpMessage) { return strtoupper($httpMessage->getMethod()); diff --git a/src/Message/AbstractNotification.php b/src/Message/AbstractNotification.php index 649fcef..a8211b4 100644 --- a/src/Message/AbstractNotification.php +++ b/src/Message/AbstractNotification.php @@ -16,7 +16,7 @@ use Omnipay\Common\Helper; use Symfony\Component\HttpFoundation\ParameterBag; -use Guzzle\Http\ClientInterface; +use Omnipay\Common\Http\ClientInterface; use Symfony\Component\HttpFoundation\Request as HttpRequest; abstract class AbstractNotification implements NotificationInterface @@ -31,7 +31,7 @@ abstract class AbstractNotification implements NotificationInterface /** * The request client. * - * @var \Guzzle\Http\ClientInterface + * @var \Omnipay\Common\Http\ClientInterface */ protected $httpClient; @@ -45,7 +45,7 @@ abstract class AbstractNotification implements NotificationInterface /** * Create a new Request * - * @param ClientInterface $httpClient A Guzzle client to make API calls with + * @param ClientInterface $httpClient A client to make API calls with * @param HttpRequest $httpRequest A Symfony HTTP request object */ public function __construct(ClientInterface $httpClient, HttpRequest $httpRequest) diff --git a/src/Traits/HasCompleteResponse.php b/src/Traits/HasCompleteResponse.php index b479b7f..fa82087 100644 --- a/src/Traits/HasCompleteResponse.php +++ b/src/Traits/HasCompleteResponse.php @@ -130,7 +130,7 @@ public function getCardReference() /** * Virtual card number for MFGroup Checkout */ - public function getVirtualCardno() + public function getVirtualCardno2() { return $this->getDataItem('virtualCardno'); }