1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
|
<?php /*
$Id: atos_board.php, v 0.1 29/10/2008 Delete $
This script is not included in the original version of osCommerce
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
*/
require('includes/application_top.php');
// For php4 users - Merci xavkick
//
if (!function_exists('file_put_contents')) {
function file_put_contents($filename, $data) {
$f = @fopen($filename, 'w');
if (!$f) {
return false;
} else {
$bytes = fwrite($f, $data);
fclose($f);
return $bytes;
}
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet1.css">
<script type="text/javascript" src="includes/general.js"></script>
</head>
<body>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" summary="" width="150%" cellspacing="2" cellpadding="2">
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" summary="" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="150%" valign="top"><table border="0" width="150%" cellspacing="0" cellpadding="2">
<!-- Atos Feed Begin //-->
<tr><td class="pageHeading"><?php echo ATOS_BOARD_PAGE_HEADING ; ?></td</tr>
<form method="post" enctype="multipart/form-data" action="<?php echo tep_href_link(FILENAME_ATOS_BOARD);?>" name="atos_feed">
<tr>
<td class="dataTableContent"><?php echo ATOS_BOARD_UPLOAD_TITLE ; ?> <input type="file" name="fichier" size="60"> <input type="submit" name="upload" action="<?php echo tep_href_link(FILENAME_ATOS_BOARD);?>" value="<?php echo ATOS_BOARD_UPLOAD ; ?>">
</td>
</form>
</tr>
</td>
<?php
// Short Header
//
$header = '
<table border="0" width="150%">
<tr>
<td class="dataTableatos"></td>
<td class="dataTableatos"><span style="font-size: 8pt">ID Commande #</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Status</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">ID Transaction</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">PRIX</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Nom client</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Status Transaction</span> </td>
<td class="dataTableatos"><span style="font-size: 8pt">Date de Payment</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Heure de Payment</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Date de Validiter Carte</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Type de carte</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Numero de carte</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Response Code</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Certificate</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Authorization Id</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Date de Capture carte</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Autoresponse Status</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Customer Ip_address</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Transaction Condition</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Bank Response Code</span></td>
</tr><span style="font-size: 8pt">' ;
//
// Format complet
//
if ( ATOS_BOARD_LONG_DISPLAY )
$header = ' </span>
<table border="0" width="150%">
<tr>
<td class="dataTableatos"><span style="font-size: 8pt">ID Commande #</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Status</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Entete</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">ID Transaction</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Nom du client</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Merchant Id</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Payment Means</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Origin Amount</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">PRIX</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Transaction Status</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Currency Code</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Date de Payment</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Heure de Payment</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Date de Validiter Carte</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Type de carte</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Numero de carte</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Response Code</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Cvv Response_code</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Complementary Code</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Certificate</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Authorization Id</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Date de Capture</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Return Context</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Autoresponse Status</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Atos Order_id</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Customer Id</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Customer Ip_address</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Account Serial</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Session Id</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Transaction Condition</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Cavv Ucaf</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Complementary Info</span></td>
<td class="dataTableatos"><span style="font-size: 8pt">Bank Response Code</span></td>
</tr><span style="font-size: 8pt">' ;
// Ligne préformatée pour l'affichage de l'import
//
$origin_line_format = '<tr class="CLASS"> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td></tr>' ;
// Format complet
//
if ( ATOS_BOARD_LONG_DISPLAY )
$origin_line_format = '<tr class="CLASS"><td class="dataTableatos" nowrap>%s</td><td class="dataTableatos" nowrap>%s</td><td class="dataTableatos" nowrap>%s</td><td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td> <td class="dataTableatos" nowrap>%s</td></tr>' ;
$displayPreviousFile = file_exists ( FILENAME_ATOS_LATEST_IMPORT ) ;
if( isset($_POST['upload']) || $displayPreviousFile )
{
if ( isset($_POST['upload']) )
{
printf('<tr><td class="dataTableatos">%s</tr></td>', ATOS_IMPORT_TITLE) ;
$tmp_file = $_FILES['fichier']['tmp_name'];
}
else
//
// Affichage de la date du dernier import
//
{
printf('<tr><td class="dataTableatos">%s : <strong>%s</strong></tr></td>', ATOS_LATEST_IMPORT_TITLE, date("d F Y H:i:s", filemtime(FILENAME_ATOS_LATEST_IMPORT))) ;
$tmp_file = FILENAME_ATOS_LATEST_IMPORT ;
}
if( !is_uploaded_file($tmp_file) && isset($_POST['upload']) )
{
echo "Le fichier est introuvable" ;
exit() ;
}
$handle = fopen($tmp_file, "r"); // Fichier temporaire détruit automatique a la fin du script
$lines = fread($handle, filesize($tmp_file)) ;
preg_match_all('#TRANSACTION.*#', $lines, $result) ;
$result = array_shift($result) ;
echo $header ;
foreach($result as $line)
{
// Post-format
//
if ( $i++ % 2 ) $line_format = str_replace("CLASS", "dataTableatos", $origin_line_format) ;
else $line_format = str_replace("CLASS", "dataTableatos", $origin_line_format) ;
// Tout va bien !
//
$error_flag = false ;
$val = explode("\t", $line) ;
// On saute les entêtes ...
//
if ( $val[0] != "TRANSACTION" ) continue ;
// Valeurs du journal ATOS
//
$entete = $val[0] ;
$transaction_id = $val[1] ;
$merchant_id = $val[2] ;
$payment_means = $val[3] ;
$origin_amount = $val[4] ;
$amount = $val[5] ;
$payment_date = $val[18] ;
$payment_time = $val[8] ;
$card_validity = $val[9] ;
$card_type = $val[10] ;
$card_number = $val[11] ;
$response_code = $val[12] ;
$cvv_response_code = $val[13] ;
$complementary_code = $val[14] ;
$certificate = $val[15] ;
$authorization_id = $val[16] ;
$capture_date = $val[17] ;
$transaction_status = $val[7] ;
$return_context = $val[19] ;
$autoresponse_status = $val[20] ;
$atos_order_id = $val[21] ;
$atos_customer_id = $val[22] ;
$customer_ip_address = $val[23] ;
$account_serial = $val[24] ;
$session_id = $val[25] ;
$transaction_condition = $val[26] ;
$cavv_ucaf = $val[27] ;
$complementary_info = $val[28] ;
$bank_response_code = $val[29] ;
// Post-traitements afin d'obtenir des équivalences entre les valeurs ATOS/osC
//
$payment_date = preg_replace('/([0-9]{4})([0-9]{2})([0-9]{2})/', '\1-\2-\3', $payment_date) ;
$payment_time = preg_replace('/([0-9]{2})([0-9]{2})([0-9]{2})/', '\1:\2:\3', $payment_time) ;
$card_number = preg_replace('/([0-9]{4}).([0-9]{2})/', '\1 #### #### ##\2', $card_number) ;
$amount = (float)($amount / 100) ;
// Récupération du numéro de la commande correspondante
// cc_owner disponible (modif de checkout_process.php)
$query = 'SELECT o.`orders_id` FROM ' . TABLE_ORDERS . ' o where cc_owner = "' . $transaction_id . '" and cc_number = "' . $card_number . '" ;' ;
// Obsolète : version avec cc_owner non renseigné (permets d'affecter les anciennes transaction avant modif de checkout_process.php)
// décommenter cette ligne pour affecter les anciennes commandes. recommenter ensuite.
//$query = 'SELECT o.`orders_id`,ot.`orders_id`,o.`customers_name`,ot.`customers_name` FROM ' . TABLE_ORDERS . ' o LEFT JOIN ' . TABLE_HOLDING_ORDERS . ' ot on (o.orders_id = ot.orders_id) where o.cc_number = "' . $card_number . '" ;' ;
$order_qr = tep_db_query($query) ;
$order = tep_db_fetch_array($order_qr) ;
$orders_id = $order['orders_id'] ;
$name = $order['customers_name'] ;
$currency_code = $name;
// Montant de la commande
//
if ( $orders_id )
{
$query = 'SELECT ot.`value` FROM ' . TABLE_ORDERS_TOTAL . ' ot where class = "ot_total" and orders_id = "' . $orders_id . '"' ;
$orders_total_qr = tep_db_query($query) ;
$orders_total = tep_db_fetch_array($orders_total_qr) ;
$orders_total_value = sprintf("%.04f", $orders_total['value']) ;
// Montant de la commande différent de celui de la transaction
//
if ( $amount != $orders_total_value ) $error_flag = true ;
}
else
{
$orders_total_value = 0 ;
}
/////////////////////////////////////order check//////////////////////////////////////////////////////////
// Récupération du numéro de la commande correspondante
// cc_owner disponible (modif de checkout_process.php)
//
$query1 = 'SELECT oc.`orders_id`,`customers_name` FROM ' . TABLE_HOLDING_ORDERS . ' oc where customers_id = "' . $atos_customer_id . '" ;' ;
$order_qr1 = tep_db_query($query1) ;
$order1 = tep_db_fetch_array($order_qr1) ;
$orders_id1 = $order1['orders_id'] ;
$name = $order1['customers_name'] ;
$currency_code = $name;
if ( $orders_id1 )
{
$query_check1 = 'SELECT ot.`value` FROM ' . TABLE_HOLDING_ORDERS_TOTAL . ' ot where class = "ot_total" and orders_id = "' . $orders_id1 . '"' ;
$orders_total_qr1 = tep_db_query($query_check1) ;
$orders_total1 = tep_db_fetch_array($orders_total_qr1) ;
$orders_total_value1 = sprintf("%.04f", $orders_total1['value']) ;
// Montant de la commande différent de celui de la transaction
//
if ( $amount != $orders_total_value1 ) $error_flag = true ;
}
else
{
$orders_total_value1 = 0 ;
}
/////////////////////////////////////order check//////////////////////////////////////////////////////////
// Valeur atos > 0 : Commande invalide
//
if ( $response_code > 0 ) $error_flag = 1 ;
// Si le numéro de commande est vide, commande perdue ???
//add ordercheck
if ( ! strlen(($orders_id) || ($orders_id1)) )
//end ordercheck
{
$status = "<STRONG>" . ATOS_BOARD_UNKNOWN . "</STRONG>" ;
$export = 0 ; // Commande pas trouvée on exporte pas
}
else
{
$status = ATOS_BOARD_CREATED ;
$export = 1 ;
}
// Vérification de l'unicité de l'import
//
if ( $export )
{
$atos_query = tep_db_query('SELECT a.`orders_id` FROM '. TABLE_ATOS_BOARD . ' a where orders_id = "' . $orders_id . '" ;') ;
$atos_qr = tep_db_fetch_array($atos_query) ;
if ( strlen($atos_qr['orders_id']) )
{
$status = ATOS_BOARD_EXISTS ;
$export = 0 ;
}
//add ordercheck
if ( strlen($atos_qr['orders_id1']) )
{
$status = ATOS_BOARD_EXISTS ;
$export = 0 ;
//end ordercheck
}
}
// Lien hypertexte vers la commande
// Add order check/////
if ( $orders_id )
$order_link = '<a href="' . tep_href_link(FILENAME_ORDERS, 'oID=' . $orders_id . '&action=edit') . '" >' . $orders_id . '</a>' ;
else
// Commande non répertoriée
$order_link = '<a href="' . tep_href_link(FILENAME_ORDERS_CHECK, 'ocID=' . $orders_id1 . '&action=edit') . '" >' . $orders_id1 . '</a>' ;
// End order check/////
// Status pour les commandes déjà importées
//
if ( ! isset($_POST['upload']) && $displayPreviousFile )
$status = '<span style="color:navy;">' . ATOS_BOARD_ARCHIVE . '</span>' ;
// Bouton vert ou rouge !
//
$image_status = $error_flag ? tep_image(DIR_WS_IMAGES . 'icon_status_red.gif') : tep_image(DIR_WS_IMAGES . 'icon_status_green.gif') ;
// Affichage du résultat de l'importation
//
if ( ATOS_BOARD_LONG_DISPLAY )
printf($line_format, $order_link, $status, $entete, $transaction_id, $merchant_id, $payment_means, $origin_amount, $amount, $currency_code, $payment_date, $payment_time, $card_validity, $card_type, $card_number, $response_code, $cvv_response_code, $complementary_code, $certificate, $authorization_id, $capture_date, $transaction_status, $return_context, $autoresponse_status, $atos_order_id, $customer_id, $customer_ip_address, $account_serial, $session_id, $transaction_condition, $cavv_ucaf, $complementary_info, $bank_response_code) ;
else
printf($line_format, $image_status, $order_link, $status, $transaction_id, $amount, $currency_code, $payment_date, $payment_time, $card_validity, $card_type, $card_number, $response_code, $certificate, $authorization_id, $capture_date, $transaction_status, $autoresponse_status, $customer_ip_address, $transaction_condition, $bank_response_code) ;
// Insertion dans la table ATOS_BOARD
//
if ( $export && isset($_POST['upload']) )
{
$query = 'INSERT into ' . TABLE_ATOS_BOARD . ' (orders_id, entete, transaction_id, merchant_id, payment_means, origin_amount, amount, currency_code, payment_date, payment_time, card_validity, card_type, card_number, response_code, cvv_response_code, complementary_code, certificate, authorization_id, capture_date, transaction_status, return_context, autoresponse_status, atos_order_id, atos_customer_id, customer_ip_address, account_serial, session_id, transaction_condition, cavv_ucaf, complementary_info, bank_response_code) values ( "' . $orders_id . '","' . $entete . '","' . $transaction_id . '","' . $merchant_id . '","' . $payment_means . '","' . $origin_amount . '","' . $amount . '","' . $currency_code . '","' . $payment_date . '","' . $payment_time . '","' . $card_validity . '","' . $card_type . '","' . $card_number . '","' . $response_code . '","' . $cvv_response_code . '","' . $complementary_code . '","' . $certificate . '","' . $authorization_id . '","' . $capture_date . '","' . $transaction_status . '","' . $return_context . '","' . $autoresponse_status . '","' . $atos_order_id . '","' . $customer_id . '","' . $customer_ip_address . '","' . $account_serial . '","' . $session_id . '","' . $transaction_condition . '","' . $cavv_ucaf . '","' . $complementary_info . '","' . $bank_response_code . '");' ;
tep_db_query($query) ;
// Générer un fichier backup pour la session en cours
//
$creating_image_file = 1 ;
}
}
//
// Backup du fichier de cette session
//
if ( isset($_POST['upload']) && $creating_image_file )
file_put_contents(FILENAME_ATOS_LATEST_IMPORT, $lines) ;
fclose($handle) ;
echo "</table>" ; // Fin table header+lines
}
?>
<!-- Atos Feed End //-->
</table>
<!-- body_text_eof //-->
</tr>
</table>
<style type="text/css" media="print">
.menu{
display:none;
}
.print{
display:none;
}
<!--@page{size:landscape}-->
</style>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> |
Partager