Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 92 additions & 2 deletions Form/ConfigurationForm.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
Expand All @@ -17,7 +17,7 @@
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions I18n/backOffice/default/fr_FR.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 7 additions & 1 deletion Payzen/PayzenApi.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
50 changes: 38 additions & 12 deletions templates/backOffice/default/payzen/module-configuration.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{form name="payzen.configuration.form"}

<form action="{url path="/admin/module/payzen/configure"}" method="post">
{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
Expand All @@ -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"}

Expand All @@ -60,21 +61,21 @@
{render_form_field field="allowed_cards"}

<p class="title title-without-tabs">{intl d='payzen.bo.default' l="One time payment"}</p>

{custom_render_form_field field="minimum_amount"}
<div class="input-group">
<input type="number" {form_field_attributes field="minimum_amount"}>
<span class="input-group-addon">{currency attr='symbol'}</span>
</div>
{/custom_render_form_field}

{custom_render_form_field field="maximum_amount"}
<div class="input-group">
<input type="number" {form_field_attributes field="maximum_amount"}>
<span class="input-group-addon">{currency attr='symbol'}</span>
</div>
{/custom_render_form_field}

{custom_render_form_field field="three_ds_minimum_order_amount"}
<div class="input-group">
<input type="number" {form_field_attributes field="three_ds_minimum_order_amount"}>
Expand All @@ -92,37 +93,62 @@
<span class="input-group-addon">{currency attr='symbol'}</span>
</div>
{/custom_render_form_field}

{custom_render_form_field field="multi_maximum_amount"}
<div class="input-group">
<input type="number" {form_field_attributes field="multi_maximum_amount"}>
<span class="input-group-addon">{currency attr='symbol'}</span>
</div>
{/custom_render_form_field}

{custom_render_form_field field="multi_first_payment"}
<div class="input-group">
<input type="number" {form_field_attributes field="multi_first_payment"}>
<span class="input-group-addon">%</span>
</div>
{/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"}
<div class="alert alert-info">
{intl l="Install and activate Payzen multiple times payment module to get configuration options." d='payzen.bo.default'}
</div>
{/elseloop}

<p class="title title-without-tabs">{intl d='payzen.bo.default' l="Choozeo multiple times payment"}</p>

{loop name="choozeo-plugin-enabled" type="module" code="PayzenChoozeo" active="1"}
{custom_render_form_field field="choozeo_minimum_amount"}
<div class="input-group">
<input type="number" {form_field_attributes field="choozeo_minimum_amount"}>
<span class="input-group-addon">{currency attr='symbol'}</span>
</div>
{/custom_render_form_field}

{custom_render_form_field field="choozeo_maximum_amount"}
<div class="input-group">
<input type="number" {form_field_attributes field="choozeo_maximum_amount"}>
<span class="input-group-addon">{currency attr='symbol'}</span>
</div>
{/custom_render_form_field}

{render_form_field field="choozeo_number_of_payments"}
{/loop}

{elseloop rel="choozeo-plugin-enabled"}
<div class="alert alert-info">
{intl l="Install and activate PayzenChoozeo module to get configuration options." d='payzen.bo.default'}
</div>
{/elseloop}
<p class="title title-without-tabs">{intl d='payzen.bo.default' l="One off SEPA payment (SDD)"}</p>

{loop name="oneoffsepa-plugin-enabled" type="module" code="PayzenOneOffSEPA" active="1"}
<p>{intl d="payzen.bo.default" l="No configuration needed"}.</p>
{/loop}

{elseloop rel="oneoffsepa-plugin-enabled"}
<div class="alert alert-info">
{intl l="Install and activate 'Payzen One Off SEPA' module to get configuration options." d='payzen.bo.default'}
Expand All @@ -132,15 +158,15 @@

<div class="col-md-4">
<p class="title title-without-tabs">{intl d='payzen.bo.default' l="Email configuration"}</p>

{render_form_field field="send_confirmation_message_only_if_paid"}
{render_form_field field="send_payment_confirmation_message"}

<div class="well well-sm">
<span class="glyphicon glyphicon-info-sign"></span>
{intl d='payzen.bo.default' l='You can <a href="%url">edit the payment confirmation email</a> sent to the customer after a successful payment.' url={url path="/admin/configuration/messages"}}
</div>

<p class="title title-without-tabs">{intl d='payzen.bo.default' l="Payment page"}</p>

{render_form_field field="default_language"}
Expand Down