From 23cacc804381b16f2e7c20b647f128c98ba419a9 Mon Sep 17 00:00:00 2001 From: Honza Machala Date: Thu, 30 Jun 2016 23:25:02 +0200 Subject: [PATCH 1/9] Small cleanup --- .gitignore | 2 +- phpunit.xml | 16 ++++++---------- src/Message/AbstractRequest.php | 3 ++- src/Message/AbstractResponse.php | 3 ++- src/Message/EchoRequest.php | 5 +---- src/Message/InitPaymentRequest.php | 18 +----------------- src/Message/ProcessPaymentRequest.php | 6 ------ tests/bootstrap.php | 5 ----- tests/unit/PurchaseTest.php | 3 ++- tests/unit/Sign/DataSignatorTest.php | 13 +++++++++---- tests/unit/Sign/DataVerifierTest.php | 10 +++++++--- tests/unit/Sign/SignatorTest.php | 7 +++++-- tests/unit/Sign/VerifierTest.php | 7 +++++-- 13 files changed, 41 insertions(+), 57 deletions(-) delete mode 100644 tests/bootstrap.php diff --git a/.gitignore b/.gitignore index 4f38912..157ff0c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ .idea -vendor +vendor/ composer.lock diff --git a/phpunit.xml b/phpunit.xml index fc6bb9d..6f00bcd 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,23 +1,19 @@ - - + stopOnFailure="false"> - + ./tests/ - - - - + diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index a019567..3869caa 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -2,10 +2,11 @@ namespace Omnipay\Csob\Message; +use Omnipay\Common\Message\AbstractRequest as OmnipayAbstractRequest; use Omnipay\Csob\Sign\DataSignator; use Omnipay\Csob\Sign\DataVerifier; -abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest +abstract class AbstractRequest extends OmnipayAbstractRequest { /** @var DataSignator */ private $signator; diff --git a/src/Message/AbstractResponse.php b/src/Message/AbstractResponse.php index 0859561..0cc17cc 100644 --- a/src/Message/AbstractResponse.php +++ b/src/Message/AbstractResponse.php @@ -2,9 +2,10 @@ namespace Omnipay\Csob\Message; +use Omnipay\Common\Message\AbstractResponse as OmnipayAbstractResponse; use Omnipay\Csob\Sign\DataVerifier; -class AbstractResponse extends \Omnipay\Common\Message\AbstractResponse +class AbstractResponse extends OmnipayAbstractResponse { /** @var DataVerifier */ private $verifier; diff --git a/src/Message/EchoRequest.php b/src/Message/EchoRequest.php index 56e4719..aee48c5 100644 --- a/src/Message/EchoRequest.php +++ b/src/Message/EchoRequest.php @@ -25,10 +25,7 @@ public function setDttm($value) */ public function getData() { - $data = [ - "merchantId" => $this->getParameter('merchantId'), - "dttm" => $this->getParameter('dttm'), - ]; + $data = $this->getParameters(); $data['signature'] = $this->signData($data); return $data; } diff --git a/src/Message/InitPaymentRequest.php b/src/Message/InitPaymentRequest.php index 6291b00..7253e18 100644 --- a/src/Message/InitPaymentRequest.php +++ b/src/Message/InitPaymentRequest.php @@ -96,23 +96,7 @@ public function setLanguage($value) */ public function getData() { - $data = [ - "merchantId" => $this->getParameter('merchantId'), - "orderNo" => $this->getParameter('orderNo'), - "dttm" => $this->getParameter('dttm'), - "payOperation" => $this->getParameter('payOperation'), - "payMethod" => $this->getParameter('payMethod'), - "totalAmount" => $this->getParameter('totalAmount'), - "currency" => $this->getParameter('currency'), - "closePayment" => $this->getParameter('closePayment'), - "returnUrl" => $this->getParameter('returnUrl'), - "returnMethod" => $this->getParameter('returnMethod'), - "cart" => $this->getParameter('cart'), - "description" => $this->getParameter('description'), - "merchantData" => $this->getParameter('merchantData'), - "customerId" => $this->getParameter('customerId'), - "language" => $this->getParameter('language'), - ]; + $data = $this->getParameters(); $data['signature'] = $this->signData($data); return $data; } diff --git a/src/Message/ProcessPaymentRequest.php b/src/Message/ProcessPaymentRequest.php index 6ad8665..cc0a554 100644 --- a/src/Message/ProcessPaymentRequest.php +++ b/src/Message/ProcessPaymentRequest.php @@ -28,12 +28,6 @@ public function setMerchantId($value) public function getData() { return $this->getParameters(); - $data = [ - "merchantId" => $this->getParameter('merchantId'), - "payId" => $this->getParameter('payId'), - "dttm" => $this->getParameter('dttm'), - ]; - return $data; } /** diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index 0f47be9..0000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,5 +0,0 @@ -addCartItem($item); $purchase->setDttm('xyz'); $expected = [ diff --git a/tests/unit/Sign/DataSignatorTest.php b/tests/unit/Sign/DataSignatorTest.php index e051a09..b3ead7c 100644 --- a/tests/unit/Sign/DataSignatorTest.php +++ b/tests/unit/Sign/DataSignatorTest.php @@ -1,15 +1,20 @@ "A1029DTmM7", diff --git a/tests/unit/Sign/DataVerifierTest.php b/tests/unit/Sign/DataVerifierTest.php index baf1157..dfaa54e 100644 --- a/tests/unit/Sign/DataVerifierTest.php +++ b/tests/unit/Sign/DataVerifierTest.php @@ -1,13 +1,17 @@ "518778", diff --git a/tests/unit/Sign/SignatorTest.php b/tests/unit/Sign/SignatorTest.php index a376ea7..31b8de4 100644 --- a/tests/unit/Sign/SignatorTest.php +++ b/tests/unit/Sign/SignatorTest.php @@ -1,13 +1,16 @@ sign($text); diff --git a/tests/unit/Sign/VerifierTest.php b/tests/unit/Sign/VerifierTest.php index 7e3e721..7be0a1a 100644 --- a/tests/unit/Sign/VerifierTest.php +++ b/tests/unit/Sign/VerifierTest.php @@ -1,13 +1,16 @@ sign($text); From bc77333f7c5dde84344751082e3109e87809f72b Mon Sep 17 00:00:00 2001 From: Honza Machala Date: Thu, 21 Jul 2016 09:41:24 +0200 Subject: [PATCH 2/9] Spelling of currency --- src/Purchase.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Purchase.php b/src/Purchase.php index 7dae23c..1da0ba9 100644 --- a/src/Purchase.php +++ b/src/Purchase.php @@ -9,10 +9,10 @@ */ class Purchase { - const CURENCY_CZK = 'CZK'; - const CURENCY_EUR = 'EUR'; - const CURENCY_USD = 'USD'; - const CURENCY_GBP = 'GBP'; + const CURRENCY_CZK = 'CZK'; + const CURRENCY_EUR = 'EUR'; + const CURRENCY_USD = 'USD'; + const CURRENCY_GBP = 'GBP'; const LANG_CZ = 'CZ'; const LANG_EN = 'EN'; @@ -75,7 +75,7 @@ class Purchase * * @var string */ - private $currency = self::CURENCY_CZK; + private $currency = self::CURRENCY_CZK; /** * It indicates whether the payment should automatically be put in the queue From 133ebf75bac6c5598dcd75c2ad633d14e4f895ea Mon Sep 17 00:00:00 2001 From: Honza Machala Date: Thu, 21 Jul 2016 09:44:00 +0200 Subject: [PATCH 3/9] HUF and PLN support --- src/Purchase.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Purchase.php b/src/Purchase.php index 1da0ba9..4cc6281 100644 --- a/src/Purchase.php +++ b/src/Purchase.php @@ -13,6 +13,8 @@ class Purchase const CURRENCY_EUR = 'EUR'; const CURRENCY_USD = 'USD'; const CURRENCY_GBP = 'GBP'; + const CURRENCY_HUF = 'HUF'; + const CURRENCY_PLN = 'PLN'; const LANG_CZ = 'CZ'; const LANG_EN = 'EN'; @@ -71,7 +73,7 @@ class Purchase /** * Currency code. - * Approved values: CZK, EUR, USD, GBP + * Approved values: CZK, EUR, USD, GBP, HUF, PLN * * @var string */ From 8cf5f24e3c89c19ad056a3fd66723a173fffdd4d Mon Sep 17 00:00:00 2001 From: Honza Machala Date: Thu, 21 Jul 2016 09:48:10 +0200 Subject: [PATCH 4/9] Real list of supported languages for csob --- src/Purchase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Purchase.php b/src/Purchase.php index 4cc6281..8b3f091 100644 --- a/src/Purchase.php +++ b/src/Purchase.php @@ -145,7 +145,7 @@ class Purchase /** * Preferred language mutation to be displayed on the payment gateway. * Czech mutation is by default. - * Approved values: CZ, EN, DE, SK + * Approved values: CZ, EN, DE, FR, HU, IT, JP, PL, PT, RO, RU, SK, ES, TR, VN * * @var string */ From ea995d4d1e108fdbb2887a70f2be065f249a60cc Mon Sep 17 00:00:00 2001 From: Honza Machala Date: Thu, 21 Jul 2016 09:48:56 +0200 Subject: [PATCH 5/9] Increased version to 1.6 --- src/Gateway.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Gateway.php b/src/Gateway.php index e1942cd..36a3554 100644 --- a/src/Gateway.php +++ b/src/Gateway.php @@ -16,12 +16,12 @@ * ČSOB payment gateway * * @package Omnipay\Csob - * @see https://github.com/csob/paymentgateway/wiki/eAPI-1.5-EN + * @see https://github.com/csob/paymentgateway/wiki/eAPI-v1.6-EN */ class Gateway extends AbstractGateway { - const URL_SANDBOX = 'https://iapi.iplatebnibrana.csob.cz/api/v1.5'; - const URL_PRODUCTION = 'https://api.platebnibrana.csob.cz/api/v1.5'; + const URL_SANDBOX = 'https://iapi.iplatebnibrana.csob.cz/api/v1.6'; + const URL_PRODUCTION = 'https://api.platebnibrana.csob.cz/api/v1.6'; /** @var DataSignator */ private $signator; From dbf68128a931d83520d72a5c031d6611290e56fb Mon Sep 17 00:00:00 2001 From: Honza Machala Date: Thu, 21 Jul 2016 10:14:06 +0200 Subject: [PATCH 6/9] Added author --- composer.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 43ebbc7..ff6c58f 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,11 @@ "authors": [ { "name": "Michal Sänger", - "email": "michal.sanger@bileto.cz" + "email": "michal.sanger@bileto.com" + }, + { + "name": "Jan Machala", + "email": "jan.machala@bileto.com" } ], "autoload": { From 9bbcdec764e07a57bf8d20d2ddca62c27c697b51 Mon Sep 17 00:00:00 2001 From: Honza Machala Date: Thu, 21 Jul 2016 10:16:06 +0200 Subject: [PATCH 7/9] Updated dev-dependencies --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index ff6c58f..06cd3a7 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ }, "require-dev": { "omnipay/tests": "^2.0", - "symfony/var-dumper": "^2.7", - "mockery/mockery": "^0.9.4" + "symfony/var-dumper": "3.1.*", + "mockery/mockery": "0.9.*" } } From 13a7ca0ae0a72618cd0ff75bc7be5592450706b7 Mon Sep 17 00:00:00 2001 From: Honza Machala Date: Thu, 21 Jul 2016 10:18:27 +0200 Subject: [PATCH 8/9] Updated omnipay-common to v2.5 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 06cd3a7..076d6c7 100644 --- a/composer.json +++ b/composer.json @@ -27,10 +27,10 @@ "psr-4": { "Omnipay\\Csob\\" : "src/" } }, "require": { - "omnipay/common": "2.3.*" + "omnipay/common": "2.5.*" }, "require-dev": { - "omnipay/tests": "^2.0", + "omnipay/tests": "2.0.*", "symfony/var-dumper": "3.1.*", "mockery/mockery": "0.9.*" } From 2f393855c4c1f3257f71e36ce5ca72413a1bd008 Mon Sep 17 00:00:00 2001 From: Honza Machala Date: Fri, 22 Jul 2016 11:30:48 +0200 Subject: [PATCH 9/9] Instructions for allowing acceptance PLN and HUF --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index dc258d1..9af92c8 100644 --- a/README.md +++ b/README.md @@ -48,3 +48,8 @@ try { dump((string)$e); } ``` + +## Settings + + +If you would like to use `PLN` and `HUF` currencies, you need to send email to `akceptacekaret@csob.cz` with your MerchantIds (sandbox and production). This functionality will be available September 2016.