Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added payout support. #16

Merged
merged 4 commits into from
Nov 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}

}
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