Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ekyna/PayumPayzen
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: camilleislasse/PayumPayzen
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 5 commits
  • 4 files changed
  • 1 contributor

Commits on Feb 6, 2023

  1. Addition of a field to allow adding a personalized url. Because endpo…

    …ints can change and it's hard to have endpoints hard-coded in the code
    Camille Islasse committed Feb 6, 2023
    Copy the full SHA
    1c53f1c View commit details
  2. Endpoint url can be null

    Camille Islasse committed Feb 6, 2023
    Copy the full SHA
    649f1f9 View commit details
  3. Add unit test and update readme

    Camille Islasse committed Feb 6, 2023
    Copy the full SHA
    3b11a9a View commit details
  4. Add test if endpoint is null and endpoint_url has custom url

    Camille Islasse committed Feb 6, 2023
    Copy the full SHA
    cb0f9b9 View commit details
  5. refacto PSR

    Camille Islasse committed Feb 6, 2023
    Copy the full SHA
    d8b5379 View commit details
Showing with 55 additions and 16 deletions.
  1. +2 −1 README.md
  2. +10 −1 src/Api/Api.php
  3. +16 −14 src/PayzenGatewayFactory.php
  4. +27 −0 tests/Api/ApiTest.php
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PayumPayzen
===========

PayZen Payum Gateway (Systempay, Scellius, CLIC&PAY, OSB)
PayZen Payum Gateway (Systempay, Scellius, CLIC&PAY, OSB, SOGE_COMMERCE)

[![Build](https://github.com/ekyna/PayumPayzen/actions/workflows/build.yml/badge.svg?branch=master)](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
11 changes: 10 additions & 1 deletion src/Api/Api.php
Original file line number Diff line number Diff line change
@@ -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,13 +251,15 @@ private function getConfigResolver(): OptionsResolver
])
->setDefaults([
'endpoint' => null,
'endpoint_url' => null,
'hash_mode' => self::HASH_MODE_SHA256,
'debug' => false,
])
->setAllowedTypes('site_id', 'string')
->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/';
}
30 changes: 16 additions & 14 deletions src/PayzenGatewayFactory.php
Original file line number Diff line number Diff line change
@@ -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();
27 changes: 27 additions & 0 deletions tests/Api/ApiTest.php
Original file line number Diff line number Diff line change
@@ -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',
];
}

/**