Skip to content

Commit 473c7c3

Browse files
Merge branch 'support/1.x.x/release/1.3.0' into support/1.x.x/master
2 parents 8285e55 + d49a497 commit 473c7c3

13 files changed

Lines changed: 1452 additions & 506 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.3.0, 2020-08-19
2+
- Enable signature algorithm selection (SHA-1 or HMAC-SHA-256).
3+
- Added Spanish translation.
4+
15
1.2.1, 2020-01-20
26
- Fix links to plugin configuration documentation.
37
- Improve plugin translations.

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
Anyone is welcome to contribute to PayZen payment plugin for Drupal Commerce. There are various ways you can contribute:
44

55
- Raise an issue on GitHub.
6-
- Send us a Pull Request with your bug fixes.
6+
- Send us a Pull Request on **develop** branch with your bug fixes.
77
- Fork your own copy of the repository to add new features.
8-
- Provide feedback and suggestions on enhancements.
8+
- Provide feedback and suggestions on enhancements.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PayZen for Drupal Commerce
22

3-
PayZen for Drupal Commerce is an open source plugin that links e-commerce websites based on Drupal Drupal Commerce to PayZen secure payment gateway developed by [Lyra Network](https://www.lyra.com/).
3+
PayZen for Drupal Commerce is an open source plugin that links e-commerce websites based on Drupal Commerce to PayZen secure payment gateway developed by [Lyra Network](https://www.lyra.com/).
44

55
# Installation & Upgrade
66

@@ -15,7 +15,7 @@ PayZen for Drupal Commerce is an open source plugin that links e-commerce websit
1515
- In section `Actions` click on `edit` next to the desired PayZen payment method.
1616
- You can now enter your gateway credentials.
1717
- Click on the `Save` button.
18-
- In section `SETTINGS` check Active to activate payment method.
18+
- In section `SETTINGS` check __Active__ to activate payment method.
1919
- Click on `Save changes` button.
2020

2121
## License

commerce_payzen/commerce_payzen.admin.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function theme_commerce_payzen_backend_multi_options($variables)
3434

3535
$output .= ' <th>' . payzen_t('Count') . '</th>
3636
<th>' . payzen_t('Period') . '</th>
37-
<th>' . payzen_t('1st payment') . '</th>
37+
<th>' . payzen_t('1st installment') . '</th>
3838
<th></th>
3939
</tr>
4040
</thead>

commerce_payzen/commerce_payzen.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ core = 7.x
99
files[] = commerce_payzen.module
1010

1111
; Information about project
12-
version = "7.x-1.2.1"
12+
version = "7.x-1.3.0"
1313
core = "7.x"
1414
project = "commerce_payzen"
1515
datestamp = "1483709826"

commerce_payzen/commerce_payzen.module

Lines changed: 61 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function commerce_payzen_commerce_payment_method_info()
3636
'title' => payzen_t('PayZen - Standard payment'),
3737
'short_title' => payzen_t('PayZen - Standard payment'),
3838
'display_title' => $display_img . ' <span>' . $display_title . '</span>',
39-
'description' => payzen_t('Pay by credit card using PayZen payment platform.'),
39+
'description' => payzen_t('Pay by credit card using PayZen payment gateway.'),
4040
'terminal' => FALSE,
4141
'offsite' => TRUE,
4242
'offsite_autoredirect' => TRUE,
@@ -54,7 +54,7 @@ function commerce_payzen_commerce_payment_method_info()
5454
'title' => payzen_t('PayZen - Payment in installments'),
5555
'short_title' => payzen_t('PayZen - Payment in installments'),
5656
'display_title' => $display_img . ' <span>' . $display_title . '</span>',
57-
'description' => payzen_t('Pay by credit card in installments with PayZen payment platform.'),
57+
'description' => payzen_t('Pay by credit card in installments with PayZen payment gateway.'),
5858
'terminal' => FALSE,
5959
'offsite' => TRUE,
6060
'offsite_autoredirect' => TRUE,
@@ -72,7 +72,7 @@ function commerce_payzen_commerce_payment_method_info()
7272
'title' => payzen_t('PayZen - Payment with PayPal'),
7373
'short_title' => payzen_t('PayZen - Payment with PayPal'),
7474
'display_title' => $display_img . ' <span>' . $display_title . '</span>',
75-
'description' => payzen_t('Payment with PayPal using PayZen payment platform.'),
75+
'description' => payzen_t('Payment with PayPal using PayZen payment gateway.'),
7676
'terminal' => FALSE,
7777
'offsite' => TRUE,
7878
'offsite_autoredirect' => TRUE,
@@ -150,19 +150,19 @@ function commerce_payzen_settings_module_info()
150150
),
151151
'#children' => '<table><tbody>
152152
<tr>
153-
<td style="width: 200px; text-align:right;">'.payzen_t('Developed by:') . '</td>
154-
<td><a href="http://www.lyra-network.com/" target="_blank">Lyra network</a></td>
153+
<td style="width: 200px; text-align:right;">' . payzen_t('Developed by:') . '</td>
154+
<td><a href="http://www.lyra.com/" target="_blank">Lyra network</a></td>
155155
</tr>
156156
<tr>
157-
<td style="width: 200px; text-align:right;">'. payzen_t('Contact us:') . '</td>
157+
<td style="width: 200px; text-align:right;">' . payzen_t('Contact us:') . '</td>
158158
<td><a href="mailto:' . PayzenTools::getDefault('SUPPORT_EMAIL') . '">' . PayzenTools::getDefault('SUPPORT_EMAIL') . '</a></td>
159159
</tr>
160160
<tr>
161-
<td style="width: 200px; text-align:right;">'. payzen_t('Module version:') . '</td>
161+
<td style="width: 200px; text-align:right;">' . payzen_t('Module version:') . '</td>
162162
<td>' . PayzenTools::getDefault('PLUGIN_VERSION') . '</td>
163163
</tr>
164164
<tr>
165-
<td style="width: 200px; text-align:right;">'. payzen_t('Gateway version') . '</td>
165+
<td style="width: 200px; text-align:right;">' . payzen_t('Gateway version:') . '</td>
166166
<td>' . PayzenTools::getDefault('GATEWAY_VERSION') . '</td>
167167
</tr>' . $doc_tr . '</tbody></table>'
168168
);
@@ -178,6 +178,7 @@ function commerce_payzen_gateway_access_settings($settings = NULL)
178178
'payzen_key_test' => PayzenTools::getDefault('KEY_TEST'),
179179
'payzen_key_prod' => PayzenTools::getDefault('KEY_PROD'),
180180
'payzen_ctx_mode' => PayzenTools::getDefault('CTX_MODE'),
181+
'payzen_sign_algo' => PayzenTools::getDefault('SIGN_ALGO'),
181182
'payzen_platform_url' => PayzenTools::getDefault('GATEWAY_URL')
182183
)
183184
);
@@ -190,7 +191,7 @@ function commerce_payzen_gateway_access_settings($settings = NULL)
190191

191192
$form['gateway_access'] = array(
192193
'#type' => 'fieldset',
193-
'#title' => payzen_t('Payment gateway access'),
194+
'#title' => payzen_t('PAYMENT GATEWAY ACCESS'),
194195
'#collapsible' => TRUE,
195196
'#collapsed' => FALSE
196197
);
@@ -235,6 +236,19 @@ function commerce_payzen_gateway_access_settings($settings = NULL)
235236
$form['gateway_access']['payzen_ctx_mode']['#attributes']['disabled'] = 'disabled';
236237
}
237238

239+
$form['gateway_access']['payzen_sign_algo'] = array(
240+
'#type' => 'radios',
241+
'#title' => payzen_t('Signature algorithm'),
242+
'#description' => payzen_t('Algorithm used to compute the payment form signature. Selected algorithm must be the same as one configured in the PayZen Back Office.<br /><b>The HMAC-SHA-256 algorithm should not be activated if it is not yet available in the PayZen Back Office, the feature will be available soon.</b>'),
243+
'#options' => payzen_sign_algo_options(),
244+
'#default_value' => $settings['gateway_access']['payzen_sign_algo'],
245+
'#required' => TRUE
246+
);
247+
248+
if (PayzenTools::$pluginFeatures['shatwo']) {
249+
$form['gateway_access']['payzen_sign_algo']['#description'] = preg_replace('#<br /><b>[^<>]+</b>#', '', $form['gateway_access']['payzen_sign_algo']['#description']);
250+
}
251+
238252
$form['gateway_access']['payzen_ipn_url'] = array(
239253
'#type' => 'item',
240254
'#title' => payzen_t('Instant Payment Notification URL'),
@@ -450,7 +464,7 @@ function commerce_payzen_standard_settings_form($settings = NULL)
450464
'#type' => 'select',
451465
'#multiple' => 'multiple',
452466
'#title' => payzen_t('Card types'),
453-
'#description' => payzen_t('The card type(s) that can be used for the payment. Select none to use platform configuration.'),
467+
'#description' => payzen_t('The card type(s) that can be used for the payment. Select none to use gateway configuration.'),
454468
'#options' => PayzenApi::getSupportedCardTypes(),
455469
'#default_value' => $selected_cards
456470
);
@@ -479,7 +493,7 @@ function commerce_payzen_multi_settings_form($settings = NULL)
479493
'#type' => 'select',
480494
'#multiple' => 'multiple',
481495
'#title' => payzen_t('Card types'),
482-
'#description' => payzen_t('The card type(s) that can be used for the payment. Select none to use platform configuration.'),
496+
'#description' => payzen_t('The card type(s) that can be used for the payment. Select none to use gateway configuration.'),
483497
'#options' => commerce_payzen_multi_cards(),
484498
'#default_value' => $selected_cards
485499
);
@@ -502,8 +516,8 @@ function commerce_payzen_multi_settings_form($settings = NULL)
502516
'#theme' => 'commerce_payzen_backend_multi_options',
503517
'#title' => payzen_t('Payment options'),
504518
'#description' => $cb_avail ?
505-
payzen_t('Click on &laquo;Add&raquo; button to configure one or more payment options. <br /><b>Label: </b>The option label to display on the frontend. <br /><b>Min. amount: </b>Minimum amount to enable the payment option. <br /><b>Max. amount: </b>Maximum amount to enable the payment option. <br /><b>Contract: </b>ID of the contract to use with the option. <br /><b>Count: </b>Total number of payments. <br /><b>Period: </b>Delay (in days) between payments. <br /><b>1st payment: </b>Amount of first payment, in percentage of total amount. If empty, all payments will have the same amount.') :
506-
payzen_t('Click on &laquo;Add&raquo; button to configure one or more payment options. <br /><b>Label: </b>The option label to display on the frontend. <br /><b>Min. amount: </b>Minimum amount to enable the payment option. <br /><b>Max. amount: </b>Maximum amount to enable the payment option. <br /><b>Count: </b>Total number of payments. <br /><b>Period: </b>Delay (in days) between payments. <br /><b>1st payment: </b>Amount of first payment, in percentage of total amount. If empty, all payments will have the same amount.'),
519+
payzen_t('Click on &laquo;Add&raquo; button to configure one or more payment options. <br /><b>Label: </b>The option label to display on the frontend. <br /><b>Min. amount: </b>Minimum amount to enable the payment option. <br /><b>Max. amount: </b>Maximum amount to enable the payment option. <br /><b>Contract: </b>ID of the contract to use with the option. <br /><b>Count: </b>Total number of installments. <br /><b>Period: </b>Delay (in days) between installments. <br /><b>1st installment: </b>Amount of first installment, in percentage of total amount. If empty, all installments will have the same amount.') :
520+
payzen_t('Click on &laquo;Add&raquo; button to configure one or more payment options. <br /><b>Label: </b>The option label to display on the frontend. <br /><b>Min. amount: </b>Minimum amount to enable the payment option. <br /><b>Max. amount: </b>Maximum amount to enable the payment option. <br /><b>Count: </b>Total number of installments. <br /><b>Period: </b>Delay (in days) between installments. <br /><b>1st installment: </b>Amount of first installment, in percentage of total amount. If empty, all installments will have the same amount.'),
507521
'#default_value' => $options,
508522
'#element_validate' => array('commerce_payzen_multi_settings_options_validate')
509523
);
@@ -784,7 +798,7 @@ function commerce_payzen_multi_submit_form_submit($payment_method, $pane_form, $
784798
}
785799

786800
/**
787-
* Payment method callback: prepare form to redirect to payment platform (single and multiple payment).
801+
* Payment method callback: prepare form to redirect to payment gateway (single and multiple payment).
788802
*/
789803
function commerce_payzen_redirect_form($form, &$form_state, $order, $payment_method)
790804
{
@@ -804,7 +818,7 @@ function commerce_payzen_redirect_form($form, &$form_state, $order, $payment_met
804818

805819
$settings = $payment_method['settings'];
806820

807-
// Set payment platform access parameters.
821+
// Set payment gateway access parameters.
808822
foreach ($settings['gateway_access'] as $name => $value) {
809823
$param_name = substr($name, strpos($name, '_') + 1);
810824
$payzen_request->set($param_name, $value);
@@ -961,14 +975,21 @@ function commerce_payzen_process_ipn()
961975
$_POST,
962976
$settings['gateway_access']['payzen_ctx_mode'],
963977
$settings['gateway_access']['payzen_key_test'],
964-
$settings['gateway_access']['payzen_key_prod']
978+
$settings['gateway_access']['payzen_key_prod'],
979+
$settings['gateway_access']['payzen_sign_algo']
965980
);
966981

967982
if (! $payzen_response->isAuthentified()) {
968983
watchdog(
969984
'commerce_payzen',
970-
'Suspect request sent to commerce_payzen_process_payment, IP: %ip',
971-
array('%ip' => $_SERVER['REMOTE_ADDR']),
985+
'%ip tries to access commerce_payzen_process_payment without valid signature with parameters: %params.',
986+
array('%ip' => $_SERVER['REMOTE_ADDR'], $params => print_r($_POST, true)),
987+
WATCHDOG_ERROR
988+
);
989+
990+
watchdog(
991+
'commerce_payzen',
992+
'Signature algorithm selected in module settings must be the same as one selected in PayZen Back Office.',
972993
WATCHDOG_ERROR
973994
);
974995

@@ -1032,18 +1053,25 @@ function commerce_payzen_redirect_form_validate($order, $payment_method)
10321053
$_REQUEST,
10331054
$settings['gateway_access']['payzen_ctx_mode'],
10341055
$settings['gateway_access']['payzen_key_test'],
1035-
$settings['gateway_access']['payzen_key_prod']
1056+
$settings['gateway_access']['payzen_key_prod'],
1057+
$settings['gateway_access']['payzen_sign_algo']
10361058
);
10371059

10381060
if (! $payzen_response->isAuthentified()) {
1061+
watchdog(
1062+
'commerce_payzen',
1063+
'%ip tries to access commerce_payzen_process_payment without valid signature with parameters: %params.',
1064+
array('%ip' => $_SERVER['REMOTE_ADDR'], $params => print_r($_REQUEST, true)),
1065+
WATCHDOG_ERROR
1066+
);
1067+
10391068
watchdog(
10401069
'commerce_payzen',
1041-
'Suspect request sent to commerce_payzen_redirect_form_validate, IP: %ip',
1042-
array('%ip' => $_SERVER['REMOTE_ADDR']),
1070+
'Signature algorithm selected in module settings must be the same as one selected in PayZen Back Office.',
10431071
WATCHDOG_ERROR
10441072
);
10451073

1046-
drupal_set_message(payzen_t('An error has occured in the payment process.'), 'error');
1074+
drupal_set_message(payzen_t('An error has occurred during the payment process.'), 'error');
10471075
return FALSE;
10481076
}
10491077

@@ -1055,15 +1083,15 @@ function commerce_payzen_redirect_form_validate($order, $payment_method)
10551083
WATCHDOG_ERROR
10561084
);
10571085

1058-
drupal_set_message(payzen_t('An error has occured in the payment process.'), 'error');
1086+
drupal_set_message(payzen_t('An error has occurred during the payment process.'), 'error');
10591087
return FALSE;
10601088
}
10611089

10621090
if (! $payzen_response->get('trans_status')) {
10631091
// Form error.
10641092
watchdog('commerce_payzen', $payzen_response->getLogMessage(), array(), WATCHDOG_ERROR);
10651093

1066-
drupal_set_message(payzen_t('An error has occured in the payment process.'), 'error');
1094+
drupal_set_message(payzen_t('An error has occurred during the payment process.'), 'error');
10671095
return FALSE;
10681096
}
10691097

@@ -1083,7 +1111,7 @@ function commerce_payzen_redirect_form_validate($order, $payment_method)
10831111
if (variable_get('maintenance_mode', FALSE)) {
10841112
$message = payzen_t('The shop is in maintenance mode. The automatic notification cannot work.');
10851113
} else {
1086-
$message = payzen_t('The automatic notification has not worked. Have you correctly set up the notification URL in your PayZen Back Office ?');
1114+
$message = payzen_t('The automatic validation has not worked. Have you correctly set up the notification URL in your PayZen Back Office?');
10871115
$message .= '<br />';
10881116
$message .= payzen_t('For understanding the problem, please read the documentation of the module: <br />&nbsp;&nbsp;&nbsp;- Chapter &laquo;To read carefully before going further&raquo;<br />&nbsp;&nbsp;&nbsp;- Chapter &laquo;Server URL settings&raquo;');
10891117
}
@@ -1201,6 +1229,14 @@ function payzen_ctx_mode_options()
12011229
);
12021230
}
12031231

1232+
function payzen_sign_algo_options()
1233+
{
1234+
return array(
1235+
PayzenApi::ALGO_SHA1 => 'SHA-1',
1236+
PayzenApi::ALGO_SHA256 => 'HMAC-SHA-256'
1237+
);
1238+
}
1239+
12041240
function payzen_language_options()
12051241
{
12061242
$languages = array();

0 commit comments

Comments
 (0)