/** * CallBack * This function is called by the bank server in order to confirm the transaction previously executed * @param $response from the Gateway Server * @return boolean */ public function CallBack($response) { $bank = self::getModule(); $url = $bank['test_mode'] ? $bank['url_test'] : $bank['url_official']; // Resend all the variables to paypal to confirm the receipt message $result = self::processIPN($response); if (!empty($response['custom'])) { // Get the orderid back from the bank post variables $orderid = trim($response['custom']); if (!empty($orderid) && is_numeric($orderid)) { //check the ipn result received back from paypal if ($result) { Orders::Complete($orderid, true); // Complete the order information and it executes all the tasks to do Payments::confirm($orderid, true); // Set the payment confirm } else { Payments::confirm($orderid, false); } } } die; }
/** * CallBack * This function is called by the bank server in order to confirm the transaction previously executed * @param $response from the Gateway Server * @return boolean */ public function CallBack($response) { Shineisp_Commons_Utilities::logs("Start callback", "iwbank.log"); // Get the orderid back from the bank post variables $orderid = trim($response['custom']); $ret = ""; $payer_id = $response["payer_id"]; $thx_id = $response["thx_id"]; $verify_sign = $response["verify_sign"]; $amount = $response["amount"]; $code = '2E121E96A508BDBA39782E43D2ACC12274A991A7EDE25502F42D99542D26CF3D'; //Inserire il merchant_key indicato all'interno del sito IWSMILE su POS VIRTUALE/Configurazione/Notifica Pagamento. $str = "thx_id=" . $thx_id . "&amount=" . $amount . "&verify_sign=" . $verify_sign; $str .= "&payer_id=" . $payer_id; $str .= "&merchant_key=" . $code; Shineisp_Commons_Utilities::logs("Callback parameters: {$str}", "iwbank.log"); $url = "https://checkout.iwsmile.it/Pagamenti/trx.check"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, $str); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_POST, TRUE); $content = curl_exec($ch); $c_error = "NONE"; $ret = 'NON DISPONIBILE'; if (curl_errno($ch) != 0) { $c_error = curl_error($ch); } else { if (strstr($content, "OK")) { $ret = "VERIFICATO"; Shineisp_Commons_Utilities::logs("Order Completed: {$orderid}", "iwbank.log"); // Complete the order Orders::Complete($orderid, true); // Complete the order information and it executes all the tasks to do Shineisp_Commons_Utilities::logs("Confirm the payment for the order: {$orderid}", "iwbank.log"); Payments::confirm($orderid); // Set the payment confirm } elseif (strstr($content, "KO")) { // Order not verified $ret = 'NON VERIFICATO'; } elseif (strstr($content, "IR")) { // Request is not valid $ret = 'RICHIESTA NON VALIDA'; } elseif (strstr($content, "EX")) { // Request expired $ret = 'RICHIESTA SCADUTA'; } } curl_close($ch); Shineisp_Commons_Utilities::logs("Callback Payment Result: {$ret}", "iwbank.log"); Shineisp_Commons_Utilities::logs("End callback", "iwbank.log"); return true; }