/** * Funzione per elaborare il risultato (server to server) * @return string Restituisce un codice con l'esito, può essere * "OK": esito positivo; "KO": esito negativo, problema generico; * "AB": transazione abbandonata; "NO": numero ordine non rilevato */ public function manageResultServer() { if ($this->config["BP_PROD_REQUEST"] == 'TRUE') { $chiaveMac = $this->config["BP_MAC_AVVIO_PROD"]; } else { $chiaveMac = $this->config["BP_MAC_AVVIO_TEST"]; } $esito = $this->framework->getVar('esito', ''); $mac = $this->framework->getVar('MAC'); $importo = $this->framework->getVar('IMPORTO'); $orderid = $this->framework->getVar('ORDER_ID'); $transaction = $this->framework->getVar('TRANSACTION_ID'); $merchant = $this->framework->getVar('MERCHANT_ID'); $divisa = $this->framework->getVar('DIVISA'); $cod_aut = $this->framework->getVar('COD_AUT'); $str = $transaction . $merchant . $orderid . $cod_aut . $importo . $divisa . $chiaveMac; $macc = md5($str); $maccalcolato = strtoupper($macc); $log = 'importo:' . $importo . chr(13) . chr(10); $log .= 'divisa:' . $divisa . chr(13) . chr(10); $log .= 'esito:' . $cod_aut . chr(13) . chr(10); $log .= 'ordine nymero:' . $orderid . chr(13) . chr(10); $log .= 'transazione:' . $transaction . chr(13) . chr(10); $log .= 'negoziante:' . $merchant . chr(13) . chr(10); $log .= 'mac ricevuto :' . $mac . chr(13) . chr(10); $log .= 'mac calcolato :' . $maccalcolato . chr(13) . chr(10); $log .= 'esito passato :' . $esito . chr(13) . chr(10); $this->framework->writeLog($log); $importot = $importo / 100; $importof = number_format($importot, 2, ",", "."); $order_id = $orderid; $this->order_id = $order_id; $this->codice_esito = $cod_aut; if (!isset($order_id) || empty($order_id)) { // non c'è numero ordine: elaborazione fallita return "NO"; } else { if ($mac == $maccalcolato && $esito == '1') { return "OK"; } elseif ($mac == $maccalcolato && $esito == '2') { return "KO"; } else { return "KO"; } } }
<?php define("_PROPAYMENT", 1); // carico il file principale ProPayment require_once "ProPayment.php"; // costruisco la classe ProPayment, passando il nome del modulo $propay = new ProPayment("Egipsy"); // chiamo la funzione di gestione del risultato (parametro FALSE per modalità server to server) $propay->manageResult(true);
/** * Salva la configurazione * @param string $modulename */ public function save($modulename) { require_once JPATH_ROOT . "/propayment/ProPayment.php"; $propay = new ProPayment($modulename); $propay->write_configuration(); }
<?php define("_PROPAYMENT", 1); // carico il file principale ProPayment require_once "ProPayment.php"; // costruisco la classe ProPayment, passando il nome del modulo $propay = new ProPayment("Egipsy"); // chiamo la funzione di gestione del risultato (parametro FALSE per modalità redirect) $propay->manageResult(false);