/**
  * Post process functionalities.
  *
  * @return 	this
  */
 public function postProcess()
 {
     // get session id
     $session = Tools::getValue('session');
     // if session is not valid
     if (!$session || !isset($session)) {
         Tools::redirect('/');
     }
     // get checkmeout configuration
     $configuration = unserialize(Configuration::get('CHECKMEOUT'));
     // redirect if configuration is not valid
     if (!isset($configuration['CHECKMEOUT_API_TOKEN'], $configuration['CHECKMEOUT_API_SECRET'], $configuration['CHECKMEOUT_REFERENCE'])) {
         Tools::redirect('/');
     }
     // get the token
     $token = $configuration['CHECKMEOUT_API_TOKEN'];
     // get the secret
     $secret = $configuration['CHECKMEOUT_API_SECRET'];
     // initialize base class
     $checkmeout = new CheckMeOutBase($token, $secret);
     // get checkout details
     $details = $checkmeout->getCheckoutDetails($session);
     // get the payment method
     $method = strtoupper($details['transaction_method']);
     // case what status should we used
     $status = Configuration::get('PS_OS_PREPARATION');
     // if method is asiapay
     if ($method == 'ASIAPAY' || $method == 'PAYPAL') {
         $status = Configuration::get('PS_OS_PAYMENT');
     }
     // get cart object
     $cart = $this->context->cart;
     // get customer object
     $customer = new Customer($cart->id_customer);
     // get currency object
     $currency = $this->context->currency;
     // get total cart valie
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     // additional email variables
     $mailVars = array();
     // if cart address is not set, it means this
     // customer is newly registered
     if (is_null($details['address_index']) || !isset($details['address_index']) || empty($details['address_index'])) {
         // create the address
         $address = $this->createAddress($cart, $customer, $details);
         // set delivery address
         $cart->id_address_delivery = $address['id_address'];
         // set invoice address
         $cart->id_address_invoice = $address['id_address'];
     } else {
         // get the address
         $address = $this->updateAddress($cart, $customer, $details);
         // set delivery address
         $cart->id_address_delivery = $address['id_address'];
         // set invoice address
         $cart->id_address_invoice = $address['id_address'];
     }
     // save and validate order
     $this->module->validateOrder($cart->id, $status, $total, $this->module->displayName . '-' . $method, NULL, $mailVars, (int) $currency->id, false, $customer->secure_key);
     // redirect to order confirmation
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key . '&session=' . $session);
 }