Skip to content

Commit

Permalink
Merge pull request #207 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 6.3.0
  • Loading branch information
cyattilakiss committed Jun 26, 2020
2 parents 852bd0d + 462aa2a commit 97833db
Show file tree
Hide file tree
Showing 17 changed files with 308 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @msilvagarcia @cyattilakiss @Aleffio @AlexandrosMor @rikterbeek @acampos1916
* @msilvagarcia @cyattilakiss @AlexandrosMor @acampos1916 @Aleffio @rikterbeek
16 changes: 15 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,21 @@ jobs:
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
- name: Run integration tests
run: vendor/bin/phpunit --testsuite=integration --no-coverage
env:
INTEGRATION_USERNAME: ${{ secrets.INTEGRATION_USERNAME }}
INTEGRATION_PASSWORD: ${{ secrets.INTEGRATION_PASSWORD }}
INTEGRATION_X_API_KEY: ${{ secrets.INTEGRATION_X_API_KEY }}
INTEGRATION_MERCHANT_ACCOUNT: ${{ secrets.INTEGRATION_MERCHANT_ACCOUNT }}
INTEGRATION_SKIN_CODE: ${{ secrets.INTEGRATION_SKIN_CODE }}
INTEGRATION_HMAC_SIGNATURE: ${{ secrets.INTEGRATION_HMAC_SIGNATURE }}
INTEGRATION_STORE_PAYOUT_USERNAME: ${{ secrets.INTEGRATION_STORE_PAYOUT_USERNAME }}
INTEGRATION_STORE_PAYOUT_PASSWORD: ${{ secrets.INTEGRATION_STORE_PAYOUT_PASSWORD }}
INTEGRATION_REVIEW_PAYOUT_USERNAME: ${{ secrets.INTEGRATION_REVIEW_PAYOUT_USERNAME }}
INTEGRATION_REVIEW_PAYOUT_PASSWORD: ${{ secrets.INTEGRATION_REVIEW_PAYOUT_PASSWORD }}

- name: Run unit tests
run: vendor/bin/phpunit --testsuite=unit --coverage-clover build/clover.xml --log-junit build/tests-log.xml

# PHPUnit generates absolute file paths and SonarCloud expects relative file paths. This command removes the
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<testsuite name="unit">
<directory>./tests/Unit</directory>
</testsuite>
<testsuite name="integration">
<directory>./tests/Integration</directory>
</testsuite>
<testsuite name="all">
<directory>./tests</directory>
</testsuite>
Expand Down
2 changes: 1 addition & 1 deletion src/Adyen/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class Client
{
const LIB_VERSION = "6.2.0";
const LIB_VERSION = "6.3.0";
const LIB_NAME = "adyen-php-api-library";
const USER_AGENT_SUFFIX = "adyen-php-api-library/";
const ENDPOINT_TEST = "https://pal-test.adyen.com";
Expand Down
58 changes: 57 additions & 1 deletion src/Adyen/Util/HmacSignature.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

class HmacSignature
{
const EVENT_CODE = "eventCode";
/**
* @param string $hmacKey Can be found in Customer Area
* @param array $params The response from Adyen
Expand Down Expand Up @@ -69,7 +70,7 @@ private function getNotificationDataToSign($params)
// `empty` treats too many value types as empty. `isset` should prevent some of these cases.
$value = (isset($params['amount']['value'])) ? $params['amount']['value'] : "";
$currency = (!empty($params['amount']['currency'])) ? $params['amount']['currency'] : "";
$eventCode = (!empty($params['eventCode'])) ? $params['eventCode'] : "";
$eventCode = (!empty($params[self::EVENT_CODE])) ? $params[self::EVENT_CODE] : "";
$success = (!empty($params['success'])) ? $params['success'] : "";

$dataToSign = array(
Expand Down Expand Up @@ -103,4 +104,59 @@ public function isValidNotificationHMAC($hmacKey, $params)

return $expectedSign == $merchantSign;
}
/**
* Returns true when the event code support HMAC validation
*
* @param $response
*/
public function isHmacSupportedEventCode($response)
{
$eventCodes = array(
"ADVICE_OF_DEBIT",
"AUTHORISATION",
"AUTHORISATION_PENDING",
"AUTHORISE_REFERRAL",
"CANCELLATION",
"CANCEL_OR_REFUND",
"CAPTURE",
"CAPTURE_FAILED",
"CAPTURE_WITH_EXTERNAL_AUTH",
"CHARGEBACK",
"CHARGEBACK_REVERSED",
"DEACTIVATE_RECURRING",
"FRAUD_ONLY",
"FUND_TRANSFER",
"HANDLED_EXTERNALLY",
"MANUAL_REVIEW_ACCEPT",
"NOTIFICATION_OF_CHARGEBACK",
"NOTIFICATION_OF_FRAUD",
"OFFER_CLOSED",
"ORDER_OPENED",
"PAIDOUT_REVERSED",
"PAYOUT_DECLINE",
"PAYOUT_EXPIRE",
"PAYOUT_THIRDPARTY",
"PREARBITRATION_LOST",
"PREARBITRATION_WON",
"PROCESS_RETRY",
"RECURRING_CONTRACT",
"REFUND",
"REFUNDED_REVERSED",
"REFUND_FAILED",
"REFUND_WITH_DATA",
"REQUEST_FOR_INFORMATION",
"SECOND_CHARGEBACK",
"SUBMIT_RECURRING",
"VOID_PENDING_REFUND",
"POSTPONED_REFUND",
"TECHNICAL_CANCEL",
"AUTHORISATION_ADJUSTMENT",
"CANCEL_AUTORESCUE",
"AUTORESCUE"
);
if (array_key_exists(self::EVENT_CODE, $response) && in_array($response[self::EVENT_CODE], $eventCodes)) {
return true;
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
*
*/

namespace Adyen;
namespace Adyen\Integration;

use Adyen\Util\Util;
use Adyen\TestCase;
use Adyen\Service;

class BinLookupTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
*
*/

namespace Adyen;
namespace Adyen\Integration;

use Adyen\TestCase;
use Adyen\Service;
use Adyen\Util\Uuid;

class CheckoutTest extends TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen API Library for PHP
*
* Copyright (c) 2020 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
*/

namespace Adyen\Integration;

namespace Adyen;
use Adyen\TestCase;
use Adyen\Service;

/**
* Created by PhpStorm.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
*
*/

namespace Adyen;
namespace Adyen\Integration;

use Adyen\TestCase;
use Adyen\Service;
use Adyen\Util\Util;

class DirectoryLookupTest extends TestCase
Expand Down
27 changes: 26 additions & 1 deletion tests/ExceptionTest.php → tests/Integration/ExceptionTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen API Library for PHP
*
* Copyright (c) 2020 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
*/

/**
* Created by PhpStorm.
* User: rikt
* Date: 11/18/15
* Time: 12:01 PM
*/

namespace Adyen;
namespace Adyen\Integration;

use Adyen\TestCase;
use Adyen\Service;

class ExceptionTest extends \Adyen\TestCase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,44 @@
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen API Library for PHP
*
* Copyright (c) 2020 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
*/

/**
* Created by PhpStorm.
* User: rikt
* Date: 11/6/15
* Time: 2:39 PM
*/

namespace Adyen;
namespace Adyen\Integration;

use Adyen\TestCase;
use Adyen\Service;

class ModificationTest extends TestCase
{
public function testCancelModification()
{
// create a payment
require_once __DIR__.'/CreatePaymentRequestTest.php';
require_once __DIR__ . '/CreatePaymentRequestTest.php';
$test = new CreatePaymentRequestTest();
$result = $test->testCreatePaymentSuccess();

Expand All @@ -33,7 +58,7 @@ public function testCancelModification()
public function testRefundModification()
{
// create a payment
require_once __DIR__.'/CreatePaymentRequestTest.php';
require_once __DIR__ . '/CreatePaymentRequestTest.php';
$test = new CreatePaymentRequestTest();
$result = $test->testCreatePaymentSuccess();

Expand Down Expand Up @@ -63,7 +88,7 @@ public function testRefundModification()
public function testAdjustDecreaseModification()
{
// create a payment
require_once __DIR__.'/CreatePaymentRequestTest.php';
require_once __DIR__ . '/CreatePaymentRequestTest.php';
$test = new CreatePaymentRequestTest();
$result = $test->testCreatePaymentSuccess();

Expand All @@ -90,7 +115,7 @@ public function testAdjustDecreaseModification()
public function testAdjustIncreaseModification()
{
// create a payment
require_once __DIR__.'/CreatePaymentRequestTest.php';
require_once __DIR__ . '/CreatePaymentRequestTest.php';
$test = new CreatePaymentRequestTest();
$result = $test->testCreatePaymentSuccess();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,23 @@
*
*/

namespace Adyen;
namespace Adyen\Integration;

use Adyen\TestCase;
use Adyen\Service;

/**
* Class PayoutThirdPartyTest
*
* @package Adyen\Integration
*/
class PayoutThirdPartyTest extends TestCase
{
protected function setUp(): void
{
$this->markTestIncomplete('Configure Payout accounts');
}

public function testStoreDetailAndSubmitPayoutThirdPartyMissingReference()
{
// initialize client
Expand Down Expand Up @@ -326,7 +339,7 @@ public function testConfirmPayoutThirdPartyInvalidReference()
// check if exception is correct
$this->assertEquals('Adyen\AdyenException', get_class($e));
$this->assertEquals(
'Invalid Request: Original pspReference is invalid for this environment!',
'Original pspReference required for this operation',
$e->getMessage()
);
}
Expand Down Expand Up @@ -367,7 +380,7 @@ public function testDeclinePayoutThirdPartySuccess()
public function testDeclinePayoutThirdPartyInvalidReference()
{
$this->expectException('Adyen\AdyenException');
$this->expectExceptionMessage('Invalid Request: Original pspReference is invalid for this environment!');
$this->expectExceptionMessage('Original pspReference required for this operation');
// initialize client
$client = $this->createReviewPayoutClient();

Expand Down
30 changes: 26 additions & 4 deletions tests/PosPaymentTest.php → tests/Integration/PosPaymentTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
<?php

namespace Adyen;

use Adyen\Util\Util;
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen API Library for PHP
*
* Copyright (c) 2020 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
*/

namespace Adyen\Integration;

use Adyen\TestCase;
use Adyen\Service;

class PosPaymentTest extends TestCase
{
Expand Down
Loading

0 comments on commit 97833db

Please sign in to comment.