Skip to content

Commit

Permalink
Merge pull request #106 from sufcboy/feature/gh-refund-with-data
Browse files Browse the repository at this point in the history
Feature/gh refund with data
  • Loading branch information
rikterbeek authored Jun 7, 2019
2 parents 7cf7e34 + 57c956b commit 2670374
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Adyen/Service/Modification.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class Modification extends \Adyen\Service
*/
protected $refund;

/**
* @var ResourceModel\Modification\RefundWithData
*/
protected $refundWithData;

/**
* @var ResourceModel\Modification\AdjustAuthorisation
*/
Expand All @@ -42,6 +47,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->refundWithData = new \Adyen\Service\ResourceModel\Modification\RefundWithData($this);
$this->adjustAuthorisation = new \Adyen\Service\ResourceModel\Modification\AdjustAuthorisation($this);
}

Expand Down Expand Up @@ -89,6 +95,17 @@ public function refund($params)
return $result;
}

/**
* @param $params
* @return mixed
* @throws \Adyen\AdyenException
*/
public function refundWithData($params)
{
$result = $this->refundWithData->request($params);
return $result;
}

/**
* @param $params
* @return mixed
Expand Down
32 changes: 32 additions & 0 deletions src/Adyen/Service/ResourceModel/Modification/RefundWithData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php


namespace Adyen\Service\ResourceModel\Modification;


class RefundWithData extends \Adyen\Service\AbstractResource
{
/**
* @var string
*/
protected $endpoint;

/**
* Include applicationInfo key in the request parameters
*
* @var bool
*/
protected $allowApplicationInfo = true;

/**
* Refund constructor.
*
* @param \Adyen\Service $service
*/
public function __construct($service)
{
$this->endpoint = $service->getClient()->getConfig()->get('endpoint') .
'/pal/servlet/Payment/' . $service->getClient()->getApiPaymentVersion() . '/refundWithData';
parent::__construct($service, $this->endpoint, $this->allowApplicationInfo);
}
}
50 changes: 50 additions & 0 deletions tests/MockTest/ModificationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Adyen\MockTest;

class ModificationTest extends TestCaseMock
{
/**
* @param $jsonFile
* @param $httpStatus
* @dataProvider successRefundWithDataProvider
* @throws \Adyen\AdyenException
*/
public function testRefundWithDataSuccess($jsonFile, $httpStatus)
{
// create Checkout client
$client = $this->createMockClient($jsonFile, $httpStatus);

// initialize service
$service = new \Adyen\Service\Modification($client);

$params = json_decode('
{
"amount":{
"value":1500,
"currency":"GBP"
},
"selectedRecurringDetailReference":"8315535507322518",
"shopperReference":"myshopperreference",
"reference":"myreference",
"merchantAccount":"mymerchantaccount",
"recurring":{
"contract":"RECURRING"
},
"shopperInteraction":"ContAuth"
}',
true
);

$result = $service->refundWithData($params);

$this->assertContains($result['resultCode'], array('Received'));
}

public static function successRefundWithDataProvider()
{
return array(
array('tests/Resources/Modification/refundWithData-success.json', 200),
);
}
}
4 changes: 4 additions & 0 deletions tests/Resources/Modification/refundWithData-success.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"pspReference": "8835538461311270",
"resultCode": "Received"
}

0 comments on commit 2670374

Please sign in to comment.