Skip to content

Commit

Permalink
Merge pull request Credit-Jeeves#19 from PayLeaseBrian/split-dd-stand…
Browse files Browse the repository at this point in the history
…alone-credit

Implement limited functionality for Split Pay - DirectDebitService::standaloneCredits
  • Loading branch information
francoisneron authored Dec 15, 2017
2 parents 8e1771b + 865790b commit 38c3250
Show file tree
Hide file tree
Showing 7 changed files with 930 additions and 67 deletions.
2 changes: 1 addition & 1 deletion source/Paysafe/DirectDebit/ShippingDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @property string $country
* @property string $zip
*/
class ShippingDetails
class ShippingDetails extends \Paysafe\JSONObject
{

//put your code here
Expand Down
128 changes: 66 additions & 62 deletions source/Paysafe/DirectDebit/StandaloneCredits.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,74 +17,78 @@
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Paysafe\DirectDebit;

/*
* @property string $id
* @property string $merchantRefNum
* @property int $amount
* @property \Paysafe\DirectDebit\ach $ach
* @property \Paysafe\DirectDebit\eft $eft
* @property \Paysafe\DirectDebit\bacs $bacs
* @property \Paysafe\DirectDebit\profile $profile
* @property \Paysafe\DirectDebit\billingDetails $billingDetails
* @property \Paysafe\DirectDebit\ShippingDetails $shippingDetails
* @property string $customerIp
* @property string $dupCheck
* @property string $txnTime
* @property string $currencyCode
* @property \Paysafe\Error $error
* @property string $status
*/
namespace Paysafe\DirectDebit;

class StandaloneCredits extends \Paysafe\JSONObject implements \Paysafe\Pageable {
use Paysafe\PaysafeException;

public static function getPageableArrayKey() {
return "standaloneCredits";
}
/**
* @property string $id
* @property string $merchantRefNum
* @property int $amount
* @property \Paysafe\DirectDebit\ACH $ach
* @property \Paysafe\DirectDebit\EFT $eft
* @property \Paysafe\DirectDebit\BACS $bacs
* @property \Paysafe\DirectDebit\Profile $profile
* @property \Paysafe\DirectDebit\Filter $filter
* @property \Paysafe\DirectDebit\BillingDetails $billingDetails
* @property \Paysafe\DirectDebit\ShippingDetails $shippingDetails
* @property string $customerIp
* @property bool $dupCheck
* @property string $txnTime
* @property string $currencyCode
* @property \Paysafe\Error $error
* @property string $status
* @property \Paysafe\Link[] $links
* @property \Paysafe\DirectDebit\SplitPay[] $splitpay
*/
class StandaloneCredits extends \Paysafe\JSONObject implements \Paysafe\Pageable
{
public static function getPageableArrayKey() {
return "standaloneCredits";
}

protected static $fieldTypes = array(
'id' => 'string',
'merchantRefNum' => 'string',
'amount' => 'int',
'ach' => '\Paysafe\DirectDebit\ACH',
'eft' => '\Paysafe\DirectDebit\EFT',
'bacs' => '\Paysafe\DirectDebit\BACS',
'profile' => '\Paysafe\DirectDebit\Profile',
'filter' => '\Paysafe\DirectDebit\Filter',
'billingDetails' => '\Paysafe\DirectDebit\BillingDetails',
'shippingDetails' => '\Paysafe\DirectDebit\ShippingDetails',
'customerIp' => 'string',
'dupCheck' => 'bool',
'txnTime' => 'string',
'currencyCode' => 'string',
'error' => '\Paysafe\Error',
'status' => array(
'RECEIVED',
'PENDING',
'PROCESSING',
'COMPLETED',
'FAILED',
'CANCELLED'
),
'links' => 'array:\Paysafe\Link'
);
protected static $fieldTypes = array(
'id' => 'string',
'merchantRefNum' => 'string',
'amount' => 'int',
'ach' => '\Paysafe\DirectDebit\ACH',
'eft' => '\Paysafe\DirectDebit\EFT',
'bacs' => '\Paysafe\DirectDebit\BACS',
'profile' => '\Paysafe\DirectDebit\Profile',
'filter' => '\Paysafe\DirectDebit\Filter',
'billingDetails' => '\Paysafe\DirectDebit\BillingDetails',
'shippingDetails' => '\Paysafe\DirectDebit\ShippingDetails',
'customerIp' => 'string',
'dupCheck' => 'bool',
'txnTime' => 'string',
'currencyCode' => 'string',
'error' => '\Paysafe\Error',
'status' => array(
'RECEIVED',
'PENDING',
'PROCESSING',
'COMPLETED',
'FAILED',
'CANCELLED'
),
'links' => 'array:\Paysafe\Link',
'splitpay' => 'array:\Paysafe\DirectDebit\SplitPay',
);

/**
*
* @param type $linkName
* @return \Paysafe\HostedPayment\Link
* @throws PaysafeException
*/
public function getLink( $linkName ) {
if (!empty($this->link)) {
foreach ($this->link as $link) {
if ($link->rel == $linkName) {
return $link;
}
/**
* @param string $linkName
* @return \Paysafe\Link
* @throws \Paysafe\PaysafeException
*/
public function getLink( $linkName ) {
if (!empty($this->links)) {
foreach ($this->links as $link) {
if ($link->rel == $linkName) {
return $link;
}
}
throw new PaysafeException("Link $linkName not found in purchase.");
}

throw new PaysafeException("Link $linkName not found in stand alone credit.");
}
}
6 changes: 4 additions & 2 deletions source/Paysafe/DirectDebitService.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ private function standalonecreditsACH( DirectDebit\StandaloneCredits $standalone
$standalonecredits->checkRequiredFields();
$standalonecredits->setOptionalFields(array(
'customerIp',
'dupCheck'
'dupCheck',
'splitpay',
));
$request = new Request(array(
'method' => Request::POST,
Expand Down Expand Up @@ -437,7 +438,8 @@ private function standalonecreditsEFT( DirectDebit\StandaloneCredits $standalone
$standalonecredits->checkRequiredFields();
$standalonecredits->setOptionalFields(array(
'customerIp',
'dupCheck'
'dupCheck',
'splitpay',
));

$request = new Request(array(
Expand Down
2 changes: 1 addition & 1 deletion tests/paysafe/AccountManagement/TransferTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function testAllFieldsValidValues()
* This may seem like a trivial test, but behind the scenes toJson triggers data validation. Bad data will
* result in an exception.
* Not only does this test ensure the proper operation of the json encoding in JSONObject, but it validates
* our understanding of the data requirements in Authorization
* our understanding of the data requirements in Transfer
*/
$this->assertThat($t->toJson(), $this->equalTo(json_encode($t_array)));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/paysafe/CardPayments/RefundTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function testAllFieldsValueValues()
* This may seem like a trivial test, but behind the scenes toJson triggers data validation. Bad data will
* result in an exception.
* Not only does this test ensure the proper operation of the json encoding in JSONObject, but it validates
* our understanding of the data requirements in Authorization
* our understanding of the data requirements in Refund
*/
$this->assertThat($refund->toJson(), $this->equalTo(json_encode($refund_array)));
}
Expand Down
Loading

0 comments on commit 38c3250

Please sign in to comment.