OpenCart 🇺🇦

Метод ModelPaymentPPExpress::paymentRequestInfo(...)

Схема

public mixed paymentRequestInfo ( )

Аргументы

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

Описание

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

Исходный код

$data['PAYMENTREQUEST_0_SHIPPINGAMT'] = '';
$data['PAYMENTREQUEST_0_CURRENCYCODE'] = $this->currency->getCode();
$data['PAYMENTREQUEST_0_PAYMENTACTION'] = $this->config->get('pp_express_method');

$i = 0;
$item_total = 0;

foreach ($this->cart->getProducts() as $item) {
	$data['L_PAYMENTREQUEST_0_DESC' . $i] = '';

	$option_count = 0;
	foreach ($item['option'] as $option) {
		if ($option['type'] != 'file') {
			$value = $option['option_value'];
		} else {
			$filename = $this->encryption->decrypt($option['option_value']);
			$value = utf8_substr($filename, 0, utf8_strrpos($filename, '.'));
		}

		$data['L_PAYMENTREQUEST_0_DESC' . $i] .= ($option_count > 0 ? ', ' : '') . $option['name'] . ':' . (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value);

		$option_count++;
	}

	$data['L_PAYMENTREQUEST_0_DESC' . $i] = substr($data['L_PAYMENTREQUEST_0_DESC' . $i], 0, 126);

	$item_price = $this->currency->format($item['price'], false, false, false);

	$data['L_PAYMENTREQUEST_0_NAME' . $i] = $item['name'];
	$data['L_PAYMENTREQUEST_0_NUMBER' . $i] = $item['model'];
	$data['L_PAYMENTREQUEST_0_AMT' . $i] = $item_price;
	$item_total += number_format($item_price * $item['quantity'], 2);
	$data['L_PAYMENTREQUEST_0_QTY' . $i] = $item['quantity'];

	$data['L_PAYMENTREQUEST_0_ITEMURL' . $i] = $this->url->link('product/product', 'product_id=' . $item['product_id']);

	if ($this->config->get('config_cart_weight')) {
		$weight = $this->weight->convert($item['weight'], $item['weight_class_id'], $this->config->get('config_weight_class_id'));
		$data['L_PAYMENTREQUEST_0_ITEMWEIGHTVALUE' . $i] = number_format($weight / $item['quantity'], 2);
		$data['L_PAYMENTREQUEST_0_ITEMWEIGHTUNIT' . $i] = $this->weight->getUnit($this->config->get('config_weight_class_id'));
	}

	if ($item['length'] > 0 || $item['width'] > 0 || $item['height'] > 0) {
		$unit = $this->length->getUnit($item['length_class_id']);
		$data['L_PAYMENTREQUEST_0_ITEMLENGTHVALUE' . $i] = $item['length'];
		$data['L_PAYMENTREQUEST_0_ITEMLENGTHUNIT' . $i] = $unit;
		$data['L_PAYMENTREQUEST_0_ITEMWIDTHVALUE' . $i] = $item['width'];
		$data['L_PAYMENTREQUEST_0_ITEMWIDTHUNIT' . $i] = $unit;
		$data['L_PAYMENTREQUEST_0_ITEMHEIGHTVALUE' . $i] = $item['height'];
		$data['L_PAYMENTREQUEST_0_ITEMHEIGHTUNIT' . $i] = $unit;
	}

	$i++;
}

if (!empty($this->session->data['vouchers'])) {
	foreach ($this->session->data['vouchers'] as $voucher) {
		$item_total += $this->currency->format($voucher['amount'], false, false, false);;

		$data['L_PAYMENTREQUEST_0_DESC' . $i] = '';
		$data['L_PAYMENTREQUEST_0_NAME' . $i] = $voucher['description'];
		$data['L_PAYMENTREQUEST_0_NUMBER' . $i] = 'VOUCHER';
		$data['L_PAYMENTREQUEST_0_QTY' . $i] = 1;
		$data['L_PAYMENTREQUEST_0_AMT' . $i] = $this->currency->format($voucher['amount'], false, false, false);
		$i++;
	}
}

// Totals
$this->load->model('setting/extension');

$total_data = array();
$total = 0;
$taxes = $this->cart->getTaxes();

// Display prices
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
	$sort_order = array();

	$results = $this->model_setting_extension->getExtensions('total');

	foreach ($results as $key => $value) {
		$sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
	}

	array_multisort($sort_order, SORT_ASC, $results);

	foreach ($results as $result) {
		if ($this->config->get($result['code'] . '_status')) {
			$this->load->model('total/' . $result['code']);

			$this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
		}

		$sort_order = array();

		foreach ($total_data as $key => $value) {
			$sort_order[$key] = $value['sort_order'];
		}

		array_multisort($sort_order, SORT_ASC, $total_data);
	}
}

foreach ($total_data as $total_row) {
	if (!in_array($total_row['code'], array('total', 'sub_total'))) {
		if ($total_row['value'] != 0) {
			$item_price = $this->currency->format($total_row['value'], false, false, false);
			$data['L_PAYMENTREQUEST_0_NUMBER' . $i] = $total_row['code'];
			$data['L_PAYMENTREQUEST_0_NAME' . $i] = $total_row['title'];
			$data['L_PAYMENTREQUEST_0_AMT' . $i] = $this->currency->format($total_row['value'], false, false, false);
			$data['L_PAYMENTREQUEST_0_QTY' . $i] = 1;
			$item_total = number_format($item_total + $item_price, 2);
			$i++;
		}
	}
}

$data['PAYMENTREQUEST_0_ITEMAMT'] = number_format($item_total, 2, '.', '');
$data['PAYMENTREQUEST_0_AMT'] = number_format($item_total, 2, '.', '');

$z = 0;

$recurring_products = $this->cart->getRecurringProducts();
if(!empty($recurring_products)) {

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

	foreach($recurring_products as $item) {
		$data['L_BILLINGTYPE' . $z] = 'RecurringPayments';

		if($item['recurring_trial'] == 1) {
			$trial_amt = $this->currency->format($this->tax->calculate($item['recurring_trial_price'], $item['tax_class_id'], $this->config->get('config_tax')), false, false, false) * $item['quantity'].' '.$this->currency->getCode();
			$trial_text =  sprintf($this->language->get('text_trial'), $trial_amt, $item['recurring_trial_cycle'], $item['recurring_trial_frequency'], $item['recurring_trial_duration']);
		} else {
			$trial_text = '';
		}

		$recurring_amt = $this->currency->format($this->tax->calculate($item['recurring_price'], $item['tax_class_id'], $this->config->get('config_tax')), false, false, false)  * $item['quantity'].' '.$this->currency->getCode();
		$recurring_description = $trial_text . sprintf($this->language->get('text_recurring'), $recurring_amt, $item['recurring_cycle'], $item['recurring_frequency']);

		if($item['recurring_duration'] > 0) {
			$recurring_description .= sprintf($this->language->get('text_length'), $item['recurring_duration']);
		}

		$data['L_BILLINGAGREEMENTDESCRIPTION' . $z] = $recurring_description;
		$z++;
	}
}

return $data;