adding refabonne as parameter

This commit is contained in:
Christophe LATOUR 2017-12-06 16:02:23 +01:00
parent 0cc31c3d61
commit 578f689093

View File

@ -441,14 +441,14 @@ class Paybox extends PaymentModule
* Save Information de Paiement Paybox (retour de la banque)
* @param array $values Tableau de retour Paybox
**/
public function saveInformationPaiement($values,$direct_plus=false) {
public function saveInformationPaiement($values,$direct_plus=false, $refabonne = null) {
if(isset($values['u'])
|| !empty($values['u'])
&& !$direct_plus
) {
$cart = new Cart((int)$values["r"]);
$this->saveInformationCB($values,$cart->id_customer);
$this->saveInformationCB($values,$cart->id_customer, $refabonne);
}
$sql_cart = 'SELECT `num_transaction`
@ -485,12 +485,11 @@ class Paybox extends PaymentModule
* Save Information de carte Paiement Paybox (retour de la banque + handle de la cart)
* @param array $values Tableau de retour Paybox
**/
public function saveInformationCB($values,$id_customer) {
public function saveInformationCB($values,$id_customer, $refabonne = null) {
$handle = explode(' ',$values['u']);
$date = substr($values["d"], -2).substr($values["d"], 0, 2);
$payment = str_replace("_", " ",$values["c"]);
$customer = new Customer((int)$id_customer);
$refabonne = $customer->email;
$exists = Db::getInstance()->getValue('
SELECT `id_paybox_card`
@ -502,14 +501,17 @@ class Paybox extends PaymentModule
');
if (empty($exists)) {
$count_cards = Db::getInstance()->getValue('
SELECT COUNT(`id_paybox_card`)
FROM `'._DB_PREFIX_.'paybox_customer_agreement`
WHERE `id_customer` = '.(int)$id_customer.'
');
if ($count_cards) {
$refabonne = $customer->email.((int)$count_cards+1);
}
if ($refabonne === null) {
$refabonne = $customer->email;
$count_cards = Db::getInstance()->getValue('
SELECT COUNT(`id_paybox_card`)
FROM `'._DB_PREFIX_.'paybox_customer_agreement`
WHERE `id_customer` = '.(int)$id_customer.'
');
if ($count_cards) {
$refabonne = $customer->email.((int)$count_cards+1);
}
}
$num_value = $values["n"].'XXXXX'.$values["j"];
$save = Db::getInstance()->execute('
INSERT INTO `ps_paybox_customer_agreement`