academe / SagePay-Integration

HTTP Messages for the Sage Pay REST (Pi) gateway.
GNU General Public License v3.0
9 stars 5 forks source link

Go PSR-7 #28

Closed judgej closed 8 years ago

judgej commented 8 years ago

A new branch PSR-7 has been created to manage this.

From the start, this package generates and accepts arrays of data, and provides additional HTTP details (GET/POST/auh) as separate properties. This was so it could stick to PHP5.4 and be integrated in standalone plugins for various non-composer PHP packages.

Now let's branch and got PSR-7 all-out. The idea is that this package accepts and generates PSR-7 messages. These messages can be put "onto the wire" using various HTTP clients, such as Guzzle 6+.

judgej commented 8 years ago

"final tweaks" to PSR-7 only response direct instantiation.

Any message from Sage Pay now must be either used to instantiate a response object from a PSR-7 message, or via fromData() method. So these are roughly equivalent:

$response = ... // PSR-7 ResponseInterface object from client
$session_key = new \Academe\SagePay\Psr7\Response\SessionKey($response);
// OR
$session_key = \Academe\SagePay\Psr7\Response\SessionKey::fromData($_POST, $httpStatusCodeFromClient);

The first one is preferable.

judgej commented 8 years ago

Everything now supports PSR-7 Request, Response and ServerRequest messages. It can also all be driven by array data if not using a PSR-7 HTTP client.