/*
sembra che le specifiche di questo metodo siano al 99% le stesse di monetawebsetefi (probabilmente è una versione più nuova dello stesso backend con url diversi)
*/
/*
per fare una personalizzazione grafica bisogna inviare i 3 files header/footer/style (più eventuali immagini, loghi,
banner) all’indirizzo e-mail pg-support@constriv.it, avendo cura di indicare nel
messaggio la ragione sociale e l’URL del sito web del merchant.
*/
require_once("MedodoDiPagamento.php");
class Triveneto extends MedodoDiPagamento{
var $nome_metodo = "Carta di credito";
var $step_var = "vp_step";
//configurazione merchant
var $id = "89025555";//TranPortalID --- hitsicily demo: PG312Test
var $password = "test";//hitsicily demo: Cons9135
var $action = "1";//Tipo di transazione (PaymentInit url): 1=Purchase 4=Authorization
//Operazioni contabili (Payment url): 2=Credit 3=Reversal 5=Capture 9=Void
/* vecchi
var $PaymentInitUrl = "https://www.constriv.com/cg/servlet/PaymentInitHTTPServlet";
var $PaymentUrl = "https://www.constriv.com/cg/servlet/PaymentTranHTTPServlet";//serve per inviare operazioni contabili (contambilizzazione/storno)
var $id_demo = "89025555";
var $password_demo = "test";
var $PaymentInitUrl_demo = "https://test4.constriv.com/cg301/servlet/PaymentInitHTTPServlet";
var $PaymentUrl_demo = "https://test4.constriv.com/cg301/servlet/PaymentTranHTTPServlet";
*/
var $PaymentInitUrl = "https://ipg.constriv.com/IPGWeb/servlet/PaymentInitHTTPServlet";
var $PaymentUrl = "https://ipg.constriv.com/IPGWeb/servlet/PaymentTranHTTPServlet";//serve per inviare operazioni contabili (contambilizzazione/storno) NON USATO PER ORA
var $id_demo = "89023333";//hitisicily: 89027777, labellatoscana: 89023333
var $password_demo = "test";
var $PaymentInitUrl_demo = "https://ipg-test4.constriv.com/IPGWeb/servlet/PaymentInitHTTPServlet";
var $PaymentUrl_demo = "https://ipg-test4.constriv.com/IPGWeb/servlet/PaymentTranHTTPServlet";
var $descrizione = '';
//*****************************************************************************************************************************************************//
// LA SICUREZZA DELLA CONFERMA S2S STA TUTTA NEL FATTO CHE L'UTENTE NON CONOSCE QUESTO IDENTIFICATIVO CHE MI VIENE POSTATO COME UDF2 SUL S2S !
// (il cliente non conosce ne' i contenuti udf, ne' l'indirizzo s2s perchè vengono scambiati con una chiamata curl, si potrebbe comunque migliorare inviando un hash invece dell'identificativo di conferma)
//*****************************************************************************************************************************************************//
var $identificativo = '';//fino 256 caratteri
var $lingua = "ITA";
/*
var $restart_params = array(
"TRANSACTION_ID"=>"",
"MERCHANT_ID"=>"",
"ORDER_ID"=>"",
"COD_AUT"=>"",
"IMPORTO"=>"",
"DIVISA"=>"", "MAC"=>""
);
*/
function demoInfo(){
return 'Carte ambiente demo (cvv/data qualsiasi):
4539990000000012 simula esito positivo
4539990000000020 simula esito negativo
4999000055550000 simula dati non corretti';
}
function auto(){
$this->indiLingua();
if($this->demo){
$this->PaymentInitUrl = $this->PaymentInitUrl_demo;
$this->PaymentUrl = $this->PaymentUrl_demo;
$this->id = $this->id_demo;
$this->password = $this->password_demo;
$this->action = "1";
}
$this->importo = number_format(str_replace(",", ".", $this->importo), 2, ".", "");
switch($_GET[$this->step_var]){
default:
$this->Procedura->iniziato($this->nome_metodo);
$data = array(
"trackid" => $this->identificativo,
"id" => $this->id,
"password" => $this->password,
"action" => $this->action,
"amt" => $this->importo,
"currencycode" => 978,
"langid" => $this->lingua,
"responseURL" => $this->Procedura->genera_link_agg(array($this->step_var=>"s2s")),
"errorURL" => $this->Procedura->genera_link_agg(array($this->step_var=>"error")),
"udf1" => "",//se impostato con “SHA1” permette di ricevere nel campo UDF1 del Notification Message il codice hash, calcolato con algoritmo SHA-1, della carta di credito usata dall’acquirente per il pagamento. "udf2" => "",
"udf2" => $this->identificativo,
"udf3" => "EMAILADDR:".$this->cliente_email,//se inizia con “EMAILADDR:” la parte seguente del campo viene interpretata come l’indirizzo email del Cardholder.
"udf4" => "",
"udf5" => "",//se inizia con “HPP_TIMEOUT=” imposta un timeout di minuti sulla HPP. Se il Cardholder rimane sulla pagina oltre questo periodo, il Payment Gateway non elaborerà la transazione, inviando lo specifico codice di errore CT0001.
);
$ch = curl_init($this->PaymentInitUrl);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
if(strpos($response, "!ERROR!") === 0){
trigger_error("Errore durante la generazione dell'id pagamento sul server della banca: ".$this->identificativo." ($response)", E_USER_ERROR);
return $this->Procedura->errore();
}
else{
//$response:
//4317277501633650:https://test4.constriv.com/cg301/gateway/payment/payment.jsp
$response = explode(":", $response);
$payment_id = array_shift($response);
$this->Procedura->comunicazione_s2s($this->identificativo, "Ricevuto id pagamento Triveneto: ".$payment_id);
$url = implode(":", $response)."?PaymentID=$payment_id";
}
if(false&&$this->demo){
return 'Quando online l\'utente viene automaticamente reindirizzato a '.$url.'';
}
else{
$this->Procedura->redirect($url);
return;
}
break;
case 'return_ok':
return $this->Procedura->concluso();
case 's2s':
// paymentid: 5194750121040020
// result: CAPTURED
// auth: 999999
// avr: N
// ref: 400252078443
// tranid: 8595534121040020
// postdate: 0102
// trackid: 1234
// udf1:
// udf2:
// udf3:
// udf4:
// udf5:
// responsecode: 00
// cardtype: VISA
// payinst: CC
// liability: Y
/*
$body = "";
foreach($_POST as $k=>$v) $body .= "\n\t$k:\t$v";
mail("c@localhost", $info, $body);
*/
// $info = $_POST['result']." (".$_POST['responsecode'].") ".($_POST['errorText']?("ERRORE: ".$_POST['errorText']):"");
$info = '';
foreach($_POST as $k=>$v) $info .= "\t$k:\t$v\n";
/*
if(is_local()){
$_POST['responsecode'] = '00';
$_POST['udf2'] = 'A40781';
}
*/
if($_POST['responsecode'] === '00'/* || is_local()*/){
$url = $this->Procedura->genera_link_agg(array($this->step_var=>"return_ok"));
$this->Procedura->confermato($_POST['udf2']);
}
else{
$url = $this->Procedura->genera_link_agg(array($this->step_var=>"error"));
}
$this->Procedura->comunicazione_s2s($this->identificativo, $info);
$this->pulisciOutput();
echo "REDIRECT=".$url;
die;
case 'return_ko':
return $this->Procedura->annulla();
case 'error':
return $this->Procedura->errore();
}
}
function indiLingua(){
switch($GLOBALS['DATI']["lang"]) {
case "ita":
$this->lingua = "ITA";
break;
case "fra":
$this->lingua = "FRA";
break;
case "spa":
$this->lingua = "ESP";
break;
case "ger":
$this->lingua = "DEU";
break;
case "slo":
$this->lingua = "SLO";
break;
default:
$this->lingua = "USA";
break;
}
}
}
?>