コード例 #1
0
ファイル: payment.php プロジェクト: kosmosby/medicine-prof
 function getOrder($where = array(), $type = 'array')
 {
     $order = new osePaymentOrder();
     return $order->getOrder($where, $type);
 }
コード例 #2
0
	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);
	}