Skip to content
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
105 changes: 105 additions & 0 deletions lib/Paymill/Models/Request/Checksum.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,27 @@ class Checksum extends Base
*/
private $_handling_amount;

/**
* Client identifier
*
* @var string $_client
*/
private $_client;

/**
* Reusable payment
*
* @var bool $_requireReusablePayment
*/
private $_requireReusablePayment;

/**
* Reusable payment description
*
* @var string $_reusablePaymentDescription
*/
private $_reusablePaymentDescription;

/**
* Creates an instance of the checksum request model
*/
Expand All @@ -129,6 +150,30 @@ function __construct()
$this->_serviceResource = 'checksums/';
}

/**
* Sets the identifier of the Client for the transaction
*
* @param string $clientId Client identifier
*
* @return $this
*/
public function setClient($client)
{
$this->_client = $client;

return $this;
}

/**
* Returns the identifier of the Client associated with the checksum. If no client is available null will be returned
*
* @return string
*/
public function getClient()
{
return $this->_client;
}

/**
* Set amount
*
Expand Down Expand Up @@ -515,6 +560,54 @@ public function setHandlingAmount($handling_amount)
return $this;
}

/**
* Get require reusable payment
*
* @return bool
*/
public function getRequireReusablePayment()
{
return $this->_requireReusablePayment;
}

/**
* Set require reusable payment
*
* @param bool $requireReusablePayment Reusable payment
*
* @return $this
*/
public function setRequireReusablePayment($requireReusablePayment)
{
$this->_requireReusablePayment = $requireReusablePayment;

return $this;
}

/**
* Get reusable payment description
*
* @return string
*/
public function getReusablePaymentDescription()
{
return $this->_reusablePaymentDescription;
}

/**
* Set reusable payment description
*
* @param string $reusablePaymentDescription Reusable payment description
*
* @return $this
*/
public function setReusablePaymentDescription($reusablePaymentDescription)
{
$this->_reusablePaymentDescription = $reusablePaymentDescription;

return $this;
}

/**
* Returns an array of parameters customized for the given method name
*
Expand Down Expand Up @@ -582,6 +675,18 @@ public function parameterize($method)
$parameterArray['handling_amount'] = $this->getHandlingAmount();
}

if($this->getRequireReusablePayment()) {
$parameterArray['require_reusable_payment'] = $this->getRequireReusablePayment();
}

if($this->getReusablePaymentDescription()) {
$parameterArray['reusable_payment_description'] = $this->getReusablePaymentDescription();
}

if($this->getClient()) {
$parameterArray['client'] = $this->getClient();
}

// Unite params:

if($this->getAppId()) {
Expand Down
15 changes: 13 additions & 2 deletions tests/unit/Paymill/Models/Request/ChecksumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected function tearDown()
public function setGetTest()
{
$sample = array(
'client' => 'client_88a388d9dd48f86c3136',
'checksum_type' => Checksum::TYPE_PAYPAL,
'checksum_action' => Checksum::ACTION_TRANSACTION,
'amount' => '200',
Expand Down Expand Up @@ -88,10 +89,13 @@ public function setGetTest()
)
),
'shipping_amount' => '50',
'handling_amount' => '50'
'handling_amount' => '50',
'require_reusable_payment' => true,
'reusable_payment_description' => 'Paymill Paypal test'
);

$this->_model
->setClient($sample['client'])
->setChecksumType($sample['checksum_type'])
->setChecksumAction($sample['checksum_action'])
->setAmount($sample['amount'])
Expand All @@ -104,8 +108,11 @@ public function setGetTest()
->setItems($sample['items'])
->setShippingAmount($sample['shipping_amount'])
->setHandlingAmount($sample['handling_amount'])
->setRequireReusablePayment($sample['require_reusable_payment'])
->setReusablePaymentDescription($sample['reusable_payment_description'])
;

$this->assertEquals($this->_model->getClient(), $sample['client']);
$this->assertEquals($this->_model->getChecksumType(), $sample['checksum_type']);
$this->assertEquals($this->_model->getChecksumAction(), $sample['checksum_action']);
$this->assertEquals($this->_model->getAmount(), $sample['amount']);
Expand All @@ -118,7 +125,8 @@ public function setGetTest()
$this->assertEquals($this->_model->getItems(), $sample['items']);
$this->assertEquals($this->_model->getShippingAmount(), $sample['shipping_amount']);
$this->assertEquals($this->_model->getHandlingAmount(), $sample['handling_amount']);

$this->assertEquals($this->_model->getRequireReusablePayment(), $sample['require_reusable_payment']);
$this->assertEquals($this->_model->getReusablePaymentDescription(), $sample['reusable_payment_description']);
return $this->_model;
}

Expand Down Expand Up @@ -154,6 +162,7 @@ public function parameterizeTestGetOne(Checksum $model)
public function parameterizeTestCreate(Checksum $model)
{
$parameterArray = array();
$parameterArray['client'] = 'client_88a388d9dd48f86c3136';
$parameterArray['checksum_type'] = Checksum::TYPE_PAYPAL;
$parameterArray['checksum_action'] = Checksum::ACTION_TRANSACTION;
$parameterArray['amount'] = '200';
Expand Down Expand Up @@ -201,6 +210,8 @@ public function parameterizeTestCreate(Checksum $model)
);
$parameterArray['shipping_amount'] = '50';
$parameterArray['handling_amount'] = '50';
$parameterArray['require_reusable_payment'] = true;
$parameterArray['reusable_payment_description'] = 'Paymill Paypal test';

$creationArray = $model->parameterize("create");

Expand Down