Example #1
0
 function onBeforeOrderCreate(&$order, &$do)
 {
     if (parent::onBeforeOrderCreate($order, $do) === true) {
         return true;
     }
     if (!function_exists('curl_init')) {
         $this->app->enqueueMessage('The eSelect payment plugin needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error');
         $do = false;
         return false;
     }
     $this->ccLoad();
     ob_start();
     $dbg = '';
     $amount = number_format($order->cart->full_total->prices[0]->price_value_with_tax, 2, '.', '');
     require_once dirname(__FILE__) . DS . 'eselect_lib.php';
     $txnArray = array('type' => 'purchase', 'order_id' => uniqid(), 'cust_id' => $this->user->user_id, 'amount' => $amount, 'pan' => $this->cc_number, 'expdate' => $this->cc_month . $this->cc_year, 'crypt_type' => '7', 'dynamic_descriptor' => '');
     $mpgTxn = new mpgTransaction($txnArray);
     if ($this->payment_params->ask_ccv) {
         $cvdTemplate = array('cvd_indicator' => 1, 'cvd_value' => $this->cc_CCV);
         $mpgCvdInfo = new mpgCvdInfo($cvdTemplate);
         $mpgTxn->setCvdInfo($mpgCvdInfo);
     }
     $mpgRequest = new mpgRequest($mpgTxn);
     $mpgHttpPost = new mpgHttpsPost($this->payment_params->store_id, $this->payment_params->api_token, $mpgRequest, (int) $this->payment_params->debug != 0);
     $mpgResponse = $mpgHttpPost->getMpgResponse();
     $ret = $mpgResponse->getResponseCode();
     if ($ret !== null && $ret != 'null') {
         $ret = (int) $ret;
         if ($ret < 50 && $mpgResponse->getComplete() == 'true') {
             ob_get_clean();
             ob_start();
             $this->modifyOrder($order, $this->payment_params->verified_status, true, true);
         } else {
             $responseMsg = $mpgResponse->getMessage();
             if (!empty($responseMsg)) {
                 $this->app->enqueueMessage($responseMsg);
             } else {
                 $this->app->enqueueMessage('Eselect/Moneris Response Error');
             }
             $do = false;
         }
     } else {
         if (!empty($mpgHttpPost->curl_err)) {
             $this->app->enqueueMessage($mpgHttpPost->curl_err_msg);
         } else {
             $msg = $mpgResponse->getMessage();
             if (empty($msg)) {
                 $this->app->enqueueMessage('Eselect/Moneris Generic Error');
             } else {
                 $this->app->enqueueMessage('Eselect/Moneris: ' . $msg);
             }
         }
         $do = false;
     }
     if ($do == false) {
         return true;
     }
     $this->ccClear();
     return true;
 }
 function run_transaction($txnArray, $cvdTemplate = array(), $avsTemplate = array(), $custInfo = array())
 {
     global $db, $config;
     if (is_file($config['root_dir'] . '/plugins/payment/moneris/lib/mpgclasses.php')) {
         require_once $config['root_dir'] . '/plugins/payment/moneris/lib/mpgclasses.php';
     } else {
         return;
     }
     $store_id = $this->config['store_id'];
     $api_token = $this->config['api_token'];
     $mpgTxn = new mpgTransaction($txnArray);
     if ($cvdTemplate) {
         $mpgCvdInfo = new mpgCvdInfo($cvdTemplate);
         $mpgTxn->setCvdInfo($mpgCvdInfo);
     }
     if ($avsTemplate) {
         $mpgAvsInfo = new mpgAvsInfo($avsTemplate);
         $mpgTxn->setAvsInfo($mpgAvsInfo);
     }
     if ($custInfo) {
         $mpgCustInfo = new mpgCustInfo($custInfo);
         $mpgTxn->setCustInfo($mpgCustInfo);
     }
     $mpgRequest = new mpgRequest($mpgTxn);
     $mpgHttpPost = new mpgHttpsPost($store_id, $api_token, $mpgRequest, $this->config['testing']);
     $mpgResponse = $mpgHttpPost->getMpgResponse();
     return $mpgResponse;
 }
Example #3
0
 function doDirectPayment(&$params)
 {
     //make sure i've been called correctly ...
     if (!$this->_profile) {
         return self::error('Unexpected error, missing profile');
     }
     if ($params['currencyID'] != 'CAD') {
         return self::error('Invalid currency selection, must be $CAD');
     }
     /* unused params: cvv not yet implemented, payment action ingored (should test for 'Sale' value?)
        [cvv2] => 000
        [ip_address] => 192.168.0.103
        [payment_action] => Sale
        [contact_type] => Individual
        [geo_coord_id] => 1 */
     //this code based on Moneris example code #
     //create an mpgCustInfo object
     $mpgCustInfo = new mpgCustInfo();
     //call set methods of the mpgCustinfo object
     $mpgCustInfo->setEmail($params['email']);
     //get text representations of province/country to send to moneris for billing info
     $billing = array('first_name' => $params['first_name'], 'last_name' => $params['last_name'], 'address' => $params['street_address'], 'city' => $params['city'], 'province' => $params['state_province'], 'postal_code' => $params['postal_code'], 'country' => $params['country']);
     $mpgCustInfo->setBilling($billing);
     $my_orderid = $params['invoiceID'];
     // set orderid as invoiceID to help match things up with Moneris later
     $expiry_string = sprintf('%04d%02d', $params['year'], $params['month']);
     $txnArray = array('type' => 'purchase', 'order_id' => $my_orderid, 'amount' => sprintf('%01.2f', $params['amount']), 'pan' => $params['credit_card_number'], 'expdate' => substr($expiry_string, 2, 4), 'crypt_type' => '7', 'cust_id' => $params['contact_id']);
     // Allow further manipulation of params via custom hooks
     CRM_Utils_Hook::alterPaymentProcessorParams($this, $params, $txnArray);
     //create a transaction object passing the hash created above
     $mpgTxn = new mpgTransaction($txnArray);
     //use the setCustInfo method of mpgTransaction object to
     //set the customer info (level 3 data) for this transaction
     $mpgTxn->setCustInfo($mpgCustInfo);
     // add a recurring payment if requested
     if ($params['is_recur'] && $params['installments'] > 1) {
         //Recur Variables
         $recurUnit = $params['frequency_unit'];
         $recurInterval = $params['frequency_interval'];
         $next = time();
         $day = 60 * 60 * 24;
         switch ($recurUnit) {
             case 'day':
                 $next += $recurInterval * $day;
                 break;
             case 'week':
                 $next += $recurInterval * $day * 7;
                 break;
             case 'month':
                 $date = getdate();
                 $date['mon'] += $recurInterval;
                 while ($date['mon'] > 12) {
                     $date['mon'] -= 12;
                     $date['year'] += 1;
                 }
                 $next = mktime($date['hours'], $date['minutes'], $date['seconds'], $date['mon'], $date['mday'], $date['year']);
                 break;
             case 'year':
                 $date = getdate();
                 $date['year'] += 1;
                 $next = mktime($date['hours'], $date['minutes'], $date['seconds'], $date['mon'], $date['mday'], $date['year']);
                 break;
             default:
                 die('Unexpected error!');
         }
         $startDate = date("Y/m/d", $next);
         // next payment in moneris required format
         $numRecurs = $params['installments'] - 1;
         //$startNow = 'true'; -- setting start now to false will mean the main transaction doesn't happen!
         $recurAmount = sprintf('%01.2f', $params['amount']);
         //Create an array with the recur variables
         $recurArray = array('recur_unit' => $recurUnit, 'start_date' => $startDate, 'num_recurs' => $numRecurs, 'start_now' => 'true', 'period' => $recurInterval, 'recur_amount' => $recurAmount);
         $mpgRecur = new mpgRecur($recurArray);
         // set the Recur Object to mpgRecur
         $mpgTxn->setRecur($mpgRecur);
     }
     //create a mpgRequest object passing the transaction object
     $mpgRequest = new mpgRequest($mpgTxn);
     // create mpgHttpsPost object which does an https post ##
     // [extra parameter added to library by AD]
     $isProduction = $this->_profile['mode'] == 'live';
     $mpgHttpPost = new mpgHttpsPost($this->_profile['storeid'], $this->_profile['apitoken'], $mpgRequest, $isProduction);
     // get an mpgResponse object
     $mpgResponse = $mpgHttpPost->getMpgResponse();
     $params['trxn_result_code'] = $mpgResponse->getResponseCode();
     if (self::isError($mpgResponse)) {
         if ($params['trxn_result_code']) {
             return self::error($mpgResponse);
         } else {
             return self::error('No reply from server - check your settings &/or try again');
         }
     }
     /* Check for application errors */
     $result =& self::checkResult($mpgResponse);
     if (is_a($result, 'CRM_Core_Error')) {
         return $result;
     }
     /* Success */
     $params['trxn_result_code'] = (int) $mpgResponse->getResponseCode();
     // todo: above assignment seems to be ignored, not getting stored in the civicrm_financial_trxn table
     $params['trxn_id'] = $mpgResponse->getTxnNumber();
     $params['gross_amount'] = $mpgResponse->getTransAmount();
     return $params;
 }
 public function actionCreditPayment()
 {
     $customer_model = new Customer();
     $commande_model = new Commande();
     $order_totals;
     $credit_card = new CreditCard($_POST['ccNumber'], $_POST['cvdNumber'], $_POST['ccName'], $_POST['expYear'], $_POST['expMonth']);
     $customer_model->attributes = Yii::app()->user->getState('Customer');
     $commande_model->attributes = Yii::app()->user->getState('Commande');
     $order_totals = $this->getInvoiceTotals($customer_model, $commande_model);
     $city = Goodcity::model()->findByPk($commande_model->comgoodcitykey);
     if (sizeof($customer_model->search()->getData()) == 0) {
         $customer_model->bilsignupip = CHttpRequest::getUserHostAddress();
         $customer_model->save();
         $commande_model->bilkey = $customer_model->bilkey;
         $commande_model->comdebut = date("Y-m-d");
         $commande_model->save();
     } else {
         $customerTemp = $customer_model->search()->getData();
         $customer_model->bilkey = $customerTemp[0]->attributes['bilkey'];
     }
     Yii::import('ext.mail.vendors.*');
     require "mpgClasses.php";
     $store_id = 'monca70830';
     $api_token = 'bFqjQoK69Li9wve1JkUk';
     /*$store_id='store5';
       $api_token='yesguy';*/
     $typePurchase = 'purchase';
     $typeAdd = 'res_add_cc';
     $cust_id = $customer_model->bilkey;
     $phone = $customer_model['bilphone1'];
     $email = $customer_model['bilemail'];
     $note = "Mailbox in {$city->goodcity} for {$commande_model->comperiod}";
     $order_id = 'MailNetwork-' . date("dmy-G:i:s");
     $amount = str_replace(',', '', $order_totals['total']);
     $pan = $credit_card['cardNumber'];
     $expiry_date = substr($credit_card['expYear'], 2) . $credit_card['expMonth'];
     $crypt = '7';
     $dynamic_descriptor = 'MailingNetwork';
     $status_check = 'false';
     $txnArray = array('type' => $typePurchase, 'order_id' => $order_id, 'cust_id' => $cust_id, 'amount' => $amount, 'pan' => $pan, 'expdate' => $expiry_date, 'crypt_type' => $crypt, 'dynamic_descriptor' => $dynamic_descriptor);
     $cvd_indicator = '1';
     $cvd_value = $credit_card['cardCVD'];
     $cvdTemplate = array('cvd_indicator' => $cvd_indicator, 'cvd_value' => $cvd_value);
     $mpgCvdInfo = new mpgCvdInfo($cvdTemplate);
     $mpgAvsInfo = null;
     $mpgTxn = new mpgTransaction($txnArray);
     $mpgTxn->setCvdInfo($mpgCvdInfo);
     $mpgTxn->setAvsInfo($mpgAvsInfo);
     $mpgRequest = new mpgRequest($mpgTxn);
     $mpgHttpPost = new mpgHttpsPost($store_id, $api_token, $mpgRequest);
     $mpgResponse = $mpgHttpPost->getMpgResponse();
     if ($mpgResponse->getComplete()) {
         if ($mpgResponse->getResponseCode() > 0 && $mpgResponse->getResponseCode() <= 49) {
             $auth_code = $mpgResponse->getAuthCode();
             //Add card to vault if first purchase worked
             $txnArray = array('type' => $typeAdd, 'order_id' => $order_id, 'cust_id' => $cust_id, 'amount' => $amount, 'phone' => $phone, 'email' => $email, 'note' => $note, 'pan' => $pan, 'expdate' => $expiry_date, 'crypt_type' => $crypt, 'dynamic_descriptor' => $dynamic_descriptor);
             $cvd_indicator = '1';
             $cvd_value = $credit_card['cardCVD'];
             $cvdTemplate = array('cvd_indicator' => $cvd_indicator, 'cvd_value' => $cvd_value);
             $mpgCvdInfo = null;
             $mpgAvsInfo = null;
             $mpgTxn = new mpgTransaction($txnArray);
             $mpgTxn->setCvdInfo($mpgCvdInfo);
             $mpgTxn->setAvsInfo($mpgAvsInfo);
             $mpgRequest = new mpgRequest($mpgTxn);
             $mpgHttpPost = new mpgHttpsPost($store_id, $api_token, $mpgRequest);
             $mpgResponse = $mpgHttpPost->getMpgResponse();
             //Redirect to receipt after adding card
             $city = Goodcity::model()->findByPk($commande_model->comgoodcitykey);
             $this->render('application/2-orderform', array('goodcity' => $city, 'thanks' => true, 'payment_type' => "credit_card", 'payment_method' => "email", 'order_totals' => $order_totals, 'customer_model' => $customer_model, 'commande_model' => $commande_model, 'auth_code' => $auth_code));
             $this->sendEmailConfirmation($customer_model, $city, $commande_model, $auth_code, $order_totals);
         } else {
             $this->redirect(array('user/order', 'transactionError' => true));
         }
     } else {
         $this->redirect(array('user/order', 'transactionError' => true));
     }
 }
Example #5
0
 /**
  *
  * @return HTML
  */
 function _process()
 {
     $data = JRequest::get('post');
     $order = JTable::getInstance('Orders', 'TiendaTable');
     $order->load($data['order_id']);
     $items = $order->getItems();
     $orderpayment_id = $data['orderpayment_id'];
     $orderpayment_amount = $data['orderpayment_amount'];
     $amount = $data['orderpayment_amount'];
     /************************ Request Variables ***************************/
     $store_id = $this->_store_id;
     $api_token = $this->_api_token;
     /************************** Recur Variables *****************************/
     $is_recurring = $order->isRecurring();
     // Check recurring items are present or not
     if ($is_recurring) {
         $vars->cmd = '_cart';
         $vars->mixed_cart = true;
         // Adjust the orderpayment amount since it's a mixed cart
         // first orderpayment is just the non-recurring items total
         // then upon return, ask user to checkout again for recurring items
         $recurAmount = $order->recurring_trial ? $order->recurring_trial_price : $order->recurring_amount;
         $recurInterval = $order->recurring_trial ? $order->recurring_trial_period_interval : $order->recurring_period_interval;
         // '10';
         $numRecurs = recurring_payments;
         //'4';
         $recurUnit = $order->recurring_trial ? $order->recurring_trial_period_unit : $order->recurring_period_unit;
         // (day | week | month)
         $orderpayment->orderpayment_amount = $orderpayment->orderpayment_amount - $recurAmount;
         $orderpayment->save();
         $amount = $orderpayment->orderpayment_amount;
         $startNow = 'true';
         $startDate = date("Y/m/d");
         // '2006/11/30'; //yyyy/mm/dd
         /****************************** Recur Array **************************/
         $recurArray = array('recur_unit' => $recurUnit, 'start_date' => $startDate, 'num_recurs' => $numRecurs, 'start_now' => $startNow, 'period' => $recurInterval, 'recur_amount' => $recurAmount);
         /****************************** Recur Object **************************/
         $mpgRecur = new mpgRecur($recurArray);
     }
     /****************** Transactional Variables ************************/
     $type = 'purchase';
     // genrate the unique Order Id to preserve the payment Id also
     $orderid = 'ord-' . $orderpayment_id . '-' . date("dmy-G:i:s");
     //Check decimal (.) exist or not
     $temp_amount = explode('.', $amount);
     if (count($temp_amount) <= 1) {
         $amount = $amount . ".0";
     }
     $cust_id = JFactory::getUser()->id;
     $pan = $data['cardnum'];
     // '4242424242424242';
     $expiry_date = $data['cardexp'];
     // YYMM, so 0812 = December 2008
     $crypt = '7';
     // SSL-enabled merchant
     $commcard_invoice = '';
     $commcard_tax_amount = '';
     /******************* Customer Information Variables ********************/
     $instructions = '';
     $billing = $this->_getBillingAddress($data);
     /************************** AVS Variables *****************************/
     $avs_street_number = intval($billing['address']);
     $avs_street_name = $billing['address'];
     $avs_zipcode = $billing['postal_code'];
     /************************** CVD Variables *****************************/
     $cvd_indicator = '1';
     // yes, we're using CVD
     $cvd_value = $data['cardcvv'];
     /********************** AVS Associative Array *************************/
     $avsTemplate = array('avs_street_number' => $avs_street_number, 'avs_street_name' => $avs_street_name, 'avs_zipcode' => $avs_zipcode);
     /********************** CVD Associative Array *************************/
     $cvdTemplate = array('cvd_indicator' => $cvd_indicator, 'cvd_value' => $cvd_value);
     /************************** AVS Object ********************************/
     $mpgAvsInfo = new mpgAvsInfo($avsTemplate);
     /************************** CVD Object ********************************/
     $mpgCvdInfo = new mpgCvdInfo($cvdTemplate);
     /******************** Customer Information Object *********************/
     $mpgCustInfo = new mpgCustInfo();
     /********************** Set Customer Information **********************/
     $mpgCustInfo->setBilling($billing);
     $shipping = $this->_getShippingAddress($data);
     $mpgCustInfo->setShipping($shipping);
     $email = JFactory::getUser()->email;
     $mpgCustInfo->setEmail($email);
     $mpgCustInfo->setInstructions($instructions);
     /*********************** Set Line Item Information *********************/
     foreach ($items as $itemObject) {
         $items_temp[0] = array('name' => $itemObject->orderitem_name, 'quantity' => $itemObject->orderitem_quantity, 'product_code' => $itemObject->orderitem_name, 'extended_amount' => $itemObject->orderitem_price);
         $mpgCustInfo->setItems($items_temp[0]);
     }
     /***************** Transactional Associative Array ********************/
     $txnArray = array('type' => $type, 'order_id' => $orderid, 'cust_id' => $cust_id, 'amount' => $amount, 'pan' => $pan, 'expdate' => $expiry_date, 'crypt_type' => $crypt, 'commcard_invoice' => '', 'commcard_tax_amount' => '');
     /********************** Transaction Object ****************************/
     $mpgTxn = new mpgTransaction($txnArray);
     /******************** Set Customer Information ************************/
     $mpgTxn->setCustInfo($mpgCustInfo);
     /************************ Set AVS and CVD *****************************/
     $mpgTxn->setAvsInfo($mpgAvsInfo);
     $mpgTxn->setCvdInfo($mpgCvdInfo);
     /************************* Request Object *****************************/
     $mpgRequest = new mpgRequest($mpgTxn);
     /************************ HTTPS Post Object ***************************/
     $mpgHttpPost = new mpgHttpsPost($store_id, $api_token, $mpgRequest);
     /****************8********** Response *********************************/
     $mpgResponse = $mpgHttpPost->getMpgResponse();
     return $this->_evaluateResponse($mpgResponse);
 }
Example #6
0
 function doDirectPayment(&$params)
 {
     # make sure i've been called correctly ...
     if (!$this->_profile) {
         return CRM_Contribute_Payment_Moneris::error();
     }
     if ($params['currencyID'] != 'CAD') {
         return CRM_Contribute_Payment_Moneris::error();
     }
     /* unused params: cvv not yet implemented, payment action ingored (should test for 'Sale' value?)
        [cvv2] => 000
        [ip_address] => 192.168.0.103
        [payment_action] => Sale
        [contact_type] => Individual
        [geo_coord_id] => 1 */
     # this code based on Moneris example code #
     ## create an mpgCustInfo object
     $mpgCustInfo = new mpgCustInfo();
     ## call set methods of the mpgCustinfo object
     $mpgCustInfo->setEmail($params['email']);
     ## get text representations of province/country to send to moneris for billing info #
     $province = CRM_Core_PseudoConstant::stateProvince($params['state_province_id']);
     $country = CRM_Core_PseudoConstant::country($params['country_id']);
     $billing = array(first_name => $params['first_name'], last_name => $params['last_name'], address => $params['street_address'], city => $params['city'], province => $province, postal_code => $params['postal_code'], country => $country);
     $mpgCustInfo->setBilling($billing);
     $my_orderid = $params['invoiceID'];
     // set orderid as invoiceID to help match things up with Moneris later
     $expiry_string = sprintf('%04d%02d', $params['year'], $params['month']);
     $txnArray = array(type => 'purchase', order_id => $my_orderid, amount => sprintf('%01.2f', $params['amount']), pan => $params['credit_card_number'], expdate => substr($expiry_string, 2, 4), crypt_type => '7', cust_id => $params['contact_id']);
     ## create a transaction object passing the hash created above
     $mpgTxn = new mpgTransaction($txnArray);
     ## use the setCustInfo method of mpgTransaction object to
     ## set the customer info (level 3 data) for this transaction
     $mpgTxn->setCustInfo($mpgCustInfo);
     ## create a mpgRequest object passing the transaction object
     $mpgRequest = new mpgRequest($mpgTxn);
     ## create mpgHttpsPost object which does an https post ##
     // [extra parameter added to library by AD]
     $isProduction = $this->_profile['mode'] == 'live';
     $mpgHttpPost = new mpgHttpsPost($this->_profile['storeid'], $this->_profile['apitoken'], $mpgRequest, $isProduction);
     ## get an mpgResponse object ##
     $mpgResponse = $mpgHttpPost->getMpgResponse();
     $params['trxn_result_code'] = $mpgResponse->getResponseCode();
     if (CRM_Contribute_Payment_Moneris::isError($mpgResponse)) {
         return CRM_Contribute_Payment_Moneris::error($mpgResponse);
     }
     /* Check for application errors */
     $result =& CRM_Contribute_Payment_Moneris::checkResult($mpgResponse);
     if (is_a($result, 'CRM_Core_Error')) {
         return $result;
     }
     /* Success */
     $params['trxn_result_code'] = (int) $mpgResponse->getResponseCode();
     // todo: above assignment seems to be ignored, not getting stored in the civicrm_financial_trxn table
     $params['trxn_id'] = $mpgResponse->getTxnNumber();
     $params['gross_amount'] = $mpgResponse->getTransAmount();
     return $params;
 }
Example #7
0
$avs_zipcode = 'M1M1M1';
/************************** CVD Variables *****************************/
$cvd_indicator = '1';
$cvd_value = '198';
/********************** AVS Associative Array *************************/
$avsTemplate = array('avs_street_number' => $avs_street_number, 'avs_street_name' => $avs_street_name, 'avs_zipcode' => $avs_zipcode);
/********************** CVD Associative Array *************************/
$cvdTemplate = array('cvd_indicator' => $cvd_indicator, 'cvd_value' => $cvd_value);
/************************** AVS Object ********************************/
$mpgAvsInfo = new mpgAvsInfo($avsTemplate);
/************************** CVD Object ********************************/
$mpgCvdInfo = new mpgCvdInfo($cvdTemplate);
/***************** Transactional Associative Array ********************/
$txnArray = array('type' => $type, 'order_id' => $order_id, 'cust_id' => $cust_id, 'amount' => $amount, 'pan' => $pan, 'expdate' => $expiry_date, 'crypt_type' => $crypt);
/********************** Transaction Object ****************************/
$mpgTxn = new mpgTransaction($txnArray);
/************************ Set AVS and CVD *****************************/
$mpgTxn->setAvsInfo($mpgAvsInfo);
$mpgTxn->setCvdInfo($mpgCvdInfo);
/************************ Request Object ******************************/
$mpgRequest = new mpgRequest($mpgTxn);
/*********************** HTTPS Post Object ****************************/
$mpgHttpPost = new mpgHttpsPost($store_id, $api_token, $mpgRequest);
/***************************** Response ******************************/
$mpgResponse = $mpgHttpPost->getMpgResponse();
print "\nCardType = " . $mpgResponse->getCardType();
print "\nTransAmount = " . $mpgResponse->getTransAmount();
print "\nTxnNumber = " . $mpgResponse->getTxnNumber();
print "\nReceiptId = " . $mpgResponse->getReceiptId();
print "\nTransType = " . $mpgResponse->getTransType();
print "\nReferenceNum = " . $mpgResponse->getReferenceNum();
Example #8
0
/********************** Set Customer Information **********************/
$billing = array('first_name' => $first_name, 'last_name' => $last_name, 'company_name' => $company_name, 'address' => $address, 'city' => $city, 'province' => $province, 'postal_code' => $postal_code, 'country' => $country, 'phone_number' => $phone_number, 'fax' => $fax, 'tax1' => $tax1, 'tax2' => $tax2, 'tax3' => $tax3, 'shipping_cost' => $shipping_cost);
$mpgCustInfo->setBilling($billing);
$shipping = array('first_name' => $first_name, 'last_name' => $last_name, 'company_name' => $company_name, 'address' => $address, 'city' => $city, 'province' => $province, 'postal_code' => $postal_code, 'country' => $country, 'phone_number' => $phone_number, 'fax' => $fax, 'tax1' => $tax1, 'tax2' => $tax2, 'tax3' => $tax3, 'shipping_cost' => $shipping_cost);
$mpgCustInfo->setShipping($shipping);
$mpgCustInfo->setEmail($email);
$mpgCustInfo->setInstructions($instructions);
/*********************** Set Line Item Information *********************/
$item[0] = array('name' => $item_name[0], 'quantity' => $item_quantity[0], 'product_code' => $item_product_code[0], 'extended_amount' => $item_extended_amount[0]);
$item[1] = array('name' => $item_name[1], 'quantity' => $item_quantity[1], 'product_code' => $item_product_code[1], 'extended_amount' => $item_extended_amount[1]);
$mpgCustInfo->setItems($item[0]);
$mpgCustInfo->setItems($item[1]);
/***************** Transactional Associative Array ********************/
$txnArray = array('type' => $type, 'order_id' => $order_id, 'cust_id' => $cust_id, 'amount' => $amount, 'pan' => $pan, 'expdate' => $expiry_date, 'crypt_type' => $crypt);
/********************** Transaction Object ****************************/
$mpgTxn = new mpgTransaction($txnArray);
/******************** Set Customer Information ************************/
$mpgTxn->setCustInfo($mpgCustInfo);
/************************* Request Object *****************************/
$mpgRequest = new mpgRequest($mpgTxn);
/************************ HTTPS Post Object ***************************/
$mpgHttpPost = new mpgHttpsPost($store_id, $api_token, $mpgRequest);
/******************************** Response ****************************/
$mpgResponse = $mpgHttpPost->getMpgResponse();
print "\nCardType = " . $mpgResponse->getCardType();
print "\nTransAmount = " . $mpgResponse->getTransAmount();
print "\nTxnNumber = " . $mpgResponse->getTxnNumber();
print "\nReceiptId = " . $mpgResponse->getReceiptId();
print "\nTransType = " . $mpgResponse->getTransType();
print "\nReferenceNum = " . $mpgResponse->getReferenceNum();
print "\nResponseCode = " . $mpgResponse->getResponseCode();