Skip to content

Commit

Permalink
Merge pull request #16 from SwiTool/develop
Browse files Browse the repository at this point in the history
Added payout support.
  • Loading branch information
rikterbeek authored Nov 23, 2016
2 parents 2e283af + cf99cd2 commit ee6eef3
Show file tree
Hide file tree
Showing 14 changed files with 766 additions and 46 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
composer.lock

# ignore Mac OS X file
.DS_Store
.DS_Store

# ignore PhpStorm .idea folder
.idea
67 changes: 67 additions & 0 deletions src/Adyen/Service/Payout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

namespace Adyen\Service;

class Payout extends \Adyen\Service
{

protected $_confirm;
protected $_decline;
protected $_storeDetailsAndSubmit;
protected $_submit;
protected $_confirmThirdParty;
protected $_declineThirdParty;
protected $_storeDetailsAndSubmitThirdParty;
protected $_submitThirdParty;

public function __construct(\Adyen\Client $client)
{
parent::__construct($client);

$this->_confirm = new \Adyen\Service\ResourceModel\Payout\Confirm($this);
$this->_decline = new \Adyen\Service\ResourceModel\Payout\Decline($this);
$this->_storeDetailsAndSubmit = new \Adyen\Service\ResourceModel\Payout\StoreDetailsAndSubmit($this);
$this->_submit = new \Adyen\Service\ResourceModel\Payout\Submit($this);
$this->_confirmThirdParty = new \Adyen\Service\ResourceModel\Payout\ThirdParty\ConfirmThirdParty($this);
$this->_declineThirdParty = new \Adyen\Service\ResourceModel\Payout\ThirdParty\DeclineThirdParty($this);
$this->_storeDetailsAndSubmitThirdParty = new \Adyen\Service\ResourceModel\Payout\ThirdParty\StoreDetailsAndSubmitThirdParty($this);
$this->_submitThirdParty = new \Adyen\Service\ResourceModel\Payout\ThirdParty\SubmitThirdParty($this);

}

public function confirm($params) {
$result = $this->_confirm->request($params);
return $result;
}
public function decline($params) {
$result = $this->_decline->request($params);
return $result;
}
public function storeDetailsAndSubmit($params) {
$result = $this->_storeDetailsAndSubmit->request($params);
return $result;
}
public function submit($params) {
$result = $this->_submit->request($params);
return $result;
}
public function confirmThirdParty($params) {
$result = $this->_confirmThirdParty->request($params);
return $result;
}
public function declineThirdParty($params) {
$result = $this->_declineThirdParty->request($params);
return $result;
}
public function storeDetailsAndSubmitThirdParty($params) {
$result = $this->_storeDetailsAndSubmitThirdParty->request($params);
return $result;
}
public function submitThirdParty($params) {
$result = $this->_submitThirdParty->request($params);
return $result;
}



}
20 changes: 20 additions & 0 deletions src/Adyen/Service/ResourceModel/Payout/Confirm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Adyen\Service\ResourceModel\Payout;

class Confirm extends \Adyen\Service\AbstractResource
{
protected $_requiredFields = array(
'merchantAccount',
'originalReference'
);

protected $_endpoint;

public function __construct($service)
{
$this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/confirm';
parent::__construct($service, $this->_endpoint, $this->_requiredFields);
}

}
20 changes: 20 additions & 0 deletions src/Adyen/Service/ResourceModel/Payout/Decline.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Adyen\Service\ResourceModel\Payout;

class Decline extends \Adyen\Service\AbstractResource
{
protected $_requiredFields = array(
'merchantAccount',
'originalReference'
);

protected $_endpoint;

public function __construct($service)
{
$this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/decline';
parent::__construct($service, $this->_endpoint, $this->_requiredFields);
}

}
25 changes: 25 additions & 0 deletions src/Adyen/Service/ResourceModel/Payout/StoreDetailsAndSubmit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Adyen\Service\ResourceModel\Payout;

class StoreDetailsAndSubmit extends \Adyen\Service\AbstractResource
{
protected $_requiredFields = array(
'amount.currency',
'amount.value',
'merchantAccount',
'recurring.contract',
'reference',
'shopperEmail',
'shopperReference',
);

protected $_endpoint;

public function __construct($service)
{
$this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/storeDetailAndSubmit';
parent::__construct($service, $this->_endpoint, $this->_requiredFields);
}

}
26 changes: 26 additions & 0 deletions src/Adyen/Service/ResourceModel/Payout/Submit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Adyen\Service\ResourceModel\Payout;

class Submit extends \Adyen\Service\AbstractResource
{
protected $_requiredFields = array(
'amount.currency',
'amount.value',
'merchantAccount',
'recurring.contract',
'reference',
'shopperEmail',
'shopperReference',
'selectedRecurringDetailReference'
);

protected $_endpoint;

public function __construct($service)
{
$this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/submit';
parent::__construct($service, $this->_endpoint, $this->_requiredFields);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Adyen\Service\ResourceModel\Payout\ThirdParty;

class ConfirmThirdParty extends \Adyen\Service\AbstractResource
{
protected $_requiredFields = array(
'merchantAccount',
'originalReference'
);

protected $_endpoint;

public function __construct($service)
{
$this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/confirmThirdParty';
parent::__construct($service, $this->_endpoint, $this->_requiredFields);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Adyen\Service\ResourceModel\Payout\ThirdParty;

class DeclineThirdParty extends \Adyen\Service\AbstractResource
{
protected $_requiredFields = array(
'merchantAccount',
'originalReference'
);

protected $_endpoint;

public function __construct($service)
{
$this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/declineThirdParty';
parent::__construct($service, $this->_endpoint, $this->_requiredFields);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Adyen\Service\ResourceModel\Payout\ThirdParty;

class StoreDetailsAndSubmitThirdParty extends \Adyen\Service\AbstractResource
{
protected $_requiredFields = array(
'merchantAccount',
'shopperEmail',
'shopperReference',
'reference',
'recurring.contract',
'amount.currency',
'amount.value',
'bank.iban',
'bank.ownerName',
'bank.countryCode'
);

protected $_endpoint;

public function __construct($service)
{
$this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/storeDetailAndSubmitThirdParty';
parent::__construct($service, $this->_endpoint, $this->_requiredFields);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Adyen\Service\ResourceModel\Payout\ThirdParty;

class SubmitThirdParty extends \Adyen\Service\AbstractResource
{
protected $_requiredFields = array(
'amount.currency',
'amount.value',
'merchantAccount',
'recurring.contract',
'reference',
'shopperEmail',
'shopperReference',
'selectedRecurringDetailReference'
);

protected $_endpoint;

public function __construct($service)
{
$this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/submitThirdParty';
parent::__construct($service, $this->_endpoint, $this->_requiredFields);
}

}
10 changes: 5 additions & 5 deletions tests/DirectoryLookupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@

class DirectoryLookupTest extends TestCase
{

public function testDirectoryLookup()
{

$this->_needSkinCode();
// initialize client
$client = $this->createClient();

Expand Down Expand Up @@ -72,11 +73,10 @@ public function testDirectoryLookupEmptyParameters()
// initialize service
$service = new Service\DirectoryLookup($client);

$error = null;
$e = null;
try {
$result = $service->directoryLookup("");
} catch (\Exception $e) {
$error = $e;
}

$this->assertEquals('Adyen\AdyenException', get_class($e));
Expand All @@ -87,6 +87,7 @@ public function testDirectoryLookupEmptyParameters()

public function testDirectoryLookupFailed()
{
$this->_needSkinCode();
// initialize client
$client = $this->createClient();

Expand All @@ -113,11 +114,10 @@ public function testDirectoryLookupFailed()
// convert the result into an array
$params = json_decode($json, true);

$error = null;
$e = null;
try {
$result = $service->directoryLookup($params);
} catch (\Exception $e) {
$error = $e;
}

$this->assertEquals('Adyen\AdyenException', get_class($e));
Expand Down
Loading

0 comments on commit ee6eef3

Please sign in to comment.