trigger_error("2024: da aggiornare"); // $this->Metodi['ideal']->mid = ''; // $this->Metodi['ideal']->sha_in_key = ''; // $this->Metodi['ideal']->sha_out_key = ''; /* https://internetkassa.abnamro.nl/ncol/test/backoffice/container/index?branding=ABN tnxpoggibonsi osmmc317! CONFIGURAZIONE SUL PANNELLO DEL GESTORE: Post-payment URLs and parameters To automate your back-office tasks, you can define the URLs of two executable pages on your site in the "Transaction feedback" tab, "Direct HTTP server-to-server request" section (URL fields) of the Technical Information page. http://demo.tnx.it/vesuvio_tours/Payments/tipo:ideal/step:s2s/ ATTENZIONE AI PARAMETRI AGGIUNTIVI NELL’URL, VANNO TOLTI PRIMA DI FARE IL CALCOLO SHA Timing of the feedback request Online but switch to a deferred request in intervals when the online requests fail: SHA-1-IN Signature field in the "Data and origin verification" tab, “Checks for e-Commerce” SHA-1-OUT The passphrase is defined in the Merchant’s Technical information, in the “Transaction Feedback” tab, in the “All transaction Submission modes” section Informazioni tecniche > Info di test simulazione in base alla carta */ require_once("MedodoDiPagamento.php"); class iDealAbnAbro extends MedodoDiPagamento{ var $nome_metodo = "iDeal"; var $step_var = "id_step"; //configurazione merchant var $mid = ""; var $sha_in_key = ""; var $sha_out_key = ""; var $descrizione = ''; var $identificativo = ''; //en_US, nl_NL, fr_FR, … var $lingua = "en_US"; //ISO alpha order currency code, for example: EUR, USD, GBP, CHF, … var $divisa = "EUR"; var $restart_params = array( 'orderID' => '', 'currency' => '', 'amount' => '', 'STATUS' => '', 'CN' => '', 'TRXDATE' => '', 'PAYID' => '', 'COMPLUS' => '', 'IP' => '', 'SHASIGN' => '', ); var $response_codes = array( '1' => 'PAGAMENTO ANNULLATO',//aggiunto io non c'è in documentazione '5' => 'Authorised', '9' => 'Payment requested', '0' => 'Invalid or incomplete', '2' => 'Authorization refused', '51' => 'Authorisation waiting', '91' => 'Payment processing', '52' => 'Authorisation not known', '92' => 'Payment uncertain', '93' => 'Payment refused', ); function demoInfo(){ return "Per il pagamento usare numero carta 5399999999999999 (oppure 4111113333333333 per generare un rifiuto, oppure 4111116666666666 per un risultato incerto), un cvv2 di 3 cifre casuali e una scadenza valida. Con importo 9999 la transazione viene negata, con qualsiasi altro importo la transazione viene autorizzata."; } function sha($params_in, $in_out='in'){ $params = array(); foreach($params_in as $k=>$v){ if(!$v && $v!=='0') unset($v);//Parameters that do not have a value should NOT be included in the string to hash else $params[strtoupper($k)] = $v;//al } ksort($params);//All parameters need to be arranged alphabetically. $stringa_sha = ''; // $stringa_sha_a = array(); foreach($params as $k=>$v){ $stringa_sha .= "$k=$v".$this->{"sha_".$in_out."_key"}; // $stringa_sha_a[] = "$k=$v"; } // return sha1(implode($this->{"sha_".$in_out."_key"}, $stringa_sha_a));//test return strtoupper(sha1($stringa_sha)); } function createForm(){ $iAmount = round(floatval(str_replace(",", ".", $this->importo)) * 100); //All parameters that you send (and that appear in the list in Appendix: List of Parameters to be included in SHA IN Calculation), will be included in the string to be hashed. $params = array(//All parameter names should be in UPPERCASE (to avoid any case confusion). // "HTTP_REFERER" => strtolower(substr($_SERVER['SERVER_PROTOCOL'], 0, strpos($_SERVER['SERVER_PROTOCOL'], '/'))) . '://' . $_SERVER['HTTP_HOST'] . '/',//non serve se si usa sha! anzi fa casino...non combacia il calcolo! "PSPID" => $this->mid, "ORDERID" => $this->uniqueID(),//Your unique order number (merchant reference). The system checks that a payment has not been requested twice for the same order. The orderID has to be assigned dynamically. "AMOUNT" => $iAmount, "CURRENCY" => $this->divisa, "LANGUAGE" => $this->lingua, "COM" => $this->descrizione, "CN" => $this->cliente_nome,// Customer Name, optional "EMAIL" => $this->cliente_email,// Customer Email, optional "OWNERADDRESS" => $this->cliente_indirizzo,// Customer Address, optional "OWNERTOWN" => $this->cliente_citta,// Customer City, optional "OWNERZIP" => $this->cliente_cap,// Customer Postalcode, optional "OWNERCTY" => $this->cliente_nazione,// Customer’s country, optional "OWNERTELNO" => $this->cliente_telefono,// Customer’s telephone number, optional // "PM" => $this->sPaymentType, // "CATALOGURL" => $this->exit_url,//(Absolute) URL of your catalogue. When the transaction has been processed, your customer is requested to return to this URL via a button. "HOMEURL" => $this->Procedura->genera_link_agg(array($this->step_var=>"return_ko")),//(Absolute) URL of your home page. When the transaction has been processed, your customer is requested to return to this URL via a button. When you send the value “NONE”, the button leading back to the merchant’s site will be hidden., "ACCEPTURL" => $this->Procedura->genera_link_agg(array($this->step_var=>"return_ok")),//URL of the web page to display to the customer when the payment has been authorised (status 5), stored (status 4), accepted (status 9) or is waiting to be accepted (pending, status 41, 51 or 91)., "DECLINEURL" => $this->Procedura->genera_link_agg(array($this->step_var=>"error")),//URL of the web page to show the customer when the acquirer declines the authorisation (status 2 or 93) more than the maximum permissible number of times. "EXCEPTIONURL" => $this->Procedura->genera_link_agg(array($this->step_var=>"uncertain")),//URL of the web page to display to the customer when the payment result is uncertain (status 52 or 92). If this field is empty, the customer will see the accepturl instead. "CANCELURL" => $this->Procedura->genera_link_agg(array($this->step_var=>"return_ko")),//URL of the web page to display to the customer when he cancels the payment (status 1). If this field is empty, the customer will see the declineurl instead "COMPLUS" => $this->identificativo, //Field for submitting a value you would like to be returned in the feedback request. // "PARAMPLUS" => $this->escapeHtml($this->lingua), . //Field for submitting some parameters and their values you would like to be returned in the feedback request. // "" => , ); $url = "https://internetkassa.abnamro.nl/ncol/".($this->demo?"test":"prod")."/orderstandard.asp"; if($this->sha_in_key) $params['SHASIGN'] = $this->sha($params, 'in'); $html = '
'; if(true) $html .= $this->autoSubmitForm('form_pagamento_tnx'); else $html = nl2br($this->Procedura->htmlentities($html)).$html; return $html; } function s2s_print_reply(){ $this->pulisciOutput(); die; // If your post-payment page replies with: an HTML page (containing an tag) or A redirection // (HTTP 302 Object Moved) // our system will send this HTML page “as is” to the client browser or perform the redirection, rather // than redirecting your customer at the end of your post-payment feedback process to one of the 4 // URLs you may have sent in the hidden fields (accepturl, exceptionurl, cancelurl and declineurl as // described here: Redirection depending on the payment result). } function auto(){ $this->indiLingua(); if($this->demo){ $this->mid = 'tnxpoggibonsi'; $this->sha_in_key = 'UY}J4uwbi/Ez1l/wPr6'; $this->sha_out_key = 'kEM!Hz.(9b8J3ouMrvT'; // $this->mid = '003071607'; // $this->sha_in_key = 'UY-JasdwrgaetyhhsdarwwPr6'; // $this->sha_out_key = '24f4wrywfgbarg-rwyhqr-4wtga'; } $this->importo = number_format(str_replace(",", ".", $this->importo), 2, ",", ""); $spazio = strpos($this->cliente_cap, " "); if($spazio !== false) $this->cliente_cap = substr($this->cliente_cap, 0, $spazio);//Il problema era lo ZIP dell'utente in cui era è inserita anche la città (1098JC Amsterdam), la banca blocca il pagamento in questo caso. switch($_GET[$this->step_var]){ default: $this->Procedura->iniziato($this->nome_metodo); return $this->createForm(); break; break; case 'return_ok': return $this->Procedura->concluso(); break; case 's2s': /* $body .= "\nhttp://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI] " . date ("d-M-Y H:i:s", mktime()) . " " . __FILE__ . " " . __LINE__; $body .= "\n\n" . print_r(array('$_GET'=>$_GET, '$_POST'=>$_POST, '$_SERVER'=>$_SERVER, '$_SESSION'=>$_SESSION), TRUE); mail("carlo@tnx.it", "iDeal S2s", $body); */ // | indi_rew1: Pagamento/k:d740d1/r:2090/tipo:ideal/step:s2s/ // | orderID: 2090_50_1378224833 // | currency: EUR // | amount: 50 // | PM: CreditCard // | ACCEPTANCE: test123 // | STATUS: 9 // | CARDNO: XXXXXXXXXXXX0904 // | ED: 0218 // | CN: ada cognome // | TRXDATE: 09/03/13 // | PAYID: 23528987 // | NCERROR: 0 // | BRAND: MasterCard // | COMPLUS: 2090_50 // | IP: 213.243.232.46 // | SHASIGN: 375E6383888233A0B020AB7BA10752C724D0CD05 // | l: eng // | p: pagamento // | 1: k:d740d1 // | k: d740d1 // | 2: r:2090 // | r: 2090 // | 3: tipo:ideal // | tipo: ideal // | 4: step:s2s // | step: s2s $params = $_GET; /* tolgo roba che non è della banca (andrebbe messo in una variabile) */ unset($params['SHASIGN']); unset($params['indi_rew1']); unset($params['l']); unset($params['p']); unset($params[$this->step_var]); unset($params[$this->Procedura->metodo_var]); foreach($params as $k=>$v){ if(is_numeric($k)) unset($params[$k]); else $params[$k] = stripslashes($v); } /* tolgo roba che non è della banca */ $SHASIGN = $this->sha($params, 'out'); if($SHASIGN == $_GET["SHASIGN"]){ // mail("c@localhost", "iDEAL OK OK OK OK OK OK", $body); $this->Procedura->comunicazione_s2s($params['COMPLUS'], ($this->response_codes[$_GET["STATUS"]]?$this->response_codes[$_GET["STATUS"]]:$_GET["STATUS"])." (PAYID: ".$params['PAYID'].", ACCEPTANCE: ".$params['ACCEPTANCE'].")"); if(in_array($_GET["STATUS"], array(5, 9))){ if($this->Procedura->isConfermato()){ trigger_error("non dovrebbe servire più c'è un controllo isConfermato su tutte le s2s delle procedure di pagamento"); //a volte la conferma arriva due volte, questa la dichiarazione di iDeal: //For this transaction the paying customer has called for the confirmationpage twice. This resulted in a double feedback request. This is the result of consumer's behaviour after the payment. $this->Procedura->comunicazione_s2s($params['COMPLUS'], "TNX: rilevata una doppia conferma del pagamento, le azioni di conferma vengono ignorate"); $body .= "\nhttp://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI] " . date ("d-M-Y H:i:s", mktime()) . " " . __FILE__ . " " . __LINE__; $body .= "\n\n" . print_r(array('$_GET'=>$_GET, '$_POST'=>$_POST, '$_SERVER'=>$_SERVER, '$_SESSION'=>$_SESSION), TRUE); mail("carlo@tnx.it", "iDeal: rilevata una doppia conferma del pagamento, le azioni di conferma vengono ignorate", $body); } else $this->Procedura->confermato($params['COMPLUS']); } else{ if($_GET["STATUS"] == 92) $this->Procedura->comunicazione_s2s($params['COMPLUS'], "Pagamento incerto, attendere nuova comunicazione"); $body = ''; foreach($params as $k=>$v) $body .= "\n| $k:\t$v"; $this->Procedura->comunicazione_s2s($params['COMPLUS'], $body); } } else{ $body = "ERRORE VERIFICA FIRMA DELLA COMUNICAZIONE S2S"; foreach($params as $k=>$v) $body .= "\n| $k:\t$v"; $this->Procedura->comunicazione_s2s($params['COMPLUS']?$params['COMPLUS']:$this->identificativo, $body); $body .= "\nhttp://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI] " . date ("d-M-Y H:i:s", mktime()) . " " . __FILE__ . " " . __LINE__; $body .= "\n\n" . print_r(array('$_GET'=>$_GET, '$_POST'=>$_POST, '$_SERVER'=>$_SERVER, '$_SESSION'=>$_SESSION), TRUE); mail("carlo@tnx.it", "ERRORE S2S ".$this->nome_metodo, $body); } $this->s2s_print_reply(); break; case 'return_ko': return $this->Procedura->annulla(); break; case 'error': return $this->Procedura->errore(); break; case 'uncertain': return $this->Procedura->incerto(); break; } } function indiLingua(){ switch($GLOBALS['DATI']["lang"]) { case "ita": $this->lingua = "it_IT"; break; case "fra": $this->lingua = "fr_FR"; break; case "spa": $this->lingua = "es_ES"; break; case "ger": $this->lingua = "es_ES"; break; case "nld": $this->lingua = "nl_NL"; break; default: $this->lingua = "en_US"; break; } } } ?>