Ejemplo n.º 1
0
 function ePayOneOffPay($orderInfo, $credit_info, $params = array(), $TransactionType = 'AUTH_CAPTURE', $trialPayment = false)
 {
     ini_set('max_execution_time', '180');
     $config = oseMscConfig::getConfig('', 'obj');
     $cc_methods = explode(',', $config->cc_methods);
     if (!in_array('ePay', $cc_methods) || $config->enable_cc == false) {
         //return self::getErrorMessage('cc', '0003', null);
     }
     $pConfig = $config;
     //oseRegistry::call('msc')->getConfig('payment', 'obj');
     if (!isset($pConfig->ePay_testmode) || $pConfig->ePay_testmode == true) {
         $test_mode = true;
         $ePayCustomerID = '87654321';
         $ePayUsername = null;
     } else {
         $test_mode = false;
         $ePayCustomerID = $pConfig->ePayCustomerID;
         $ePayUsername = $pConfig->ePayUsername;
         if (empty($ePayCustomerID)) {
             return self::getErrorMessage('cc', '0001', null);
         }
     }
     if (empty($orderInfo->payment_price)) {
         return self::getErrorMessage('cc', '0002', null);
     }
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_osemsc' . DS . 'libraries' . DS . 'class.connection.php';
     $result = array();
     $db = oseDB::instance();
     $user_id = $orderInfo->user_id;
     $msc_id = $orderInfo->entry_id;
     $order_id = $orderInfo->order_id;
     $order_number = $orderInfo->order_number;
     $orderInfoParams = oseJson::decode($orderInfo->params);
     $desc = parent::generateDesc($order_id);
     $billingInfo = parent::getBillingInfo($orderInfo->user_id);
     $taxRate = isset($orderInfoParams->tax_rate) ? $orderInfoParams->tax_rate : 0;
     $currency = $orderInfo->payment_currency;
     $user =& JFactory::getUser($orderInfo->user_id);
     $app =& JFactory::getApplication();
     $currentSession = JSession::getInstance('none', array());
     $stores = $currentSession->getStores();
     $Itemid = parent::getItemid();
     $amount = $orderInfo->payment_price;
     $postVar = array();
     /* $totalAmount in cents, as required by ePay:
     		The total amount in cents for the transaction, eg $1.00 = 100
     		*/
     $postVar['ePayTotalAmount'] = intval(($taxRate / 100 * $amount + $amount) * 100);
     $postVar['ePayCustomerFirstName'] = substr($billingInfo->firstname, 0, 50);
     $postVar['ePayCustomerLastName'] = substr($billingInfo->lastname, 0, 50);
     $postVar['ePayCustomerEmail'] = $billingInfo->email;
     $postVar['ePayCustomerAddress'] = substr($billingInfo->addr1, 0, 60);
     $postVar['ePayCustomerPostcode'] = substr(str_replace(" ", "", $billingInfo->postcode), 0, 6);
     $creditCardExpiryDate = $credit_info["creditcard_expirationdate"];
     $creditCardExpiryDate = explode("-", strval($creditCardExpiryDate));
     $postVar['ePayCardHoldersName'] = $credit_info["creditcard_name"];
     $postVar['ePayCardNumber'] = $credit_info["creditcard_number"];
     $postVar['ePayCardExpiryMonth'] = $creditCardExpiryDate[1];
     $postVar['ePayCardExpiryYear'] = $creditCardExpiryDate[0];
     $postVar['ePayCVN'] = $credit_info["creditcard_cvv"];
     $postVar['ePayCustomerInvoiceDescription'] = $desc;
     $postVar['ePayCustomerInvoiceRef'] = $order_number;
     $postVar['ePayTrxnNumber'] = '';
     $postVar['ePayOption1'] = '';
     $postVar['ePayOption2'] = '';
     $postVar['ePayOption3'] = '';
     $resArray = self::ePayAPIConnect($ePayCustomerID, $ePayUsername, $test_mode, $postVar, false);
     if ($resArray['ePayTrxnStatus'] == true) {
         if ($TransactionType == 'AUTH_CAPTURE') {
             if ($trialPayment == false) {
                 $params['payment_serial_number'] = $resArray['ePayTrxnNumber'];
                 $return = parent::confirmOrder($order_id, $params, 0, $user->id, 'ePay');
             } else {
                 $return = $resArray;
             }
         } elseif ($TransactionType == 'AUTH_ONLY') {
             $return = $resArray;
         }
         return $return;
     } else {
         return self::getErrorMessage('cc', '0000', $resArray['ePayTrxnError']);
     }
 }