public static function save($params) { $result = array(); $result['success'] = true; if (empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Error"); return $result; } unset($params['allow_work']); //oseExit($params); $db = oseDB::instance(); $msc_id = $params['msc_id']; $member_id = $params['member_id']; $msc = oseRegistry::call('msc'); $member = oseRegistry::call('member'); $payment = oseRegistry::call('payment'); $ext = $msc->getExtInfo($msc_id, 'msc', 'obj'); $member->instance($member_id); $userInfo = $member->getBasicInfo('obj'); $order = new osePaymentOrder(); $orderValues = array(); $payment_mode = 'a'; $price = '10'; $orderValues['payment_method'] = 'paypal'; $orderValues['order_number'] = $payment->generateOrderNumber($user->id); $orderValues['payment_price'] = $price; //$payment->pricing($msc_id,$payment_mode); $orderValues['payment_mode'] = $payment_mode; //$orderValues['create_date'] = oseHTML::getDateTime(); $orderValues['params'] = $payment->generateOrderParams($msc_id, $price, $payment_mode); $orderValues['params'] = http_build_query($orderValues['params']); $orderId = $order->generateOrder($msc_id, $member_id, $orderValues); if (!$orderId) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Join History: No Membership "); } $post = JRequest::get('post'); $member = oseRegistry::call('member'); $email = $member->getInstance('email'); $emailTempDetail = $email->getDoc($ext->wel_email, 'obj'); $variables = $email->getEmailVariablesWelcome($orderId); $emailParams = $email->buildEmailParams($emailTempDetail->type); $emailDetail = $email->transEmail($emailTempDetail, $variables, $emailParams); $email->sendEmail($emailDetail, $userInfo->email); $emailConfig = oseMscConfig::getConfig('email', 'obj'); if ($emailConfig->sendWel2Admin) { $email->sendToAdminGroup($emailDetail, $emailConfig->admin_group); } if (empty($msc_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Join History: No Membership "); } if (!oseMemHistory::record($msc_id, $member_id, 'join')) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_(" Fail Record Member's Footprint! "); } return $result; }
function ePayCreateProfile1($orderInfo, $credit_info, $params = array()) { ini_set('max_execution_time', '180'); // Now proceed the Recurring payment plan creation; // Load Basic Information; $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(); $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 = '******'; $ePayPassword = '******'; } else { $test_mode = false; $ePayCustomerID = $pConfig->ePayCustomerID; $ePayUsername = $pConfig->ePayUsername; $ePayPassword = $pConfig->ePayPassword; if (empty($ePayCustomerID) || empty($ePayUsername)) { return self::getErrorMessage('cc', '0001', null); } } // Assign Values; $refID = substr($order_number, 0, 19) . "A"; $invoice = substr($order_number, 0, 19) . "A"; $name = "MEM{$msc_id}UID{$user_id}_" . date("Ymdhis"); // Credit Card Informaiton; $creditcard = $credit_info["creditcard_number"]; $cardCode = $credit_info["creditcard_cvv"]; $expiration = $credit_info["creditcard_expirationdate"]; $expiration = strval($expiration); // Recurring payment setting; $msc = oseRegistry::call('msc'); //oseExit($mscTrialRecurrence); $initStartDate = date("d/m/Y", strtotime("+ 1 day")); $initAmount = $orderInfo->payment_price; $recurAmount = $orderInfoParams->next_total; $totalOccurrences = 9999; /// Finished getting all necessary Information;/// /// Start Creating Subscription Plans ; // Check if Price is set correctly; if (empty($recurAmount)) { return self::getErrorMessage('cc', '0002'); } // First time charge for those does not support initial payments; // SUITABLE HERE - ePay; $result = self::ePayOneOffPay($orderInfo, $credit_info, $params, $TransactionType = 'AUTH_CAPTURE', true); if ($result['ePayTrxnStatus'] == false) { return self::getErrorMessage('cc', '0000', $result['ePayTrxnError']); } if (!empty($orderInfoParams->has_trial)) { $trialOccurrences = "1"; $mscTrialRecurrence = self::TranslateInterval($orderInfoParams->t1, $orderInfoParams->p1); $recurStartDate = date("d/m/Y", strtotime("+ {$mscTrialRecurrence['length']} {$mscTrialRecurrence['unit']}")); $mscRegRecurrence = self::TranslateInterval($orderInfoParams->t3, $orderInfoParams->p3); } else { $trialOccurrences = "0"; $mscRegRecurrence = self::TranslateInterval($orderInfoParams->t3, $orderInfoParams->p3); $recurStartDate = date("d/m/Y", strtotime("+ {$mscRegRecurrence['length']} {$mscRegRecurrence['unit']}")); } // Start creating profiles; $postVar = array(); $postVar['CustomerRef'] = $user->id; //$postVar['ePayTotalAmount']= $taxRate / 100 * $recurAmount+ $recurAmount; //oseExit($billingInfo); if (!empty($billingInfo->firstname)) { $postVar['CustomerFirstName'] = substr($billingInfo->firstname, 0, 50); $postVar['CustomerLastName'] = substr($billingInfo->lastname, 0, 50); } else { $customerName = explode(' ', $credit_info["creditcard_name"]); $postVar['CustomerFirstName'] = substr($customerName[0], 0, 50); $postVar['CustomerLastName'] = substr($customerName[count($customerName) - 1], 0, 50); } $postVar['CustomerEmail'] = $billingInfo->email; $postVar['CustomerAddress'] = substr($billingInfo->addr1, 0, 50); $postVar['CustomerPostcode'] = substr(str_replace(" ", "", $billingInfo->postcode), 0, 6); $postVar['CustomerState'] = substr($billingInfo->state, 0, 50); $postVar['CustomerCountry'] = substr($billingInfo->country, 0, 20); $creditCardExpiryDate = $credit_info["creditcard_expirationdate"]; $creditCardExpiryDate = explode("-", strval($creditCardExpiryDate)); $postVar['RebillCCName'] = substr($credit_info["creditcard_name"], 0, 50); $postVar['RebillCCNumber'] = substr($credit_info["creditcard_number"], 0, 19); $postVar['RebillCCExpMonth'] = substr($creditCardExpiryDate[1], 0, 2); $postVar['RebillCCExpYear'] = substr($creditCardExpiryDate[0], 0, 4); $postVar['RebillInvRef'] = $refID; $postVar['RebillInvDesc'] = ''; $postVar['RebillInitAmt'] = 0; $postVar['RebillInitDate'] = $initStartDate; $postVar['RebillRecurAmt'] = intval(($taxRate / 100 * $recurAmount + $recurAmount) * 100); $postVar['RebillStartDate'] = $recurStartDate; $postVar['RebillInterval'] = $mscRegRecurrence['length']; $postVar['RebillIntervalType'] = $mscRegRecurrence['IntervalType']; $postVar['RebillEndDate'] = date("d/m/Y", strtotime("+ 3 years")); $resArray = self::ePayRebillAPIConnect($ePayCustomerID, $ePayUsername, $ePayPassword, $test_mode, $postVar, true); if ($resArray['Result'] == 'Success') { $params['payment_serial_number'] = $refID; $params['payment_method'] = 'ePay'; $return = self::confirmOrder($order_id, $params); return $return; } else { $params['payment_serial_number'] = $refID; $params['payment_mode'] = 'm'; $params['payment_method'] = 'ePay'; //$return = self:: confirmOrder($order_id, $params ); return self::getErrorMessage('cc', '0004', $resArray['ErrorDetails']); } }
function getOrder($where = array(), $type = 'array') { $order = new osePaymentOrder(); return $order->getOrder($where, $type); }
function update() { $db = oseDB::instance(); $user = JFactory::getUser(); $query = " SELECT * FROM `#__osemsc_order`" . " WHERE `user_id` = '{$user->id}' AND `payment_method` IN ('beanstream','authorize','paypal_cc')" . " AND `payment_mode` = 'a' AND `order_status`='confirmed'"; $db->setQuery($query); $list = oseDB::loadList(); if (count($list) < 1) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Error'); $result = oseJson::encode($result); } $creditInfo = array(); $post = JRequest::get('post'); $order_id = JRequest::getInt('order_id'); $creditInfo['creditcard_type'] = $post['creditcard_type']; $creditInfo['creditcard_name'] = $post['creditcard_name']; $creditInfo['creditcard_owner'] = $creditInfo['creditcard_name']; $creditInfo['creditcard_number'] = JRequest::getCmd('creditcard_number'); $creditInfo['creditcard_year'] = $post['creditcard_year']; $creditInfo['creditcard_month'] = $post['creditcard_month']; $creditInfo['creditcard_expirationdate'] = $post['creditcard_year'] . '-' . $post['creditcard_month']; $creditInfo['creditcard_cvv'] = $post['creditcard_cvv']; $payment = oseRegistry::call('payment'); $pOrder = new osePaymentOrder(); $orderInfo = $pOrder->getOrder(array('`order_id` = ' . $order_id), 'obj'); switch ($orderInfo->payment_method) { case ('beanstream'): $updated = $pOrder->BeanStreamModify($orderInfo, $creditInfo); break; case ('authorize'): $updated = $pOrder->AuthorizeARBUpdateProfile($orderInfo, $creditInfo); $result = array(); if ($updated['success']) { $result['success'] = true; $result['title'] = JText::_('Success'); $result['content'] = JText::_('Updated!'); } else { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = $updated['content']; } $result = oseJson::encode($result); oseExit($result); break; case ('paypal_cc'): $updated = $pOrder->PaypalAPIUpdateCreditCard($orderInfo, $creditInfo); $result = array(); if ($updated['success']) { $result['success'] = true; $result['title'] = JText::_('Success'); $result['content'] = JText::_('Updated!'); } else { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = $updated['content']; } $result = oseJson::encode($result); oseExit($result); break; default: break; } $result = array(); if ($updated) { $result['success'] = true; $result['title'] = JText::_('Success'); $result['content'] = JText::_('Updated!'); } else { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Error'); } $result = oseJson::encode($result); oseExit($result); }