-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #7 Get Direct Debit Mandate and Mandate Collection.
not yet tested or tried against sandbox.
- Loading branch information
Showing
8 changed files
with
269 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace Consilience\Starling\Payments\Request; | ||
|
||
/** | ||
* Gets a specific direct debit mandate associated with the specified address. | ||
*/ | ||
|
||
use Consilience\Starling\Payments\Request\Models\Endpoint; | ||
use Consilience\Starling\Payments\AbstractRequest; | ||
use UnexpectedValueException; | ||
|
||
class GetDirectDebitMandate extends AbstractRequest | ||
{ | ||
/** | ||
* @inherit | ||
*/ | ||
protected $pathTemplate = 'account/{accountUid}/address/{addressUid}/mandate/{mandateUid}'; | ||
|
||
protected $httpMethod = 'GET'; | ||
|
||
protected $accountUid; | ||
protected $addressUid; | ||
protected $mandateUid; | ||
|
||
/** | ||
* @param string $paymentBusinessUid | ||
* @param string $accountUid the accound to retrieve | ||
*/ | ||
public function __construct(Endpoint $endpoint, $accountUid, $addressUid, $mandateUid) | ||
{ | ||
$this->setEndpoint($endpoint); | ||
$this->setAccountUid($accountUid); | ||
$this->setAddressUid($addressUid); | ||
$this->setMandateUid($mandateUid); | ||
} | ||
|
||
/** | ||
* @param string UID | ||
*/ | ||
protected function setAccountUid($value) | ||
{ | ||
$this->assertUid($value); | ||
|
||
$this->accountUid = $value; | ||
} | ||
|
||
/** | ||
* @param string UID | ||
*/ | ||
protected function setAddressUid($value) | ||
{ | ||
$this->assertUid($value); | ||
|
||
$this->addressUid = $value; | ||
} | ||
|
||
/** | ||
* @param string UID | ||
*/ | ||
protected function setMandateUid($value) | ||
{ | ||
$this->assertUid($value); | ||
|
||
$this->mandateUid = $value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Consilience\Starling\Payments\Request; | ||
|
||
/** | ||
* Gets a specific direct debit mandate associated with the specified address. | ||
*/ | ||
|
||
use Consilience\Starling\Payments\Request\Models\Endpoint; | ||
use Consilience\Starling\Payments\AbstractRequest; | ||
use UnexpectedValueException; | ||
|
||
class GetDirectDebitMandates extends AbstractRequest | ||
{ | ||
/** | ||
* @inherit | ||
*/ | ||
protected $pathTemplate = 'account/{accountUid}/address/{addressUid}/mandate'; | ||
|
||
protected $httpMethod = 'GET'; | ||
|
||
protected $accountUid; | ||
protected $addressUid; | ||
|
||
/** | ||
* @param string $paymentBusinessUid | ||
* @param string $accountUid the accound to retrieve | ||
*/ | ||
public function __construct(Endpoint $endpoint, $accountUid, $addressUid) | ||
{ | ||
$this->setEndpoint($endpoint); | ||
$this->setAccountUid($accountUid); | ||
$this->setAddressUid($addressUid); | ||
} | ||
|
||
/** | ||
* @param string UID | ||
*/ | ||
protected function setAccountUid($value) | ||
{ | ||
$this->assertUid($value); | ||
|
||
$this->accountUid = $value; | ||
} | ||
|
||
/** | ||
* @param string UID | ||
*/ | ||
protected function setAddressUid($value) | ||
{ | ||
$this->assertUid($value); | ||
|
||
$this->addressUid = $value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace Consilience\Starling\Payments\Response; | ||
|
||
/** | ||
* A mandate that allows a specific originator to claim direct debit payments. | ||
*/ | ||
|
||
use Consilience\Starling\Payments\Response\Models\BacsOriginator; | ||
use Consilience\Starling\Payments\AbstractResponse; | ||
|
||
class DirectDebitMandate extends AbstractResponse | ||
{ | ||
/** | ||
* @var string UUID | ||
* Unique identifier of the company requesting or receiving the payment. | ||
*/ | ||
protected $paymentBusinessUid; | ||
|
||
/** | ||
* @var string UUID | ||
* Unique identifier of the account containing the funds sent or received. | ||
*/ | ||
protected $paymentAccountUid; | ||
|
||
/** | ||
* @var string UUID | ||
* Unique identifier of the payment account address. | ||
*/ | ||
protected $addressUid; | ||
|
||
/** | ||
* @var string UUID | ||
* Unique identifier of the BACS mandate. | ||
*/ | ||
protected $mandateUid; | ||
|
||
/** | ||
* @var string one of static::DIRECT_DEBIT_STATUS_* | ||
* Status of the direct debit mandate. | ||
*/ | ||
protected $reference; | ||
|
||
/** | ||
* @var BacsOriginator | ||
*/ | ||
protected $bacsOriginator; | ||
|
||
/** | ||
* @var string one of static::DIRECT_DEBIT_STATUS_* | ||
* Status of the direct debit mandate. | ||
*/ | ||
protected $status; | ||
|
||
/** | ||
* Create a model and set the property. | ||
* | ||
* @param array $data source data to hydrate the model | ||
*/ | ||
protected function setBacsOriginator(array $data) | ||
{ | ||
$this->bacsOriginator = BacsOriginator::fromArray($data); | ||
} | ||
|
||
/** | ||
* @return bool true if the account address is active. | ||
*/ | ||
public function isActive() | ||
{ | ||
return $this->status === static::DIRECT_DEBIT_STATUS_ACTIVE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Consilience\Starling\Payments\Response; | ||
|
||
/** | ||
* | ||
*/ | ||
|
||
use Consilience\Starling\Payments\AbstractCollection; | ||
use Consilience\Starling\Payments\Response\DirectDebitMandate; | ||
|
||
class DirectDebitMandateCollection extends AbstractCollection | ||
{ | ||
/** | ||
* @param mixed $item | ||
* @return bool | ||
*/ | ||
protected function hasExpectedStrictType($item) | ||
{ | ||
return $item instanceof DirectDebitMandate; | ||
} | ||
|
||
/** | ||
* @inherit | ||
*/ | ||
protected function createInstance(array $data) | ||
{ | ||
return new DirectDebitMandate($data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Consilience\Starling\Payments\Response\Models; | ||
|
||
/** | ||
* A party that is able to set up direct debit mandates and | ||
* send and receive payments via BACS | ||
*/ | ||
|
||
use Consilience\Starling\Payments\HydratableTrait; | ||
use Consilience\Starling\Payments\ModelInterface; | ||
|
||
class BacsOriginator implements ModelInterface | ||
{ | ||
use HydratableTrait; | ||
|
||
/** | ||
* @var string UUID | ||
* Starling's unique identifier of the originator. | ||
*/ | ||
protected $originatorUid; | ||
|
||
/** | ||
* @var string 6 characters; example 987654 | ||
* BACS's unique identifier of the originator. | ||
*/ | ||
protected $serviceUserNumber; | ||
|
||
/** | ||
* @var string 0 to 33 characters; example : "Southern Electric" | ||
* The name of the originator as registered with BACS. | ||
*/ | ||
protected $name; | ||
} |