Skip to content

Commit 5eb3c2f

Browse files
Merge branch 'support/1.x/hotfix/1.3.1' into support/1.x/master
2 parents 473c7c3 + 616c53a commit 5eb3c2f

11 files changed

Lines changed: 75 additions & 87 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
1.3.0, 2020-08-19
1+
1.3.1, 2021-02-01:
2+
- Bug fix: do not update order status in the code to use configured one.
3+
- Bug fix: save correct payment currency and amount.
4+
- Fix the amount of installments when saving the payment details on orders.
5+
6+
1.3.0, 2020-08-19:
27
- Enable signature algorithm selection (SHA-1 or HMAC-SHA-256).
38
- Added Spanish translation.
49

5-
1.2.1, 2020-01-20
10+
1.2.1, 2020-01-20:
611
- Fix links to plugin configuration documentation.
712
- Improve plugin translations.
813
- [prodfaq] Fix notice about shifting the shop to production mode.
914
- [technical] Manage enabled/disabled features by plugin variant.
1015

11-
1.2.0, 2017-09-18
16+
1.2.0, 2017-09-18:
1217
- Bug fix: update order status only if order is paid by our payment methods.
1318
- Merging single and multiple payment modules in the same package.
1419
- Possibility to define several options for payment in installments.
@@ -23,4 +28,4 @@
2328
- Bug fix: compatibilty with PayZen multiple payment module.
2429

2530
1.0, 2011-12-06:
26-
- Module creation.
31+
- Module creation.

COPYING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright © 2011-2020 Lyra Network.
1+
Copyright © 2011-2021 Lyra Network.
22

33
PayZen for Drupal Commerce is free software: you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by

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.3.0"
12+
version = "7.x-1.3.1"
1313
core = "7.x"
1414
project = "commerce_payzen"
1515
datestamp = "1483709826"

commerce_payzen/commerce_payzen.module

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ function commerce_payzen_process_ipn()
983983
watchdog(
984984
'commerce_payzen',
985985
'%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)),
986+
array('%ip' => $_SERVER['REMOTE_ADDR'], '%params' => print_r($_POST, true)),
987987
WATCHDOG_ERROR
988988
);
989989

@@ -1061,7 +1061,7 @@ function commerce_payzen_redirect_form_validate($order, $payment_method)
10611061
watchdog(
10621062
'commerce_payzen',
10631063
'%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)),
1064+
array('%ip' => $_SERVER['REMOTE_ADDR'], '%params' => print_r($_REQUEST, true)),
10651065
WATCHDOG_ERROR
10661066
);
10671067

@@ -1141,7 +1141,7 @@ function commerce_payzen_process_transaction($order, $payment_method, $payzen_re
11411141
}
11421142

11431143
$trans_id = $payzen_response->get('trans_id');
1144-
if ($payment_method['method_id'] === 'payzen_multi' && ($sequence_number = $payzen_response->get('sequence_number'))) {
1144+
if (($payment_method['method_id'] === 'payzen_multi') && ($sequence_number = $payzen_response->get('sequence_number'))) {
11451145
$trans_id .= '-' . $sequence_number;
11461146
}
11471147

@@ -1152,8 +1152,19 @@ function commerce_payzen_process_transaction($order, $payment_method, $payzen_re
11521152
$transaction->instance_id = $payment_method['instance_id'];
11531153
}
11541154

1155-
$currency_code = $payzen_response->get('effective_currency');
1156-
$amount_in_cents = $payzen_response->get('effective_amount');
1155+
$amount_in_cents = null;
1156+
$currency_code = null;
1157+
if ($payment_method['method_id'] === 'payzen_multi') {
1158+
$currency_code = $payzen_response->get('effective_currency');
1159+
$amount_in_cents = $payzen_response->get('effective_amount');
1160+
1161+
// Currency in client website is different than gateway currency.
1162+
if ($payzen_response->get('effective_currency') !== $payzen_response->get('currency')) {
1163+
$rate = $payzen_response->get('change_rate') ? $payzen_response->get('change_rate') : 1;
1164+
$amount_in_cents = round(($payzen_response->get('effective_amount') * $rate), 0);
1165+
$currency_code = $payzen_response->get('currency');
1166+
}
1167+
}
11571168

11581169
if (! $currency_code || ! $amount_in_cents) {
11591170
$currency_code = $payzen_response->get('currency');
@@ -1201,24 +1212,19 @@ function commerce_payzen_process_transaction($order, $payment_method, $payzen_re
12011212
return FALSE;
12021213
} else {
12031214
commerce_payment_redirect_pane_next_page($order, $payzen_response->getLogMessage());
1204-
return TRUE;
1205-
}
1206-
}
12071215

1208-
function commerce_payzen_commerce_payment_order_paid_in_full($order, $transaction)
1209-
{
1210-
if (empty($order->data['payment_method'])) {
1211-
return;
1212-
}
1213-
1214-
list ($method_id, ) = explode('|', $order->data['payment_method']);
1216+
// Update order status (fully paid).
1217+
if (($order->status === 'pending') && ($transaction->status === COMMERCE_PAYMENT_STATUS_SUCCESS)) {
1218+
// We calculate the balance to know whether the order was fully paid or not.
1219+
$balance = commerce_payment_order_balance($order);
1220+
if (! empty($balance) && $balance['amount'] <= 0) {
1221+
// Order for multi fully paid so update order status.
1222+
commerce_order_status_update($order, 'processing', FALSE, NULL, payzen_t('Order fully paid.'));
1223+
}
1224+
}
12151225

1216-
$payzen_methods = array('payzen_standard', 'payzen_multi', 'payzen_paypal');
1217-
if (! in_array($method_id, $payzen_methods)) {
1218-
return;
1226+
return TRUE;
12191227
}
1220-
1221-
commerce_order_status_update($order, 'processing', FALSE, NULL, payzen_t('Order fully paid.'));
12221228
}
12231229

12241230
function payzen_ctx_mode_options()

commerce_payzen/includes/PayzenApi.php

Lines changed: 24 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -215,35 +215,32 @@ public static function getSupportedCardTypes()
215215
'CB' => 'CB', 'E-CARTEBLEUE' => 'e-Carte Bleue', 'MAESTRO' => 'Maestro', 'MASTERCARD' => 'Mastercard',
216216
'VISA' => 'Visa', 'VISA_ELECTRON' => 'Visa Electron', 'VPAY' => 'V PAY', 'AMEX' => 'American Express',
217217
'ACCORD_STORE' => 'Cartes Enseignes Partenaires', 'ACCORD_STORE_SB' => 'Cartes Enseignes Partenaires (sandbox)',
218-
'ALINEA' => 'Carte myalinea', 'ALINEA_CDX' => 'Carte Cadeau Alinéa',
219-
'ALINEA_CDX_SB' => 'Carte Cadeau Alinéa (sandbox)', 'ALINEA_SB' => 'Carte myalinea (sandbox)',
220-
'ALIPAY' => 'Alipay', 'ALLOBEBE_CDX' => 'Carte Cadeau Allobébé', 'ALLOBEBE_CDX_SB' => 'Carte Cadeau Allobébé (sandbox)',
218+
'ALINEA_CDX' => 'Carte Cadeau Alinéa', 'ALINEA_CDX_SB' => 'Carte Cadeau Alinéa (sandbox)', 'ALIPAY' => 'Alipay',
219+
'ALLOBEBE_CDX' => 'Carte Cadeau Allobébé', 'ALLOBEBE_CDX_SB' => 'Carte Cadeau Allobébé (sandbox)', 'APETIZ' => 'Apetiz',
221220
'AUCHAN' => 'Carte Auchan', 'AUCHAN_SB' => 'Carte Auchan (sandbox)', 'AURORE-MULTI' => 'Cpay Aurore',
222221
'BANCONTACT' => 'Bancontact Mistercash', 'BIZZBEE_CDX' => 'Carte Cadeau Bizzbee',
223-
'BIZZBEE_CDX_SB' => 'Carte Cadeau Bizzbee (sandbox)', 'BOULANGER' => 'Carte b+',
224-
'BOULANGER_SB' => 'Carte b+ (sandbox)', 'BRICE_CDX' => 'Carte Cadeau Brice',
225-
'BRICE_CDX_SB' => 'Carte Cadeau Brice (sandbox)', 'COFINOGA' => 'Cofinoga',
226-
'CONECS' => 'Conecs', 'APETIZ' => 'Apetiz',
227-
'CHQ_DEJ' => 'Chèque Déjeuner',
228-
'SODEXO' => 'Pass Restaurant', 'EDENRED' => 'Ticket Restaurant',
229-
'CORA_BLANCHE' => 'Cora blanche', 'CORA_PREM' => 'Cora Visa Premier', 'CORA_VISA' => 'Cora Visa',
230-
'DINERS' => 'Diners', 'DISCOVER' => 'Discover', 'E_CV' => 'e-Chèque-Vacances', 'ECCARD' => 'EC Card',
231-
'EDENRED_EC' => 'Ticket EcoCheque', 'EDENRED_TC' => 'Ticket Compliments',
232-
'EDENRED_TR' => 'Ticket Restaurant', 'ELV' => 'ELV',
233-
'FULLCB3X' => 'Paiement en 3 fois CB', 'FULLCB4X' => 'Paiement en 4 fois CB',
234-
'GOOGLEPAY' => 'Google Pay', 'GIROPAY' => 'Giropay', 'IDEAL' => 'iDEAL', 'ILLICADO' => 'Carte Illicado',
235-
'ILLICADO_SB' => 'Carte Illicado (sandbox)', 'JCB' => 'JCB',
236-
'KLARNA' => 'Klarna', 'LEROY-MERLIN' => 'Carte Maison Financement',
237-
'LEROY-MERLIN_SB' => 'Carte Maison Financement (sandbox)', 'MASTERPASS' => 'MasterPass',
238-
'MULTIBANCO' => 'Multibanco', 'NORAUTO' => 'Carte Norauto option Financement', 'NORAUTO_SB' => 'Carte Norauto option Financement (sandbox)',
239-
'ONEY' => 'Paiement en 3 ou 4 fois par CB', 'ONEY_SANDBOX' => 'Paiement en 3 ou 4 fois par CB (sandbox)', 'ONEY_3X_4X' => 'Paiement en 3 ou 4 fois Oney',
240-
'PAYDIREKT' => 'Paydirekt', 'PAYLIB' => 'Paylib', 'PAYPAL' => 'PayPal', 'PAYPAL_SB' => 'PayPal Sandbox',
241-
'POSTFINANCE' => 'PostFinance Card', 'POSTFINANCE_EFIN' => 'PostFinance E-Finance', 'SCT' => 'Virement SEPA',
242-
'SDD' => 'Prélèvement SEPA', 'SOFICARTE' => 'Soficarte',
243-
'SOFORT_BANKING' => 'Sofort', 'TRUFFAUT_CDX' => 'Carte Cadeau Truffaut', 'UNION_PAY' => 'UnionPay',
244-
'VILLAVERDE' => 'Carte Cadeau VillaVerde', 'VILLAVERDE_SB' => 'Carte Cadeau VillaVerde (sandbox)',
245-
'WECHAT' => 'WeChat Pay', 'MYBANK' => 'MyBank', 'PRZELEWY24' => 'Przelewy24',
246-
'ONEY_ENSEIGNE' => 'Cartes enseignes Oney'
222+
'BIZZBEE_CDX_SB' => 'Carte Cadeau Bizzbee (sandbox)', 'BOULANGER' => 'Carte b+', 'BOULANGER_SB' => 'Carte b+ (sandbox)',
223+
'BRICE_CDX' => 'Carte Cadeau Brice', 'BRICE_CDX_SB' => 'Carte Cadeau Brice (sandbox)', 'BUT' => 'But', 'CABAL' => 'Cabal',
224+
'CARNET' => 'Carnet', 'CA_DO_CARTE' => 'CA DO Carte', 'CHQ_DEJ' => 'Chèque Déjeuner', 'CONECS' => 'Conecs',
225+
'CONFORAMA' => 'Conforama', 'CORA' => 'Cora', 'CORA_BLANCHE' => 'Cora blanche', 'CORA_PREM' => 'Cora Visa Premier',
226+
'CORA_VISA' => 'Cora Visa', 'CVCO' => 'Chèque-Vacances Connect', 'DINERS' => 'Diners', 'DISCOVER' => 'Discover',
227+
'ECCARD' => 'EC Card', 'EDENRED' => 'Ticket Restaurant', 'EDENRED_EC' => 'Ticket EcoCheque',
228+
'EDENRED_SC' => 'Ticket Sport & Culture', 'EDENRED_TC' => 'Ticket Compliments', 'EDENRED_TR' => 'Ticket Restaurant',
229+
'ELO' => 'Elo', 'E_CV' => 'e-Chèque-Vacances', 'FRANFINANCE_3X' => 'Paiement en 3 fois',
230+
'FRANFINANCE_4X' => 'Paiement en 4 fois', 'FULLCB3X' => 'Paiement en 3 fois CB', 'FULLCB4X' => 'Paiement en 4 fois CB',
231+
'GEMO_CDX' => 'Carte Cadeau Gémo', 'GEMO_CDX_SB' => 'Carte Cadeau Gémo (sandbox)', 'GIROPAY' => 'Giropay',
232+
'GOOGLEPAY' => 'Google Pay', 'HIPER' => 'Hiper', 'HIPERCARD' => 'Hipercard', 'IDEAL' => 'iDEAL', 'JCB' => 'JCB',
233+
'JOUECLUB_CDX' => 'Carte Cadeau Joué Club', 'JOUECLUB_CDX_SB' => 'Carte Cadeau Joué Club (sandbox)',
234+
'JULES_CDX' => 'Carte Cadeau Jules', 'JULES_CDX_SB' => 'Carte Cadeau Jules (sandbox)', 'KLARNA' => 'Klarna',
235+
'LECLERC' => 'Carte Reglo', 'MC_CORDOBESA' => 'Mastercard Cordobesa',
236+
'MULTIBANCO' => 'Multibanco', 'MYBANK' => 'MyBank', 'NARANJA' => 'Naranja', 'NORAUTO' => 'Carte Norauto option Financement',
237+
'NORAUTO_SB' => 'Carte Norauto option Financement (sandbox)', 'ONEY_3X_4X' => 'Paiement en 3 ou 4 fois Oney',
238+
'ONEY_ENSEIGNE' => 'Cartes enseignes Oney', 'PAYDIREKT' => 'Paydirekt', 'PAYLIB' => 'Paylib', 'PAYPAL' => 'PayPal',
239+
'PAYPAL_SB' => 'PayPal Sandbox', 'PICWIC' => 'Carte Picwic', 'PICWIC_SB' => 'Carte Picwic (sandbox)',
240+
'POSTFINANCE' => 'PostFinance Card', 'POSTFINANCE_EFIN' => 'PostFinance E-Finance', 'PRESTO' => 'Presto',
241+
'PRZELEWY24' => 'Przelewy24', 'S-MONEY' => 'S-money', 'SCT' => 'Virement SEPA', 'SDD' => 'Prélèvement SEPA',
242+
'SODEXO' => 'Pass Restaurant', 'SOFORT_BANKING' => 'Sofort', 'SOROCRED' => 'Sorocred',
243+
'TRUFFAUT_CDX' => 'Carte Cadeau Truffaut', 'UNION_PAY' => 'UnionPay', 'WECHAT' => 'WeChat Pay'
247244
);
248245
}
249246

@@ -331,28 +328,5 @@ public static function sign($parameters, $key, $algo, $hashed = true)
331328
throw new \InvalidArgumentException("Unsupported algorithm passed : {$algo}.");
332329
}
333330
}
334-
335-
/**
336-
* PHP is not yet a sufficiently advanced technology to be indistinguishable from magic...
337-
* so don't use magic_quotes, they mess up with the gateway response analysis.
338-
*
339-
* @param array $potentially_quoted_data
340-
* @return mixed
341-
*/
342-
public static function uncharm($potentially_quoted_data)
343-
{
344-
if (get_magic_quotes_gpc()) {
345-
$sane = array();
346-
foreach ($potentially_quoted_data as $k => $v) {
347-
$sane_key = stripslashes($k);
348-
$sane_value = is_array($v) ? self::uncharm($v) : stripslashes($v);
349-
$sane[$sane_key] = $sane_value;
350-
}
351-
} else {
352-
$sane = $potentially_quoted_data;
353-
}
354-
355-
return $sane;
356-
}
357331
}
358332
}

commerce_payzen/includes/PayzenRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ public function __construct($encoding = 'UTF-8')
121121
// Defining all parameters and setting formats and default values.
122122
$this->addField('signature', 'Signature', '#^[0-9a-f]{40}$#u', true);
123123

124+
$this->addField('vads_acquirer_transient_data', 'Acquirer transient data', $ans255);
124125
$this->addField('vads_action_mode', 'Action mode', '#^INTERACTIVE|SILENT$#u', true, 11);
125126
$this->addField('vads_amount', 'Amount', '#^' . $supzero . '$#u', true);
126127
$this->addField('vads_available_languages', 'Available languages', '#^(|[A-Za-z]{2}(;[A-Za-z]{2})*)$#u', false, 2);

commerce_payzen/includes/PayzenResponse.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class PayzenResponse
9393
*/
9494
public function __construct($params, $ctx_mode, $key_test, $key_prod, $algo = PayzenApi::ALGO_SHA1)
9595
{
96-
$this->rawResponse = PayzenApi::uncharm($params);
96+
$this->rawResponse = $params;
9797
$this->certificate = trim(($ctx_mode == 'PRODUCTION') ? $key_prod : $key_test);
9898

9999
if (in_array($algo, PayzenApi::$SUPPORTED_ALGOS)) {
@@ -225,12 +225,14 @@ public function getRiskAssessment()
225225
* @param string $name
226226
* @return string
227227
*/
228-
public function get($name)
228+
public function get($name, $hasPrefix = true)
229229
{
230-
// Manage shortcut notations by adding 'vads_'.
231-
$name = (substr($name, 0, 5) != 'vads_') ? 'vads_' . $name : $name;
230+
if ($hasPrefix) {
231+
// Manage shortcut notations by adding 'vads_' prefix.
232+
$name = (substr($name, 0, 5) != 'vads_') ? 'vads_' . $name : $name;
233+
}
232234

233-
return @$this->rawResponse[$name];
235+
return array_key_exists($name, $this->rawResponse) ? $this->rawResponse[$name] : null;
234236
}
235237

236238
/**
@@ -249,7 +251,7 @@ public function getExtInfo($key)
249251
*/
250252
public function getSignature()
251253
{
252-
return @$this->rawResponse['signature'];
254+
return $this->get('signature', false);
253255
}
254256

255257
/**

commerce_payzen/includes/PayzenTools.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class PayzenTools
2020
private static $SUPPORT_EMAIL = 'support@payzen.eu';
2121

2222
private static $GATEWAY_VERSION = 'V2';
23-
private static $CMS_IDENTIFIER = 'Drupal_Commerce_7.x-1.x';
24-
private static $PLUGIN_VERSION = '1.3.0';
23+
private static $CMS_IDENTIFIER = 'Drupal_Commerce_1.x';
24+
private static $PLUGIN_VERSION = '1.3.1';
2525
private static $DOC_PATTERN = '${doc.pattern}';
2626

2727

commerce_payzen/translations/payzen.de.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Drupal Commerce PayZen (7.x-"
4-
"1.3.0)\n"
4+
"1.3.1)\n"
55
"Report-Msgid-Bugs-To: \n"
66
"POT-Creation-Date: 2020-08-05 08:41+0100\n"
77
"PO-Revision-Date: 2020-08-05 08:56+0100\n"

commerce_payzen/translations/payzen.es.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Drupal Commerce PayZen (7.x-"
4-
"1.3.0)\n"
4+
"1.3.1)\n"
55
"Report-Msgid-Bugs-To: \n"
66
"POT-Creation-Date: 2020-08-05 08:20+0100\n"
77
"PO-Revision-Date: 2020-08-05 08:41+0100\n"

0 commit comments

Comments
 (0)