OpenCart 🇺🇦

Схема

public mixed inbound ( )

Аргументы

Аргумент Возможный тип Описание
У метода нет аргументов

Описание

Метод пока еще не документирован.

Исходный код

$encrypted      = $this->request->post;
$secret         = $this->config->get('openbaypro_secret');
$active         = $this->config->get('openbay_status');
$s1             = $this->config->get('openbaypro_string1');
$s2             = $this->config->get('openbaypro_string2');

$this->load->model('openbay/ebay_openbay');
$this->load->model('openbay/ebay_product');
$this->load->model('openbay/ebay_order');

if(empty($encrypted)) {
	$this->response->setOutput(json_encode(array('msg' => 'error 002')));
} else {
	$token  = $this->openbay->ebay->pbkdf2($s1, $s2, 1000, 32);
	$data   = $this->openbay->ebay->decrypt($encrypted['data'],$token, true);

	if($secret == $data['secret'] && $active == 1) {
		if($data['action'] == 'ItemUnsold') {
			$this->openbay->ebay->log('Action: Unsold Item');
			$product_id = $this->openbay->ebay->getProductId($data['itemId']);

			if($product_id != false) {
				$this->openbay->ebay->log('eBay item link found with internal product');
				$rules = $this->model_openbay_ebay_product->getRelistRule($data['itemId']);

				if(!empty($rules)) {
					$this->openbay->ebay->log('Item is due to be automatically relisted');
					$this->db->query("INSERT INTO `" . DB_PREFIX . "ebay_listing_pending` SET `ebay_item_id` = '".$this->db->escape($data['itemId'])."', `product_id` = '".(int)$product_id."', `key` = '".$this->db->escape($data['key'])."'");
					$this->openbay->ebay->removeItemByItemId($data['itemId']);
				} else {
					$this->openbay->ebay->log('No automation rule set');
					$this->openbay->ebay->removeItemByItemId($data['itemId']);
				}
			}

			$this->response->setOutput(json_encode(array('msg' => 'ok')));
		}

		if($data['action'] == 'ItemListed') {
			$this->openbay->ebay->log('Action: Listed Item');

			$product_id = $this->openbay->ebay->getProductIdFromKey($data['key']);

			if($product_id != false) {
				$this->openbay->ebay->createLink($product_id, $data['itemId'], '');
				$this->db->query("DELETE FROM `" . DB_PREFIX . "ebay_listing_pending` WHERE `key` = '".$data['key']."' LIMIT 1");
				$this->openbay->ebay->log('A link was found with product id: '.$product_id.', item id: '.$data['itemId'].' and key: '.$data['key']);
			} else {
				$this->openbay->ebay->log('No link found to previous item');
			}

			$this->response->setOutput(json_encode(array('msg' => 'ok')));
		}

		if($data['action'] == 'newOrder') {
			$this->openbay->ebay->log('Action: newOrder / Order data from polling');
			$this->model_openbay_ebay_openbay->importOrders($data['data2']);
			$this->response->setOutput(json_encode(array('msg' => 'ok')));
		}

		if($data['action'] == 'notificationOrder') {
			$this->openbay->ebay->log('Action: notificationOrder / Order data from notification');
			$this->model_openbay_ebay_openbay->importOrders($data['data']);
			$this->response->setOutput(json_encode(array('msg' => 'ok')));
		}

		if($data['action'] == 'outputLog') {
			$this->model_openbay_ebay_openbay->outputLog();
		}

		if($data['action'] == 'updateLog') {
			$this->model_openbay_ebay_openbay->updateLog();
		}
	} else {
		$this->openbay->ebay->log('Secret incorrect or module not active.');
		$this->response->setOutput(json_encode(array('msg' => 'error 001')));
	}
}