94 lines
3.0 KiB
PHP
94 lines
3.0 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');
|
||
|
|
||
|
if (Tools::getValue('id_paybox_card')) {
|
||
|
$paybox_card = Db::getInstance()->getValue('
|
||
|
SELECT *
|
||
|
FROM `ps_paybox_customer_agreement`
|
||
|
WHERE `handle` = "'.pSQL($values["u"]).'"
|
||
|
AND `date`='.(int)$values["d"].'
|
||
|
AND `refabonne`='.(int)$value['b'].'
|
||
|
AND `id_customer`='.(int)$id_customer.'
|
||
|
');
|
||
|
if(empty($paybox_card)) {
|
||
|
Tools::redirect('authentication.php');
|
||
|
}
|
||
|
}
|
||
|
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;
|
||
|
$cvv = explode('++', $paybox_card['handle']);
|
||
|
$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' => $paybox_card['handle'],
|
||
|
'DATEVAL' => $paybox_card['date'],
|
||
|
'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] == "XXXXXX" || $code_reponse[0] == "XXXXXX") {
|
||
|
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;
|
||
|
}
|
||
|
}
|