/**
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     $cart = $this->context->cart;
     $veritranspay = new VeritransPay();
     $keys = $veritranspay->execValidation($cart);
     // if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active)
     //  Tools::redirect('index.php?controller=order&step=1');
     // // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     // $authorized = false;
     // foreach (Module::getPaymentModules() as $module)
     //  if ($module['name'] == 'veritranspay')
     //  {
     //    $authorized = true;
     //    break;
     //  }
     // if (!$authorized)
     //  die($this->module->l('This payment method is not available.', 'validation'));
     // $customer = new Customer($cart->id_customer);
     //   if (!Validate::isLoadedObject($customer))
     //    Tools::redirect('index.php?controller=order&step=1');
     //    $usd = Configuration::get('VT_KURS');
     //   $cf = Configuration::get('VT_CONVENIENCE_FEE') * 0.01;
     //   $veritrans = new Veritrans();
     //   $url = Veritrans_Config::PAYMENT_REDIRECT_URL;
     //   $shipping_cost = $cart->getTotalShippingCost();
     //   $currency = $this->context->currency;
     //   $total = $cart->getOrderTotal(true, Cart::BOTH);
     //   $mailVars = array(
     //    '{merchant_id}' => Configuration::get('MERCHANT_ID'),
     //    '{merchant_hash}' => nl2br(Configuration::get('MERCHANT_HASH'))
     //   );
     //   $billing_address = new Address($cart->id_address_invoice);
     //   $delivery_address = new Address($cart->id_address_delivery);
     //   $veritrans->version = Configuration::get('VT_API_VERSION');
     //   $veritrans->environment = Configuration::get('VT_ENVIRONMENT');
     //   $veritrans->payment_type = Configuration::get('VT_PAYMENT_TYPE') == 'vtdirect' ? Veritrans_Config::VT_DIRECT : Veritrans_Config::VT_WEB;
     //   $veritrans->merchant_id = Configuration::get('VT_MERCHANT_ID');
     //   $veritrans->merchant_hash_key = Configuration::get('VT_MERCHANT_HASH');
     //   $veritrans->client_key = Configuration::get('VT_CLIENT_KEY');
     //   $veritrans->server_key = Configuration::get('VT_SERVER_KEY');
     //   $veritrans->enable_3d_secure = Configuration::get('VT_3D_SECURE');
     //   $veritrans->force_sanitization = true;
     //   // Billing Address
     //   $veritrans->first_name = $billing_address->firstname;
     //   $veritrans->last_name = $billing_address->lastname;
     //   $veritrans->address1 = $billing_address->address1;
     //   $veritrans->address2 = $billing_address->address2;
     //   $veritrans->city = $billing_address->city;
     //   $veritrans->country_code = $billing_address->id_country;
     //   $veritrans->postal_code = $billing_address->postcode;
     //   $veritrans->phone = $billing_address->phone_mobile;
     //   $veritrans->email = $customer->email;
     //   if($this->context->cart->isVirtualCart()) {
     //    $veritrans->required_shipping_address = 0;
     //    $veritrans->billing_different_with_shipping = 0;
     //   } else {
     //    $veritrans->required_shipping_address = 1;
     //    if ($cart->id_address_delivery != $cart->id_address_invoice)
     //    {
     //      $veritrans->billing_different_with_shipping = 1;
     //      $veritrans->shipping_first_name = $delivery_address->firstname;
     //      $veritrans->shipping_last_name = $delivery_address->lastname;
     //      $veritrans->shipping_address1 = $delivery_address->address1;
     //      $veritrans->shipping_address2 = $delivery_address->address2;
     //      $veritrans->shipping_city = $delivery_address->city;
     //      $veritrans->shipping_country_code = $delivery_address->id_country;
     //      $veritrans->shipping_postal_code = $delivery_address->postcode;
     //      $veritrans->shipping_phone = $delivery_address->phone_mobile;
     //    } else
     //    {
     //      $veritrans->billing_different_with_shipping = 0;
     //    }
     //   }
     //   $items = $this->addCommodities($cart, $shipping_cost, $usd);
     //   // convert the currency
     //   $cart_currency = new Currency($cart->id_currency);
     //   if ($cart_currency->iso_code != 'IDR')
     //   {
     //    // check whether if the IDR is installed or not
     //    if (Currency::exists('IDR', null))
     //    {
     //      // use default rate
     //      $conversion_func = function($input) use($cart_currency) { return Tools::convertPriceFull($input, $cart_currency, new Currency(Currency::getIdByIsoCode('IDR'))); };
     //    } else
     //    {
     //      // use rate
     //      $conversion_func = function($input) { return $input * intval(Configuration::get('VT_KURS')); };
     //    }
     //    foreach ($items as &$item) {
     //      $item['price'] = intval(round(call_user_func($conversion_func, $item['price'])));
     //    }
     //   }
     //   $veritrans->items = $items;
     //   $this->module->validateOrder($cart->id, Configuration::get('VT_ORDER_STATE_ID'), $cart->getOrderTotal(true, Cart::BOTH), $this->module->displayName, NULL, $mailVars, (int)$currency->id, false, $customer->secure_key);
     //   $veritrans->order_id = $this->module->currentOrder;
     $veritrans_api_version = Configuration::get('VT_API_VERSION');
     $veritrans_payment_method = Configuration::get('VT_PAYMENT_TYPE');
     if (array_key_exists('errors', $keys)) {
         if ($keys['errors']) {
             var_dump($keys['errors']);
             exit;
         }
     }
     if ($veritrans_api_version == 2 && $veritrans_payment_method == 'vtweb') {
         if ($keys['isWarning']) {
             Tools::redirectLink('index.php?fc=module&module=veritranspay&controller=warning&redirlink=' . $keys['redirect_url'] . '&message=' . $keys['message']);
         }
         Tools::redirectLink($keys['redirect_url']);
     } else {
         if ($veritrans_api_version == 2 && $veritrans_payment_method == 'vtdirect') {
         }
     }
 }
<?php

$useSSL = true;
$root_dir = str_replace('modules/veritranspay', '', dirname($_SERVER['SCRIPT_FILENAME']));
include_once $root_dir . '/config/config.inc.php';
$controller = new FrontController();
if (Tools::usingSecureMode()) {
    $useSSL = $controller->ssl = true;
}
$controller->init();
include_once $root_dir . '/modules/veritranspay/veritranspay.php';
if (!$cookie->isLogged(true)) {
    Tools::redirect('authentication.php?back=order.php');
} elseif (!Customer::getAddressesTotalById((int) $cookie->id_customer)) {
    Tools::redirect('address.php?back=order.php?step=1');
}
$veritransPay = new VeritransPay();
$keys = $veritransPay->execValidation($cart);
$veritrans_api_version = Configuration::get('VT_API_VERSION');
$veritrans_payment_method = Configuration::get('VT_PAYMENT_TYPE');
if ($keys['errors']) {
    var_dump($keys['errors']);
    exit;
} else {
    if ($veritrans_api_version == 2 && $veritrans_payment_method == 'vtweb') {
        Tools::redirectLink($keys['redirect_url']);
    } else {
        if ($veritrans_api_version == 2 && $veritrans_payment_method == 'vtdirect') {
        }
    }
}