OpenCart 🇺🇦

Метод ControllerPaymentAmazonCheckout::uploadOrderAdjustment(...)

Схема

public mixed uploadOrderAdjustment ( )

Аргументы

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

Описание

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

Исходный код

$this->language->load('payment/amazon_checkout');

$json = array();

if (!empty($this->request->files['file']['name'])) {
	$filename = basename(html_entity_decode($this->request->files['file']['name'], ENT_QUOTES, 'UTF-8'));

	if ($this->request->files['file']['error'] != UPLOAD_ERR_OK) {
		$json['error'] = $this->language->get('error_upload');
	}
} else {
	$json['error'] = $this->language->get('error_upload');
}

if (!isset($json['error'])) {
	if (is_uploaded_file($this->request->files['file']['tmp_name']) && file_exists($this->request->files['file']['tmp_name'])) {
		$flat = str_replace(",", "\t", file_get_contents($this->request->files['file']['tmp_name']));

		$this->load->library('cba');

		$cba = new CBA($this->config->get('amazon_checkout_merchant_id'), $this->config->get('amazon_checkout_access_key'),
				$this->config->get('amazon_checkout_access_secret'));

		$response = $cba->orderAdjustment($flat);

		$response_xml = simplexml_load_string($response);
		$submission_id = (string)$response_xml->SubmitFeedResult->FeedSubmissionInfo->FeedSubmissionId;

		if (!empty($submission_id)) {
			$json['success'] = $this->language->get('text_upload_success');
			$json['submission_id'] = $submission_id;
		}
	}
}

$this->response->setOutput(json_encode($json));