shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

liqpay.php (2345B)


      1 <?php
      2 class ControllerExtensionPaymentLiqPay extends Controller {
      3 	public function index() {
      4 		$data['button_confirm'] = $this->language->get('button_confirm');
      5 
      6 		$this->load->model('checkout/order');
      7 
      8 		$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
      9 
     10 		$data['action'] = 'https://liqpay.com/?do=clickNbuy';
     11 
     12 		$xml  = '<request>';
     13 		$xml .= '	<version>1.2</version>';
     14 		$xml .= '	<result_url>' . $this->url->link('checkout/success', '', true) . '</result_url>';
     15 		$xml .= '	<server_url>' . $this->url->link('extension/payment/liqpay/callback', '', true) . '</server_url>';
     16 		$xml .= '	<merchant_id>' . $this->config->get('payment_liqpay_merchant') . '</merchant_id>';
     17 		$xml .= '	<order_id>' . $this->session->data['order_id'] . '</order_id>';
     18 		$xml .= '	<amount>' . $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false) . '</amount>';
     19 		$xml .= '	<currency>' . $order_info['currency_code'] . '</currency>';
     20 		$xml .= '	<description>' . $this->config->get('config_name') . ' ' . $order_info['payment_firstname'] . ' ' . $order_info['payment_address_1'] . ' ' . $order_info['payment_address_2'] . ' ' . $order_info['payment_city'] . ' ' . $order_info['email'] . '</description>';
     21 		$xml .= '	<default_phone></default_phone>';
     22 		$xml .= '	<pay_way>' . $this->config->get('payment_liqpay_type') . '</pay_way>';
     23 		$xml .= '</request>';
     24 
     25 		$data['xml'] = base64_encode($xml);
     26 		$data['signature'] = base64_encode(sha1($this->config->get('payment_liqpay_signature') . $xml . $this->config->get('payment_liqpay_signature'), true));
     27 
     28 		return $this->load->view('extension/payment/liqpay', $data);
     29 	}
     30 
     31 	public function callback() {
     32 		$xml = base64_decode($this->request->post['operation_xml']);
     33 		$signature = base64_encode(sha1($this->config->get('payment_liqpay_signature') . $xml . $this->config->get('payment_liqpay_signature'), true));
     34 
     35 		$posleft = strpos($xml, 'order_id');
     36 		$posright = strpos($xml, '/order_id');
     37 
     38 		$order_id = substr($xml, $posleft + 9, $posright - $posleft - 10);
     39 
     40 		if ($signature == $this->request->post['signature']) {
     41 			$this->load->model('checkout/order');
     42 
     43 			$this->model_checkout_order->addOrderHistory($order_id, $this->config->get('config_order_status_id'));
     44 		}
     45 	}
     46 }