From 833d99ca8c23a4d36880633c847144ce057e0b37 Mon Sep 17 00:00:00 2001 From: BSc Vassil Nikolov Date: Tue, 1 Dec 2015 13:48:11 +0200 Subject: [PATCH 1/6] add ClientId to checksum --- lib/Paymill/Models/Request/Checksum.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/Paymill/Models/Request/Checksum.php b/lib/Paymill/Models/Request/Checksum.php index 607f16f..e3e69bd 100755 --- a/lib/Paymill/Models/Request/Checksum.php +++ b/lib/Paymill/Models/Request/Checksum.php @@ -121,6 +121,8 @@ class Checksum extends Base */ private $_handling_amount; + private $_clientId; + /** * Creates an instance of the checksum request model */ @@ -129,6 +131,18 @@ function __construct() $this->_serviceResource = 'checksums/'; } + public function setClientId($clientId) + { + $this->_clientId = $clientId; + + return $this; + } + + public function getClientId() + { + return $this->_clientId; + } + /** * Set amount * @@ -582,6 +596,10 @@ public function parameterize($method) $parameterArray['handling_amount'] = $this->getHandlingAmount(); } + if($this->getClientId()) { + $parameterArray['client_id'] = $this->getClientId(); + } + // Unite params: if($this->getAppId()) { From 803de65f513f67cef4c4ec381b93db2b66d532ae Mon Sep 17 00:00:00 2001 From: cyrrill Date: Tue, 22 Dec 2015 21:33:29 -0600 Subject: [PATCH 2/6] Add Checksum reusable payment fields --- lib/Paymill/Models/Request/Checksum.php | 70 +++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/lib/Paymill/Models/Request/Checksum.php b/lib/Paymill/Models/Request/Checksum.php index 607f16f..c7ae9c8 100755 --- a/lib/Paymill/Models/Request/Checksum.php +++ b/lib/Paymill/Models/Request/Checksum.php @@ -121,6 +121,20 @@ class Checksum extends Base */ private $_handling_amount; + /** + * Reusable payment + * + * @var bool $_requireReusablePayment + */ + private $_requireReusablePayment; + + /** + * Reusable payment description + * + * @var string $_reusablePaymentDescription + */ + private $_reusablePaymentDescription; + /** * Creates an instance of the checksum request model */ @@ -515,6 +529,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 +644,14 @@ 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(); + } + // Unite params: if($this->getAppId()) { From 0121184d62b56b124847718a17de4102816da4df Mon Sep 17 00:00:00 2001 From: cyrrill Date: Tue, 22 Dec 2015 21:49:36 -0600 Subject: [PATCH 3/6] Update ChecksumTest --- tests/unit/Paymill/Models/Request/ChecksumTest.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/unit/Paymill/Models/Request/ChecksumTest.php b/tests/unit/Paymill/Models/Request/ChecksumTest.php index d9b0f5a..96e3d0a 100755 --- a/tests/unit/Paymill/Models/Request/ChecksumTest.php +++ b/tests/unit/Paymill/Models/Request/ChecksumTest.php @@ -88,7 +88,9 @@ public function setGetTest() ) ), 'shipping_amount' => '50', - 'handling_amount' => '50' + 'handling_amount' => '50', + 'require_reusable_payment' => true, + 'reusable_payment_description' => 'Paymill Paypal test' ); $this->_model @@ -104,6 +106,8 @@ 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->getChecksumType(), $sample['checksum_type']); @@ -118,7 +122,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; } @@ -201,6 +206,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"); From 4f5bae8aa76bd17b407b77b4bd0a99e897d752d0 Mon Sep 17 00:00:00 2001 From: cyrrill Date: Thu, 24 Dec 2015 04:43:10 -0600 Subject: [PATCH 4/6] Documenting client id methods --- lib/Paymill/Models/Request/Checksum.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/Paymill/Models/Request/Checksum.php b/lib/Paymill/Models/Request/Checksum.php index 93e0eeb..4828b27 100755 --- a/lib/Paymill/Models/Request/Checksum.php +++ b/lib/Paymill/Models/Request/Checksum.php @@ -121,6 +121,11 @@ class Checksum extends Base */ private $_handling_amount; + /** + * Client identifier + * + * @var string $_clientId + */ private $_clientId; /** @@ -145,6 +150,13 @@ function __construct() $this->_serviceResource = 'checksums/'; } + /** + * Sets the identifier of the Client for the transaction + * + * @param string $clientId Client identifier + * + * @return $this + */ public function setClientId($clientId) { $this->_clientId = $clientId; @@ -152,6 +164,11 @@ public function setClientId($clientId) 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 getClientId() { return $this->_clientId; From abeec06078f70892c133aaf75a80004b7455f1f4 Mon Sep 17 00:00:00 2001 From: cyrrill Date: Thu, 24 Dec 2015 04:44:34 -0600 Subject: [PATCH 5/6] Test client id in checksum --- tests/unit/Paymill/Models/Request/ChecksumTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unit/Paymill/Models/Request/ChecksumTest.php b/tests/unit/Paymill/Models/Request/ChecksumTest.php index 96e3d0a..c388f32 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_id' => 'client_88a388d9dd48f86c3136', 'checksum_type' => Checksum::TYPE_PAYPAL, 'checksum_action' => Checksum::ACTION_TRANSACTION, 'amount' => '200', @@ -94,6 +95,7 @@ public function setGetTest() ); $this->_model + ->setClientId($sample['client_id']) ->setChecksumType($sample['checksum_type']) ->setChecksumAction($sample['checksum_action']) ->setAmount($sample['amount']) @@ -110,6 +112,7 @@ public function setGetTest() ->setReusablePaymentDescription($sample['reusable_payment_description']) ; + $this->assertEquals($this->_model->getClientId(), $sample['client_id']); $this->assertEquals($this->_model->getChecksumType(), $sample['checksum_type']); $this->assertEquals($this->_model->getChecksumAction(), $sample['checksum_action']); $this->assertEquals($this->_model->getAmount(), $sample['amount']); @@ -159,6 +162,7 @@ public function parameterizeTestGetOne(Checksum $model) public function parameterizeTestCreate(Checksum $model) { $parameterArray = array(); + $parameterArray['client_id'] = 'client_88a388d9dd48f86c3136'; $parameterArray['checksum_type'] = Checksum::TYPE_PAYPAL; $parameterArray['checksum_action'] = Checksum::ACTION_TRANSACTION; $parameterArray['amount'] = '200'; From f283e6f18148bc44759ef67c64a747b938a5eac1 Mon Sep 17 00:00:00 2001 From: cyrrill Date: Thu, 24 Dec 2015 07:05:08 -0600 Subject: [PATCH 6/6] Renames to client --- lib/Paymill/Models/Request/Checksum.php | 16 ++++++++-------- .../unit/Paymill/Models/Request/ChecksumTest.php | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/Paymill/Models/Request/Checksum.php b/lib/Paymill/Models/Request/Checksum.php index 4828b27..50ac7f9 100755 --- a/lib/Paymill/Models/Request/Checksum.php +++ b/lib/Paymill/Models/Request/Checksum.php @@ -124,9 +124,9 @@ class Checksum extends Base /** * Client identifier * - * @var string $_clientId + * @var string $_client */ - private $_clientId; + private $_client; /** * Reusable payment @@ -157,9 +157,9 @@ function __construct() * * @return $this */ - public function setClientId($clientId) + public function setClient($client) { - $this->_clientId = $clientId; + $this->_client = $client; return $this; } @@ -169,9 +169,9 @@ public function setClientId($clientId) * * @return string */ - public function getClientId() + public function getClient() { - return $this->_clientId; + return $this->_client; } /** @@ -683,8 +683,8 @@ public function parameterize($method) $parameterArray['reusable_payment_description'] = $this->getReusablePaymentDescription(); } - if($this->getClientId()) { - $parameterArray['client_id'] = $this->getClientId(); + if($this->getClient()) { + $parameterArray['client'] = $this->getClient(); } // Unite params: diff --git a/tests/unit/Paymill/Models/Request/ChecksumTest.php b/tests/unit/Paymill/Models/Request/ChecksumTest.php index c388f32..96bc2fc 100755 --- a/tests/unit/Paymill/Models/Request/ChecksumTest.php +++ b/tests/unit/Paymill/Models/Request/ChecksumTest.php @@ -42,7 +42,7 @@ protected function tearDown() public function setGetTest() { $sample = array( - 'client_id' => 'client_88a388d9dd48f86c3136', + 'client' => 'client_88a388d9dd48f86c3136', 'checksum_type' => Checksum::TYPE_PAYPAL, 'checksum_action' => Checksum::ACTION_TRANSACTION, 'amount' => '200', @@ -95,7 +95,7 @@ public function setGetTest() ); $this->_model - ->setClientId($sample['client_id']) + ->setClient($sample['client']) ->setChecksumType($sample['checksum_type']) ->setChecksumAction($sample['checksum_action']) ->setAmount($sample['amount']) @@ -112,7 +112,7 @@ public function setGetTest() ->setReusablePaymentDescription($sample['reusable_payment_description']) ; - $this->assertEquals($this->_model->getClientId(), $sample['client_id']); + $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']); @@ -162,7 +162,7 @@ public function parameterizeTestGetOne(Checksum $model) public function parameterizeTestCreate(Checksum $model) { $parameterArray = array(); - $parameterArray['client_id'] = 'client_88a388d9dd48f86c3136'; + $parameterArray['client'] = 'client_88a388d9dd48f86c3136'; $parameterArray['checksum_type'] = Checksum::TYPE_PAYPAL; $parameterArray['checksum_action'] = Checksum::ACTION_TRANSACTION; $parameterArray['amount'] = '200';