97 lines
3.1 KiB
PHP
97 lines
3.1 KiB
PHP
<?php
|
|
require_once(dirname(__FILE__).'/../../config/config.inc.php');
|
|
require_once(dirname(__FILE__).'/../../init.php');
|
|
require_once(dirname(__FILE__).'/paybox.php');
|
|
|
|
global $cart, $smarty;
|
|
|
|
$module = new Paybox();
|
|
$controller->preProcess();
|
|
|
|
if (!$cookie->isLogged())
|
|
Tools::redirect('authentication.php');
|
|
|
|
$id_paybox_card = Tools::getValue('id_paybox_card', false);
|
|
if ($id_paybox_card) {
|
|
$paybox_card = Db::getInstance()->getRow('
|
|
SELECT *
|
|
FROM `ps_paybox_customer_agreement`
|
|
WHERE `id_customer` = '.(int)$cart->id_customer.'
|
|
AND `id_paybox_card` = '.(int)$id_paybox_card.'
|
|
');
|
|
if(empty($paybox_card)) {
|
|
Tools::redirect('order.php?step=3&cgv=1&paybox_error=1');
|
|
}
|
|
}
|
|
include(dirname(__FILE__).'/../../header.php');
|
|
|
|
if(Configuration::get('PBX_DEMO_MODE') == 0) {
|
|
$curl = curl_init('https://preprod-ppps.paybox.com/PPPS.php');
|
|
} else {
|
|
//$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'));
|
|
|
|
$num_question = Configuration::get('NUM_QUESTION_PAYBOX') + 1;
|
|
Configuration::updateValue('NUM_QUESTION_PAYBOX', $num_question);
|
|
|
|
$montant == (int)sprintf('%010d', number_format(Tools::convertPrice($cart->getOrderTotal(), null, false), 2, '.', '') * 100);
|
|
$devise = 978;
|
|
$card_info = explode('++', $paybox_card['handle']);
|
|
$numbers = urldecode($card_info[0]);
|
|
$dateval = $card_info[1];
|
|
$cvv = $card_info[2];
|
|
$customer = new Customer((int)$cart->id_customer);
|
|
$refabonne = md5($customer->email);
|
|
|
|
$postfields = array(
|
|
'VERSION' => '00104',
|
|
'TYPE' => '00053',
|
|
'SITE' => $pbx_site,
|
|
'RANG' => $pbx_rang,
|
|
'CLE' => 'EFNLJKFB',
|
|
'NUMQUESTION' => $num_question,
|
|
'MONTANT' => $montant,
|
|
'DEVISE' => $devise,
|
|
'REFERENCE' => (int)$cart->id,
|
|
'REFABONNE' => md5($customer),
|
|
'PORTEUR' => $numbers,
|
|
'DATEVAL' => $dateval,
|
|
'ACTIVITE' => '027',
|
|
/*'CVV' => Configuration::get('PBX_DEMO_MODE') == 0 ?'123':$cvv,*/
|
|
'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);
|
|
|
|
$data = explode('&', $response);
|
|
$code_reponse = explode('CODEREPONSE=', $data[6]);
|
|
|
|
mail('marion@antadis.com', 'Paiement reponse globale', http_build_query($response,'',', '));
|
|
|
|
// payment success
|
|
if (Configuration::get('PBX_DEMO_MODE') == 0) {
|
|
if ($code_reponse[1] == "00000" || $code_reponse[0] == "00000") {
|
|
return true;
|
|
}
|
|
} else {
|
|
if ($code_reponse[1] == "00000" || $code_reponse[0] == "00000") {
|
|
return true;
|
|
} else {
|
|
mail('marion@antadis.com', 'Soucis paiement reponse globale', json_encode($response));
|
|
return false;
|
|
}
|
|
} |