function onTP_Processpayment($data)
 {
     if (JVERSION >= '1.6.0') {
         include JPATH_SITE . '/plugins/payment/linkpoint/linkpoint/lib/lphp.php';
     } else {
         include JPATH_SITE . '/plugins/payment/linkpoint/lib/lphp.php';
     }
     if (JVERSION >= '1.6.0') {
         $pemfilepath = JPATH_SITE . '/plugins/payment/linkpoint/linkpoint/staging_cert.pem';
     } else {
         $pemfilepath = JPATH_SITE . '/plugins/payment/linkpoint/staging_cert.pem';
     }
     $plgPaymentLinkpointHelper = new plgPaymentLinkpointHelper();
     $host = $plgPaymentLinkpointHelper->buildLinkpointUrl();
     $orderid = $data['oid'];
     $mylphp = new lphp();
     $order["host"] = $host;
     $order["port"] = $this->port;
     $order["keyfile"] = $pemfilepath;
     $order["configfile"] = $this->store_id;
     $order["ordertype"] = "SALE";
     $testmode = $this->params->get('testmode', '1');
     if ($testmode == 1) {
         $order["result"] = "GOOD";
         # For test transactions, set to GOOD, DECLINE, or DUPLICATE
     } else {
         $order["result"] = "LIVE";
     }
     $order["transactionorigin"] = "ECI";
     # For credit card retail txns, set to RETAIL, for Mail order/telephone order, set to MOTO, for e-commerce, leave out or set to ECI
     $order["oid"] = $data['oid'];
     # Order ID number must be unique. If not set, gateway will assign one.
     // Transaction Details
     $order["chargetotal"] = $data['chargetotal'];
     //Card Info
     $order["cardnumber"] = $data['creditcard_number'];
     $order["cardexpmonth"] = str_pad($data['expire_month'], 2, "0", STR_PAD_LEFT);
     $order["cardexpyear"] = substr($data['expire_year'], 2);
     $order["cvmvalue"] = $data['creditcard_code'];
     $order["debug"] = "true";
     # for development only - not intended for production use
     $raw_data = $mylphp->curl_process($order);
     # use curl methods
     $status = $this->translateResponse($raw_data['r_approved']);
     //Error Handling
     $error = array();
     $error['code'] = $raw_data['r_code'];
     $error['desc'] = $raw_data['r_message '];
     $result = array('transaction_id' => md5($data['oid']), 'order_id' => $data['oid'], 'status' => $status, 'total_paid_amt' => $data["chargetotal"], 'raw_data' => $raw_data, 'error' => $error, 'return' => $data['return']);
     return $result;
 }
 function onTP_Processpayment($data, $vars = array())
 {
     $isValid = true;
     $error = array();
     $error['code'] = '';
     $error['desc'] = '';
     include dirname(__FILE__) . '/linkpoint/lib/lphp.php';
     $pemfilepath = dirname(__FILE__) . '/linkpoint/staging_cert.pem';
     $plgPaymentLinkpointHelper = new plgPaymentLinkpointHelper();
     $host = $plgPaymentLinkpointHelper->buildLinkpointUrl();
     $orderid = $data['oid'];
     $mylphp = new lphp();
     $order["host"] = $host;
     $order["port"] = $this->port;
     $order["keyfile"] = $pemfilepath;
     $order["configfile"] = $this->store_id;
     $order["ordertype"] = "SALE";
     $testmode = $this->params->get('testmode', '1');
     if ($testmode == 1) {
         $order["result"] = "GOOD";
         # For test transactions, set to GOOD, DECLINE, or DUPLICATE
     } else {
         $order["result"] = "LIVE";
     }
     $order["transactionorigin"] = "ECI";
     # For credit card retail txns, set to RETAIL, for Mail order/telephone order, set to MOTO, for e-commerce, leave out or set to ECI
     $order["oid"] = $data['oid'];
     # Order ID number must be unique. If not set, gateway will assign one.
     // Transaction Details
     $order["chargetotal"] = $data['chargetotal'];
     //Card Info
     $order["cardnumber"] = $data['creditcard_number'];
     $order["cardexpmonth"] = str_pad($data['expire_month'], 2, "0", STR_PAD_LEFT);
     $order["cardexpyear"] = substr($data['expire_year'], 2);
     $order["cvmvalue"] = $data['creditcard_code'];
     $order["debug"] = "true";
     # for development only - not intended for production use
     $raw_data = $mylphp->curl_process($order);
     # use curl methods
     //3.compare response order id and send order id in notify URL
     $res_orderid = '';
     $res_orderid = $data['oid'];
     if ($isValid) {
         if (!empty($vars) && $res_orderid != $vars->order_id) {
             $isValid = false;
             $error['desc'] = "ORDER_MISMATCH" . "Invalid ORDERID; notify order_is " . $vars->order_id . ", and response " . $res_orderid;
         }
     }
     // amount check
     if ($isValid) {
         if (!empty($vars)) {
             // Check that the amount is correct
             $order_amount = (double) $vars->amount;
             $retrunamount = (double) $data["chargetotal"];
             $epsilon = 0.01;
             if ($order_amount - $retrunamount > $epsilon) {
                 $raw_data['r_approved'] = 'ERROR';
                 // change response status to ERROR FOR AMOUNT ONLY
                 $isValid = false;
                 $error['desc'] .= "ORDER_AMOUNT_MISTMATCH - order amount= " . $order_amount . ' response order amount = ' . $retrunamount;
             }
         }
     }
     // translet response
     $status = $this->translateResponse($raw_data['r_approved']);
     //Error Handling
     $error = array();
     $error['code'] .= $raw_data['r_code'];
     $error['desc'] .= $raw_data['r_message '];
     $result = array('transaction_id' => md5($data['oid']), 'order_id' => $data['oid'], 'status' => $status, 'total_paid_amt' => $data["chargetotal"], 'raw_data' => $raw_data, 'error' => $error, 'return' => $data['return']);
     return $result;
 }