Skip to content

Commit e427cf5

Browse files
committed
Add error codes for soft declines support; fix code style
1 parent a0a1908 commit e427cf5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+143
-143
lines changed

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
run: composer install --prefer-dist --no-progress --no-suggest
3030

3131
- name: Run test suite
32-
run: vendor/bin/phpunit tests
32+
run: composer test

.travis.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
##### Version 2.0.0 (2021-04-23)
2+
3+
Add PHP 8 support in composer.json
4+
Drop PHP 7.0 support
5+
16
##### Version 1.7.2 (2020-09-02)
27

38
Add merchant-transaction-id to payment response parsing

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ if (!empty($paymentResponse->error)) {
6161
}
6262

6363
// Redirect user to received URL
64-
if ($paymentResp->gw->statusCode === Status::CARD_FORM_URL_SENT) {
64+
if ($paymentResponse->gw->statusCode === Status::CARD_FORM_URL_SENT) {
6565
header("Location: {$paymentResponse->gw->redirectUrl}");
6666
}
6767
```
@@ -104,7 +104,7 @@ $response = $gw->process($smsRequest);
104104

105105
// Parse Gateway response as a payment response
106106
$paymentResponse = $sms->parseResponse($response);
107-
echo $paymentResp->gw->statusCode === Status::SUCCESS ? "SUCCESS" : "FAILED";
107+
echo $paymentResponse->gw->statusCode === Status::SUCCESS ? "SUCCESS" : "FAILED";
108108
```
109109

110110
## Documentation
@@ -231,6 +231,16 @@ $message->useToken();
231231
$message->command()
232232
->setPaymentMethodDataSource(Command::DATA_SOURCE_USE_GATEWAY_SAVED_CARDHOLDER_INITIATED)
233233
->setPaymentMethodDataToken('<initial gateway-transaction-id>');
234+
235+
$response = $gw->process($message);
236+
$paymentResponse = $message->parseResponse($response);
237+
if (
238+
!empty($paymentResponse->error) &&
239+
$paymentResponse->error->code === ErrorCode::EEC_ACQUIRER_SOFT_DECLINE &&
240+
!empty($paymentResponse->gw->redirectUrl)
241+
) {
242+
header("Location: {$paymentResponse->gw->redirectUrl}");
243+
}
234244
```
235245

236246
### Callback validation

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
"require-dev": {
1919
"phpunit/phpunit": "^6.0 | ^9.5",
2020
"php-parallel-lint/php-parallel-lint": "^1.3",
21-
"friendsofphp/php-cs-fixer": "^2.1"
21+
"friendsofphp/php-cs-fixer": "^2.1",
22+
"phpstan/phpstan": "^0.12"
2223
},
2324
"scripts": {
2425
"test": [
2526
"./vendor/bin/parallel-lint . --exclude vendor",
26-
"./vendor/bin/phpunit"
27+
"./vendor/bin/phpstan analyse --level 5 src tests",
28+
"./vendor/bin/phpunit",
29+
"./vendor/bin/php-cs-fixer fix --using-cache=false --dry-run"
2730
],
2831
"cs": "./vendor/bin/php-cs-fixer fix --using-cache=false"
2932
}

src/Gateway/Http/Crypto/RequestDigest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class RequestDigest extends Digest
2424
* @param string $username
2525
* @param string $secret
2626
* @param string $fullUrl
27-
* @param string $qop
2827
*
2928
* @throws RequestException
3029
*/

src/Gateway/Http/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function getData()
9494
/**
9595
* Set prepared JSON string.
9696
*
97-
* @param $preparedData string
97+
* @param string $preparedData
9898
*/
9999
public function setPreparedData($preparedData)
100100
{

src/Gateway/Http/Transport/Curl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Curl implements HttpTransportInterface
4444
/**
4545
* cURL resource.
4646
*
47-
* @var resource
47+
* @var resource|null|false|mixed
4848
*/
4949
private $ch;
5050

@@ -217,7 +217,7 @@ public function getStatus(): int
217217
*/
218218
public function close()
219219
{
220-
if (is_resource($this->ch)) {
220+
if (!empty($this->ch)) {
221221
curl_close($this->ch);
222222

223223
$this->ch = null;

src/Gateway/Responses/Constants/ErrorCode.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class ErrorCode
5858
const EEC_NO_PARENT_TRANSACTION_PROVIDED = 1157;
5959
const EEC_DYNAMIC_DESCRIPTOR_ERROR = 1158;
6060
const EEC_UCOF_ERROR = 1159;
61+
const EEC_SUSPECTED_FRAUD = 1160;
6162

6263
const EEC_TERMINAL_NOT_FOUND = 1200;
6364
const EEC_ALL_TERMINAL_COUNTERS_EXCEEDED = 1201;
@@ -69,6 +70,7 @@ class ErrorCode
6970

7071
const EEC_DECLINED_BY_ACQUIRER = 1301;
7172
const EEC_ACQUIRER_ERROR = 1302;
73+
const EEC_ACQUIRER_SOFT_DECLINE = 1303;
7274

7375
const EEC_INVALID_FORM_ID = 1400;
7476
const EEC_FORM_UNAVAILABLE = 1401;

tests/Gateway/DataSets/AuthTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class AuthTest extends TestCase
1717
{
18-
public function testSuccess()
18+
public function testSuccess(): void
1919
{
2020
$expected = [
2121
DataSet::AUTH_DATA_SESSION_ID => 'foo',
@@ -32,7 +32,7 @@ public function testSuccess()
3232
$this->assertEquals('aaaa', $auth->getSecretKey());
3333
}
3434

35-
public function testGetObjectId()
35+
public function testGetObjectId(): void
3636
{
3737
$authAccount = new Auth();
3838
$authAccount->setAccountGUID('3383e58e-9cde-4ffa-85cf-81cd25b2423e');

0 commit comments

Comments
 (0)