コード例 #1
0
ファイル: payment_moneris.php プロジェクト: annggeel/tienda
 /**
  *
  * @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);
 }
コード例 #2
0
$item_quantity[0] = '1';
$item_product_code[0] = 'JRSCDA344';
$item_extended_amount[0] = '129.99';
$item_name[1] = 'Patrick Roy Signed Koho Stick';
$item_quantity[1] = '1';
$item_product_code[1] = 'JPREEA344';
$item_extended_amount[1] = '59.99';
/******************** Customer Information Object *********************/
$mpgCustInfo = new mpgCustInfo();
/********************** 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);