Skip to content

Commit

Permalink
Support to omnipay version 3 (#8)
Browse files Browse the repository at this point in the history
* Update to omnipay 3

- Update to omnipay 3 is necessary to be able to work with laravel 5.6

Signed-off-by: Andres Garcia <[email protected]>

* Update Readme

Signed-off-by: Andres Garcia <[email protected]>

* Change createRequest for request method

Signed-off-by: Andres Garcia <[email protected]>

* Rewind stream to avoid null messages

Signed-off-by: Andres Garcia <[email protected]>

* Update composer json and fix EOL

Signed-off-by: Andres Garcia <[email protected]>
  • Loading branch information
dranes authored Jun 12, 2018
1 parent 2b71e22 commit 3d503c1
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ to your `composer.json` file:
```json
{
"require": {
"dranes/omnipay-paysimple": "1.2.*"
"dranes/omnipay-paysimple": "~2.0"
}
}
```
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
"psr-4": { "Omnipay\\Paysimple\\" : "src/" }
},
"require": {
"omnipay/common": "~2.0"
"league/omnipay": "^3.0",
"squizlabs/php_codesniffer": "^3"
},
"require-dev": {
"omnipay/tests": "~2.0"
"omnipay/tests": "^3.0"
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
"dev-master": "3.0.x-dev"
}
}
}
21 changes: 7 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="League Test Suite">
<directory>tests</directory>
<testsuite name="Omnipay Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
<directory>./src</directory>
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
24 changes: 19 additions & 5 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@
* } else {
* $response = $transaction->getMessage();
* }
*
* // Retrieving bank accounts
*
* // Retrieving bank accounts
* $response = $gateway->retrieveBankAccounts(['CustomerId' => '1234567'])->send();
* $accounts = $response->getMessage();
*
*
* // Retrieving credit card
* $response = $gateway->retrieveCreditCards(['CustomerId' => '1234567'])->send();
* $accounts = $response->getMessage();
*
*
* // Delete a credit card
* $response = $gateway->deleteCreditCard(['AccountId' => '635402'])->send();
*
*
* // Delete a bank account
* $response = $gateway->deleteBankAccount(['AccountId' => '635402'])->send();
* </code>
Expand All @@ -93,6 +93,20 @@ public function getName()
return 'Paysimple';
}

/**
* Get default parameters for this gateway
*
* @return void
*/
public function getDefaultParameters()
{
return [
'username' => '',
'secret' => '',
'testMode' => false
];
}

/**
* Get the gateway username key
*
Expand Down
14 changes: 6 additions & 8 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,13 @@ public function sendData($data, array $headers = null)
$data = json_encode($data);
}

$httpRequest = $this->httpClient->createRequest(
$this->getHttpMethod(),
$this->getEndPoint(),
$headers,
$data
);

try {
$httpResponse = $httpRequest->send();
$httpResponse = $this->httpClient->request(
$this->getHttpMethod(),
$this->getEndPoint(),
$headers,
$data
);
} catch (ClientErrorResponseException $e) {
$httpResponse = $e->getResponse();
}
Expand Down
7 changes: 5 additions & 2 deletions src/Message/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public function isCancelled()

public function getMessage()
{
return $this->response->json();
$this->response->getBody()->rewind();
return json_decode($this->response->getBody()->getContents(), true);
}

public function getCode()
Expand All @@ -50,7 +51,9 @@ public function getCode()

public function getTransactionReference()
{
$json = $this->response->json();

$this->response->getBody()->rewind();
$json = json_decode($this->response->getBody()->getContents(), true);

return $json['Response']['Id'];
}
Expand Down

0 comments on commit 3d503c1

Please sign in to comment.