A jednocześnie przy błędzie nie ma tego znaku zapytania... dla ststusu OK
NOT OK RESPONSE
ERROR: WRONG POS ID
Ktoś ma jakies pojęcie co w tym kodzie może generować ten znak zapyatnia?? pytajnik generuje sie przy tym ostatnim OK do tego doszedłem...
<?php
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/platnoscipl.php');
$errors = '';
$platnoscipl = new Platnoscipl();
$server = 'www.platnosci.pl';
$gateway = '/paygw/UTF/Payment/get/txt';
if(!isset($_POST['pos_id']) || !isset($_POST['session_id']) || !isset($_POST['ts']) || !isset($_POST['sig'])) {
die('ERROR: EMPTY PARAMETERS'); //-- brak wszystkich parametrow
}
if ($_POST['pos_id'] != Configuration::get('PLATNOSCI_POS_ID')){
die('ERROR: WRONG POS ID'); //--- bledny numer POS
}
$sig = md5( $_POST['pos_id'] . $_POST['session_id'] . $_POST['ts'] . Configuration::get('PLATNOSCI_AUTH_KEY_2'));
if ($_POST['sig'] != $sig){
die('ERROR: WRONG SIGNATURE'); //--- bledny podpis
}
$ts = time();
$sig = md5( Configuration::get('PLATNOSCI_POS_ID') . $_POST['session_id'] . $ts . Configuration::get('PLATNOSCI_AUTH_KEY_1'));
$params = "pos_id=" . Configuration::get('PLATNOSCI_POS_ID') . "&session_id=" . $_POST['session_id'] . "&ts=" . $ts . "&sig=" . $sig;
$header = 'POST '.$gateway.' HTTP/1.0'."\r\n" .
'Host: '.$server."\r\n".
'Content-Type: application/x-www-form-urlencoded'."\r\n".
'Content-Length: '.strlen($params)."\r\n".
'Connection: close'."\r\n\r\n";
if ($fd = @fsockopen('ssl://' . $server, 443, $errno, $errstr, 30))
{
fputs($fd, $header.$params);
$verified = false;
$read = '';
while (!feof($fd))
{ $line = fgets($fd, 1024);
if (substr($line,0,6)=="trans_"){
$pair = explode(":",$line);
$response[$pair[0]] = trim($pair[1]);
}
$read .= $line;
}
fclose ($fd);
$result = $platnoscipl->get_status($response);
if ($result['code']&&(intval($result['code'])!=0)){
switch (intval($result['code'])) {
case 1: // Nowa
$trans_state = Configuration::get('PAYMENT_NEW_STATE');
break;
case 2: // Anulowana
$trans_state = _PS_OS_CANCELED_;
break;
case 3: // Odrzucona
$trans_state = _PS_OS_ERROR_;
break;
case 5: // Oczekuje na odbiĂłr
$trans_state = Configuration::get('PAYMENT_AWAITING_RECEIPT_STATE');
break;
case 7: // Odrzucona
$trans_state = _PS_OS_ERROR_;
break;
case 99: // Odebrana, zakonczona
$trans_state = _PS_OS_PAYMENT_;
break;
case 888: // Błędny status
$trans_state = _PS_OS_ERROR_;
break;
default:
die('OK');
}
if (!isset($response['trans_amount'])||empty($response['trans_amount']))
$errors .= $platnoscipl->l('Brak trans_amount, brak info o kwocie.').'<br />';
if (!isset($response['trans_order_id'])||empty($response['trans_order_id']))
$errors .= $platnoscipl->l('Brak trans_order_id, brak odniesienia do koszyka.').'<br />';
if (!isset($response['trans_id'])||empty($response['trans_id']))
$errors .= $platnoscipl->l('Brak trans_id, nieznany nr transakcji.').'<br />';
if (empty($errors))
{
$cart = new Cart(intval($response['trans_order_id']));
if (!$cart->id){
$errors = $platnoscipl->l('Nie znaleziono koszyka').'<br />';
}
elseif (!Order::getOrderByCartId($response['trans_order_id'])){
$cart = new Cart($response['trans_order_id']);
define('_USER_ID_LANG_', intval($cart->id_lang));
$cart = null;
$platnoscipl->validateOrder($response['trans_order_id'], $trans_state, intval($response['trans_amount'])/100, $platnoscipl->displayName, 'platnosci.pl ID transkacji: '.$response['trans_id']);
}else{
$order_id = Order::getOrderByCartId($response['trans_order_id']);
$history = new OrderHistory();
$history->id_order = intval($order_id);
$history->changeIdOrderState($trans_state, intval($order_id));
$history->addWithemail(true);
}
}
}
echo 'OK';
if (!empty($errors))
die('ERROR: PROBLEMS WITH PROCESSING PAYMENT: '.$errors);
}else
die('ERROR: COULD NOT GET PAYMENT STATUS'); //--- nie udalo sie polaczenie z platnosci.pl
?>