/**
  * Returns the HTML code for the Paymill payment method.
  *
  * @return  string  HTML code
  */
 static function _PaymillProcessor($processMethod)
 {
     global $_ARRAYLANG;
     $landingPage = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page')->findOneByModuleCmdLang('Shop' . MODULE_INDEX, 'success', FRONTEND_LANG_ID);
     $arrShopOrder = array('order_id' => $_SESSION['shop']['order_id'], 'amount' => intval(bcmul($_SESSION['shop']['grand_total_price'], 100, 0)), 'currency' => Currency::getActiveCurrencyCode());
     switch ($processMethod) {
         case 'paymill_cc':
             $return = \PaymillCCHandler::getForm($arrShopOrder, $landingPage);
             break;
         case 'paymill_elv':
             $return = \PaymillELVHandler::getForm($arrShopOrder, $landingPage);
             break;
         case 'paymill_iban':
             $return = \PaymillIBANHandler::getForm($arrShopOrder, $landingPage);
             break;
     }
     if (_PAYMENT_DEBUG && \PaymillHandler::$arrError) {
         $strError = '<font color="red"><b>' . $_ARRAYLANG['TXT_SHOP_PSP_FAILED_TO_INITIALISE_YELLOWPAY'] . '<br /></b>';
         if (_PAYMENT_DEBUG) {
             $strError .= join('<br />', \PaymillHandler::$arrError);
             //.'<br />';
         }
         return $strError . '</font>';
     }
     if (empty($return)) {
         foreach (\PaymillHandler::$arrError as $error) {
             \DBG::log("Paymill Error: {$error}");
         }
     }
     return $return;
 }
    /**
     * Creates and returns the HTML Form for requesting the payment service.
     *
     * @access  public     
     * @return  string                      The HTML form code
     */
    static function getForm($arrOrder, $landingPage = null)
    {
        global $_ARRAYLANG;
        if (gettype($landingPage) != 'object' || get_class($landingPage) != 'Cx\\Core\\ContentManager\\Model\\Entity\\Page') {
            self::$arrError[] = 'No landing page passed.';
        }
        if (($sectionName = $landingPage->getModule()) && !empty($sectionName)) {
            self::$sectionName = $sectionName;
        } else {
            self::$arrError[] = 'Passed landing page is not an application.';
        }
        JS::registerCSS('modules/shop/payments/paymill/css/paymill_styles.css');
        JS::registerJS('modules/shop/payments/paymill/js/creditcardBrandDetection.js');
        JS::registerJS(self::$paymillJsBridge);
        $testMode = intval(\Cx\Core\Setting\Controller\Setting::getValue('paymill_use_test_account', 'Shop')) == 0;
        $apiKey = $testMode ? \Cx\Core\Setting\Controller\Setting::getValue('paymill_test_public_key', 'Shop') : \Cx\Core\Setting\Controller\Setting::getValue('paymill_live_public_key', 'Shop');
        $mode = $testMode ? 'true' : 'false';
        $code = <<<APISETTING
                var PAYMILL_PUBLIC_KEY = '{$apiKey}';
                var PAYMILL_TEST_MODE  = {$mode};
                var VALIDATE_CVC       = true;
APISETTING;
        JS::registerCode($code);
        JS::registerCode(self::$formScript);
        \ContrexxJavascript::getInstance()->setVariable(array('invalid-card-holdername' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVAILD_CARD_HOLDER'], 'invalid-card-cvc' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVAILD_CARD_CVC'], 'invalid-card-number' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVAILD_CARD_NUMBER'], 'invalid-card-expiry-date' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVAILD_CARD_EXPIRY_DATE']), 'shop');
        $formContent = self::getElement('div', 'class="paymill-error-text"');
        $formContent .= self::fieldset('');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', $_ARRAYLANG['TXT_SHOP_CREDIT_CARD_NUMBER']);
        $formContent .= Html::getInputText('', '', '', 'class="card-number" size="20"');
        $formContent .= self::closeElement('div');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::openElement('label');
        $formContent .= $_ARRAYLANG['TXT_SHOP_CVC'] . '&nbsp;';
        $formContent .= self::getElement('span', 'class="tooltip-trigger icon-info"');
        $formContent .= self::getElement('span', 'class="tooltip-message"', $_ARRAYLANG['TXT_SHOP_CVC_TOOLTIP']);
        $formContent .= self::closeElement('label');
        $formContent .= Html::getInputText('', '', '', 'class ="card-cvc" size="4" maxlength="4"');
        $formContent .= self::closeElement('div');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', $_ARRAYLANG['TXT_SHOP_CARD_HOLDER']);
        $formContent .= Html::getInputText('', '', '', 'class="card-holdername" size="20"');
        $formContent .= self::closeElement('div');
        $arrMonths = array();
        for ($i = 1; $i <= 12; $i++) {
            $month = str_pad($i, 2, '0', STR_PAD_LEFT);
            $arrMonths[$month] = $month;
        }
        $arrYears = array();
        $currentYear = date('Y');
        for ($i = $currentYear; $i <= $currentYear + 6; $i++) {
            $arrYears[$i] = $i;
        }
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', $_ARRAYLANG['TXT_SHOP_CARD_EXPIRY']);
        $formContent .= Html::getSelect('card-expiry-month', $arrMonths, '', false, '', 'class="card-expiry-month"');
        $formContent .= Html::getSelect('card-expiry-year', $arrYears, '', false, '', 'class="card-expiry-year"');
        $formContent .= self::closeElement('div');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', '&nbsp;');
        $formContent .= Html::getInputButton('', $_ARRAYLANG['TXT_SHOP_BUY_NOW'], 'submit', '', 'class="submit-button"');
        $formContent .= self::closeElement('div');
        $formContent .= Html::getHidden('handler', 'paymill_cc');
        $formContent .= self::closeElement('fieldset');
        $form = Html::getForm('', Cx\Core\Routing\Url::fromPage($landingPage)->toString(), $formContent, 'card-tds-form', 'post');
        return $form;
    }