/** * Response * Create the Order, Invoice and send an email to the customer * @param $response from the Gateway Server * @return order_id or false */ public function Response($response) { if (!empty($response['status']) && $response['status'] == 2) { if (!empty($response['item_number'])) { $product = array('id' => $response['item_number'], 'name' => $response['item_name']); if (!empty($response['transaction_id'])) { $orderid = trim($response['transaction_id']); // Complete the order with the payment details if (Orders::Complete($orderid)) { return $orderid; } } } } return false; }
/** * 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; }
/** * Response * Create the Order, Invoice and send an email to the customer * @param $response from the Gateway Server * @return order_id or false */ public function Response($response) { $bank = self::getModule(); if (!empty($response['payment_status']) && $response['payment_status'] == "Completed") { if (!empty($response['item_number'])) { $product = array('id' => $response['item_number'], 'name' => $response['item_name']); // Get the indexes of the order and bankid $indexes = trim($response['custom']); list($orderid, $bankid) = explode(",", $indexes); if (is_numeric($orderid) && is_numeric($bankid)) { $bank = Banks::find($bankid, null, true); // Replacing the comma with the dot in the amount value. $amount = str_replace(",", ".", $response['amount']); $GatewayResponse['id'] = $response['thx_id']; $GatewayResponse['item'] = $response['item_name']; $GatewayResponse['amount'] = $amount; $GatewayResponse['bank_id'] = $bankid; $GatewayResponse['status'] = $response['payment_status'] == "Completed" ? 1 : 0; } // Complete the order with the payment details if (Orders::Complete($orderid)) { return $orderid; } else { return false; } } } return false; }
/** * 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; }