Skip to content

Commit

Permalink
Merge pull request #31 from paynl/feature/PLUG-331
Browse files Browse the repository at this point in the history
Feature/plug 331
  • Loading branch information
woutse authored Feb 23, 2021
2 parents 2b735c3 + 368d49e commit 0b87848
Showing 1 changed file with 33 additions and 13 deletions.
46 changes: 33 additions & 13 deletions paynlpaymentmethods/paynlpaymentmethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct()
{
$this->name = 'paynlpaymentmethods';
$this->tab = 'payments_gateways';
$this->version = '4.2.12';
$this->version = '4.2.13';

$this->payLogEnabled = null;
$this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
Expand Down Expand Up @@ -725,16 +725,7 @@ public function startPayment(Cart $cart, $payment_option_id, $extra_data = array
$description = Configuration::get('PAYNL_DESCRIPTION_PREFIX') . $description;
}

$object_string = 'prestashop ';
if(isset($this->version) && !empty($this->version)){
$object_string .= $this->version;
}
if(defined('_PS_VERSION_') && !empty(_PS_VERSION_)){
$object_string .= ' | ' . _PS_VERSION_;
}
if(defined('PHP_VERSION') && !empty(PHP_VERSION)){
$object_string .= ' | ' . PHP_VERSION;
}


$startData = array(
'amount' => $cart->getOrderTotal(true, Cart::BOTH, null, null, false),
Expand All @@ -746,7 +737,7 @@ public function startPayment(Cart $cart, $payment_option_id, $extra_data = array
'testmode' => Configuration::get('PAYNL_TEST_MODE'),
'extra1' => $cart->id,
'products' => $products,
'object' => substr($object_string, 0, 64),
'object' => $this->getObjectInfo()
);

$addressData = $this->_getAddressData($cart);
Expand Down Expand Up @@ -798,6 +789,21 @@ public function startPayment(Cart $cart, $payment_option_id, $extra_data = array
return $payTransaction->getRedirectUrl();
}

/**
* @return false|string
*/
private function getObjectInfo()
{
$object_string = 'prestashop | ';
$object_string .= !empty($this->version) ? $this->version : '-';
$object_string .= ' | ';
$object_string .= defined('_PS_VERSION_') ? _PS_VERSION_ : '-';
$object_string .= ' | ';
$object_string .= substr(phpversion(), 0, 3);

return substr($object_string, 0, 64);
}

/**
* Retrieve the settings of a specific payment with payment_profile_id
*
Expand Down Expand Up @@ -929,7 +935,7 @@ private function _getAddressData(Cart $cart)
$enduser['initials'] = $objShippingAddress->firstname;
$enduser['firstName'] = $objShippingAddress->firstname;
$enduser['lastName'] = $objShippingAddress->lastname;
$enduser['birthDate'] = $customer->birthday;
$enduser['birthDate'] = $this->getDOB($customer->birthday);
$enduser['phoneNumber'] = $objShippingAddress->phone ? $objShippingAddress->phone : $objShippingAddress->phone_mobile;
$enduser['emailAddress'] = $customer->email;
$enduser['gender'] = $customer->id_gender == 1 ? 'M' : ($customer->id_gender == 2 ? 'F' : '');
Expand Down Expand Up @@ -966,6 +972,20 @@ private function _getAddressData(Cart $cart)
);
}

/**
* @param $dob
* @return string|null
*/
private function getDOB($dob)
{
if (empty(trim($dob))) {
return null;
} elseif ($dob == '00-00-0000' || $dob == '0000-00-00') {
return null;
}
return $dob;
}

/**
* Retrieve language
*
Expand Down

0 comments on commit 0b87848

Please sign in to comment.