From d12f6a142aaf679905ceb9f84f7f3e984edf08e4 Mon Sep 17 00:00:00 2001 From: George Georgiou Date: Fri, 9 Feb 2018 15:23:44 +0200 Subject: [PATCH 1/3] Add adjustAuthorisation to modification models --- src/Adyen/Service/Modification.php | 8 +++ .../Modification/AdjustAuthorisation.php | 22 +++++++ tests/ModificationTest.php | 63 ++++++++++++++++++- 3 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 src/Adyen/Service/ResourceModel/Modification/AdjustAuthorisation.php diff --git a/src/Adyen/Service/Modification.php b/src/Adyen/Service/Modification.php index c3260053b..f63696e17 100644 --- a/src/Adyen/Service/Modification.php +++ b/src/Adyen/Service/Modification.php @@ -9,6 +9,7 @@ class Modification extends \Adyen\Service protected $_cancelOrRefund; protected $_capture; protected $_refund; + protected $_adjustAthorisation; public function __construct(\Adyen\Client $client) { @@ -18,6 +19,7 @@ public function __construct(\Adyen\Client $client) $this->_cancelOrRefund = new \Adyen\Service\ResourceModel\Modification\CancelOrRefund($this); $this->_capture = new \Adyen\Service\ResourceModel\Modification\Capture($this); $this->_refund = new \Adyen\Service\ResourceModel\Modification\Refund($this); + $this->_adjustAthorisation = new \Adyen\Service\ResourceModel\Modification\AdjustAuthorisation($this); } public function cancel($params) @@ -44,4 +46,10 @@ public function refund($params) return $result; } + public function adjustAuthorisation($params) + { + $result = $this->_adjustAthorisation->request($params); + return $result; + } + } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Modification/AdjustAuthorisation.php b/src/Adyen/Service/ResourceModel/Modification/AdjustAuthorisation.php new file mode 100644 index 000000000..a294bef90 --- /dev/null +++ b/src/Adyen/Service/ResourceModel/Modification/AdjustAuthorisation.php @@ -0,0 +1,22 @@ +_endpoint = $service->getClient()->getConfig()->get('endpoint').'/pal/servlet/Payment/'.$service->getClient()->getApiVersion().'/adjustAuthorisation'; + parent::__construct($service, $this->_endpoint, $this->_requiredFields); + } + +} \ No newline at end of file diff --git a/tests/ModificationTest.php b/tests/ModificationTest.php index fa5b54bd7..3e3e55356 100644 --- a/tests/ModificationTest.php +++ b/tests/ModificationTest.php @@ -15,7 +15,7 @@ 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(); @@ -36,7 +36,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(); @@ -53,7 +53,7 @@ public function testRefundModification() $params = array( "merchantAccount" => $this->_merchantAccount, "modificationAmount" => $modificationAmount, - "reference" => $pspReference . '_refund', + "reference" => $pspReference.'_refund', "originalReference" => $pspReference ); @@ -64,4 +64,61 @@ public function testRefundModification() } + public function testAdjustDecreaseModification() + { + // create a payment + require_once __DIR__.'/CreatePaymentRequestTest.php'; + $test = new CreatePaymentRequestTest(); + $result = $test->testCreatePaymentSuccess(); + + $pspReference = $result['pspReference']; + + // create modification + $client = $this->createClient(); + + // initialize service + $service = new Service\Modification($client); + + $params = [ + "merchantAccount" => $this->_merchantAccount, + "modificationAmount" => ['currency' => 'EUR', 'value' => '750'], + "reference" => $pspReference.'_adjustAuthorisation', + "originalReference" => $pspReference + ]; + + $result = $service->adjustAuthorisation($params); + + $this->assertEquals('[adjustAuthorisation-received]', $result['response']); + + } + + public function testAdjustIncreaseModification() + { + // create a payment + require_once __DIR__.'/CreatePaymentRequestTest.php'; + $test = new CreatePaymentRequestTest(); + $result = $test->testCreatePaymentSuccess(); + + $pspReference = $result['pspReference']; + + // create modification + $client = $this->createClient(); + + // initialize service + $service = new Service\Modification($client); + + $params = [ + "merchantAccount" => $this->_merchantAccount, + "modificationAmount" => ['currency' => 'EUR', 'value' => '1600'], + "reference" => $pspReference.'_adjustAuthorisation', + "originalReference" => $pspReference + ]; + + $result = $service->adjustAuthorisation($params); + + $this->assertEquals('[adjustAuthorisation-received]', $result['response']); + + } + + } From e4031da192ebea7a08f111efbc420f71b9186676 Mon Sep 17 00:00:00 2001 From: George Georgiou Date: Fri, 9 Feb 2018 15:38:09 +0200 Subject: [PATCH 2/3] Fix php5.3 compatibility in tests --- tests/ModificationTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/ModificationTest.php b/tests/ModificationTest.php index 3e3e55356..bd4fe0c53 100644 --- a/tests/ModificationTest.php +++ b/tests/ModificationTest.php @@ -79,12 +79,12 @@ public function testAdjustDecreaseModification() // initialize service $service = new Service\Modification($client); - $params = [ + $params = array( "merchantAccount" => $this->_merchantAccount, - "modificationAmount" => ['currency' => 'EUR', 'value' => '750'], + "modificationAmount" => array('currency' => 'EUR', 'value' => '750'), "reference" => $pspReference.'_adjustAuthorisation', "originalReference" => $pspReference - ]; + ); $result = $service->adjustAuthorisation($params); @@ -107,12 +107,12 @@ public function testAdjustIncreaseModification() // initialize service $service = new Service\Modification($client); - $params = [ + $params = array( "merchantAccount" => $this->_merchantAccount, - "modificationAmount" => ['currency' => 'EUR', 'value' => '1600'], + "modificationAmount" => array('currency' => 'EUR', 'value' => '1600'), "reference" => $pspReference.'_adjustAuthorisation', "originalReference" => $pspReference - ]; + ); $result = $service->adjustAuthorisation($params); From 2965e626e98ad88559f2ab5418718b89a5ea9980 Mon Sep 17 00:00:00 2001 From: George Georgiou Date: Wed, 21 Feb 2018 15:33:32 +0200 Subject: [PATCH 3/3] Fix typo --- src/Adyen/Service/Modification.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Adyen/Service/Modification.php b/src/Adyen/Service/Modification.php index f63696e17..edb0cb543 100644 --- a/src/Adyen/Service/Modification.php +++ b/src/Adyen/Service/Modification.php @@ -9,7 +9,7 @@ class Modification extends \Adyen\Service protected $_cancelOrRefund; protected $_capture; protected $_refund; - protected $_adjustAthorisation; + protected $_adjustAuthorisation; public function __construct(\Adyen\Client $client) { @@ -19,7 +19,7 @@ public function __construct(\Adyen\Client $client) $this->_cancelOrRefund = new \Adyen\Service\ResourceModel\Modification\CancelOrRefund($this); $this->_capture = new \Adyen\Service\ResourceModel\Modification\Capture($this); $this->_refund = new \Adyen\Service\ResourceModel\Modification\Refund($this); - $this->_adjustAthorisation = new \Adyen\Service\ResourceModel\Modification\AdjustAuthorisation($this); + $this->_adjustAuthorisation = new \Adyen\Service\ResourceModel\Modification\AdjustAuthorisation($this); } public function cancel($params) @@ -48,8 +48,7 @@ public function refund($params) public function adjustAuthorisation($params) { - $result = $this->_adjustAthorisation->request($params); + $result = $this->_adjustAuthorisation->request($params); return $result; } - } \ No newline at end of file