Skip to content

Commit

Permalink
Merge branch 'hotfix/2.1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennelandais committed Jan 22, 2018
2 parents 48e87d1 + b74c21e commit d7c59f0
Show file tree
Hide file tree
Showing 4 changed files with 342 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 2.1.4

- Fix: credit card block are displaying even if no credit card payment are activated

# Version 2.1.3

- Fix local payment with hosted order
Expand Down
27 changes: 19 additions & 8 deletions src/hipay_enterprise/classes/helper/HipayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,19 @@ public static function getSortedActivatedPaymentByCountryAndCurrency(
$customer
) {
$activatedCreditCard = array();
$activatedCreditCard["credit_card"]["frontPosition"] = $configHipay["payment"]["global"]["ccFrontPosition"];
$activatedCreditCard["credit_card"]["products"] = self::getActivatedPaymentByCountryAndCurrency(
$creditCards = self::getActivatedPaymentByCountryAndCurrency(
$module,
$configHipay,
"credit_card",
$country,
$currency,
$orderTotal
);

if (!empty($creditCards)) {
$activatedCreditCard["credit_card"]["frontPosition"] = $configHipay["payment"]["global"]["ccFrontPosition"];
$activatedCreditCard["credit_card"]["products"] = $creditCards;
}

$activatedLocalPayment = self::getActivatedPaymentByCountryAndCurrency(
$module,
Expand Down Expand Up @@ -398,22 +402,27 @@ public static function getActivatedPaymentByCountryAndCurrency(
'views/img/' .
$settings["logo"];

$checkoutFieldsMandatory = isset($module->hipayConfigTool->getLocalPayment()[$name]["checkoutFieldsMandatory"]) ?
$checkoutFieldsMandatory = isset($module->hipayConfigTool->getLocalPayment(
)[$name]["checkoutFieldsMandatory"]) ?
$module->hipayConfigTool->getLocalPayment()[$name]["checkoutFieldsMandatory"] : "";
$fieldMandatory = array();
if (!empty($checkoutFieldsMandatory)) {
foreach ($checkoutFieldsMandatory as $field) {
switch ($field) {
case "phone":
if (empty($address->{$field})) {
$fieldMandatory[] = $module->l('Please enter your phone number to use this payment method.');
} else if (!preg_match('"(0|\\+33|0033)[1-9][0-9]{8}"',$address->{$field})) {
$fieldMandatory[] = $module->l(
'Please enter your phone number to use this payment method.'
);
} else if (!preg_match('"(0|\\+33|0033)[1-9][0-9]{8}"', $address->{$field})) {
$fieldMandatory[] = $module->l('Please check the phone number entered.');
}
break;
case "gender":
if (empty($customer->id_gender)) {
$fieldMandatory[] = $module->l('Please inform your civility to use this method of payment.');
$fieldMandatory[] = $module->l(
'Please inform your civility to use this method of payment.'
);
}
break;
default:
Expand All @@ -422,7 +431,7 @@ public static function getActivatedPaymentByCountryAndCurrency(
}
}

$activatedPayment[$name]['errorMsg'] = $fieldMandatory;
$activatedPayment[$name]['errorMsg'] = $fieldMandatory;
}

}
Expand Down Expand Up @@ -551,7 +560,9 @@ private static function cmpPaymentProduct($a, $b)
public static function orderExists($cart_id)
{
if ($cart_id) {
$result = (bool)Db::getInstance()->getValue('SELECT count(*) FROM `'._DB_PREFIX_.'orders` WHERE `id_cart` = '.(int)$cart_id);
$result = (bool)Db::getInstance()->getValue(
'SELECT count(*) FROM `' . _DB_PREFIX_ . 'orders` WHERE `id_cart` = ' . (int)$cart_id
);
return $result;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/hipay_enterprise/hipay_enterprise.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct()

$this->name = 'hipay_enterprise';
$this->tab = 'payments_gateways';
$this->version = '2.1.3';
$this->version = '2.1.4';
$this->module_key = 'c3c030302335d08603e8669a5210c744';
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
$this->currencies = true;
Expand Down
Loading

0 comments on commit d7c59f0

Please sign in to comment.