From 51938ec680c334a9fbcb7aa2ac50cb5e8e550ff7 Mon Sep 17 00:00:00 2001 From: Kiril Ustalov Date: Fri, 8 Jul 2016 13:14:45 +0300 Subject: [PATCH 1/3] Added dynamic mode functionality --- .../Ecopayz/Message/PurchaseRequest.php | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/src/Omnipay/Ecopayz/Message/PurchaseRequest.php b/src/Omnipay/Ecopayz/Message/PurchaseRequest.php index 07935463..4b0ed510 100644 --- a/src/Omnipay/Ecopayz/Message/PurchaseRequest.php +++ b/src/Omnipay/Ecopayz/Message/PurchaseRequest.php @@ -65,6 +65,11 @@ public function getData() $data['Amount'] = $this->getAmount(); $data['Currency'] = $this->getCurrency(); $data['MerchantFreeText'] = $this->getDescription(); + $data['OnSuccessUrl'] = $this->getOnSuccessUrl(); + $data['OnFailureUrl'] = $this->getOnFailureUrl(); + $data['TransferUrl'] = $this->getTransferUrl(); + $data['CancellationUrl'] = $this->getCancellationUrl(); + $data['CallbackUrl'] = $this->getCallbackUrl(); $data['Checksum'] = $this->calculateArrayChecksum($data); return $data; @@ -80,4 +85,113 @@ public function sendData($data) { return new PurchaseResponse($this, $data); } + + /** + * SET/GET Callback URL's for dynamic mode + */ + + /** + * Set the success cb url + * + * @param string $value success cb url + * @return self + */ + public function setOnSuccessUrl($value) + { + return $this->setParameter('OnSuccessUrl', $value); + } + + /** + * Get the success cb url + * + * @return string success cb url + */ + public function getOnSuccessUrl() + { + return $this->getParameter('OnSuccessUrl'); + } + + /** + * Set the failure cb url + * + * @param string $value failure cb url + * @return self + */ + public function setOnFailureUrl($value) + { + return $this->setParameter('OnFailureUrl', $value); + } + + /** + * Get the failure cb url + * + * @return string failure cb url + */ + public function getOnFailureUrl() + { + return $this->getParameter('OnFailureUrl'); + } + + /** + * Set the transfer cb url + * + * @param string $value transfer cb url + * @return self + */ + public function setTransferUrl($value) + { + return $this->setParameter('TransferUrl', $value); + } + + /** + * Get the transfer cb url + * + * @return string transfer cb url + */ + public function getTransferUrl() + { + return $this->getParameter('TransferUrl'); + } + + /** + * Set the cancellation cb url + * + * @param string $value cancellation cb url + * @return self + */ + public function setCancellationUrl($value) + { + return $this->setParameter('CancellationUrl', $value); + } + + /** + * Get the cancellation cb url + * + * @return string cancellation cb url + */ + public function getCancellationUrl() + { + return $this->getParameter('CancellationUrl'); + } + + /** + * Set the callback cb url + * + * @param string $value callback cb url + * @return self + */ + public function setCallbackUrl($value) + { + return $this->setParameter('CallbackUrl', $value); + } + + /** + * Get the callback cb url + * + * @return string callback cb url + */ + public function getCallbackUrl() + { + return $this->getParameter('CallbackUrl'); + } } From 3dff894bfc01561d579e665812023e5ea9990146 Mon Sep 17 00:00:00 2001 From: Alexander Shovdra Date: Sun, 17 Jul 2016 17:58:34 +0300 Subject: [PATCH 2/3] Reverting first version of callback functionality --- .../Ecopayz/Message/PurchaseRequest.php | 114 ------------------ 1 file changed, 114 deletions(-) diff --git a/src/Omnipay/Ecopayz/Message/PurchaseRequest.php b/src/Omnipay/Ecopayz/Message/PurchaseRequest.php index 4b0ed510..07935463 100644 --- a/src/Omnipay/Ecopayz/Message/PurchaseRequest.php +++ b/src/Omnipay/Ecopayz/Message/PurchaseRequest.php @@ -65,11 +65,6 @@ public function getData() $data['Amount'] = $this->getAmount(); $data['Currency'] = $this->getCurrency(); $data['MerchantFreeText'] = $this->getDescription(); - $data['OnSuccessUrl'] = $this->getOnSuccessUrl(); - $data['OnFailureUrl'] = $this->getOnFailureUrl(); - $data['TransferUrl'] = $this->getTransferUrl(); - $data['CancellationUrl'] = $this->getCancellationUrl(); - $data['CallbackUrl'] = $this->getCallbackUrl(); $data['Checksum'] = $this->calculateArrayChecksum($data); return $data; @@ -85,113 +80,4 @@ public function sendData($data) { return new PurchaseResponse($this, $data); } - - /** - * SET/GET Callback URL's for dynamic mode - */ - - /** - * Set the success cb url - * - * @param string $value success cb url - * @return self - */ - public function setOnSuccessUrl($value) - { - return $this->setParameter('OnSuccessUrl', $value); - } - - /** - * Get the success cb url - * - * @return string success cb url - */ - public function getOnSuccessUrl() - { - return $this->getParameter('OnSuccessUrl'); - } - - /** - * Set the failure cb url - * - * @param string $value failure cb url - * @return self - */ - public function setOnFailureUrl($value) - { - return $this->setParameter('OnFailureUrl', $value); - } - - /** - * Get the failure cb url - * - * @return string failure cb url - */ - public function getOnFailureUrl() - { - return $this->getParameter('OnFailureUrl'); - } - - /** - * Set the transfer cb url - * - * @param string $value transfer cb url - * @return self - */ - public function setTransferUrl($value) - { - return $this->setParameter('TransferUrl', $value); - } - - /** - * Get the transfer cb url - * - * @return string transfer cb url - */ - public function getTransferUrl() - { - return $this->getParameter('TransferUrl'); - } - - /** - * Set the cancellation cb url - * - * @param string $value cancellation cb url - * @return self - */ - public function setCancellationUrl($value) - { - return $this->setParameter('CancellationUrl', $value); - } - - /** - * Get the cancellation cb url - * - * @return string cancellation cb url - */ - public function getCancellationUrl() - { - return $this->getParameter('CancellationUrl'); - } - - /** - * Set the callback cb url - * - * @param string $value callback cb url - * @return self - */ - public function setCallbackUrl($value) - { - return $this->setParameter('CallbackUrl', $value); - } - - /** - * Get the callback cb url - * - * @return string callback cb url - */ - public function getCallbackUrl() - { - return $this->getParameter('CallbackUrl'); - } } From 38b48760941065d3662d66b8690819b0f39a17ae Mon Sep 17 00:00:00 2001 From: Alexander Shovdra Date: Sun, 17 Jul 2016 18:53:39 +0300 Subject: [PATCH 3/3] Added an option to use callbackUrl --- .../Ecopayz/Message/AbstractRequest.php | 21 +++++++++++++++++++ .../Ecopayz/Message/PurchaseRequest.php | 4 ++++ .../Ecopayz/Message/PurchaseRequestTest.php | 4 +++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Omnipay/Ecopayz/Message/AbstractRequest.php b/src/Omnipay/Ecopayz/Message/AbstractRequest.php index b8ee20fc..e168bbd4 100644 --- a/src/Omnipay/Ecopayz/Message/AbstractRequest.php +++ b/src/Omnipay/Ecopayz/Message/AbstractRequest.php @@ -96,6 +96,27 @@ public function setMerchantAccountNumber($value) return $this->setParameter('merchantAccountNumber', $value); } + /** + * Get the request callback URL. + * + * @return string + */ + public function getCallbackUrl() + { + return $this->getParameter('callbackUrl'); + } + + /** + * Sets the request callback URL. + * + * @param string $value + * @return AbstractRequest Provides a fluent interface + */ + public function setCallbackUrl($value) + { + return $this->setParameter('callbackUrl', $value); + } + /** * Get calculated checksum * diff --git a/src/Omnipay/Ecopayz/Message/PurchaseRequest.php b/src/Omnipay/Ecopayz/Message/PurchaseRequest.php index 68060389..675e29dd 100644 --- a/src/Omnipay/Ecopayz/Message/PurchaseRequest.php +++ b/src/Omnipay/Ecopayz/Message/PurchaseRequest.php @@ -78,6 +78,10 @@ public function getData() $data['TransferUrl'] = $notifyUrl; } + if ($callbackUrl = $this->getCallbackUrl()) { + $data['CallbackUrl'] = $callbackUrl; + } + $data['Checksum'] = $this->calculateArrayChecksum($data); return $data; } diff --git a/tests/Omnipay/Ecopayz/Message/PurchaseRequestTest.php b/tests/Omnipay/Ecopayz/Message/PurchaseRequestTest.php index 96fbb84f..83094c94 100644 --- a/tests/Omnipay/Ecopayz/Message/PurchaseRequestTest.php +++ b/tests/Omnipay/Ecopayz/Message/PurchaseRequestTest.php @@ -22,6 +22,7 @@ public function setUp() 'returnUrl' => 'http://example.com/return', 'cancelUrl' => 'http://example.com/cancel', 'notifyUrl' => 'http://example.com/notify', + 'callbackUrl' => 'http://example.com/callback', )); } @@ -36,10 +37,11 @@ public function testGetData() $this->assertSame('12.34', $data['Amount']); $this->assertSame('EUR', $data['Currency']); $this->assertSame('Free Text Description', $data['MerchantFreeText']); - $this->assertSame('7320d93a3daa1e296f56fa7f40d6fb8b', $data['Checksum']); + $this->assertSame('aa9f664af58922801ac1e23007962af8', $data['Checksum']); $this->assertSame('http://example.com/return', $data['OnSuccessUrl']); $this->assertSame('http://example.com/cancel', $data['OnFailureUrl']); $this->assertSame('http://example.com/notify', $data['TransferUrl']); + $this->assertSame('http://example.com/callback', $data['callbackUrl']); } public function testSendData()