OpenCart 🇺🇦

Схема

public mixed checkout ( )

Аргументы

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

Описание

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

Исходный код

if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) {
	$this->redirect($this->url->link('checkout/cart'));
}

$this->load->model('payment/pp_express');
$this->load->model('tool/image');
$this->load->model('checkout/order');

$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);

$max_amount = $this->currency->convert($order_info['total'], $this->config->get('config_currency'), 'USD');
$max_amount = min($max_amount * 1.25, 10000);
$max_amount = $this->currency->format($max_amount, $this->currency->getCode(), '', false);

$data = array(
	'METHOD' => 'SetExpressCheckout',
	'MAXAMT' => $max_amount,
	'RETURNURL' => $this->url->link('payment/pp_express/checkoutReturn', '', 'SSL'),
	'CANCELURL' => $this->url->link('checkout/checkout', '', 'SSL'),
	'REQCONFIRMSHIPPING' => 0,
	'NOSHIPPING' => 1,
	'LOCALECODE' => 'EN',
	'LANDINGPAGE' => 'Login',
	'HDRIMG' => $this->model_tool_image->resize($this->config->get('pp_express_logo'), 790, 90),
	'HDRBORDERCOLOR' => $this->config->get('pp_express_border_colour'),
	'HDRBACKCOLOR' => $this->config->get('pp_express_header_colour'),
	'PAYFLOWCOLOR' => $this->config->get('pp_express_page_colour'),
	'CHANNELTYPE' => 'Merchant',
	'ALLOWNOTE' => $this->config->get('pp_express_allow_note'),
);

$data = array_merge($data, $this->model_payment_pp_express->paymentRequestInfo());

$result = $this->model_payment_pp_express->call($data);

/**
 * If a failed PayPal setup happens, handle it.
 */
if(!isset($result['TOKEN'])) {
	$this->session->data['error'] = $result['L_LONGMESSAGE0'];
	/**
	 * Unable to add error message to user as the session errors/success are not
	 * used on the cart or checkout pages - need to be added?
	 * If PayPal debug log is off then still log error to normal error log.
	 */
	if($this->config->get('pp_express_debug') == 0) {
		$this->log->write(serialize($result));
	}

	$this->redirect($this->url->link('checkout/checkout', '', 'SSL'));
}

$this->session->data['paypal']['token'] = $result['TOKEN'];

if ($this->config->get('pp_express_test') == 1) {
	header('Location: https://www.sandbox.paypal.com/cgi‑bin/webscr?cmd=_express-checkout&token=' . $result['TOKEN'].'&useraction=commit');
} else {
	header('Location: https://www.paypal.com/cgi‑bin/webscr?cmd=_express-checkout&token=' . $result['TOKEN'].'&useraction=commit');
}