Skip to content

Commit 4fe4222

Browse files
Addition of a field to allow adding a personalized url. Because endpo… (#6)
Added SogeCommerce endpoint. Allow custom endpoint URL. --------- Commit: Camille Islasse <c.islasse@arobases.fr>
1 parent 2724498 commit 4fe4222

File tree

4 files changed

+55
-16
lines changed

4 files changed

+55
-16
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PayumPayzen
22
===========
33

4-
PayZen Payum Gateway (Systempay, Scellius, CLIC&PAY, OSB)
4+
PayZen Payum Gateway (Systempay, Scellius, CLIC&PAY, OSB, SOGE_COMMERCE)
55

66
[![Build](https://github.com/ekyna/PayumPayzen/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/ekyna/PayumPayzen/actions/workflows/build.yml)
77

@@ -24,6 +24,7 @@ $gateway = $factory->create([
2424
'hash_mode' => Api::HASH_MODE_SHA256,
2525
'directory' => __DIR__ . '/payzen-cache',
2626
'endpoint' => Api::ENDPOINT_SYSTEMPAY, // default value, see `Api::ENDPOINT_*` constants for more
27+
'endpoint_url' => // null default value, add custom endpoint not in `Api::ENDPOINT_*` constants
2728
]);
2829

2930
// Register your convert payment action

src/Api/Api.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Api
2121
const HASH_MODE_SHA256 = 'SHA256';
2222

2323
const ENDPOINT_SYSTEMPAY = 'SYSTEMPAY';
24+
const ENDPOINT_SOGECOMMERCE = 'SOGECOMMERCE';
2425
const ENDPOINT_SCELLIUS = 'SCELLIUS';
2526
const ENDPOINT_CLICANDPAY = 'CLICANDPAY';
2627
const ENDPOINT_OSB = 'OSB';
@@ -250,13 +251,15 @@ private function getConfigResolver(): OptionsResolver
250251
])
251252
->setDefaults([
252253
'endpoint' => null,
254+
'endpoint_url' => null,
253255
'hash_mode' => self::HASH_MODE_SHA256,
254256
'debug' => false,
255257
])
256258
->setAllowedTypes('site_id', 'string')
257259
->setAllowedTypes('certificate', 'string')
258260
->setAllowedValues('ctx_mode', $this->getModes())
259261
->setAllowedTypes('directory', 'string')
262+
->setAllowedTypes('endpoint_url', ['null', 'string'])
260263
->setAllowedValues('endpoint', $this->getEndPoints())
261264
->setAllowedValues('hash_mode', $this->getHashModes())
262265
->setAllowedTypes('debug', 'bool')
@@ -469,7 +472,7 @@ private function getModes(): array
469472

470473
private function getEndPoints(): array
471474
{
472-
return [null, self::ENDPOINT_SYSTEMPAY, self::ENDPOINT_SCELLIUS, self::ENDPOINT_CLICANDPAY, self::ENDPOINT_OSB];
475+
return [null, self::ENDPOINT_SYSTEMPAY, self::ENDPOINT_SOGECOMMERCE, self::ENDPOINT_SCELLIUS, self::ENDPOINT_CLICANDPAY, self::ENDPOINT_OSB];
473476
}
474477

475478
private function getHashModes(): array
@@ -479,6 +482,9 @@ private function getHashModes(): array
479482

480483
private function getUrl(): string
481484
{
485+
if ($this->config['endpoint_url'] !== null) {
486+
return $this->config['endpoint_url'];
487+
}
482488
if (self::ENDPOINT_SYSTEMPAY === $this->config['endpoint']) {
483489
return 'https://paiement.systempay.fr/vads-payment/';
484490
}
@@ -494,6 +500,9 @@ private function getUrl(): string
494500
if (self::ENDPOINT_OSB === $this->config['endpoint']) {
495501
return 'https://secure.osb.pf/vads-payment/';
496502
}
503+
if (self::ENDPOINT_SOGECOMMERCE === $this->config['endpoint']) {
504+
return 'https://sogecommerce.societegenerale.eu/vads-payment/';
505+
}
497506

498507
return 'https://secure.payzen.eu/vads-payment/';
499508
}

src/PayzenGatewayFactory.php

+16-14
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ protected function populateConfig(ArrayObject $config)
4848

4949
if (false == $config['payum.api']) {
5050
$config['payum.default_options'] = [
51-
'site_id' => null,
52-
'certificate' => null,
53-
'ctx_mode' => null,
54-
'directory' => null,
55-
'endpoint' => null,
56-
'hash_mode' => Api\Api::HASH_MODE_SHA256,
57-
'debug' => false,
51+
'site_id' => null,
52+
'certificate' => null,
53+
'ctx_mode' => null,
54+
'directory' => null,
55+
'endpoint' => null,
56+
'endpoint_url' => null,
57+
'hash_mode' => Api\Api::HASH_MODE_SHA256,
58+
'debug' => false,
5859
];
5960

6061
$config->defaults($config['payum.default_options']);
@@ -65,13 +66,14 @@ protected function populateConfig(ArrayObject $config)
6566
$config->validateNotEmpty($config['payum.required_options']);
6667

6768
$payzenConfig = [
68-
'endpoint' => $config['endpoint'],
69-
'site_id' => $config['site_id'],
70-
'certificate' => $config['certificate'],
71-
'ctx_mode' => $config['ctx_mode'],
72-
'directory' => $config['directory'],
73-
'hash_mode' => $config['hash_mode'],
74-
'debug' => $config['debug'],
69+
'endpoint' => $config['endpoint'],
70+
'endpoint_url' => $config['endpoint_url'],
71+
'site_id' => $config['site_id'],
72+
'certificate' => $config['certificate'],
73+
'ctx_mode' => $config['ctx_mode'],
74+
'directory' => $config['directory'],
75+
'hash_mode' => $config['hash_mode'],
76+
'debug' => $config['debug'],
7577
];
7678

7779
$api = new Api\Api();

tests/Api/ApiTest.php

+27
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,20 @@ public function provideCreateRequestUrl(): Generator
172172
'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',
173173
];
174174

175+
yield [
176+
[
177+
'endpoint_url' => 'https://custom-url.fr/vads-payment/',
178+
],
179+
[
180+
'vads_amount' => '1234',
181+
'vads_currency' => '978',
182+
'vads_trans_date' => '20200101120000',
183+
'vads_trans_id' => '000001',
184+
],
185+
'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',
186+
];
187+
188+
175189
yield [
176190
[
177191
'endpoint' => Api::ENDPOINT_SCELLIUS,
@@ -197,6 +211,19 @@ public function provideCreateRequestUrl(): Generator
197211
],
198212
'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',
199213
];
214+
215+
yield [
216+
[
217+
'endpoint' => Api::ENDPOINT_SOGECOMMERCE,
218+
],
219+
[
220+
'vads_amount' => '1234',
221+
'vads_currency' => '978',
222+
'vads_trans_date' => '20200101120000',
223+
'vads_trans_id' => '000001',
224+
],
225+
'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',
226+
];
200227
}
201228

202229
/**

0 commit comments

Comments
 (0)