From c1497883ab10ad205f62bce80cabdec29f3855d2 Mon Sep 17 00:00:00 2001 From: Etienne Dauvergne <contact@ekyna.com> Date: Wed, 12 May 2021 11:56:05 +0200 Subject: [PATCH 01/10] Added hash_mode config key to gateway factory. --- composer.json | 2 +- src/PayzenGatewayFactory.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 9755cb0..670debd 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "authors": [ { "name": "Etienne Dauvergne", - "homepage": "http://ekyna.com" + "homepage": "https://ekyna.com" } ], "keywords": [ diff --git a/src/PayzenGatewayFactory.php b/src/PayzenGatewayFactory.php index b06f2a0..9fb4030 100644 --- a/src/PayzenGatewayFactory.php +++ b/src/PayzenGatewayFactory.php @@ -16,7 +16,7 @@ class PayzenGatewayFactory extends GatewayFactory /** * Builds a new factory. * - * @param array $defaultConfig + * @param array $defaultConfig * @param GatewayFactoryInterface|null $coreGatewayFactory * * @return PayzenGatewayFactory @@ -53,6 +53,7 @@ protected function populateConfig(ArrayObject $config) 'ctx_mode' => null, 'directory' => null, 'endpoint' => null, + 'hash_mode' => Api\Api::HASH_MODE_SHA256, 'debug' => false, ]; @@ -69,6 +70,7 @@ protected function populateConfig(ArrayObject $config) 'certificate' => $config['certificate'], 'ctx_mode' => $config['ctx_mode'], 'directory' => $config['directory'], + 'hash_mode' => $config['hash_mode'], 'debug' => $config['debug'], ]; From 2dc8a252b8b7ab0e630121c3f9feca7ce0f0b058 Mon Sep 17 00:00:00 2001 From: Etienne Dauvergne <contact@ekyna.com> Date: Fri, 17 Dec 2021 09:39:02 +0100 Subject: [PATCH 02/10] Allow php-http/guzzle6-adapter 2. --- README.md | 1 + composer.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fb2d781..2048cb7 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ $gateway = $factory->create([ 'site_id' => '132456', 'certificate' => '132456', 'ctx_mode' => Api::MODE_PRODUCTION, + 'hash_mode' => Api::HASH_MODE_SHA256, 'directory' => __DIR__ . '/payzen-cache', ]); diff --git a/composer.json b/composer.json index 670debd..7a6d65f 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require": { "php": "^7.1", "payum/core": "^1.5", - "php-http/guzzle6-adapter": "^1.1", + "php-http/guzzle6-adapter": "^1.1|^2.0", "symfony/options-resolver": "^3.0|^4.0|^5.0", "symfony/process": "^3.0|^4.0|^5.0", "psr/log": "^1.0" From 7805cc730e6a39a95eea32cd62d52d8c644e5408 Mon Sep 17 00:00:00 2001 From: Etienne Dauvergne <contact@ekyna.com> Date: Thu, 3 Mar 2022 15:54:51 +0100 Subject: [PATCH 03/10] Allow any psr/http implementation. --- .github/workflows/build.yml | 11 +++++++---- composer.json | 10 +++++----- tests/Action/AbstractActionTest.php | 10 ---------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7d8c231..b4b7c2f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,11 +19,14 @@ jobs: strategy: fail-fast: false matrix: - php: [7.1, 7.2, 7.3, 7.4] - symfony: [^3.4, ^4.4, ^5.2] + php: [7.1, 7.2, 7.3, 7.4, 8.0] + symfony: [^3.4, ^4.4, ^5.2, ^6.0] exclude: - - php: 7.1 - symfony: ^5.2 + - { php: 7.1, symfony: ^5.2 } + - { php: 7.1, symfony: ^6.0 } + - { php: 7.2, symfony: ^6.0 } + - { php: 7.3, symfony: ^6.0 } + - { php: 7.4, symfony: ^6.0 } env: APP_ENV: test diff --git a/composer.json b/composer.json index 7a6d65f..5a61368 100644 --- a/composer.json +++ b/composer.json @@ -20,15 +20,15 @@ "MIT" ], "require": { - "php": "^7.1", + "php": "^7.1|^8.0", "payum/core": "^1.5", - "php-http/guzzle6-adapter": "^1.1|^2.0", - "symfony/options-resolver": "^3.0|^4.0|^5.0", - "symfony/process": "^3.0|^4.0|^5.0", + "symfony/options-resolver": ">3.4,<7.0", + "symfony/process": ">3.4,<7.0", "psr/log": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^7.0|^8.0" + "phpunit/phpunit": "^7.0|^8.0", + "php-http/guzzle6-adapter": "^2.0" }, "autoload": { "psr-4": { diff --git a/tests/Action/AbstractActionTest.php b/tests/Action/AbstractActionTest.php index 7f13f13..7d28f2d 100644 --- a/tests/Action/AbstractActionTest.php +++ b/tests/Action/AbstractActionTest.php @@ -16,16 +16,6 @@ */ abstract class AbstractActionTest extends GenericActionTest { - /** - * @test - */ - public function couldBeConstructedWithoutAnyArguments() - { - parent::couldBeConstructedWithoutAnyArguments(); - - $this->assertTrue(true); - } - /** * @return MockObject|GatewayInterface */ From eb9deb77d42faae05d36caf9679dec20c1bd1fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LEFEBVRE=20Cl=C3=A9ment?= <clement.lefebvre@creativeo.fr> Date: Tue, 24 May 2022 13:25:45 +0200 Subject: [PATCH 04/10] Add Clic&Pay provider --- README.md | 2 +- src/Api/Api.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2048cb7..06d3fda 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ PayumPayzen =========== -PayZen Payum Gateway (Systempay, Scellius) +PayZen Payum Gateway (Systempay, Scellius, CLIC&PAY) [](https://github.com/ekyna/PayumPayzen/actions/workflows/build.yml) diff --git a/src/Api/Api.php b/src/Api/Api.php index 8b91f74..7d3533e 100644 --- a/src/Api/Api.php +++ b/src/Api/Api.php @@ -22,6 +22,7 @@ class Api const ENDPOINT_SYSTEMPAY = 'SYSTEMPAY'; const ENDPOINT_SCELLIUS = 'SCELLIUS'; + const ENDPOINT_CLICANDPAY = 'CLICANDPAY'; /** * @var OptionsResolver @@ -204,6 +205,7 @@ private function getDirectoryPath(): string { $path = $this->config['directory']; + // Create directory if not exists if (!is_dir($path)) { if (!mkdir($path, 0755, true)) { @@ -466,7 +468,7 @@ private function getModes(): array private function getEndPoints(): array { - return [null, self::ENDPOINT_SYSTEMPAY, self::ENDPOINT_SCELLIUS]; + return [null, self::ENDPOINT_SYSTEMPAY, self::ENDPOINT_SCELLIUS, self::ENDPOINT_CLICANDPAY]; } private function getHashModes(): array @@ -484,6 +486,10 @@ private function getUrl(): string return 'https://scelliuspaiement.labanquepostale.fr/vads-payment/'; } + if (self::ENDPOINT_CLICANDPAY === $this->config['endpoint']) { + return 'https://clicandpay.groupecdn.fr/vads-payment/'; + } + return 'https://secure.payzen.eu/vads-payment/'; } From ca31701f82caff350994e5632334f6ba47b349fc Mon Sep 17 00:00:00 2001 From: Florentin Garnier <florentin@digital404.fr> Date: Sun, 25 Sep 2022 17:12:23 +0200 Subject: [PATCH 05/10] Integration of OSB endpoint --- src/Api/Api.php | 7 ++++++- tests/Api/ApiTest.php | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Api/Api.php b/src/Api/Api.php index 7d3533e..5886c4b 100644 --- a/src/Api/Api.php +++ b/src/Api/Api.php @@ -23,6 +23,7 @@ class Api const ENDPOINT_SYSTEMPAY = 'SYSTEMPAY'; const ENDPOINT_SCELLIUS = 'SCELLIUS'; const ENDPOINT_CLICANDPAY = 'CLICANDPAY'; + const ENDPOINT_OSB = 'OSB'; /** * @var OptionsResolver @@ -468,7 +469,7 @@ private function getModes(): array private function getEndPoints(): array { - return [null, self::ENDPOINT_SYSTEMPAY, self::ENDPOINT_SCELLIUS, self::ENDPOINT_CLICANDPAY]; + return [null, self::ENDPOINT_SYSTEMPAY, self::ENDPOINT_SCELLIUS, self::ENDPOINT_CLICANDPAY, self::ENDPOINT_OSB]; } private function getHashModes(): array @@ -490,6 +491,10 @@ private function getUrl(): string return 'https://clicandpay.groupecdn.fr/vads-payment/'; } + if (self::ENDPOINT_OSB === $this->config['endpoint']) { + return 'https://secure.osb.pf/vads-payment/'; + } + return 'https://secure.payzen.eu/vads-payment/'; } diff --git a/tests/Api/ApiTest.php b/tests/Api/ApiTest.php index c274a5d..1543b9b 100644 --- a/tests/Api/ApiTest.php +++ b/tests/Api/ApiTest.php @@ -184,6 +184,19 @@ public function provideCreateRequestUrl(): Generator ], 'https://scelliuspaiement.labanquepostale.fr/vads-payment/?vads_action_mode=INTERACTIVE&vads_page_action=PAYMENT&vads_payment_config=SINGLE&vads_return_mode=POST&vads_version=V2&vads_amount=1234&vads_currency=978&vads_trans_date=20200101120000&vads_trans_id=000001&vads_site_id=123456789&vads_ctx_mode=PRODUCTION&signature=p9TbeohlOZVPAmhEwfAlGxRJxFAKpNg5wYBSN9emuqs%3D', ]; + + yield [ + [ + 'endpoint' => Api::ENDPOINT_OSB, + ], + [ + 'vads_amount' => '1234', + 'vads_currency' => '978', + 'vads_trans_date' => '20200101120000', + 'vads_trans_id' => '000001', + ], + 'https://secure.osb.pf/vads-payment/?vads_action_mode=INTERACTIVE&vads_page_action=PAYMENT&vads_payment_config=SINGLE&vads_return_mode=POST&vads_version=V2&vads_amount=1234&vads_currency=978&vads_trans_date=20200101120000&vads_trans_id=000001&vads_site_id=123456789&vads_ctx_mode=PRODUCTION&signature=p9TbeohlOZVPAmhEwfAlGxRJxFAKpNg5wYBSN9emuqs%3D', + ]; } /** From 911526be35fe7e7bfbc10ee57ed1abf26554ab07 Mon Sep 17 00:00:00 2001 From: Florentin Garnier <florentin@digital404.fr> Date: Mon, 26 Sep 2022 14:00:20 +0200 Subject: [PATCH 06/10] Add OSB support --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 06d3fda..94cf489 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ PayumPayzen =========== -PayZen Payum Gateway (Systempay, Scellius, CLIC&PAY) +PayZen Payum Gateway (Systempay, Scellius, CLIC&PAY, OSB) [](https://github.com/ekyna/PayumPayzen/actions/workflows/build.yml) From 6b64383177c6d02f7aeaababf9e2cd0943079538 Mon Sep 17 00:00:00 2001 From: Francis Hilaire <Prometee@users.noreply.github.com> Date: Mon, 26 Sep 2022 15:11:26 +0200 Subject: [PATCH 07/10] Add endpoint config example --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 94cf489..e8af76b 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ $gateway = $factory->create([ 'ctx_mode' => Api::MODE_PRODUCTION, 'hash_mode' => Api::HASH_MODE_SHA256, 'directory' => __DIR__ . '/payzen-cache', + 'endpoint'. => Api::ENDPOINT_SYSTEMPAY, // Or one of the constants : `Api::ENDPOINT_*` ]); // Register your convert payment action From 2e3cd329abc45c40f6ab0e22191890e547130d38 Mon Sep 17 00:00:00 2001 From: Francis Hilaire <Prometee@users.noreply.github.com> Date: Mon, 26 Sep 2022 15:24:06 +0200 Subject: [PATCH 08/10] Add default info --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e8af76b..8aa3f41 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ $gateway = $factory->create([ 'ctx_mode' => Api::MODE_PRODUCTION, 'hash_mode' => Api::HASH_MODE_SHA256, 'directory' => __DIR__ . '/payzen-cache', - 'endpoint'. => Api::ENDPOINT_SYSTEMPAY, // Or one of the constants : `Api::ENDPOINT_*` + 'endpoint' => Api::ENDPOINT_SYSTEMPAY, // default value, see `Api::ENDPOINT_*` constants for more ]); // Register your convert payment action From 4fe42227b659994db1fb4f9d595782fbe65cad82 Mon Sep 17 00:00:00 2001 From: Camille Islasse <34024380+camilleislasse@users.noreply.github.com> Date: Mon, 6 Feb 2023 15:07:20 +0100 Subject: [PATCH 09/10] =?UTF-8?q?Addition=20of=20a=20field=20to=20allow=20?= =?UTF-8?q?adding=20a=20personalized=20url.=20Because=20endpo=E2=80=A6=20(?= =?UTF-8?q?#6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added SogeCommerce endpoint. Allow custom endpoint URL. --------- Commit: Camille Islasse <c.islasse@arobases.fr> --- README.md | 3 ++- src/Api/Api.php | 11 ++++++++++- src/PayzenGatewayFactory.php | 30 ++++++++++++++++-------------- tests/Api/ApiTest.php | 27 +++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 8aa3f41..c658b51 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ PayumPayzen =========== -PayZen Payum Gateway (Systempay, Scellius, CLIC&PAY, OSB) +PayZen Payum Gateway (Systempay, Scellius, CLIC&PAY, OSB, SOGE_COMMERCE) [](https://github.com/ekyna/PayumPayzen/actions/workflows/build.yml) @@ -24,6 +24,7 @@ $gateway = $factory->create([ 'hash_mode' => Api::HASH_MODE_SHA256, 'directory' => __DIR__ . '/payzen-cache', 'endpoint' => Api::ENDPOINT_SYSTEMPAY, // default value, see `Api::ENDPOINT_*` constants for more + 'endpoint_url' => // null default value, add custom endpoint not in `Api::ENDPOINT_*` constants ]); // Register your convert payment action diff --git a/src/Api/Api.php b/src/Api/Api.php index 5886c4b..4e01666 100644 --- a/src/Api/Api.php +++ b/src/Api/Api.php @@ -21,6 +21,7 @@ class Api const HASH_MODE_SHA256 = 'SHA256'; const ENDPOINT_SYSTEMPAY = 'SYSTEMPAY'; + const ENDPOINT_SOGECOMMERCE = 'SOGECOMMERCE'; const ENDPOINT_SCELLIUS = 'SCELLIUS'; const ENDPOINT_CLICANDPAY = 'CLICANDPAY'; const ENDPOINT_OSB = 'OSB'; @@ -250,6 +251,7 @@ private function getConfigResolver(): OptionsResolver ]) ->setDefaults([ 'endpoint' => null, + 'endpoint_url' => null, 'hash_mode' => self::HASH_MODE_SHA256, 'debug' => false, ]) @@ -257,6 +259,7 @@ private function getConfigResolver(): OptionsResolver ->setAllowedTypes('certificate', 'string') ->setAllowedValues('ctx_mode', $this->getModes()) ->setAllowedTypes('directory', 'string') + ->setAllowedTypes('endpoint_url', ['null', 'string']) ->setAllowedValues('endpoint', $this->getEndPoints()) ->setAllowedValues('hash_mode', $this->getHashModes()) ->setAllowedTypes('debug', 'bool') @@ -469,7 +472,7 @@ private function getModes(): array private function getEndPoints(): array { - return [null, self::ENDPOINT_SYSTEMPAY, self::ENDPOINT_SCELLIUS, self::ENDPOINT_CLICANDPAY, self::ENDPOINT_OSB]; + return [null, self::ENDPOINT_SYSTEMPAY, self::ENDPOINT_SOGECOMMERCE, self::ENDPOINT_SCELLIUS, self::ENDPOINT_CLICANDPAY, self::ENDPOINT_OSB]; } private function getHashModes(): array @@ -479,6 +482,9 @@ private function getHashModes(): array private function getUrl(): string { + if ($this->config['endpoint_url'] !== null) { + return $this->config['endpoint_url']; + } if (self::ENDPOINT_SYSTEMPAY === $this->config['endpoint']) { return 'https://paiement.systempay.fr/vads-payment/'; } @@ -494,6 +500,9 @@ private function getUrl(): string if (self::ENDPOINT_OSB === $this->config['endpoint']) { return 'https://secure.osb.pf/vads-payment/'; } + if (self::ENDPOINT_SOGECOMMERCE === $this->config['endpoint']) { + return 'https://sogecommerce.societegenerale.eu/vads-payment/'; + } return 'https://secure.payzen.eu/vads-payment/'; } diff --git a/src/PayzenGatewayFactory.php b/src/PayzenGatewayFactory.php index 9fb4030..534cb0e 100644 --- a/src/PayzenGatewayFactory.php +++ b/src/PayzenGatewayFactory.php @@ -48,13 +48,14 @@ protected function populateConfig(ArrayObject $config) if (false == $config['payum.api']) { $config['payum.default_options'] = [ - 'site_id' => null, - 'certificate' => null, - 'ctx_mode' => null, - 'directory' => null, - 'endpoint' => null, - 'hash_mode' => Api\Api::HASH_MODE_SHA256, - 'debug' => false, + 'site_id' => null, + 'certificate' => null, + 'ctx_mode' => null, + 'directory' => null, + 'endpoint' => null, + 'endpoint_url' => null, + 'hash_mode' => Api\Api::HASH_MODE_SHA256, + 'debug' => false, ]; $config->defaults($config['payum.default_options']); @@ -65,13 +66,14 @@ protected function populateConfig(ArrayObject $config) $config->validateNotEmpty($config['payum.required_options']); $payzenConfig = [ - 'endpoint' => $config['endpoint'], - 'site_id' => $config['site_id'], - 'certificate' => $config['certificate'], - 'ctx_mode' => $config['ctx_mode'], - 'directory' => $config['directory'], - 'hash_mode' => $config['hash_mode'], - 'debug' => $config['debug'], + 'endpoint' => $config['endpoint'], + 'endpoint_url' => $config['endpoint_url'], + 'site_id' => $config['site_id'], + 'certificate' => $config['certificate'], + 'ctx_mode' => $config['ctx_mode'], + 'directory' => $config['directory'], + 'hash_mode' => $config['hash_mode'], + 'debug' => $config['debug'], ]; $api = new Api\Api(); diff --git a/tests/Api/ApiTest.php b/tests/Api/ApiTest.php index 1543b9b..6a9f01a 100644 --- a/tests/Api/ApiTest.php +++ b/tests/Api/ApiTest.php @@ -172,6 +172,20 @@ public function provideCreateRequestUrl(): Generator 'https://paiement.systempay.fr/vads-payment/?vads_action_mode=INTERACTIVE&vads_page_action=PAYMENT&vads_payment_config=SINGLE&vads_return_mode=POST&vads_version=V2&vads_amount=1234&vads_currency=978&vads_trans_date=20200101120000&vads_trans_id=000001&vads_site_id=123456789&vads_ctx_mode=PRODUCTION&signature=p9TbeohlOZVPAmhEwfAlGxRJxFAKpNg5wYBSN9emuqs%3D', ]; + yield [ + [ + 'endpoint_url' => 'https://custom-url.fr/vads-payment/', + ], + [ + 'vads_amount' => '1234', + 'vads_currency' => '978', + 'vads_trans_date' => '20200101120000', + 'vads_trans_id' => '000001', + ], + 'https://custom-url.fr/vads-payment/?vads_action_mode=INTERACTIVE&vads_page_action=PAYMENT&vads_payment_config=SINGLE&vads_return_mode=POST&vads_version=V2&vads_amount=1234&vads_currency=978&vads_trans_date=20200101120000&vads_trans_id=000001&vads_site_id=123456789&vads_ctx_mode=PRODUCTION&signature=p9TbeohlOZVPAmhEwfAlGxRJxFAKpNg5wYBSN9emuqs%3D', + ]; + + yield [ [ 'endpoint' => Api::ENDPOINT_SCELLIUS, @@ -197,6 +211,19 @@ public function provideCreateRequestUrl(): Generator ], 'https://secure.osb.pf/vads-payment/?vads_action_mode=INTERACTIVE&vads_page_action=PAYMENT&vads_payment_config=SINGLE&vads_return_mode=POST&vads_version=V2&vads_amount=1234&vads_currency=978&vads_trans_date=20200101120000&vads_trans_id=000001&vads_site_id=123456789&vads_ctx_mode=PRODUCTION&signature=p9TbeohlOZVPAmhEwfAlGxRJxFAKpNg5wYBSN9emuqs%3D', ]; + + yield [ + [ + 'endpoint' => Api::ENDPOINT_SOGECOMMERCE, + ], + [ + 'vads_amount' => '1234', + 'vads_currency' => '978', + 'vads_trans_date' => '20200101120000', + 'vads_trans_id' => '000001', + ], + 'https://sogecommerce.societegenerale.eu/vads-payment/?vads_action_mode=INTERACTIVE&vads_page_action=PAYMENT&vads_payment_config=SINGLE&vads_return_mode=POST&vads_version=V2&vads_amount=1234&vads_currency=978&vads_trans_date=20200101120000&vads_trans_id=000001&vads_site_id=123456789&vads_ctx_mode=PRODUCTION&signature=p9TbeohlOZVPAmhEwfAlGxRJxFAKpNg5wYBSN9emuqs%3D', + ]; } /** From bb78e336611510e2a68da717f5e4da12245d17d5 Mon Sep 17 00:00:00 2001 From: Xavier Marchegay <xavier.marchegay@gmail.com> Date: Fri, 1 Sep 2023 10:34:04 +0200 Subject: [PATCH 10/10] upgrade psr/log (#8) Authored-by: Xavier Marchegay <xmarchegay@clever-age.com> --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5a61368..8b3a90b 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "payum/core": "^1.5", "symfony/options-resolver": ">3.4,<7.0", "symfony/process": ">3.4,<7.0", - "psr/log": "^1.0" + "psr/log": "^1.0|^2.0" }, "require-dev": { "phpunit/phpunit": "^7.0|^8.0",