本文整理汇总了PHP中TiendaHelperBase::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP TiendaHelperBase::getInstance方法的具体用法?PHP TiendaHelperBase::getInstance怎么用?PHP TiendaHelperBase::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiendaHelperBase
的用法示例。
在下文中一共展示了TiendaHelperBase::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: downloadFile
/**
* downloads a file
*
* @return void
*/
function downloadFile()
{
$user = JFactory::getUser();
$productfile_id = intval(JRequest::getvar('id', '', 'request', 'int'));
$product_id = intval(JRequest::getvar('product_id', '', 'request', 'int'));
$link = 'index.php?option=com_tienda&view=products&task=edit&id=' . $product_id;
Tienda::load('TiendaHelperBase', 'helpers._base');
$helper = TiendaHelperBase::getInstance('ProductDownload', 'TiendaHelper');
JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_tienda' . DS . 'tables');
$productfile = JTable::getInstance('ProductFiles', 'TiendaTable');
$productfile->load($productfile_id);
if (empty($productfile->productfile_id)) {
$this->messagetype = 'notice';
$this->message = JText::_('COM_TIENDA_INVALID FILE');
$this->setRedirect($link, $this->message, $this->messagetype);
return false;
}
// log and download
Tienda::load('TiendaFile', 'library.file');
// geting the ProductDownloadId to updated for which productdownload_max is greater then 0
$productToDownload = $helper->getProductDownloadInfo($productfile->productfile_id, $user->id);
if ($downloadFile = TiendaFile::download($productfile)) {
$link = JRoute::_($link, false);
$this->setRedirect($link);
}
}
示例2: save
/**
* Run function after saving
*/
function save($src = '', $orderingFilter = '', $ignore = '')
{
if ($return = parent::save($src, $orderingFilter, $ignore)) {
Tienda::load("TiendaHelperProduct", 'helpers.product');
$helper = TiendaHelperBase::getInstance('product');
$helper->doProductQuantitiesReconciliation($this->product_id, '0');
}
return $return;
}
示例3: save
/**
* Run function when saving
* @see tienda/admin/tables/TiendaTable#save()
*/
function save($src = '', $orderingFilter = '', $ignore = '')
{
if ($return = parent::save($src, $orderingFilter, $ignore)) {
$pa = JTable::getInstance('ProductAttributes', 'TiendaTable');
$pa->load($this->productattribute_id);
Tienda::load("TiendaHelperProduct", 'helpers.product');
$helper = TiendaHelperBase::getInstance('product');
$helper->doProductQuantitiesReconciliation($pa->product_id);
}
return $return;
}
示例4: store
/**
*
* @param unknown_type $updateNulls
* @return unknown_type
*/
function store($updateNulls = false)
{
if ($return = parent::store($updateNulls)) {
if ($this->notify_customer == '1') {
Tienda::load("TiendaHelperBase", 'helpers._base');
$helper = TiendaHelperBase::getInstance('Email');
$model = Tienda::getClass("TiendaModelSubscriptions", "models.subscriptions");
$model->setId($this->subscription_id);
$subscription = $model->getItem();
$helper->sendEmailNotices($subscription, 'subscription');
}
}
return $return;
}
示例5: store
/**
*
* @param unknown_type $updateNulls
* @return unknown_type
*/
function store($updateNulls = false)
{
if ($return = parent::store($updateNulls)) {
if ($this->notify_customer == '1') {
Tienda::load("TiendaHelperBase", 'helpers._base');
$helper = TiendaHelperBase::getInstance('Email');
$model = Tienda::getClass("TiendaModelOrders", "models.orders");
$model->setId($this->order_id);
// this isn't necessary because you specify the requested PK id as a getItem() argument
$order = $model->getItem($this->order_id, true);
$helper->sendEmailNotices($order, 'order');
}
}
return $return;
}
示例6: display
function display($cachable = false, $urlparams = false)
{
$uri = JURI::getInstance();
$view = $this->getView($this->get('suffix'), JFactory::getDocument()->getType());
$view->set('hidemenu', false);
$view->set('_doTask', true);
$view->setLayout('default');
if (version_compare(JVERSION, '1.6.0', 'ge')) {
$url = "index.php?option=com_users&view=user&task=user.edit";
} else {
$url = "index.php?option=com_user&view=user&task=edit";
}
Tienda::load("TiendaHelperBase", 'helpers._base');
$helper = TiendaHelperBase::getInstance('Ambra');
if ($helper->isInstalled()) {
$url = "index.php?option=com_ambra&view=users&task=edit&return=" . base64_encode($uri->toString());
}
$view->assign('url_profile', $url);
parent::display($cachable, $urlparams);
}
示例7: _buildQueryFields
protected function _buildQueryFields(&$query)
{
Tienda::load('TiendaHelperUser', 'helpers.user');
$date = JFactory::getDate()->toMysql();
$filter_product = $this->getState('filter_product');
$user = TiendaHelperBase::getInstance('user');
if (strlen($filter_product)) {
$default_group = $user->getUserGroup(JFactory::getUser()->id, (int) $filter_product);
} else {
$default_group = Tienda::getInstance()->get('default_user_group', '1');
}
$fields = array();
$fields[] = " p_from.product_name as product_name_from ";
$fields[] = " p_from.product_sku as product_sku_from ";
$fields[] = " p_from.product_model as product_model_from ";
$fields[] = "\n (\n SELECT \n prices.product_price\n FROM\n #__tienda_productprices AS prices \n WHERE \n prices.product_id = tbl.product_id_from \n AND prices.group_id = '{$default_group}'\n AND prices.product_price_startdate <= '{$date}' \n AND (prices.product_price_enddate >= '{$date}' OR prices.product_price_enddate = '0000-00-00 00:00:00' )\n ORDER BY prices.price_quantity_start ASC\n LIMIT 1\n ) \n AS product_price_from ";
$fields[] = " p_to.product_name as product_name_to ";
$fields[] = " p_to.product_sku as product_sku_to ";
$fields[] = " p_to.product_model as product_model_to ";
$fields[] = "\n (\n SELECT \n prices.product_price\n FROM\n #__tienda_productprices AS prices \n WHERE \n prices.product_id = tbl.product_id_to \n AND prices.group_id = '{$default_group}'\n AND prices.product_price_startdate <= '{$date}' \n AND (prices.product_price_enddate >= '{$date}' OR prices.product_price_enddate = '0000-00-00 00:00:00' )\n ORDER BY prices.price_quantity_start ASC\n LIMIT 1\n ) \n AS product_price_to ";
$query->select($this->getState('select', 'tbl.*'));
$query->select($fields);
}
示例8: _processSale
/**
* Processes the sale payment
*
* @param array $data Google Respnse data
* @return boolean Did the Response Validate ?
* @access protected
*/
function _processSale($data, $error = '', $payment_details)
{
/*
* validate the payment data
*/
$errors = array();
if (!empty($error)) {
$errors[] = $error;
}
// load the orderpayment record and set some values
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
$orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
$googleOrderNumber = $data['google-order-number']['VALUE'];
// Loading the order payment on ht basis of the google-order-number
$orderpayment->load(array('transaction_id' => $googleOrderNumber));
if (empty($orderpayment->orderpayment_id)) {
$errors[] = JText::_('COM_TIENDA_GOOGLECHECKOUT_INVALID_GOOGLE_CHECKOUT_ORDER_ID');
return count($errors) ? implode("\n", $errors) : '';
}
// Svaing Financial order state
$orderpayment->transaction_details = $payment_details;
// Svaing payment status Completed
$orderpayment->transaction_status = "Completed";
// set the order's new status and update quantities if necessary
Tienda::load('TiendaHelperOrder', 'helpers.order');
Tienda::load('TiendaHelperCarts', 'helpers.carts');
$order = JTable::getInstance('Orders', 'TiendaTable');
$order->load($orderpayment->order_id);
if (count($errors)) {
// if an error occurred
$order->order_state_id = $this->params->get('failed_order_state', '10');
// FAILED
} else {
$order->order_state_id = $this->params->get('payment_received_order_state', '17');
// PAYMENT RECEIVED
// do post payment actions
$setOrderPaymentReceived = true;
// send email
$send_email = true;
}
// update the order
if (!$order->save()) {
$errors[] = $order->getError();
}
// update the orderpayment
if (!$orderpayment->save()) {
$errors[] = $orderpayment->getError();
}
if (!empty($setOrderPaymentReceived)) {
$this->setOrderPaymentReceived($orderpayment->order_id);
}
if ($send_email) {
// send notice of new order
Tienda::load("TiendaHelperBase", 'helpers._base');
$helper = TiendaHelperBase::getInstance('Email');
$model = Tienda::getClass("TiendaModelOrders", "models.orders");
$model->setId($orderpayment->order_id);
$order = $model->getItem();
$helper->sendEmailNotices($order, 'new_order');
}
return count($errors) ? implode("\n", $errors) : '';
}
示例9: _process
function _process($data)
{
$post = JRequest::get('post');
$orderpayment_id = @$data['ssl_invoice_number'];
$errors = array();
$send_email = false;
// load the orderpayment record and set some values
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
$orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
$orderpayment->load($orderpayment_id);
if (empty($orderpayment_id) || empty($orderpayment->orderpayment_id)) {
$errors[] = JText::_('VIRTUALMERCHANT MESSAGE INVALID ORDERPAYMENTID');
return count($errors) ? implode("\n", $errors) : '';
}
$orderpayment->transaction_details = $data['ssl_result_message'];
$orderpayment->transaction_id = $data['ssl_txn_id'];
$orderpayment->transaction_status = $data['ssl_result'];
// check the stored amount against the payment amount
Tienda::load('TiendaHelperBase', 'helpers._base');
$stored_amount = TiendaHelperBase::number($orderpayment->get('orderpayment_amount'), array('thousands' => ''));
$respond_amount = TiendaHelperBase::number($data['ssl_amount'], array('thousands' => ''));
if ($stored_amount != $respond_amount) {
$errors[] = JText::_('VIRTUALMERCHANT MESSAGE AMOUNT INVALID');
$errors[] = $stored_amount . " != " . $respond_amount;
}
// set the order's new status and update quantities if necessary
Tienda::load('TiendaHelperOrder', 'helpers.order');
Tienda::load('TiendaHelperCarts', 'helpers.carts');
$order = JTable::getInstance('Orders', 'TiendaTable');
$order->load($orderpayment->order_id);
if (count($errors)) {
// if an error occurred
$order->order_state_id = $this->params->get('failed_order_state', '10');
// FAILED
} else {
$order->order_state_id = $this->params->get('payment_received_order_state', '17');
// PAYMENT RECEIVED
// do post payment actions
$setOrderPaymentReceived = true;
// send email
$send_email = true;
}
// save the order
if (!$order->save()) {
$errors[] = $order->getError();
}
// save the orderpayment
if (!$orderpayment->save()) {
$errors[] = $orderpayment->getError();
}
if (!empty($setOrderPaymentReceived)) {
$this->setOrderPaymentReceived($orderpayment->order_id);
}
if ($send_email) {
// send notice of new order
Tienda::load("TiendaHelperBase", 'helpers._base');
$helper = TiendaHelperBase::getInstance('Email');
$model = Tienda::getClass("TiendaModelOrders", "models.orders");
$model->setId($orderpayment->order_id);
$order = $model->getItem();
$helper->sendEmailNotices($order, 'new_order');
}
return count($errors) ? implode("\n", $errors) : '';
return true;
}
示例10: addRelationship
/**
*
* Adds a product relationship
*/
function addRelationship()
{
$response = array();
$response['msg'] = '';
$response['error'] = '';
Tienda::load('TiendaHelperBase', 'helpers._base');
$helper = TiendaHelperBase::getInstance();
// get elements from post
$elements = json_decode(preg_replace('/[\\n\\r]+/', '\\n', JRequest::getVar('elements', '', 'post', 'string')));
// convert elements to array that can be binded
Tienda::load('TiendaHelperBase', 'helpers._base');
$helper = TiendaHelperBase::getInstance();
$submitted_values = $helper->elementsToArray($elements);
$product_id = $submitted_values['new_relationship_productid_from'];
$product_to = $submitted_values['new_relationship_productid_to'];
$relation_type = $submitted_values['new_relationship_type'];
// verify product id exists
$product = JTable::getInstance('Products', 'TiendaTable');
$product->load($product_to, true, false);
if (empty($product->product_id) || $product_id == $product_to) {
$response['error'] = '1';
$response['msg'] = $helper->generateMessage(JText::_('COM_TIENDA_INVALID_PRODUCT'));
$response['msg'] .= $this->getRelationshipsHtml(null, $product_id);
echo json_encode($response);
return;
}
// and that relationship doesn't already exist
$producthelper = TiendaHelperBase::getInstance('Product');
if ($producthelper->relationshipExists($product_id, $product_to, $relation_type)) {
$response['error'] = '1';
$response['msg'] = $helper->generateMessage(JText::_('COM_TIENDA_RELATIONSHIP_ALREADY_EXISTS'));
$response['msg'] .= $this->getRelationshipsHtml(null, $product_id);
echo json_encode($response);
return;
}
switch ($relation_type) {
case "child":
case "required_by":
// for these two, we must flip to/from
switch ($relation_type) {
case "child":
$rtype = 'parent';
break;
case "required_by":
$rtype = 'requires';
break;
}
// check existence of required_by relationship
if ($producthelper->relationshipExists($product_to, $product_id, $rtype)) {
$response['error'] = '1';
$response['msg'] = $helper->generateMessage(JText::_('COM_TIENDA_RELATIONSHIP_ALREADY_EXISTS'));
$response['msg'] .= $this->getRelationshipsHtml(null, $product_id);
echo json_encode($response);
return;
}
// then add it, need to flip to/from
$table = JTable::getInstance('ProductRelations', 'TiendaTable');
$table->product_id_from = $product_to;
$table->product_id_to = $product_id;
$table->relation_type = $rtype;
$table->save();
break;
default:
$table = JTable::getInstance('ProductRelations', 'TiendaTable');
$table->product_id_from = $product_id;
$table->product_id_to = $product_to;
$table->relation_type = $relation_type;
$table->save();
break;
}
JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
$model = JModel::getInstance('ProductRelations', 'TiendaModel');
$model->clearCache();
$response['error'] = '0';
$response['msg'] = $this->getRelationshipsHtml(null, $product_id);
echo json_encode($response);
// Close the application.
JFactory::getApplication()->close();
}
示例11: getImageUrl
/**
* Get the URL to the path to images
* @return unknown_type
*/
function getImageUrl()
{
// Check where we should upload the file
// This is the default one
$dir = Tienda::getPath('products_images');
$url = Tienda::getUrl('products_images');
$helper = TiendaHelperBase::getInstance();
// is the image path overridden?
if (!empty($this->product_images_path) && $helper->checkDirectory($this->product_images_path, false)) {
$url = str_replace(JPATH_SITE . DS, JURI::root(), $this->product_images_path);
} else {
// try with the SKU
if (Tienda::getInstance()->get('sha1_images', '0')) {
if (!empty($this->product_sku)) {
$subdirs = $this->getSha1Subfolders($this->product_sku, '/');
$image_dir = $url . $subdirs . $this->product_sku . '/';
}
} else {
$image_dir = $url . $this->product_sku . '/';
}
// try with the SKU
if (!empty($this->product_sku)) {
$url = $image_dir;
} else {
if (Tienda::getInstance()->get('sha1_images', '0')) {
$subdirs = $this->getSha1Subfolders($this->product_id, '/');
$image_dir = $url . $subdirs . $this->product_id . '/';
} else {
$image_dir = $url . $this->product_id . '/';
}
$url = $image_dir;
}
}
return $url;
}
示例12: addProductToCompare
/**
* Adds an item to a User's Product Compare
* whether in the session or the db
*
*/
function addProductToCompare()
{
// saving the session id which will use to update the cart
$session = JFactory::getSession();
$userid = JFactory::getUser()->id;
// After login, session_id is changed by Joomla, so store this for reference
$session->set('old_sessionid', $session->getId());
$response = array();
$response['msg'] = '';
$response['error'] = '';
$product_id = JRequest::getVar('product_id');
$add = JRequest::getVar('add', 1);
//deleting product to compare
if (!$add) {
$db = JFactory::getDBO();
Tienda::load('TiendaQuery', 'library.query');
$query = new TiendaQuery();
$query->delete();
$query->from("#__tienda_productcompare");
$query->where("`product_id` = '{$product_id}' ");
$query->where("`session_id` = '" . $session->getId() . "' ");
$query->where("`user_id` = '{$userid}'");
$db->setQuery((string) $query);
if (!$db->query()) {
$response['msg'] = $helper->generateMessage($db->getErrorMsg());
$response['error'] = '1';
return false;
}
} else {
Tienda::load('TiendaHelperProductCompare', 'helpers.productcompare');
$compare_helper = new TiendaHelperProductCompare();
//check limit
$compareLimit = $compare_helper->checkLimit();
if (!$compareLimit) {
Tienda::load('TiendaHelperBase', 'helpers._base');
$helper = TiendaHelperBase::getInstance();
$limit = Tienda::getInstance()->get('compared_products', '5');
$response['msg'] = $helper->generateMessage(JText::sprintf("COM_TIENDA_ONLY_N_PRODUCTS_CAN_BE_ADDED_TO_COMPARE", $limit));
$response['error'] = '1';
echo json_encode($response);
return;
}
// create cart object out of item properties
$item = new JObject();
$item->user_id = $userid;
$item->product_id = (int) $product_id;
// add the item to the product comparison
$compare_item = $compare_helper->addItem($item);
}
//load user compared items
$model = $this->getModel($this->get('suffix'));
$model->setState('filter_user', $userid);
if (empty($user->id)) {
$model->setState('filter_session', $session->getId());
}
$items = $model->getList();
//TODO: make it to call a view
$response['msg'] .= '<ul>';
foreach ($items as $item) {
$table = JTable::getInstance('Products', 'TiendaTable');
$table->load(array('product_id' => $item->product_id));
$response['msg'] .= '<li>';
$response['msg'] .= '<a href="' . JRoute::_('index.php?option=com_tienda&view=products&task=view&id=' . $item->product_id) . '">';
$response['msg'] .= $table->product_name;
$response['msg'] .= '</a>';
$response['msg'] .= '</li>';
}
$response['msg'] .= '</ul>';
echo json_encode($response);
return;
}
示例13: _processSale
/**
* Processes the sale payment
*
* @param array $data IPN data
* @return boolean Did the IPN Validate?
* @access protected
*/
function _processSale($data, $ipnValidationFailed = '')
{
$send_email = false;
/*
* validate the payment data
*/
$errors = array();
if (!empty($ipnValidationFailed)) {
$errors[] = $ipnValidationFailed;
}
// is the recipient correct?
if (empty($data['receiver_email']) || $data['receiver_email'] != $this->_getParam('merchant_email')) {
$errors[] = JText::_('PAYPAL MESSAGE RECEIVER INVALID');
}
// load the orderpayment record and set some values
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
$orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
$orderpayment->load($data['custom']);
$orderpayment->transaction_details = $data['transaction_details'];
$orderpayment->transaction_id = $data['txn_id'];
$orderpayment->transaction_status = $data['payment_status'];
// check the stored amount against the payment amount
Tienda::load('TiendaHelperBase', 'helpers._base');
$stored_amount = TiendaHelperBase::number($orderpayment->get('orderpayment_amount'), array('thousands' => ''));
$respond_amount = TiendaHelperBase::number($data['mc_gross'], array('thousands' => ''));
if ($stored_amount != $respond_amount) {
$errors[] = JText::_('PAGSEGURO MESSAGE PAYMENT AMOUNT INVALID');
$errors[] = $stored_amount . " != " . $respond_amount;
}
// check the payment status
if (empty($data['payment_status']) || $data['payment_status'] != 'Completed' && $data['payment_status'] != 'Pending') {
$errors[] = JText::sprintf('PAYPAL MESSAGE STATUS INVALID', @$data['payment_status']);
}
// set the order's new status and update quantities if necessary
JLoader::import('com_tienda.helpers.order', JPATH_ADMINISTRATOR . '/components');
JLoader::import('com_tienda.helpers.carts', JPATH_ADMINISTRATOR . '/components');
$order = JTable::getInstance('Orders', 'TiendaTable');
$order->load($orderpayment->order_id);
if (count($errors)) {
// if an error occurred
$order->order_state_id = $this->params->get('failed_order_state', '10');
// FAILED
} elseif (@$data['payment_status'] == 'Pending') {
// if the transaction has the "pending" status,
$order->order_state_id = Tienda::getInstance('pending_order_state', '1');
// PENDING
// Update quantities for echeck payments
TiendaHelperOrder::updateProductQuantities($orderpayment->order_id, '-');
// remove items from cart
TiendaHelperCarts::removeOrderItems($orderpayment->order_id);
} else {
$order->order_state_id = $this->params->get('payment_received_order_state', '17');
// PAYMENT RECEIVED
// do post payment actions
$setOrderPaymentReceived = true;
// send email
$send_email = true;
}
// save the order
if (!$order->save()) {
$errors[] = $order->getError();
}
// save the orderpayment
if (!$orderpayment->save()) {
$errors[] = $orderpayment->getError();
}
if (!empty($setOrderPaymentReceived)) {
$this->setOrderPaymentReceived($orderpayment->order_id);
}
if ($send_email) {
// send notice of new order
Tienda::load("TiendaHelperBase", 'helpers._base');
$helper = TiendaHelperBase::getInstance('Email');
$model = Tienda::getClass("TiendaModelOrders", "models.orders");
$model->setId($orderpayment->order_id);
$order = $model->getItem();
$helper->sendEmailNotices($order, 'new_order');
}
return count($errors) ? implode("\n", $errors) : '';
}
示例14: _process
/**
*
* @return HTML
*/
function _process()
{
$send_email = false;
$data = JRequest::getVar('DATA', '', 'post');
// Invalidate data if it is in the wrong format
if (!preg_match(':^[a-zA-Z0-9]+$:', $data)) {
$data = '';
}
$this->os_info = $this->_getOperatingSystemInfo();
// set sips checkout type
// Next line is there to help me to debug
// should not be removed
//$data = '2020333732603028502c2360532d5328532d2360522d4360502c4360502c3334502c3330512d2324562d5334592c3324512c33242a2c2360532c2360502d2324502c23602a2c2360552c2360502d433c552e3328572c4048512c2334502c23605435444533303048502c2338502c2324542c4360512c2360582c4344502e3334582d233c2a2c3360532c2360502d4324512d3344502c5048512c2330502c2360582c4360512c2360582c43442a2c3360512c2360502c4360505c224324502c4360502c3360512c4340532c233c552e3330535c224324502c2360502c2338502d5334592d232c2a2c2328582c2360502c4639525c224360522e3360502c2329463c4048502c2340502c2360532e333c585c224324502d4360502c233c512c3324512b4360505c224324512d2360502c2338522c2324522c23242a2c2360592c2360502c4639525c224360532c2360502c4321413b26255438364c512c232160383651413d26254b2b4659453d6048502c3338502c23605334552d2c5c224360502d5360502c2328502c4048502c5340502c2360522e33382a2c2330502c2360512d2425353524412f34455d2330352134353529255c224360532e3360502c2324505c224324502e3360502c23292e335048512c3360502c236051334048512c3324502c2360522c23602a2c2328562c2360502d5344572d3344522d53282adc970880f8cf2717';
//
// Récupération de la variable cryptée DATA
$message = "message=" . $data;
$pathfile .= " pathfile=" . $this->_getPathfileFileName($this->params->get('pathfile'));
$bin_response = $this->_getBinPath("response");
$parm = $message . " " . $pathfile;
$result = exec("{$bin_response} {$parm}");
$sips_response_array = explode("!", $result);
list(, $code, $error, $merchant_id, $merchant_country, $amount, $transaction_id, $payment_means, $transmission_date, $payment_time, $payment_date, $response_code, $payment_certificate, $authorisation_id, $currency_code, $card_number, $cvv_flag, $cvv_response_code, $bank_response_code, $complementary_code, $complementary_info, $return_context, $caddie, $receipt_complement, $merchant_language, $language, $customer_id, $orderpayment_id, $customer_email, $customer_ip_address, $capture_day, $capture_mode, $data) = $sips_response_array;
if ($code != 0) {
$errors[] = JText::_('TIENDA_SIPS_RETURN_CODE_INVALID') . " " . $code;
} elseif ($error != 0) {
$errors[] = JText::_('TIENDA_SIPS_RETURN_ERROR') . " " . $sips_error;
} elseif ($merchant_id != $this->params->get('merchant_id')) {
$errors[] = JText::_('TIENDA_SIPS_MERCHANT_ID_RECEIVED_INVALID');
} else {
// load the orderpayment record and set some values
JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_tienda' . DS . 'tables');
$orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
$orderpayment->load($orderpayment_id);
if (empty($orderpayment_id) || empty($orderpayment->orderpayment_id)) {
$errors[] = JText::_('TIENDA_SIPS_INVALID ORDERPAYMENTID');
}
}
if (count($errors)) {
echo $errors;
print_r($errors);
$this->_sendErrorEmail($errors, $sips_response_array);
return false;
}
// check the stored amount against the payment amount
Tienda::load('TiendaHelperBase', 'helpers._base');
$stored_amount = TiendaHelperBase::number($orderpayment->get('orderpayment_amount'), array('thousands' => ''));
$respond_amount = TiendaHelperBase::number($amount, array('thousands' => ''));
if ($stored_amount != $respond_amount) {
$errors[] = JText::_('TIENDA_SIPS_AMOUNT_INVALID');
$errors[] = $stored_amount . " != " . $respond_amount;
}
// set the order's new status and update quantities if necessary
Tienda::load('TiendaHelperOrder', 'helpers.order');
Tienda::load('TiendaHelperCarts', 'helpers.carts');
$order = JTable::getInstance('Orders', 'TiendaTable');
$order->load($orderpayment->order_id);
if (count($errors) or $response_code != '00') {
if ($response_code != '00') {
$orderpayment->transaction_details = JText::_('TIENDA_SIPS_RESPONSE_CODE') . $response_code . "\n" . JText::_('TIENDA_SIPS_RESPONSE_CODE_SIPS_ERROR') . constant('TIENDA_SIPS_RESPONSE_' . $response['response_code']) . "\n" . JText::_('TIENDA_SIPS_READ_SIPS_DOCUMENTATION');
} else {
$orderpayment->transaction_details = implode(" ", $errors);
}
$order->order_state_id = $this->params->get('failed_order_state', '10');
// FAILED
// save the order
if (!$order->save()) {
$errors[] = $order->getError();
}
$send_email = false;
} else {
define($credit_card_type, $payment_means);
$credit_card = split('\\.', $card_number);
$credit_card_number = $credit_card[0] . ' #### #### ##' . $credit_card[1];
// TO DO: DECODE TIME AND DATE
$orderpayment->transaction_details = JText::_('TIENDA_SIPS_TRANSMISSION_DATE') . $transmission_date . "\n" . JText::_('TIENDA_SIPS_RESPONSE_PAYMENT_TIME') . " : " . $payment_time . "\n" . JText::_('TIENDA_SIPS_RESPONSE_PAYMENT_DATE') . " : " . $payment_date . "\n" . JText::_('TIENDA_SIPS_RESPONSE_PAYMENT_CERTIFICATE') . " : " . $payment_certificate . "\n" . JText::_('TIENDA_SIPS_RESPONSE_AUTHORIZATION_ID') . $authorisation_id . "\n" . JText::_('TIENDA_SIPS_RESPONSE_CREDIT_CARD_TYPE') . " : " . constant($credit_card_type) . "\n" . JText::_('TIENDA_SIPS_RESPONSE_CREDIT_CARD_NUMBER') . " : " . $credit_card_number;
$orderpayment->transaction_id = $transaction_id;
$orderpayment->transaction_status = $response_code;
// ???
$order->order_state_id = $this->params->get('payment_received_order_state', '17');
// save the order
if (!$order->save()) {
$errors[] = $order->getError();
}
// PAYMENT RECEIVED
$this->setOrderPaymentReceived($orderpayment->order_id);
// send email
$send_email = true;
}
// save the orderpayment
if (!$orderpayment->save()) {
$errors[] = $orderpayment->getError();
}
if ($send_email) {
// send notice of new order
Tienda::load("TiendaHelperBase", 'helpers._base');
$helper = TiendaHelperBase::getInstance('Email');
//.........这里部分代码省略.........
示例15: checkPassword2
/**
* Checks that a password and password2 match
* @return unknown_type
*/
function checkPassword2()
{
Tienda::load('TiendaHelperBase', 'helpers._base');
$helper = TiendaHelperBase::getInstance();
$response = array();
$response['msg'] = '';
$response['error'] = '';
// get elements from post
$elements = json_decode(preg_replace('/[\\n\\r]+/', '\\n', JRequest::getVar('elements', '', 'post', 'string', 'string')));
// convert elements to array that can be binded
$values = TiendaHelperBase::elementsToArray($elements);
$password = $values['password'];
$password2 = $values['password2'];
if (empty($password)) {
$response['msg'] = $helper->validationMessage("COM_TIENDA_PASSWORD_CANNOT_BE_EMPTY", 'fail');
$response['error'] = '1';
echo json_encode($response);
return;
}
if (empty($password2)) {
$response['msg'] = $helper->validationMessage("COM_TIENDA_PASSWORD_VERIFY_CANNOT_BE_EMPTY", 'fail');
$response['error'] = '1';
echo json_encode($response);
return;
}
$message = "";
if ($password != $password2) {
$message .= $helper->validationMessage('COM_TIENDA_PASSWORD_DO_NOT_MATCH', 'fail');
} else {
// no error
$message .= $helper->validationMessage('COM_TIENDA_PASSWORD_VALID', 'success');
}
$response['msg'] = $message;
$response['error'] = '1';
echo json_encode($response);
return;
}