/**
  * Init the configuration array.
  *
  * Note: If you want a configuration value that don't need to be saved
  * in the database (like available currencies), setup it in here.
  */
 private function _loadConfiguration()
 {
     $config = array();
     foreach ($this->defaults as $key => $value) {
         $config[$key] = Configuration::get($key);
     }
     $config = $this->_validateConfiguration($config);
     //DO NOT TOUCH THIS LINE HERE
     $config['EVERYPAY_ACCEPTED_CURRENCIES'] = array('EUR');
     $config['EVERYPAY_EXPIRATION_SECONDS'] = 10 * 60;
     //5 minutes
     if ($this->live_mode) {
         $this->pk = $config['EVERYPAY_PUBLIC_KEY'];
         $this->sk = $config['EVERYPAY_SECRET_KEY'];
     } else {
         Everypay\Everypay::$isTest = true;
         $this->pk = $config['EVERYPAY_TEST_PUBLIC_KEY'];
         $this->sk = $config['EVERYPAY_TEST_SECRET_KEY'];
     }
     //General smarty variables
     $generalSmarty = array('EVERYPAY_CUSTOMER_MODE' => $config['EVERYPAY_CUSTOMER_MODE'], 'EVERYPAY_BUTTON_MODE' => $config['EVERYPAY_BUTTON_MODE'], 'EVERYPAY_MODULE_NAME' => $this->name, 'EVERYPAY_LIVE_MODE' => $this->live_mode, 'EVERYPAY_PUBLIC_KEY' => $this->pk, 'EVERYPAY_TEMPLATE_DIR' => isset($module_template_dir) && !empty($module_template_dir) ? $module_template_dir : _MODULE_DIR_ . $this->name . '/');
     $config['EVERYPAY_LIVE_MODE'] = $this->live_mode;
     Context::getContext()->smarty->assign($generalSmarty);
     $this->configuration = $config;
     return $config;
 }
 function plgVmConfirmedOrder(VirtueMartCart $cart, $order)
 {
     if (!($this->_currentMethod = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return null;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
         return FALSE;
     }
     $session = JFactory::getSession();
     $return_context = $session->getId();
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['virtuemart_order_id'] = $order['details']['BT']->virtuemart_order_id;
     $dbValues['payment_method_id'] = $order['details']['BT']->virtuemart_paymentmethod_id;
     $dbValues['return_context'] = $return_context;
     $dbValues['payment_name'] = parent::renderPluginName($this->_currentMethod);
     $dbValues['cost_per_transaction'] = $this->_currentMethod->cost_per_transaction;
     $dbValues['cost_percent_total'] = $this->_currentMethod->cost_percent_total;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['payment_currency'] = $payment_currency_id;
     $this->debugLog("before store", "plgVmConfirmedOrder", 'debug');
     if ($this->_currentMethod->sandbox) {
         Everypay\Everypay::$isTest = true;
     }
     Everypay\Everypay::setApiKey($this->getSecretKey());
     $token = $this->getToken();
     $response = Everypay\Payment::create(array('token' => $token, 'description' => 'Order #' . $order['details']['BT']->order_number));
     if (isset($response->error)) {
         $new_status = $this->_currentMethod->payment_declined_status;
         $this->_handlePaymentCancel($order['details']['BT']->virtuemart_order_id, $html);
         return;
         // will not process the order
     }
     $dbValues['everypay_response_token'] = $response->token;
     $dbValues['everypay_response_description'] = $response->description;
     $dbValues['everypay_response_status'] = $response->status;
     $dbValues['everypay_response_last_four'] = $response->last_four;
     $dbValues['everypay_response_holder_name'] = $response->holder_name;
     $dbValues['payment_order_total'] = number_format($response->amount / 100, 2);
     $this->storePSPluginInternalData($dbValues);
     $cart->emptyCart();
     $session = JFactory::getSession();
     $session->clear('everypay_token', 'vm');
 }