public function actionContactUs()
 {
     $model = new ContactUsForm();
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'contactus-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     if (isset($_POST['ContactUsForm'])) {
         $model->attributes = $_POST['ContactUsForm'];
         // validate user input and redirect to the previous page if valid
         if ($model->validate()) {
             UtilityHelper::sendMail($model->email, UtilityHelper::yiiparam('salesEmail'), 'Contact Us Request - ' . $model->subject, $model->comment);
             $this->render('thankyou', array('model' => $model));
         }
     }
     // display the login form
     $this->render('contactus', array('model' => $model));
 }
 public static function callInterswitch($ref, &$json)
 {
     //$ref = $_POST['txnref'];
     $order = Order::model()->findByAttributes(array('payment_code' => $ref));
     $pay = PaymentTransaction::model()->findByAttributes(array('reference_number' => $ref));
     $url = UtilityHelper::yiiparam('interswitchGet') . '?productid=' . UtilityHelper::yiiparam('interswitchProductID') . '&transactionreference=' . $ref . '&amount=' . $order->total * 100;
     //self::sendToLog($url);
     try {
         $cURL = curl_init();
         curl_setopt($cURL, CURLOPT_URL, $url);
         curl_setopt($cURL, CURLOPT_HTTPGET, true);
         curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, 0);
         curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', 'Hash: ' . hash('sha512', UtilityHelper::yiiparam('interswitchProductID') . $ref . UtilityHelper::yiiparam('MAC_key'))));
         $result = curl_exec($cURL);
         if (FALSE === $result) {
             throw new Exception(curl_error($cURL), curl_errno($cURL));
         }
         //self::sendToLog($result,"Json things!!!");
         curl_close($cURL);
     } catch (Exception $e) {
         self::sendToLog(sprintf('Curl failed with error #%d: %s', $e->getCode(), $e->getMessage()), "CURL Interswitch Error");
         return false;
     }
     $json = json_decode($result, true);
     //$pay->transaction_date = $json['TransactionDate'];
     //$pay->reference_number = $ref;
     $pay->payment_reference = $json['PaymentReference'];
     $pay->response_description = $json['ResponseDescription'];
     $pay->response_code = $json['ResponseCode'];
     $pay->approved_amount = $json['Amount'] / 100;
     //$pay->customer_name = ;
     $pay->save();
     $json['CustomerName'] = $pay->customer_name;
     $total = UtilityHelper::formatPrice($order->total);
     $siteurl = UtilityHelper::yiiparam('siteUrl');
     if (empty($order->check)) {
         $messg = "Dear {$order->firstname} {$order->lastname},<br/><br/>You have just attempted making payment for order #{$order->id} on {$order->store_url}. Find the details below.<br/><br/>Amount: {$total}<br/><br/>Response Description: {$json['ResponseDescription']}<br/><br/>Response Code: {$json['ResponseCode']}<br/><br/>Transaction Ref No: {$ref}<br/><br/>Payment Reference: {$json['PaymentReference']}<br/><br/>Transaction Date: {$json['TransactionDate']}<br/>";
         if ($json['ResponseCode'] == '09') {
         } else {
             if ($json['ResponseCode'] == '00') {
                 UtilityHelper::sendMail(UtilityHelper::yiiparam('salesEmail'), $order->email, 'Successful Payment Notification', $messg);
                 //UtilityHelper::changeOrderStatus($order->id);
                 $order->order_status_id = 2;
                 $order->check = 1;
                 $order->save();
                 UtilityHelper::subtractOrder($order->id);
             } else {
                 UtilityHelper::sendMail(UtilityHelper::yiiparam('salesEmail'), $order->email, 'Failed Payment Notification', $messg);
                 //UtilityHelper::changeOrderStatus($order->id,10);
                 $order->order_status_id = 10;
                 $order->check = 1;
                 $order->save();
             }
         }
     }
     //return $order;
 }
 public static function callGlobalPay($txnref, &$trans)
 {
     //$txnref = $_GET["txnref"];
     $client = new SoapClient('https://www.globalpay.com.ng/globalpaywebservice/service.asmx?wsdl', array('exceptions' => 0, 'encoding' => 'UTF-8'));
     $soapaction = "https://www.eazypaynigeria.com/globalpay/getTransactions";
     $namespace = "https://www.eazypaynigeria.com/globalpay/";
     $order = Order::model()->findByAttributes(array('payment_code' => $txnref));
     $pay = PaymentTransaction::model()->findByAttributes(array('reference_number' => $txnref));
     $merch_txnref = $txnref;
     $channel = "";
     //change the merchantid to the one sent to you
     $merchantID = "174";
     $start_date = "";
     $end_date = "";
     //change the uid and pwd to the one sent to you
     $uid = "yl_ws_user";
     $pwd = "yl_ws_password";
     $payment_status = "";
     /*
     		$err = $client->getError();
     	
     		if ($err) {
     			$this->render('view2',array('response'=>$err, 'error'=>1));
     		}*/
     // Doc/lit parameters get wrapped
     $MethodToCall = "getTransactions";
     //$MethodToCall= "Checkcenter";
     $param = array('merch_txnref' => $merch_txnref, 'channel' => $channel, 'merchantID' => $merchantID, 'start_date' => $start_date, 'end_date' => $end_date, 'uid' => $uid, 'pwd' => $pwd, 'payment_status' => $payment_status);
     $result = $client->__soapCall($MethodToCall, array('parameters' => $param), array('uri' => $namespace, 'soapaction' => $soapaction));
     // Check for a fault
     if (is_soap_fault($result)) {
         //"SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})";
         return false;
     } else {
         //This gives getTransactionsResult
         $WebResult = $MethodToCall . "Result";
         // Pass the result into XML
         if (is_object($result)) {
             $xresult = $result->{$WebResult};
         } else {
             $xresult = $result[$WebResult];
         }
         $xml = simplexml_load_string($xresult);
         //self::sendToLog($xml);
         //$trans = array();
         $trans['amount'] = $xml->record->amount;
         $trans['txn_date'] = $xml->record->payment_date;
         $trans['pmt_method'] = $xml->record->channel;
         $trans['pmt_status'] = $xml->record->payment_status;
         $trans['pmt_txnref'] = $xml->record->txnref;
         $trans['currency'] = $xml->record->field_values->field_values->field[2]->currency;
         // $pnr = 'PNR';
         $trans['trans_status'] = $xml->record->payment_status_description;
         $trans['merch_name'] = $pay->customer_name;
         $trans['merch_phoneno'] = $order->telephone;
         $trans['merch_amt'] = $pay->transaction_amount;
         //$pay = new PaymentTransaction;
         $pay->transaction_date = $trans['txn_date'];
         //$pay->reference_number = ;
         $pay->payment_reference = $trans['pmt_txnref'];
         if ($trans['amount'] != $trans['merch_amt']) {
             $trans['pmt_status'] .= " ( Amount does not match and no service will be rendered)";
             $pay->response_code = $trans['pmt_status'];
         } else {
             $pay->response_code = $trans['pmt_status'];
         }
         $pay->response_description = $trans['trans_status'];
         $pay->approved_amount = $trans['amount'];
         //$pay->transaction_amount = $trans['merch_amt'];
         $pay->transaction_currency = $trans['currency'];
         //$pay->customer_name = $trans['merch_name'];
         $pay->save();
         if (empty($order->check)) {
             $message = "Dear {$order->firstname} {$order->lastname},<br/><br/>You have just attempted making payment for order #{$order->id} on {$order->store_url}. Find the details below.<br/><br/>Name : {$order->firstname} {$order->lastname} <br/><br/>Phone number : {$order->telephone} <br/><br/>Amount : " . UtilityHelper::formatPrice($trans['amount']) . " <br/><br/>Transaction Date : {$trans['txn_date']} <br/><br/>Payment Method : {$trans['pmt_method']} <br/><br/>Payment Status : {$pay->response_code} <br/><br/>Transaction Reference Number : {$trans['pmt_txnref']} <br/><br/>Currency : {$trans['currency']} <br/><br/>Transaction Status : {$trans['trans_status']} <br/><br/>";
             if ($trans['pmt_status'] == 'successful' && $trans['amount'] == $trans['merch_amt']) {
                 UtilityHelper::sendMail(UtilityHelper::yiiparam('salesEmail'), $order->email, 'Successful Payment Notification', $message);
                 //UtilityHelper::changeOrderStatus($order->id);
                 $order->order_status_id = 2;
                 $order->check = 1;
                 $order->save();
                 UtilityHelper::subtractOrder($order->id);
             } else {
                 if ($trans['pmt_status'] == 'pending') {
                 } else {
                     UtilityHelper::sendMail(UtilityHelper::yiiparam('salesEmail'), $order->email, 'Failed Payment Notification', $message);
                     //UtilityHelper::changeOrderStatus($order->id,10);
                     $order->order_status_id = 10;
                     $order->check = 1;
                     $order->save();
                 }
             }
         }
         return $order;
     }
     return false;
 }
Exemple #4
0
 protected function completePaymentTransaction($response)
 {
     $order = Order::model()->findByAttributes(array('payment_code' => $response['invoice']));
     $pay = PaymentTransaction::model()->findByAttributes(array('reference_number' => $response['invoice']));
     $pay->query_code = $response['process_code'];
     $pay->response_description = $response['message'];
     $pay->response_code = $response['status'];
     $pay->approved_amount = $response['total'];
     $pay->save();
     $total = UtilityHelper::formatPrice($order->total);
     $siteurl = UtilityHelper::yiiparam('siteUrl');
     if (empty($order->check)) {
         $messg = "Dear {$order->firstname} {$order->lastname},<br/><br/>You have just attempted making payment for order #{$order->id} on {$order->store_url}. Find the details below.<br/><br/>Amount: {$total}<br/><br/>Response Description: {$response['message']}<br/><br/>Response Code: {$response['process_code']}<br/><br/>Transaction Ref No: {$response['invoice']}<br/><br/>Payment Reference: {$response['transaction_id']}<br/><br/>Transaction Date: " . date("D/M/Y") . "<br/>";
     } else {
         if ($response['status'] == 'SUCCESS') {
             UtilityHelper::sendMail(UtilityHelper::yiiparam('salesEmail'), $order->email, 'Successful Payment Notification', $messg);
             $order->order_status_id = 2;
             $order->check = 1;
             $order->save();
             UtilityHelper::subtractOrder($order->id);
         } else {
             UtilityHelper::sendMail(UtilityHelper::yiiparam('salesEmail'), $order->email, 'Failed Payment Notification', $messg);
             $order->order_status_id = 10;
             $order->check = 1;
             $order->save();
         }
     }
     $this->logResults($response['status']);
 }