Bonjour,
J'ai un petit souci avec mon module Atos, les transactions passées et validées ne sont pas prise en compte par Google Analytics .En cherchant un peu sur internet, j'ai trouvé que les transactions n'étaient prise en compte du fait que le module ne redirige par vers la bonne page de confirmation ou le code analytics est injecté.
J'ai tenté de modifier la variable en ligne 17 $retour = 'history.php'; par $retour = 'order-confirmation.php';
mais cela ne fonctionne pas, en suivant le parcours via la fonction "Temps réel" d'Analytics, j'ai pu me rendre compte que les visiteurs étaient redirigés vers la page "order.php?step=3", qui apparait bien dans la page validation.
J'ai en ligne 23 et 132 ces variables, mais elles correspondent à un paiement refusé ou plusieurs tentative sur une carte.
La discussion que j'avais trouvée.
http://www.prestashop.com/forums/topic/67955-module-atos-non-compatible-avec-google-analytics/
Merci par avance pour votre aide
<?php
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../header.php');
$retour = 'index.php';
include(dirname(__FILE__).'/atos.php');
$atos = new ATOS();
if(!@empty($_POST))
{
$atosConf = Configuration::getMultiple(array('ATOS_MERCHAND_ID','ATOS_BIN','ATOS_BANK'));
$message = 'message='.$_POST[DATA];
$pathfile = 'pathfile='.dirname(__FILE__).'/param/pathfile';
$path_bin = $atosConf['ATOS_BIN'].'response';
$result = exec("$path_bin $pathfile $message");
$tableau = explode ('!', $result);
$cart = new Cart(intval($tableau[22]));
$Customer = new Customer(intval($cart->id_customer));
$retour = 'history.php';
$logfile = dirname(__FILE__).'/log/logs.txt';
$fp = fopen($logfile, 'a');
fwrite($fp,'Transaction '.$atosConf['ATOS_BANK'].' du : '.date('d/m/Y H:i:s',time())."\n");
if(($tableau[1]=="")&&($tableau[2]=="")){
$atos->UpdateTransactionIDFile($tableau[6],'fail');
$retour = 'order.php?step=3';
fwrite($fp,"erreur appel response\n");
fwrite($fp,"executable response non trouve $path_bin\n");
}elseif($tableau[1]!=0){
$atos->UpdateTransactionIDFile($tableau[6],'fail');
fwrite($fp," API call error.\n");
fwrite($fp,"Error message : $tableau[2]\n");
$atos->validateOrder($tableau[22],_PS_OS_ERROR_,0, $atos->displayName,'Transaction ATOS '.$tableau[2], "", "", false, $Customer->secure_key);
}elseif(Validate::isLoadedObject($cart) && $cart->OrderExists() == 0 && $tableau[18]=='05') {
$atos->UpdateTransactionIDFile($tableau[6],'fail');
$atos->validateOrder($tableau[22],_PS_OS_ERROR_,0, $atos->displayName,'Transaction ATOS '.$tableau[2], "", "", false, $Customer->secure_key);
fwrite($fp,"Error message : $tableau[2]\n");
fwrite($fp,"merchant_id : $tableau[3]\n");
fwrite($fp,"merchant_country : $tableau[4]\n");
fwrite($fp,"amount : $tableau[5]\n");
fwrite($fp,"transaction_id : $tableau[6]\n");
fwrite($fp,"transmission_date: $tableau[8]\n");
fwrite($fp,"payment_means: $tableau[7]\n");
fwrite($fp,"payment_time : $tableau[9]\n");
fwrite($fp,"payment_date : $tableau[10]\n");
fwrite($fp,"response_code : $tableau[11]\n");
fwrite($fp,"payment_certificate : $tableau[12]\n");
fwrite($fp,"authorisation_id : $tableau[13]\n");
fwrite($fp,"currency_code : $tableau[14]\n");
fwrite($fp,"card_number : $tableau[15]\n");
fwrite($fp,"[spam-filter]_flag: $tableau[16]\n");
fwrite($fp,"[spam-filter]_response_code: $tableau[17]\n");
fwrite($fp,"bank_response_code: $tableau[18]\n");
fwrite($fp,"complementary_code: $tableau[19]\n");
fwrite($fp,"complementary_info: $tableau[20]\n");
fwrite($fp,"return_context: $tableau[21]\n");
fwrite($fp,"caddie : $tableau[22]\n");
fwrite($fp,"receipt_complement : $tableau[23]\n");
fwrite($fp,"merchant_language : $tableau[24]\n");
fwrite($fp,"language : $tableau[25]\n");
fwrite($fp,"customer_id : $tableau[26]\n");
fwrite($fp,"order_id : $tableau[27]\n");
fwrite($fp,"customer_email : $tableau[28]\n");
fwrite($fp,"customer_ip_address : $tableau[29]\n");
fwrite($fp,"capture_day : $tableau[30]\n");
fwrite($fp,"capture_mode : $tableau[31]\n");
fwrite($fp,"data : $tableau[32]\n");
fwrite($fp, "Resultat : Paiement refuse\n");
} elseif(Validate::isLoadedObject($cart) && $cart->OrderExists() == 0 && $tableau[18]=='00') {
fwrite($fp,"merchant_id : $tableau[3]\n");
fwrite($fp,"merchant_country : $tableau[4]\n");
fwrite($fp,"amount : $tableau[5]\n");
fwrite($fp,"transaction_id : $tableau[6]\n");
fwrite($fp,"transmission_date: $tableau[8]\n");
fwrite($fp,"payment_means: $tableau[7]\n");
fwrite($fp,"payment_time : $tableau[9]\n");
fwrite($fp,"payment_date : $tableau[10]\n");
fwrite($fp,"response_code : $tableau[11]\n");
fwrite($fp,"payment_certificate : $tableau[12]\n");
fwrite($fp,"authorisation_id : $tableau[13]\n");
fwrite($fp,"currency_code : $tableau[14]\n");
fwrite($fp,"card_number : $tableau[15]\n");
fwrite($fp,"[spam-filter]_flag: $tableau[16]\n");
fwrite($fp,"[spam-filter]_response_code: $tableau[17]\n");
fwrite($fp,"bank_response_code: $tableau[18]\n");
fwrite($fp,"complementary_code: $tableau[19]\n");
fwrite($fp,"complementary_info: $tableau[20]\n");
fwrite($fp,"return_context: $tableau[21]\n");
fwrite($fp,"caddie : $tableau[22]\n");
fwrite($fp,"receipt_complement : $tableau[23]\n");
fwrite($fp,"merchant_language : $tableau[24]\n");
fwrite($fp,"language : $tableau[25]\n");
fwrite($fp,"customer_id : $tableau[26]\n");
fwrite($fp,"order_id : $tableau[27]\n");
fwrite($fp,"customer_email : $tableau[28]\n");
fwrite($fp,"customer_ip_address : $tableau[29]\n");
fwrite($fp,"capture_day : $tableau[30]\n");
fwrite($fp,"capture_mode : $tableau[31]\n");
fwrite($fp,"data : $tableau[32]\n");
$amount = number_format($cart->getOrderTotal(true, 3), 2, '.', '');
if(strpos($amount,'.'))
$amount =$amount*100;
$amount = str_replace('.','',$amount);
if($tableau[3]==$atosConf['ATOS_MERCHAND_ID'] AND $tableau[5]==$amount)
{
$atos->UpdateTransactionIDFile($tableau[6],'ok');
$valide = "paiement valide";
$tableau[5] = number_format(intval($tableau[5])/100, 2, '.', '');
$currency_used = new Currency(Currency::getIdByIsoCode($tableau[14]));
$Customer = new Customer($tableau[26]);
$message = 'Transaction ATOS';
if($tableau[5]=='PAYMENT_N')
{
$data = explode(';',$tableau[32]);
$mltp = array();
foreach($data as$elt)
{
$item = explode('=',$elt);
$mltp[$item[0]] = $item[1];
}
$message .= ' Paiement en '.$mltp['NB_PAYMENT'].' fois :<br/>';
preg_match_all ('#([0-9]+)/#',$mltp['PAYMENT_DUE_DATES'],$dates);
foreach($dates[1] as $date)
$message .= substr($date,6,2).'/'.substr($date,4,2).'/'.substr($date,0,4).'<br/>';
}
$atos->validateOrder($tableau[22],_PS_OS_PAYMENT_,$tableau[5],$atos->displayName,$message,array(),$currency_used->id,false,$Customer->secure_key);
}else{
$atos->UpdateTransactionIDFile($tableau[6],'fail');
$valide = "paiement invalide !";
$atos->validateOrder($tableau[22],_PS_OS_ERROR_,0, $atos->displayName,'Transaction ATOS '.$tableau[2], "", "", false, $Customer->secure_key);
}
fwrite($fp, "Resultat : ".$valide."\n");
}else{
$atos->UpdateTransactionIDFile($tableau[6],'fail');
$retour = 'order.php?step=3';
fwrite($fp,$_POST['PAIEMENT']."\n");
}
fwrite($fp, "-------------------------------------------\n");
fclose($fp);
}
echo '<h4>'.$atos->getL('wait').'</h4>';
echo '<meta http-equiv="refresh" content="0; url=http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__.$retour.'" />';
include(dirname(__FILE__).'/../../footer.php');
?>
J'ai un petit souci avec mon module Atos, les transactions passées et validées ne sont pas prise en compte par Google Analytics .En cherchant un peu sur internet, j'ai trouvé que les transactions n'étaient prise en compte du fait que le module ne redirige par vers la bonne page de confirmation ou le code analytics est injecté.
J'ai tenté de modifier la variable en ligne 17 $retour = 'history.php'; par $retour = 'order-confirmation.php';
mais cela ne fonctionne pas, en suivant le parcours via la fonction "Temps réel" d'Analytics, j'ai pu me rendre compte que les visiteurs étaient redirigés vers la page "order.php?step=3", qui apparait bien dans la page validation.
J'ai en ligne 23 et 132 ces variables, mais elles correspondent à un paiement refusé ou plusieurs tentative sur une carte.
La discussion que j'avais trouvée.
http://www.prestashop.com/forums/topic/67955-module-atos-non-compatible-avec-google-analytics/
Merci par avance pour votre aide
<?php
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../header.php');
$retour = 'index.php';
include(dirname(__FILE__).'/atos.php');
$atos = new ATOS();
if(!@empty($_POST))
{
$atosConf = Configuration::getMultiple(array('ATOS_MERCHAND_ID','ATOS_BIN','ATOS_BANK'));
$message = 'message='.$_POST[DATA];
$pathfile = 'pathfile='.dirname(__FILE__).'/param/pathfile';
$path_bin = $atosConf['ATOS_BIN'].'response';
$result = exec("$path_bin $pathfile $message");
$tableau = explode ('!', $result);
$cart = new Cart(intval($tableau[22]));
$Customer = new Customer(intval($cart->id_customer));
$retour = 'history.php';
$logfile = dirname(__FILE__).'/log/logs.txt';
$fp = fopen($logfile, 'a');
fwrite($fp,'Transaction '.$atosConf['ATOS_BANK'].' du : '.date('d/m/Y H:i:s',time())."\n");
if(($tableau[1]=="")&&($tableau[2]=="")){
$atos->UpdateTransactionIDFile($tableau[6],'fail');
$retour = 'order.php?step=3';
fwrite($fp,"erreur appel response\n");
fwrite($fp,"executable response non trouve $path_bin\n");
}elseif($tableau[1]!=0){
$atos->UpdateTransactionIDFile($tableau[6],'fail');
fwrite($fp," API call error.\n");
fwrite($fp,"Error message : $tableau[2]\n");
$atos->validateOrder($tableau[22],_PS_OS_ERROR_,0, $atos->displayName,'Transaction ATOS '.$tableau[2], "", "", false, $Customer->secure_key);
}elseif(Validate::isLoadedObject($cart) && $cart->OrderExists() == 0 && $tableau[18]=='05') {
$atos->UpdateTransactionIDFile($tableau[6],'fail');
$atos->validateOrder($tableau[22],_PS_OS_ERROR_,0, $atos->displayName,'Transaction ATOS '.$tableau[2], "", "", false, $Customer->secure_key);
fwrite($fp,"Error message : $tableau[2]\n");
fwrite($fp,"merchant_id : $tableau[3]\n");
fwrite($fp,"merchant_country : $tableau[4]\n");
fwrite($fp,"amount : $tableau[5]\n");
fwrite($fp,"transaction_id : $tableau[6]\n");
fwrite($fp,"transmission_date: $tableau[8]\n");
fwrite($fp,"payment_means: $tableau[7]\n");
fwrite($fp,"payment_time : $tableau[9]\n");
fwrite($fp,"payment_date : $tableau[10]\n");
fwrite($fp,"response_code : $tableau[11]\n");
fwrite($fp,"payment_certificate : $tableau[12]\n");
fwrite($fp,"authorisation_id : $tableau[13]\n");
fwrite($fp,"currency_code : $tableau[14]\n");
fwrite($fp,"card_number : $tableau[15]\n");
fwrite($fp,"[spam-filter]_flag: $tableau[16]\n");
fwrite($fp,"[spam-filter]_response_code: $tableau[17]\n");
fwrite($fp,"bank_response_code: $tableau[18]\n");
fwrite($fp,"complementary_code: $tableau[19]\n");
fwrite($fp,"complementary_info: $tableau[20]\n");
fwrite($fp,"return_context: $tableau[21]\n");
fwrite($fp,"caddie : $tableau[22]\n");
fwrite($fp,"receipt_complement : $tableau[23]\n");
fwrite($fp,"merchant_language : $tableau[24]\n");
fwrite($fp,"language : $tableau[25]\n");
fwrite($fp,"customer_id : $tableau[26]\n");
fwrite($fp,"order_id : $tableau[27]\n");
fwrite($fp,"customer_email : $tableau[28]\n");
fwrite($fp,"customer_ip_address : $tableau[29]\n");
fwrite($fp,"capture_day : $tableau[30]\n");
fwrite($fp,"capture_mode : $tableau[31]\n");
fwrite($fp,"data : $tableau[32]\n");
fwrite($fp, "Resultat : Paiement refuse\n");
} elseif(Validate::isLoadedObject($cart) && $cart->OrderExists() == 0 && $tableau[18]=='00') {
fwrite($fp,"merchant_id : $tableau[3]\n");
fwrite($fp,"merchant_country : $tableau[4]\n");
fwrite($fp,"amount : $tableau[5]\n");
fwrite($fp,"transaction_id : $tableau[6]\n");
fwrite($fp,"transmission_date: $tableau[8]\n");
fwrite($fp,"payment_means: $tableau[7]\n");
fwrite($fp,"payment_time : $tableau[9]\n");
fwrite($fp,"payment_date : $tableau[10]\n");
fwrite($fp,"response_code : $tableau[11]\n");
fwrite($fp,"payment_certificate : $tableau[12]\n");
fwrite($fp,"authorisation_id : $tableau[13]\n");
fwrite($fp,"currency_code : $tableau[14]\n");
fwrite($fp,"card_number : $tableau[15]\n");
fwrite($fp,"[spam-filter]_flag: $tableau[16]\n");
fwrite($fp,"[spam-filter]_response_code: $tableau[17]\n");
fwrite($fp,"bank_response_code: $tableau[18]\n");
fwrite($fp,"complementary_code: $tableau[19]\n");
fwrite($fp,"complementary_info: $tableau[20]\n");
fwrite($fp,"return_context: $tableau[21]\n");
fwrite($fp,"caddie : $tableau[22]\n");
fwrite($fp,"receipt_complement : $tableau[23]\n");
fwrite($fp,"merchant_language : $tableau[24]\n");
fwrite($fp,"language : $tableau[25]\n");
fwrite($fp,"customer_id : $tableau[26]\n");
fwrite($fp,"order_id : $tableau[27]\n");
fwrite($fp,"customer_email : $tableau[28]\n");
fwrite($fp,"customer_ip_address : $tableau[29]\n");
fwrite($fp,"capture_day : $tableau[30]\n");
fwrite($fp,"capture_mode : $tableau[31]\n");
fwrite($fp,"data : $tableau[32]\n");
$amount = number_format($cart->getOrderTotal(true, 3), 2, '.', '');
if(strpos($amount,'.'))
$amount =$amount*100;
$amount = str_replace('.','',$amount);
if($tableau[3]==$atosConf['ATOS_MERCHAND_ID'] AND $tableau[5]==$amount)
{
$atos->UpdateTransactionIDFile($tableau[6],'ok');
$valide = "paiement valide";
$tableau[5] = number_format(intval($tableau[5])/100, 2, '.', '');
$currency_used = new Currency(Currency::getIdByIsoCode($tableau[14]));
$Customer = new Customer($tableau[26]);
$message = 'Transaction ATOS';
if($tableau[5]=='PAYMENT_N')
{
$data = explode(';',$tableau[32]);
$mltp = array();
foreach($data as$elt)
{
$item = explode('=',$elt);
$mltp[$item[0]] = $item[1];
}
$message .= ' Paiement en '.$mltp['NB_PAYMENT'].' fois :<br/>';
preg_match_all ('#([0-9]+)/#',$mltp['PAYMENT_DUE_DATES'],$dates);
foreach($dates[1] as $date)
$message .= substr($date,6,2).'/'.substr($date,4,2).'/'.substr($date,0,4).'<br/>';
}
$atos->validateOrder($tableau[22],_PS_OS_PAYMENT_,$tableau[5],$atos->displayName,$message,array(),$currency_used->id,false,$Customer->secure_key);
}else{
$atos->UpdateTransactionIDFile($tableau[6],'fail');
$valide = "paiement invalide !";
$atos->validateOrder($tableau[22],_PS_OS_ERROR_,0, $atos->displayName,'Transaction ATOS '.$tableau[2], "", "", false, $Customer->secure_key);
}
fwrite($fp, "Resultat : ".$valide."\n");
}else{
$atos->UpdateTransactionIDFile($tableau[6],'fail');
$retour = 'order.php?step=3';
fwrite($fp,$_POST['PAIEMENT']."\n");
}
fwrite($fp, "-------------------------------------------\n");
fclose($fp);
}
echo '<h4>'.$atos->getL('wait').'</h4>';
echo '<meta http-equiv="refresh" content="0; url=http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__.$retour.'" />';
include(dirname(__FILE__).'/../../footer.php');
?>