diff --git a/lib/Paymill/Models/Request/Checksum.php b/lib/Paymill/Models/Request/Checksum.php index 607f16f..50ac7f9 100755 --- a/lib/Paymill/Models/Request/Checksum.php +++ b/lib/Paymill/Models/Request/Checksum.php @@ -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 */ @@ -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 * @@ -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 * @@ -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()) { diff --git a/tests/unit/Paymill/Models/Request/ChecksumTest.php b/tests/unit/Paymill/Models/Request/ChecksumTest.php index d9b0f5a..96bc2fc 100755 --- a/tests/unit/Paymill/Models/Request/ChecksumTest.php +++ b/tests/unit/Paymill/Models/Request/ChecksumTest.php @@ -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', @@ -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']) @@ -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']); @@ -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; } @@ -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'; @@ -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");