diff --git a/Form/ConfigurationForm.php b/Form/ConfigurationForm.php
old mode 100644
new mode 100755
index 0218155..608cf49
--- a/Form/ConfigurationForm.php
+++ b/Form/ConfigurationForm.php
@@ -1,7 +1,7 @@
. */
+/* along with this program. If not, see . */
/* */
/*************************************************************************************/
@@ -74,6 +74,10 @@ protected function buildForm()
/** @var Module $multiModule */
$multiEnabled = (null !== $multiModule = ModuleQuery::create()->findOneByCode('PayzenMulti')) && $multiModule->getActivate() != 0;
+ // If the Multi plugin is not enabled, all multi_fields are hidden
+ /** @var Module $multiModule */
+ $choozeoEnabled = (null !== $choozeoModule = ModuleQuery::create()->findOneByCode('PayzenChoozeo')) && $choozeoModule->getActivate() != 0;
+
$this->formBuilder
->add(
'site_id',
@@ -117,6 +121,24 @@ protected function buildForm()
)
)
)
+ ->add(
+ 'signature_algorythm',
+ 'choice',
+ array(
+ 'choices' => array(
+ 'HMAC' => 'HMAC-SHA-256',
+ 'SHA1' => 'SHA1',
+ ),
+ 'constraints' => array(new NotBlank()),
+ 'required' => true,
+ 'label' => $this->trans('Signature algorythm'),
+ 'data' => 'HMAC',
+ 'label_attr' => array(
+ 'for' => 'signature_algorythm',
+ 'help' => $this->trans('The algorythm used to compute the signature')
+ )
+ )
+ )
->add(
'platform_url',
'text',
@@ -519,6 +541,74 @@ protected function buildForm()
)
;
}
+
+ if ($choozeoEnabled) {
+ $this->formBuilder
+ ->add(
+ 'choozeo_minimum_amount',
+ 'number',
+ array(
+ 'constraints' => array(
+ new NotBlank(),
+ new GreaterThanOrEqual(array('value' => 0))
+ ),
+ 'required' => true,
+ 'label' => $this->trans('Minimum order total for multiple times'),
+ 'data' => PayzenConfigQuery::read('choozeo_minimum_amount', 0),
+ 'label_attr' => array(
+ 'for' => 'choozeo_minimum_amount',
+ 'help' => $this->trans('Minimum order total in the default currency for which multiple times payment method is available. Enter 0 for no minimum')
+ ),
+ 'attr' => [
+ 'step' => 'any'
+ ]
+ )
+ )
+ ->add(
+ 'choozeo_maximum_amount',
+ 'number',
+ array(
+ 'constraints' => array(
+ new NotBlank(),
+ new GreaterThanOrEqual(array('value' => 0))
+ ),
+ 'required' => true,
+ 'label' => $this->trans('Maximum order total for multiple times'),
+ 'data' => PayzenConfigQuery::read('choozeo_maximum_amount', 0),
+ 'label_attr' => array(
+ 'for' => 'choozeo_maximum_amount',
+ 'help' => $this->trans('Maximum order total in the default currency for which multiple times payment method is available. Enter 0 for no maximum')
+ ),
+ 'attr' => [
+ 'step' => 'any'
+ ]
+ )
+ )
+ ->add(
+ 'choozeo_number_of_payments',
+ 'number',
+ array(
+ 'constraints' => array(
+ new NotBlank(),
+ new GreaterThanOrEqual(array('value' => 3)),
+ new LessThanOrEqual(array('value' => 4))
+ ),
+ 'required' => true,
+ 'label' => $this->trans('Number of payments'),
+ 'data' => PayzenConfigQuery::read('choozeo_number_of_payments', 4),
+ 'label_attr' => array(
+ 'for' => 'choozeo_number_of_payments',
+ 'help' => $this->trans('The total number of payments')
+ ),
+ 'attr' => [
+ 'min' => 3,
+ 'max' => 4
+ ]
+ )
+ )
+
+ ;
+ }
}
public function getName()
diff --git a/I18n/backOffice/default/fr_FR.php b/I18n/backOffice/default/fr_FR.php
old mode 100644
new mode 100755
index 6e2ceac..eb73c66
--- a/I18n/backOffice/default/fr_FR.php
+++ b/I18n/backOffice/default/fr_FR.php
@@ -6,7 +6,9 @@
'Email configuration' => 'Configuration des mails',
'Install and activate \'Payzen One Off SEPA\' module to get configuration options.' => 'Installez et activez le module "Payzen prélèvement unique SEPA" pour accéder aux options de configuration',
'Install and activate Payzen multiple times payment module to get configuration options.' => 'Installez et activez le module "Payzen en plusieurs fois" pour accéder aux options de configuration',
+ 'Install and activate PayzenChoozeo module to get configuration options.' => 'Installez et activez le module "PayzenChoozeo" pour accéder aux options de configuration',
'Multiple times payment' => 'Paiement en plusieurs fois',
+ 'Choozeo multiple times payment' => 'Paiement en plusieurs fois Choozeo',
'No configuration needed' => 'Aucune configuration nécessaire',
'One off SEPA payment (SDD)' => 'Prélèvement unique SEPA (SDD)',
'One time payment' => 'Paiement en une seule fois',
diff --git a/Payzen/PayzenApi.php b/Payzen/PayzenApi.php
old mode 100644
new mode 100755
index 2443b29..e011ae7
--- a/Payzen/PayzenApi.php
+++ b/Payzen/PayzenApi.php
@@ -34,6 +34,7 @@
*/
use Payzen\Payzen;
use Thelia\Core\Translation\Translator;
+use Payzen\Model\PayzenConfigQuery;
/**
* Class managing parameters checking, form and signature building, response analysis and more
@@ -1025,7 +1026,12 @@ function sign($parameters, $key, $hashed = true)
}
}
$signContent .= $key;
- $sign = $hashed ? sha1($signContent) : $signContent;
+
+ if(PayzenConfigQuery::read('signature_algorythm', 'HMAC') == 'HMAC') {
+ $sign = $hashed ? base64_encode(hash_hmac('sha256', $signContent, $key, true)) : $signContent;
+ } else {
+ $sign = $hashed ? sha1($signContent) : $signContent;
+ }
return $sign;
}
diff --git a/templates/backOffice/default/payzen/module-configuration.html b/templates/backOffice/default/payzen/module-configuration.html
old mode 100644
new mode 100755
index a66fe93..747ae98
--- a/templates/backOffice/default/payzen/module-configuration.html
+++ b/templates/backOffice/default/payzen/module-configuration.html
@@ -12,7 +12,7 @@
{form name="payzen.configuration.form"}