Procedura->logga(array( // 'identificativo_ordine' => $this->identificativo, // 'ultimo_stato' => 'Fine procedura di conferma' // )); $this->indiLingua(); if($this->demo){ $this->configurationPackage = 'eyJzaWQiOiIwMDAwMDAwMDAwMDAwMTAiLCJjbiI6IjYxOTM4MTY2NjEwIiwicGsiOiItLS0tLUJFR0lOIFJTQSBQUklWQVRFIEtFWS0tLS0tXHJcbk1JSUNYQUlCQUFLQmdRQ2YwVGRjVHVwaGI3WCtad2VrdDFYS0VXWkRjelNHZWNmbzZ2UWZxdnJhZjVWUHpjbkpcclxuMk1jNUo3MkhCbTB1OThFSkhhbitubGUyV09aTVZHSXRUYVwvMmsxRlJXd2J0N2lRNWR6RGg1UEVlWkFTZzJVV2VcclxuaG9SOEw4TXBOQnFINmg3WklUd1ZUZlJTNExzQnZsRWZUN1B6aG01WUpLZk0rQ2R6RE0rTDlXVkVHd0lEQVFBQlxyXG5Bb0dBWWZLeHdVdEVicTh1bFZyRDNubldoRitoazFrNktlamRVcTBkTFlOMjl3OFdqYkNNS2I5SWFva21xV2lRXHJcbjVpWkdFcll4aDdHNEJEUDhBV1wvK005SFhNNG9xbTVTRWtheGhiVGxna3MrRTFzOWRUcGRGUXZMNzZUdm9kcVN5XHJcbmwyRTJCZ2hWZ0xMZ2tkaFJuOWJ1YUZ6WXRhOTVKS2ZneUtHb25OeHNRQTM5UHdFQ1FRREtiRzBLcDZLRWtOZ0Jcclxuc3JDcTNDeDJvZDVPZmlQREc4ZzNSWVpLeFwvTzlkTXk1Q00xNjBEd3VzVkpwdXl3YnBSaGNXcjNna3owUWdSTWRcclxuSVJWd3l4TmJBa0VBeWgzc2lwbWNnTjdTRDh4QkdcL010QllQcVdQMXZ4aFNWWVBmSnp1UFUzZ1M1TVJKelFIQnpcclxuc1ZDTGhUQlk3aEhTb3FpcWxxV1lhc2k4MUp6QkV3RXVRUUpCQUt3OXFHY1pqeU1IOEpVNVREU0dsbHIzanlieFxyXG5GRk1QajhUZ0pzMzQ2QUI4b3pxT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RzJkQkdPbWdcL1dLZ29EMVBMV0QyYkVmR2dKeFlCSWc5cjF3TFlwREMxdHhoeFYrMk9CUVM4NktVTGgwXHJcbk5FY3IwcUVZMDVtSTRGbEUrRFwvQnBUXC8rV0Z5S2tadWc5MnJLMEZsejcxWHlcLzltQlhiUWZtK1lLNmw5cm9SWWRcclxuSjRzSGVRYz1cclxuLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLSIsImlkeCI6MX0='; } require_once($GLOBALS['DATI']['libPath'].'/mypos/Loader.php'); $this->importo = number_format(str_replace(",", ".", $this->importo), 2, ".", ""); $cnf = new \Mypos\IPC\Config(); $cnf->setIpcURL($this->demo ? 'https://mypos.com/vmp/checkout-test/' : 'https://www.mypos.com/vmp/checkout'); $cnf->setLang($this->lingua); $cnf->setVersion('1.4'); $cnf->loadConfigurationPackage($this->configurationPackage); if($_SERVER['HTTPS'] != 'on'){ $err = 'Le chiamate notify di questo metodo richiedono SSL attiva'; trigger_error($err); $this->Procedura->errore($err); return; } switch($_GET[$this->step_var]){ default: $this->Procedura->iniziato($this->nome_metodo); $cart = new \Mypos\IPC\Cart; $cart->add($this->descrizione, 1, $this->importo); //name, quantity, price $customer = new \Mypos\IPC\Customer(); if($this->cliente_nome){ $n = explode(" ", $this->cliente_nome); $customer->setFirstName(array_shift($n)); $customer->setLastName(implode(" ", $n)); } if($this->cliente_email) $customer->setEmail($this->cliente_email); if($this->cliente_indirizzo) $customer->setAddress($this->cliente_indirizzo); if($this->cliente_citta) $customer->setCity($this->cliente_citta); if($this->cliente_cap) $customer->setZip($this->cliente_cap); if($this->cliente_nazione) $customer->setCountry($this->cliente_nazione); if($this->cliente_telefono) $customer->setPhone($this->cliente_telefono); $purchase = new \Mypos\IPC\Purchase($cnf); $purchase->setUrlCancel($this->Procedura->genera_link_agg(array($this->step_var=>"cancel"))); //User comes here after purchase cancelation - ANCHE IN CASO DI ERRORE $purchase->setUrlOk($this->Procedura->genera_link_agg(array($this->step_var=>"return_ok"))); //User comes here after purchase success $purchase->setUrlNotify($this->Procedura->genera_link_agg(array($this->step_var=>"s2s"))); //IPC sends POST reuquest to this address with purchase status - The URL_Notify should be SSL-enabled address only, i.e. it must start with "https://". Unsecure URLs will be treated as wrong and the transaction will be reversed by the system. $purchase->setOrderID($this->uniqueID(50)); //Some unique ID $purchase->setCurrency($this->currency); // $purchase->setNote('Some note'); //Not required $purchase->setCustomer($customer); $purchase->setCart($cart); $purchase->setCardTokenRequest(\Mypos\IPC\Purchase::CARD_TOKEN_REQUEST_PAY_AND_STORE); $purchase->setPaymentParametersRequired(\Mypos\IPC\Purchase::PURCHASE_TYPE_SIMPLIFIED_PAYMENT_PAGE); try{ $this->pulisciOutput(); echo $this->Procedura->loadingImg; $purchase->process(); die; } catch(\Mypos\IPC\IPC_Exception $ex){ $this->Procedura->errore($ex->getMessage()); } break; case 'return_ok': return $this->Procedura->concluso(); // case 'return_ko': case 'cancel': $this->Procedura->logga(array( 'identificativo_ordine' => $this->identificativo, 'ultimo_stato' => 'L\'utente ha annullato il pagamento' )); return $this->Procedura->errore();//per far riprovare l'utente // case 'error': // return $this->Procedura->errore("descrizione"); case 's2s': $ok = false; try{ $responce = \Mypos\IPC\Response::getInstance($cnf, $_POST, \Mypos\IPC\Defines::COMMUNICATION_FORMAT_POST); $res = $responce->getData(); // mail("c@localhost", "Debug ".microtime(true), __FILE__.":".__LINE__."\n".print_r(array($res, $info, $_REQUEST, $_SERVER), true)); /* Merchant site must have the following logic: 1. Search in DB for order with this OrderID 2. Verify that Amount and Currency match to amount from the original transaction 3. Change order status to "Paid" 4. Echo "OK" $res is one-dimensional array containing elements with keys: IPCmethod, SID, Amount, Currency, OrderID, IPC_Trnref, RequestSTAN, RequestDateTime. */ $info = ''; foreach($res as $k=>$v) $info .= "\t$k:\t$v\n"; $this->Procedura->comunicazione_s2s($this->identificativo, $info); if($this->importo == $res['Amount'] && $this->currency == $res['Currency']){ $ok = true; $identificativo = $this->identificativo;//getInstance() will validate the income data and the request signature $this->Procedura->confermato($identificativo); } else{ $err = 'Importo non corrispondente'; trigger_error($err); $this->Procedura->errore($err); } } catch(\Mypos\IPC\IPC_Exception $ex){ $this->Procedura->errore($ex->getMessage()); } $this->pulisciOutput(); echo $ok ? "OK" : "KO"; die; //Upon HTTP request, the Merchant should respond with header HTTP 200 OK with the following body content: “OK”. Every other response will be treated as communication error, call error, server error or system malfunctions. break; } } function indiLingua(){ //ISO 639-1 switch($GLOBALS['DATI']["lang"]) { case "ita": $this->lingua = "it"; break; case "fra": $this->lingua = "fr"; break; case "ger": $this->lingua = "de"; break; case "nld": $this->lingua = "nl"; break; case "spa": $this->lingua = "es"; break; default: $this->lingua = 'en'; break; } } } ?>