コード例 #1
0
 public static function getApiData($cart = null, $cardtoken = null, $context = null, $cartUseExistingToken = 0)
 {
     $hipay = new HiPay_Tpp();
     if (!$context) {
         $context = Context::getContext();
     }
     // Basic check for security
     // If no currency for the cart, redirect to first order step
     if (!$hipay->checkCurrency($cart)) {
         Tools::redirect('index.php?controller=order&xer=3');
     }
     $language = HipayClass::getLanguageCode($context->language->iso_code);
     // Retrieving Currency
     $currency_array = $hipay->getCurrency((int) $cart->id_currency);
     $currency = $currency_array[0]['iso_code'];
     foreach ($currency_array as $value) {
         if ($value['id_currency'] == $cart->id_currency) {
             $actual_currency = $value['iso_code'];
         }
     }
     if ($currency != $actual_currency) {
         $currency = $actual_currency;
     }
     // Retrieve Total
     $amount = $cart->getOrderTotal(true, Cart::BOTH);
     // Cart other details
     $cart_summary = $cart->getSummaryDetails(null, true);
     $shipping = $cart_summary['total_shipping'];
     $tax = $cart_summary['total_tax'];
     $description = '';
     // Initialize to blank
     foreach ($cart_summary['products'] as $value) {
         if ($value['reference']) {
             // Add reference of each product
             $description .= 'ref_' . $value['reference'] . ', ';
         }
     }
     // Order ID
     $orderid = $cart->id . "(" . time() . ")";
     // Trim trailing seperator
     $description = Tools::substr($description, 0, -2);
     if (Tools::strlen($description) == 0) {
         $description = 'cart_id_' . $orderid;
     }
     // If description exceeds 255 char, trim back to 255
     $max_length = 255;
     if (Tools::strlen($description) > $max_length) {
         $offset = $max_length - 3 - Tools::strlen($description);
         $description = Tools::substr($description, 0, strrpos($description, ' ', $offset)) . '...';
     }
     // Load customer and populate data array
     $customer = new Customer((int) $cart->id_customer);
     // Verify if customer is indeed a customer object
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&xer=5');
     }
     // Retrive Customer ID
     $cid = (int) $customer->id;
     // Retrieve first name and last name
     $firstname = $customer->firstname;
     $lastname = $customer->lastname;
     // Retrieve Gender
     $gender = HipayClass::getAPIGender($customer->id_gender);
     // Retrieve Email
     $email = $customer->email;
     // Retrieve Birthdate
     $birthdate = $customer->birthday;
     $birthdate = str_replace('-', '', $birthdate);
     // Load Addresses - Invoice addr and Delivery addr
     $invoice = new Address((int) $cart->id_address_invoice);
     $delivery = new Address((int) $cart->id_address_delivery);
     if (isset($invoice->phone) && $invoice->phone != '') {
         $phone = $invoice->phone;
     } elseif (isset($invoice->phone_mobile) && $invoice->phone_mobile != '') {
         $phone = $invoice->phone_mobile;
     } else {
         $phone = '';
     }
     $streetaddress = $invoice->address1;
     $streetaddress2 = $invoice->address2;
     $city = $invoice->city;
     $zipcode = $invoice->postcode;
     // Data 'state' = The USA state or the Canada state of the
     // customer making the purchase. Send this
     // information only if the address country of the
     // customer is US (USA) or CA (Canada
     $state = '';
     // Data 'country' = The country code of the customer.
     // This two-letter country code complies with ISO
     // 3166-1 (alpha 2).
     $country = HipayClass::getCountryCode($invoice->country);
     // Delivery info
     $shipto_firstname = $delivery->firstname;
     $shipto_lastname = $delivery->lastname;
     $shipto_streetaddress = $delivery->address1;
     $shipto_streetaddress2 = $delivery->address2;
     $shipto_city = $delivery->city;
     $shipto_zipcode = $delivery->postcode;
     // Data 'shipto_state' = The USA state or the Canada state of the
     // customer making the purchase. Send this
     // information only if the address country of the
     // customer is US (USA) or CA (Canada
     $shipto_state = '';
     // Data 'shipto_country' = The country code of the customer.
     // This two-letter country code complies with ISO
     // 3166-1 (alpha 2).
     $shipto_country = HipayClass::getCountryCode($delivery->country);
     // Data set => cdata1, cdata2, cdata3, cdata4
     // Custom data. You may use these parameters
     // to submit values you wish to receive back in
     // the API response messages or in the
     // notifications, e.g. you can use these
     // parameters to get back session data, order
     // content or user info.
     $cdata1 = 'c' . $orderid;
     // Cart ID
     $cdata2 = 'u' . $cid;
     // User ID
     $cdata3 = 'nnone';
     $cdata4 = 'cdata4';
     $accept_url = HipayClass::getRedirectionUrl(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'index.php?fc=module&module=' . $hipay->name . '&controller=accept');
     $decline_url = HipayClass::getRedirectionUrl(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'index.php?fc=module&module=' . $hipay->name . '&controller=decline');
     $cancel_url = HipayClass::getRedirectionUrl(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'index.php?fc=module&module=' . $hipay->name . '&controller=cancel');
     $exception_url = HipayClass::getRedirectionUrl(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'index.php?fc=module&module=' . $hipay->name . '&controller=exception');
     $pending_url = HipayClass::getRedirectionUrl(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'index.php?fc=module&module=' . $hipay->name . '&controller=pending');
     // Implementing challenge url
     // Redirecting to challenge url if url present
     if (Configuration::get('HIPAY_CHALLENGE_URL')) {
         $pending_url = Configuration::get('HIPAY_CHALLENGE_URL');
     }
     // Data 'eci'
     // Electronic Commerce Indicator (ECI).
     // The ECI indicates the security level at
     // which the payment information is
     // processed between the cardholder and
     // merchant.
     // Possible values:
     // 1 = MO/TO (Card Not Present)
     // 2 = MO/TO - Recurring
     // 3 = Installment Payment
     // 4 = Manually Keyed (Card Present)
     // 7 = Secure E-commerce with SSL/TLS
     // Encryption
     // 9 = Recurring E-commerce
     $eci = '7';
     // 3D Secure authentication
     // Data authentication_indicator
     // Indicates if the authentication should be
     // performed. Can be used to overrule the
     // merchant level configuration.
     // 0 = Bypass authentication
     // 1 = Continue if possible (Default)
     $authentication_indicator = '0';
     // Instantiate to default zero
     if ((int) Configuration::get('HIPAY_THREEDSECURE')) {
         if ($amount >= (int) Configuration::get('HIPAY_THREEDSECURE_AMOUNT')) {
             $authentication_indicator = Configuration::get('HIPAY_THREEDSECURE');
         } else {
             $authentication_indicator = '0';
         }
     }
     // If customer is using a memorized card, force the following params
     if ($cartUseExistingToken) {
         $authentication_indicator = '0';
         // Override ThreeDSecure
         $eci = '9';
         // 9 = Recurring E-commerce
     }
     $payment_product = Tools::getValue('paymentproductswitcher');
     if ($payment_product == '') {
         $payment_product = 'visa';
     }
     if (Configuration::get('HIPAY_MANUALCAPTURE')) {
         $operation = 'Authorization';
     } else {
         $operation = 'Sale';
     }
     if ($cardtoken) {
         // Important : Proceed only if cardtoken is not false!
         $data = array('operation' => $operation, 'payment_product' => $payment_product, 'description' => $description, 'long_description' => '', 'currency' => $currency, 'orderid' => $orderid, 'amount' => $amount, 'shipping' => $shipping, 'tax' => $tax, 'accept_url' => $accept_url, 'decline_url' => $decline_url, 'pending_url' => $pending_url, 'cancel_url' => $cancel_url, 'exception_url' => $exception_url, 'language' => $language, 'cdata1' => $cdata1, 'cdata2' => $cdata2, 'cdata3' => $cdata3, 'cdata4' => $cdata4, 'cid' => $cid, 'phone' => $phone, 'birthdate' => $birthdate, 'gender' => $gender, 'firstname' => $firstname, 'lastname' => $lastname, 'recipientinfo' => 'Client', 'streetaddress' => $streetaddress, 'streetaddress2' => $streetaddress2, 'city' => $city, 'state' => $state, 'zipcode' => $zipcode, 'country' => $country, 'shipto_firstname' => $shipto_firstname, 'shipto_lastname' => $shipto_lastname, 'shipto_recipientinfo' => 'Client', 'shipto_streetaddress' => $shipto_streetaddress, 'shipto_streetaddress2' => $shipto_streetaddress2, 'shipto_city' => $shipto_city, 'shipto_state' => $shipto_state, 'shipto_zipcode' => $shipto_zipcode, 'shipto_country' => $shipto_country, 'ipaddr' => $_SERVER['REMOTE_ADDR'], 'email' => $email, 'cardtoken' => $cardtoken, 'authentication_indicator' => (string) $authentication_indicator, 'eci' => $eci);
         // TPPPRS-21
         if ($birthdate == 0) {
             unset($data['birthdate']);
         }
         return $data;
     }
     return false;
 }
コード例 #2
0
 /**
  * Generates API data Note : This data structure is different from HipayToken::getApiData.
  *
  * @param $cart :
  *        	Contains cart information @param $data_type : Can be either 'null' or 'iframe'. 'null' = default dedicated page behaviour 'iframe' = Updates some values to match iframe behaviour @param $context : Optional parameter through which current context is passed. If not present, the context will get instantiated none the less. returns API response array()
  */
 public static function getApiData($cart = null, $data_type = null, $context = null, $local_card = null)
 {
     $hipay = new HiPay_Tpp();
     if (!$context) {
         $context = Context::getContext();
     }
     // Basic check for security
     // If no currency for the cart, redirect to first order step
     if (!$hipay->checkCurrency($cart)) {
         Tools::redirect('index.php?controller=order&xer=3');
     }
     $language = HipayClass::getLanguageCode($context->language->iso_code);
     // Retrieving Currency
     $currency_array = $hipay->getCurrency((int) $cart->id_currency);
     $currency = $currency_array[0]['iso_code'];
     foreach ($currency_array as $key => $value) {
         if ($value['id_currency'] == $cart->id_currency) {
             $actual_currency = $value['iso_code'];
         }
     }
     if ($currency != $actual_currency) {
         $currency = $actual_currency;
     }
     // Retrieve Total
     $amount = $cart->getOrderTotal(true, Cart::BOTH);
     // Order ID
     $orderid = $cart->id . "(" . time() . ")";
     // Cart other details
     $cart_summary = $cart->getSummaryDetails(null, true);
     $shipping = $cart_summary['total_shipping'];
     $tax = $cart_summary['total_tax'];
     $description = '';
     // Initialize to blank
     foreach ($cart_summary['products'] as $key => $value) {
         if ($value['reference']) {
             // Add reference of each product
             $description .= 'ref_' . $value['reference'] . ', ';
         }
     }
     // Trim trailing seperator
     $description = Tools::substr($description, 0, -2);
     if (Tools::strlen($description) == 0) {
         $description = 'cart_id_' . $orderid;
     }
     // If description exceeds 255 char, trim back to 255
     $max_length = 255;
     if (Tools::strlen($description) > $max_length) {
         $offset = $max_length - 3 - Tools::strlen($description);
         $description = Tools::substr($description, 0, strrpos($description, ' ', $offset)) . '...';
     }
     // Load customer and populate data array
     $customer = new Customer((int) $cart->id_customer);
     // Verify if customer is indeed a customer object
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&xer=5');
     }
     // Retrive Customer ID
     $cid = (int) $customer->id;
     // Retrieve first name and last name
     $firstname = $customer->firstname;
     $lastname = $customer->lastname;
     // Retrieve Gender
     $gender = HipayClass::getAPIGender($customer->id_gender);
     // Retrieve Email
     $email = $customer->email;
     // Retrieve Birthdate
     $birthdate = $customer->birthday;
     $birthdate = str_replace('-', '', $birthdate);
     // Load Addresses - Invoice addr and Delivery addr
     $invoice = new Address((int) $cart->id_address_invoice);
     $delivery = new Address((int) $cart->id_address_delivery);
     if (isset($invoice->phone) && $invoice->phone != '') {
         $phone = $invoice->phone;
     } elseif (isset($invoice->phone_mobile) && $invoice->phone_mobile != '') {
         $phone = $invoice->phone_mobile;
     } else {
         $phone = '';
     }
     $streetaddress = $invoice->address1;
     $streetaddress2 = $invoice->address2;
     $city = $invoice->city;
     $zipcode = $invoice->postcode;
     // Data 'state' = The USA state or the Canada state of the
     // customer making the purchase. Send this
     // information only if the address country of the
     // customer is US (USA) or CA (Canada
     $state = '';
     // Data 'country' = The country code of the customer.
     // This two-letter country code complies with ISO
     // 3166-1 (alpha 2).
     $country = HipayClass::getCountryCode($invoice->country);
     // Delivery info
     $shipto_firstname = $delivery->firstname;
     $shipto_lastname = $delivery->lastname;
     $shipto_streetaddress = $delivery->address1;
     $shipto_streetaddress2 = $delivery->address2;
     $shipto_city = $delivery->city;
     $shipto_zipcode = $delivery->postcode;
     // Data 'shipto_state' = The USA state or the Canada state of the
     // customer making the purchase. Send this
     // information only if the address country of the
     // customer is US (USA) or CA (Canada
     $shipto_state = '';
     // Data 'shipto_country' = The country code of the customer.
     // This two-letter country code complies with ISO
     // 3166-1 (alpha 2).
     $shipto_country = HipayClass::getCountryCode($delivery->country);
     // Data set => cdata1, cdata2, cdata3, cdata4
     // Custom data. You may use these parameters
     // to submit values you wish to receive back in
     // the API response messages or in the
     // notifications, e.g. you can use these
     // parameters to get back session data, order
     // content or user info.
     $cdata1 = 'c' . $orderid;
     // Cart ID
     $cdata2 = 'u' . $cid;
     // User ID
     $cdata3 = 'My+data+3';
     $cdata4 = 'My+data+4';
     // Set of return URLs
     if ($data_type == 'iframe') {
         // Template = iframe
         $accept_url = HipayClass::getRedirectionUrl(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $hipay->name . '/14iframe.php' . '?return_status=accept&content_only=1');
         $decline_url = HipayClass::getRedirectionUrl(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $hipay->name . '/14iframe.php' . '?return_status=decline&content_only=1');
         $cancel_url = HipayClass::getRedirectionUrl(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $hipay->name . '/14iframe.php' . '?return_status=cancel&content_only=1');
         $pending_url = HipayClass::getRedirectionUrl(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $hipay->name . '/14iframe.php' . '?return_status=pending&content_only=1');
         $exception_url = HipayClass::getRedirectionUrl(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $hipay->name . '/14iframe.php' . '?return_status=exception&content_only=1');
         // Template = iframe
         $template = 'iframe';
         if (Configuration::get('HIPAY_TEMPLATE_MODE') == 'basic-js') {
             $template .= '-js';
         }
     } else {
         $accept_url = HipayClass::getRedirectionUrl(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $hipay->name . '/14accept.php');
         $decline_url = HipayClass::getRedirectionUrl(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $hipay->name . '/14decline.php');
         $cancel_url = HipayClass::getRedirectionUrl(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $hipay->name . '/14cancel.php');
         $exception_url = HipayClass::getRedirectionUrl(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $hipay->name . '/14exception.php');
         $pending_url = HipayClass::getRedirectionUrl(Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $hipay->name . '/14pending.php');
         // Template = basic
         $template = Configuration::get('HIPAY_TEMPLATE_MODE');
     }
     // Implementing challenge url
     // Redirecting to challenge url if url present
     if (Configuration::get('HIPAY_CHALLENGE_URL')) {
         $pending_url = Configuration::get('HIPAY_CHALLENGE_URL');
     }
     // Data 'eci'
     // Electronic Commerce Indicator (ECI).
     // The ECI indicates the security level at
     // which the payment information is
     // processed between the cardholder and
     // merchant.
     // Possible values:
     // 1 = MO/TO (Card Not Present)
     // 2 = MO/TO - Recurring
     // 3 = Installment Payment
     // 4 = Manually Keyed (Card Present)
     // 7 = Secure E-commerce with SSL/TLS
     // Encryption
     // 9 = Recurring E-commerce
     $eci = '7';
     // 3D Secure authentication
     // Data authentication_indicator
     // Indicates if the authentication should be
     // performed. Can be used to overrule the
     // merchant level configuration.
     // 0 = Bypass authentication
     // 1 = Continue if possible (Default)
     $authentication_indicator = (int) '0';
     if ((int) Configuration::get('HIPAY_THREEDSECURE')) {
         if ($amount >= (int) Configuration::get('HIPAY_THREEDSECURE_AMOUNT')) {
             $authentication_indicator = (int) Configuration::get('HIPAY_THREEDSECURE');
         } else {
             $authentication_indicator = (int) '0';
         }
     }
     // Get last payment methods list
     $payment_product_list_upd = Tools::getValue('payment_product_list_upd');
     if (Configuration::get('HIPAY_MANUALCAPTURE')) {
         $operation = 'Authorization';
     } else {
         $operation = 'Sale';
     }
     // Intergrating Local cards logic into the data construction
     $payment_product_list = Configuration::get('HIPAY_ALLOWED_CARDS');
     if ($local_card != null) {
         // Override payment_product_list with local card
         $payment_product_list_upd = $local_card;
         $operation = 'Sale';
         // Default value
         // Override operation - Force sale, not manual capture.
         if (file_exists(_PS_ROOT_DIR_ . '/modules/' . $hipay->name . '/special_cards.xml')) {
             $local_cards = simplexml_load_file(_PS_ROOT_DIR_ . '/modules/' . $hipay->name . '/special_cards.xml');
             if (count($local_cards)) {
                 foreach ($local_cards as $key => $value) {
                     if ($local_card == (string) $value->code) {
                         if ((string) $value->manualcapture == '1') {
                             $operation = 'Authorization';
                         } else {
                             $operation = 'Sale';
                         }
                     }
                 }
             }
         }
     }
     // On module administration we change the values of display selector to get always by default the selector showed
     if (Configuration::get('HIPAY_SELECTOR_MODE') == '1') {
         $display_selector = 0;
     } else {
         $display_selector = 1;
     }
     $data = array('operation' => $operation, 'payment_product_list' => $payment_product_list_upd, 'description' => $description, 'long_description' => '', 'currency' => $currency, 'orderid' => $orderid, 'amount' => $amount, 'shipping' => $shipping, 'tax' => $tax, 'accept_url' => $accept_url, 'decline_url' => $decline_url, 'pending_url' => $pending_url, 'cancel_url' => $cancel_url, 'exception_url' => $exception_url, 'language' => $language, 'cdata1' => $cdata1, 'cdata2' => $cdata2, 'cdata3' => $cdata3, 'cdata4' => $cdata4, 'cid' => $cid, 'phone' => $phone, 'birthdate' => $birthdate, 'gender' => $gender, 'firstname' => $firstname, 'lastname' => $lastname, 'recipientinfo' => 'Client', 'streetaddress' => $streetaddress, 'streetaddress2' => $streetaddress2, 'city' => $city, 'state' => $state, 'zipcode' => $zipcode, 'country' => $country, 'shipto_firstname' => $shipto_firstname, 'shipto_lastname' => $shipto_lastname, 'shipto_recipientinfo' => 'Client', 'shipto_streetaddress' => $shipto_streetaddress, 'shipto_streetaddress2' => $shipto_streetaddress2, 'shipto_city' => $shipto_city, 'shipto_state' => $shipto_state, 'shipto_zipcode' => $shipto_zipcode, 'shipto_country' => $shipto_country, 'ipaddr' => $_SERVER['REMOTE_ADDR'], 'email' => $email, 'authentication_indicator' => strval($authentication_indicator), 'eci' => $eci, 'template' => $template, 'css' => Configuration::get('HIPAY_CSS_URL'), 'display_selector' => $display_selector);
     // TPPPRS-21
     if ($birthdate == 0) {
         unset($data['birthdate']);
     }
     // Merchant display name limited to 32 characters only
     if ($data_type == 'iframe') {
         // No merchant_display_name for mode iframe
     } else {
         $merchant_display_name = Tools::substr(Configuration::get('PS_SHOP_NAME'), 0, 32);
         $data['merchant_display_name'] = $merchant_display_name;
     }
     return $data;
 }
コード例 #3
0
 public function hookPayment($params)
 {
     if (!$this->active) {
         return;
     }
     // Verify if customer has memorized tokens
     $cart = $this->context->cart;
     $tokens = HipayToken::getTokens($cart->id_customer);
     // Retrieve list of tokens
     if (isset($tokens['0'])) {
         $token_display = 'true';
     } else {
         $token_display = 'false';
     }
     if (_PS_VERSION_ >= '1.5') {
         // Get invoice Country
         $customer = new Customer((int) $cart->id_customer);
         $customerInfo = $customer->getAddresses((int) $cart->id_lang);
         foreach ($customerInfo as $key => $value) {
             if ($value['id_address'] == $cart->id_address_invoice) {
                 $invoice_country = HipayClass::getCountryCode($value['country']);
             }
         }
     }
     // End Get invoice country
     // Verify if systems should display memorized tokens
     $allow_memorize = HipayClass::getShowMemorization();
     // If both are true, activate additional info to allow payment via existing token
     if ($allow_memorize == 'true') {
         $currency_array = $this->getCurrency((int) $cart->id_currency);
         $currency = $currency_array[0]['iso_code'];
         foreach ($currency_array as $value) {
             if ($value['id_currency'] == $cart->id_currency) {
                 $actual_currency = $value['iso_code'];
             }
         }
         if ($currency != $actual_currency) {
             $currency = $actual_currency;
         }
         $this->context->smarty->assign(array('cart_id' => $cart->id, 'currency' => $currency, 'amount' => $cart->getOrderTotal(true, Cart::BOTH)));
     }
     // Create dynamic payment button
     $card_str = Configuration::get('HIPAY_ALLOWED_CARDS');
     // Cards filter by country
     if ($invoice_country != 'FR') {
         $card_str = str_replace('cb', '', $card_str);
     }
     if ($invoice_country != 'BE') {
         $card_str = str_replace('bcmc', '', $card_str);
     }
     $cart_arr = explode(',', $card_str);
     $card_currency = Configuration::get('HIPAY_CURRENCY_CARDS');
     $card_curr_val = array();
     if (Tools::strlen($card_currency) > 3) {
         $currency_array = $this->getCurrency((int) $cart->id_currency);
         $currency = $currency_array[0]['iso_code'];
         foreach ($currency_array as $value) {
             if ($value['id_currency'] == $cart->id_currency) {
                 $actual_currency = $value['iso_code'];
             }
         }
         $card_currency_arr = explode(',', Tools::substr($card_currency, 1, -1));
         foreach ($card_currency_arr as $value) {
             foreach ($cart_arr as $cardvalue) {
                 if ($value == '"' . $actual_currency . '-' . $cardvalue . '"') {
                     $card_curr_val[$cardvalue] = true;
                 }
             }
         }
     } else {
         foreach ($cart_arr as $cardvalue) {
             $card_curr_val[$cardvalue] = true;
         }
     }
     $btn_image = '';
     $card_currency_ok = '0';
     $payment_product_list_upd = '';
     $count_ccards = 0;
     foreach ($cart_arr as $value) {
         if ($value == 'visa' && $card_curr_val['visa']) {
             $btn_image .= '<img class= "hipay_method" src="' . _MODULE_DIR_ . $this->name . '/img/visa_small.png" alt="Visa" />';
             $card_currency_ok = '1';
             $payment_product_list_upd .= 'visa,';
             $count_ccards++;
         }
         if ($value == 'mastercard' && $card_curr_val['mastercard']) {
             $btn_image .= '<img class= "hipay_method" src="' . _MODULE_DIR_ . $this->name . '/img/mc_small.png" alt="MasterCard" />';
             $card_currency_ok = '1';
             $payment_product_list_upd .= 'mastercard,';
             $count_ccards++;
         }
         if ($value == 'american-express' && $card_curr_val['american-express']) {
             $btn_image .= '<img class= "hipay_method" src="' . _MODULE_DIR_ . $this->name . '/img/amex_small.png" alt="American Express" />';
             $card_currency_ok = '1';
             $payment_product_list_upd .= 'american-express,';
             $count_ccards++;
         }
         if ($value == 'bcmc' && $card_curr_val['bcmc']) {
             $btn_image .= '<img class= "hipay_method" src="' . _MODULE_DIR_ . $this->name . '/img/bcmc_small.png" alt="Bancontact / Mister Cash" />';
             $card_currency_ok = '1';
             $payment_product_list_upd .= 'bcmc,';
             $count_ccards++;
         }
         if ($value == 'cb' && $card_curr_val['cb']) {
             $btn_image .= '<img class= "hipay_method" src="' . _MODULE_DIR_ . $this->name . '/img/cb_small.png" alt="CB" />';
             $card_currency_ok = '1';
             $payment_product_list_upd .= 'cb,';
             $count_ccards++;
         }
         if ($value == 'maestro' && $card_curr_val['maestro']) {
             $btn_image .= '<img class= "hipay_method" src="' . _MODULE_DIR_ . $this->name . '/img/maestro_small.png" alt="Maestro" />';
             $card_currency_ok = '1';
             $payment_product_list_upd .= 'maestro,';
             $count_ccards++;
         }
     }
     // Assign smarty variables
     $this->context->smarty->assign(array('hipay_ssl' => Configuration::get('PS_SSL_ENABLED'), 'token_display' => $token_display, 'allow_memorize' => $allow_memorize, 'tokens' => $tokens, 'payment_mode' => Configuration::get('HIPAY_PAYMENT_MODE'), 'PS_VERSION' => _PS_VERSION_, 'btn_image' => $btn_image, 'card_currency_ok' => $card_currency_ok, 'payment_product_list_upd' => $payment_product_list_upd, 'count_ccards' => $count_ccards));
     // Assign paths
     $this->smarty->assign(array('this_path' => $this->_path, 'this_path_bw' => $this->_path, 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/'));
     // Local cards variables
     $localPayments = Tools::jsonDecode(Configuration::get('HIPAY_LOCAL_PAYMENTS'));
     $local_cards = $this->checkLocalCards();
     // Retrieving images and storing in any array associate to the card code.
     $local_cards_img = array();
     $local_cards_name = array();
     $show_cards = array();
     if (count($local_cards)) {
         $currency_array = $this->getCurrency((int) $cart->id_currency);
         $currency = $currency_array[0]['iso_code'];
         foreach ($currency_array as $value) {
             if ($value['id_currency'] == $cart->id_currency) {
                 $actual_currency = $value['iso_code'];
             }
         }
         foreach ($local_cards as $value) {
             $local_cards_img[(string) $value->code] = (string) $value->image;
             $local_cards_name[(string) $value->code] = (string) $value->name;
             // Get local card country
             $local_cards_countries[(string) $value->code] = (string) $value->countries;
             // End Get local card country
             $show_cards[(string) $value->code] = 'false';
             // Initialize to false
             // Assigning temporary code to variable
             $card_code = (string) $value->code;
             foreach ($value->currencies as $value) {
                 foreach ($value->iso_code as $value) {
                     if (Tools::strtoupper($actual_currency) == Tools::strtoupper((string) $value)) {
                         $show_cards[$card_code] = 'true';
                         // Update to true
                     }
                 }
             }
             // Check local card country
             if (strpos($local_cards_countries[$card_code], $invoice_country) === false && $local_cards_countries[$card_code] != 'ALL') {
                 $show_cards[$card_code] = 'false';
             }
             // End Check local card country
         }
     }
     if (count($localPayments)) {
         $allow_local_cards = 'true';
     } else {
         $allow_local_cards = 'false';
     }
     $this->smarty->assign(array('allow_local_cards' => $allow_local_cards, 'local_cards_list' => $localPayments, 'local_cards_img' => $local_cards_img, 'local_cards_name' => $local_cards_name, 'show_cards' => $show_cards));
     // modif One Page Checkout
     // Check if cart is in OPC
     $is_opc = Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'true' : 'false';
     $id_opc = '';
     // Set id_opc to empty by default
     if ($is_opc == 'true') {
         $id_opc = 'OPC';
         // This will update hidden field 'ioBB' to 'ioBBOPC' to prevent duplicate id
     }
     // Add generic smarty variables;
     $this->smarty->assign(array('id_opc' => $id_opc));
     return $this->display(__FILE__, 'payment.tpl');
 }