Merge branch 'ticket-payboxAgreement' into develop
This commit is contained in:
commit
0c40f60da5
@ -261,10 +261,10 @@ class Paybox extends PaymentModule
|
||||
'pbx_link_plus' => $pbx_link_plus,
|
||||
));
|
||||
|
||||
return ($this->display(__FILE__, 'hookpayment.tpl'));
|
||||
return ($this->display(__FILE__, 'hookpayment.tpl'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Save Information de Paiement Paybox (retour de la banque)
|
||||
* @param array $values Tableau de retour Paybox
|
||||
@ -273,8 +273,8 @@ class Paybox extends PaymentModule
|
||||
|
||||
mail('marion@antadis.com', 'Transaction value', http_build_query($values,'',', ')); // dev
|
||||
|
||||
if(isset($values['u'])
|
||||
|| !empty($values['u'])
|
||||
if(isset($values['u'])
|
||||
|| !empty($values['u'])
|
||||
&& !$direct_plus
|
||||
) {
|
||||
$cart = new Cart((int)$values["r"]);
|
||||
@ -287,7 +287,7 @@ class Paybox extends PaymentModule
|
||||
$exists = Db::getInstance()->getValue($sql_cart);
|
||||
|
||||
if (empty($exists)) {
|
||||
$sql = 'INSERT INTO `ps_paybox_transaction`
|
||||
$sql = 'INSERT INTO `ps_paybox_transaction`
|
||||
(`amount`, `id_cart`, `num_appel`, `num_autorisation`, `paiement`, `type`, `num_transaction`, `code_erreur`, `date_carte`, `date_add`)
|
||||
VALUES (
|
||||
'. (int)$values["m"] .',
|
||||
@ -317,12 +317,14 @@ class Paybox extends PaymentModule
|
||||
|
||||
mail('marion@antadis.com', 'Transaction value + Save CB', http_build_query($values,'',', ')); // dev
|
||||
$handle = explode(' ',$values['u']);
|
||||
$date = substr($values["d"], -2).substr($values["d"], 0, 2);
|
||||
$payment = str_replace("_", " ",$values["c"]);
|
||||
|
||||
$exists = Db::getInstance()->getValue('
|
||||
SELECT `id_paybox_card`
|
||||
FROM `ps_paybox_customer_agreement`
|
||||
WHERE `handle` = "'.pSQL($handle[0]).'"
|
||||
AND `date`='.(int)$values["d"].'
|
||||
WHERE `handle` = "'.pSQL($handle[0]).'"
|
||||
AND `date`="'.pSQL($date).'"
|
||||
AND `refabonne`='.(int)$values['b'].'
|
||||
AND `id_customer`='.(int)$id_customer.'
|
||||
');
|
||||
@ -330,15 +332,15 @@ class Paybox extends PaymentModule
|
||||
if (empty($exists)) {
|
||||
$num_value = (int)$values["n"].'XXXXX'.(int)$values["j"];
|
||||
$save = Db::getInstance()->execute('
|
||||
INSERT INTO `ps_paybox_customer_agreement`
|
||||
INSERT INTO `ps_paybox_customer_agreement`
|
||||
(`id_customer`,`refabonne`,`handle`,`value`,`date`,`payment_type`)
|
||||
VALUES (
|
||||
'. (int)$id_customer .',
|
||||
'. (int)$values["b"] .',
|
||||
"'. pSQL($handle[0]) .'",
|
||||
"'. pSQL($num_value) .'",
|
||||
'. (int)$values["d"] .',
|
||||
"'. pSQL($values["c"]) .'"
|
||||
"'.pSQL($date).'",
|
||||
"'. pSQL($payment) .'"
|
||||
)');
|
||||
|
||||
if(!$save) {
|
||||
@ -353,15 +355,15 @@ class Paybox extends PaymentModule
|
||||
if(Tools::getValue('noCancelHook')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// if(Tools::isSubmit('generateDiscount'))
|
||||
// return false;
|
||||
|
||||
|
||||
if($params['order']->module != $this->name)
|
||||
return false;
|
||||
if(!($order = $params['order']) OR !Validate::isLoadedObject($order))
|
||||
return false;
|
||||
|
||||
|
||||
if($cookie->profile == 1
|
||||
|| $cookie->profile == 7
|
||||
|| $cookie->profile == 11) {
|
||||
@ -384,7 +386,7 @@ class Paybox extends PaymentModule
|
||||
// if(Tools::isSubmit('generateDiscount')) {
|
||||
// return FALSE;
|
||||
// }
|
||||
|
||||
|
||||
if($params['order']->module != $this->name) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -403,7 +405,7 @@ class Paybox extends PaymentModule
|
||||
if($cookie->profile == 1
|
||||
|| $cookie->profile == 7
|
||||
|| $cookie->profile == 11) {
|
||||
|
||||
|
||||
$order = new Order($order_detail->id_order);
|
||||
|
||||
if ($order->payment == "Paybox") {
|
||||
@ -416,7 +418,7 @@ class Paybox extends PaymentModule
|
||||
$this->refundProduct($params['id_order_detail']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -467,7 +469,7 @@ class Paybox extends PaymentModule
|
||||
$montant = min($amt, $order->total_paid_real - ((int) $total_shipping * $order->total_shipping) - $total_refunded);
|
||||
|
||||
$refund = $this->sendRefundPaybox($montant, 978, $transaction['num_transaction'], $order->id_cart, $transaction['num_appel']);
|
||||
|
||||
|
||||
if (!$refund) {
|
||||
// mail('thibault@antadis.com', 'Erreur dans le remboursement produit', 'Erreur remboursement échoué pour la commande ' . $order_detail->id_order);
|
||||
mail('karen@bebeboutik.com', 'Erreur dans le remboursement', 'Erreur remboursement échoué pour la commande ' . $order_detail->id_order);
|
||||
@ -509,12 +511,12 @@ class Paybox extends PaymentModule
|
||||
|
||||
if($montant > 0) {
|
||||
$refund = $this->sendRefundPaybox($montant, 978, $transaction['num_transaction'], $order->id_cart, $transaction['num_appel']);
|
||||
|
||||
|
||||
if (!$refund) {
|
||||
// mail('thibault@antadis.com', 'Erreur dans le remboursement des shippings', 'Erreur remboursement échoué pour la commande ' . $order->id);
|
||||
mail('karen@bebeboutik.com', 'Erreur dans le remboursement', 'Erreur remboursement échoué pour la commande ' . $order->id);
|
||||
mail('doreen@bebeboutik.com', 'Erreur dans le remboursement', 'Erreur remboursement échoué pour la commande ' . $order->id);
|
||||
mail('contact@bebeboutik.com', 'Erreur dans le remboursement', 'Erreur remboursement échoué pour la commande ' . $order->id);
|
||||
mail('doreen@bebeboutik.com', 'Erreur dans le remboursement', 'Erreur remboursement échoué pour la commande ' . $order->id);
|
||||
mail('contact@bebeboutik.com', 'Erreur dans le remboursement', 'Erreur remboursement échoué pour la commande ' . $order->id);
|
||||
} else {
|
||||
$this->refundSave($order->id, 0, $montant, $cookie->id_employee);
|
||||
}
|
||||
@ -533,10 +535,10 @@ class Paybox extends PaymentModule
|
||||
**/
|
||||
public function sendRefundPaybox($montant, $devise, $num_transaction, $reference, $num_appel) {
|
||||
$curl = curl_init('https://ppps.paybox.com/PPPS.php');
|
||||
|
||||
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_COOKIESESSION, true);
|
||||
|
||||
|
||||
$pbx_site = trim(Configuration::get('PBX_SITE'));
|
||||
$pbx_rang = trim(Configuration::get('PBX_RANG'));
|
||||
$pbx_id = trim(Configuration::get('PBX_ID'));
|
||||
@ -562,13 +564,13 @@ class Paybox extends PaymentModule
|
||||
'REFERENCE' => $reference,
|
||||
'DATEQ' => date('dmYHis')
|
||||
);
|
||||
|
||||
|
||||
$trame = http_build_query($postfields, '', '&');
|
||||
|
||||
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $trame);
|
||||
|
||||
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
@ -597,7 +599,7 @@ class Paybox extends PaymentModule
|
||||
**/
|
||||
protected function refundSave($id_order, $id_order_detail = 0, $montant, $id_employee) {
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'refund_transaction`
|
||||
INSERT INTO `'._DB_PREFIX_.'refund_transaction`
|
||||
(`id_order`, `id_order_detail`, `amount`, `date`, `id_employee`)
|
||||
VALUES (
|
||||
'. (int)$id_order .',
|
||||
@ -609,7 +611,7 @@ class Paybox extends PaymentModule
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load les informations d'une transaction paybox
|
||||
* @param int $id_cart Numéro du panier à charger
|
||||
@ -618,7 +620,7 @@ class Paybox extends PaymentModule
|
||||
public function loadTransaction($id_cart) {
|
||||
return Db::getInstance()->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'paybox_transaction`
|
||||
FROM `'._DB_PREFIX_.'paybox_transaction`
|
||||
WHERE `id_cart` = '. (int)$id_cart
|
||||
);
|
||||
}
|
||||
@ -627,7 +629,7 @@ class Paybox extends PaymentModule
|
||||
/**
|
||||
* Recupere la liste des remboursements effectués sur un id cmomande
|
||||
* @param int $order_id id de la commande
|
||||
* @return array
|
||||
* @return array
|
||||
**/
|
||||
public static function getAllRefundbyOrder($order_id) {
|
||||
return Db::getInstance()->executeS('
|
||||
@ -639,4 +641,4 @@ class Paybox extends PaymentModule
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user