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"}
- {form_hidden_fields exclude="multi_minimum_amount,multi_maximum_amount,multi_first_payment,multi_number_of_payments"} + {form_hidden_fields exclude="multi_minimum_amount,multi_maximum_amount,multi_first_payment,multi_number_of_payments,choozeo_minimum_amount,choozeo_maximum_amount"} {include file = "includes/inner-form-toolbar.html" hide_flags = true @@ -36,6 +36,7 @@ {render_form_field field="test_certificate"} {render_form_field field="production_certificate"} {render_form_field field="platform_url"} + {render_form_field field="signature_algorythm"} {render_form_field field="mode"} {render_form_field field="allowed_ip_list"} @@ -60,21 +61,21 @@ {render_form_field field="allowed_cards"}

{intl d='payzen.bo.default' l="One time payment"}

- + {custom_render_form_field field="minimum_amount"}
{currency attr='symbol'}
{/custom_render_form_field} - + {custom_render_form_field field="maximum_amount"}
{currency attr='symbol'}
{/custom_render_form_field} - + {custom_render_form_field field="three_ds_minimum_order_amount"}
@@ -92,37 +93,62 @@ {currency attr='symbol'}
{/custom_render_form_field} - + {custom_render_form_field field="multi_maximum_amount"}
{currency attr='symbol'}
{/custom_render_form_field} - + {custom_render_form_field field="multi_first_payment"}
%
{/custom_render_form_field} - + {render_form_field field="multi_number_of_payments"} {render_form_field field="multi_payments_interval"} {/loop} - + {elseloop rel="multi-plugin-enabled"}
{intl l="Install and activate Payzen multiple times payment module to get configuration options." d='payzen.bo.default'}
{/elseloop} +

{intl d='payzen.bo.default' l="Choozeo multiple times payment"}

+ + {loop name="choozeo-plugin-enabled" type="module" code="PayzenChoozeo" active="1"} + {custom_render_form_field field="choozeo_minimum_amount"} +
+ + {currency attr='symbol'} +
+ {/custom_render_form_field} + + {custom_render_form_field field="choozeo_maximum_amount"} +
+ + {currency attr='symbol'} +
+ {/custom_render_form_field} + + {render_form_field field="choozeo_number_of_payments"} + {/loop} + + {elseloop rel="choozeo-plugin-enabled"} +
+ {intl l="Install and activate PayzenChoozeo module to get configuration options." d='payzen.bo.default'} +
+ {/elseloop}

{intl d='payzen.bo.default' l="One off SEPA payment (SDD)"}

{loop name="oneoffsepa-plugin-enabled" type="module" code="PayzenOneOffSEPA" active="1"}

{intl d="payzen.bo.default" l="No configuration needed"}.

{/loop} - + {elseloop rel="oneoffsepa-plugin-enabled"}
{intl l="Install and activate 'Payzen One Off SEPA' module to get configuration options." d='payzen.bo.default'} @@ -132,15 +158,15 @@

{intl d='payzen.bo.default' l="Email configuration"}

- + {render_form_field field="send_confirmation_message_only_if_paid"} {render_form_field field="send_payment_confirmation_message"} - +
{intl d='payzen.bo.default' l='You can edit the payment confirmation email sent to the customer after a successful payment.' url={url path="/admin/configuration/messages"}}
- +

{intl d='payzen.bo.default' l="Payment page"}

{render_form_field field="default_language"}