shop.balmet.com

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

pp_braintree_button.php (2337B)


      1 <?php
      2 class ControllerExtensionModulePPBraintreeButton extends Controller {
      3 	private $gateway = null;
      4 
      5 	public function index() {
      6 		if ($this->config->get('payment_pp_braintree_status') == 1) {
      7 			$this->initialise();
      8 
      9 			$status = true;
     10 
     11 			if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout')) || (!$this->customer->isLogged() && ($this->cart->hasRecurringProducts() || $this->cart->hasDownload()))) {
     12 				$status = false;
     13 			}
     14 
     15 			if ($status) {
     16 				$this->load->model('checkout/order');
     17 				$this->load->model('extension/payment/pp_braintree');
     18 
     19 				$create_token = array();
     20 
     21 				$data['client_token'] = $this->model_extension_payment_pp_braintree->generateToken($this->gateway, $create_token);
     22 
     23 				$data['payment_pp_braintree_settlement_immediate'] = $this->config->get('payment_pp_braintree_settlement_immediate');
     24 				$data['payment_pp_braintree_paypal_button_colour'] = $this->config->get('payment_pp_braintree_paypal_button_colour');
     25 				$data['payment_pp_braintree_paypal_button_size'] = $this->config->get('payment_pp_braintree_paypal_button_size');
     26 				$data['payment_pp_braintree_paypal_button_shape'] = $this->config->get('payment_pp_braintree_paypal_button_shape');
     27 
     28 				/*
     29 				 * The auth total is just a guess as to what the end total will be since the user has not
     30 				 * selected a shipping option yet. The user does not see this amount during checkout but the figure
     31 				 * may be too low if buying a low value item and shipping is more than 50% of the item value.
     32 				 */
     33 				$data['auth_total'] = $this->cart->getTotal() * 1.5;
     34 				$data['currency_code'] = $this->session->data['currency'];
     35 				$data['action'] = $this->url->link('extension/payment/pp_braintree/expressConfirm', '', true);
     36 
     37 				return $this->load->view('extension/module/pp_braintree_button', $data);
     38 			}
     39 		}
     40 	}
     41 
     42 	private function initialise() {
     43 		$this->load->model('extension/payment/pp_braintree');
     44 
     45 		if ($this->config->get('payment_pp_braintree_access_token') != '') {
     46 			$this->gateway = $this->model_extension_payment_pp_braintree->setGateway($this->config->get('payment_pp_braintree_access_token'));
     47 		} else {
     48 			$this->model_extension_payment_pp_braintree->setCredentials();
     49 		}
     50 	}
     51 }