/** * 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'] . ' '; $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', '', ' '); $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; }
/** * 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::registerJS(self::$paymillJsBridge); \ContrexxJavascript::getInstance()->setVariable(array('invalid-card-holder' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVAILD_CARD_HOLDER'], 'invalid-account-number' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVALID_ACC_NUMBER'], 'invalid-bank-code' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVALID_BANK_CODE']), 'shop'); $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}; APISETTING; JS::registerCode($code); JS::registerCode(self::$formScript); $formContent = self::getElement('div', 'class="paymill-error-text"'); $formContent .= self::fieldset(''); $formContent .= self::openElement('div', 'class="row"'); $formContent .= self::getElement('label', '', $_ARRAYLANG['TXT_SHOP_PAYMILL_ELV_ACCOUNT_NUMBER']); $formContent .= Html::getInputText('', '', '', 'class="elv-account"'); $formContent .= self::closeElement('div'); $formContent .= self::openElement('div', 'class="row"'); $formContent .= self::getElement('label', '', $_ARRAYLANG['TXT_SHOP_PAYMILL_ELV_BANK_CODE']); $formContent .= Html::getInputText('', '', '', 'class ="elv-bankcode"'); $formContent .= self::closeElement('div'); $formContent .= self::openElement('div', 'class="row"'); $formContent .= self::getElement('label', '', $_ARRAYLANG['TXT_SHOP_PAYMILL_ACCOUNT_HOLDER']); $formContent .= Html::getInputText('', '', '', 'class="elv-holdername"'); $formContent .= self::closeElement('div'); $formContent .= self::openElement('div', 'class="row"'); $formContent .= self::getElement('label', '', ' '); $formContent .= Html::getInputButton('', $_ARRAYLANG['TXT_SHOP_BUY_NOW'], 'submit', '', 'class="submit-button"'); $formContent .= self::closeElement('div'); $formContent .= Html::getHidden('handler', 'paymill_elv'); $formContent .= self::closeElement('fieldset'); $form = Html::getForm('', Cx\Core\Routing\Url::fromPage($landingPage)->toString(), $formContent, 'payment-form', 'post'); return $form; }
/** * Creates and returns the HTML Form for requesting the payment service. * * The parameters in $uriparam are appended to the base index URI. * If empty, this defaults to "section=Shop&cmd=success". * * @access public * @global array $_ARRAYLANG * @param array $arrFields The parameter array * @param string $submitValue The optional label for the submit button * @param boolean $autopost If true, the form is automatically submitted. Defaults to false. * @param array $arrSettings Settings from \Cx\Core\Setting * @param object $landingPage The optional URI parameter string * @return string The HTML form code */ static function getForm($arrFields, $submitValue = 'Send', $autopost = false, $arrSettings = null, $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.'; } if (empty($arrSettings)) { $settingDb = \Cx\Core\Setting\Controller\Setting::getArray(self::$sectionName, 'config'); if (!empty($settingDb) && $settingDb['postfinance_active']['value']) { $arrSettings = $settingDb; } else { self::$arrError[] = "Could not load settings."; } } if (empty($arrFields['PSPID'])) { $arrFields['PSPID'] = $arrSettings['postfinance_shop_id']['value']; } if (empty($arrFields['OPERATION'])) { $arrFields['OPERATION'] = $arrSettings['postfinance_authorization_type']['value']; } if (empty($arrFields['LANGUAGE'])) { $arrFields['LANGUAGE'] = strtolower(FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID)) . '_' . strtoupper(FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID)); } $baseUri = Cx\Core\Routing\Url::fromPage($landingPage)->toString() . '?result='; if (empty($arrFields['ACCEPTURL'])) { $arrFields['ACCEPTURL'] = $baseUri . '1'; } if (empty($arrFields['DECLINEURL'])) { $arrFields['DECLINEURL'] = $baseUri . '2'; } if (empty($arrFields['EXCEPTIONURL'])) { $arrFields['EXCEPTIONURL'] = $baseUri . '2'; } if (empty($arrFields['CANCELURL'])) { $arrFields['CANCELURL'] = $baseUri . '0'; } if (empty($arrFields['BACKURL'])) { $arrFields['BACKURL'] = $baseUri . '2'; } if (!self::setFields($arrFields)) { self::$arrError[] = 'Failed to verify keys.'; return false; } $arrFields['SHASIGN'] = self::signature($arrFields, $arrSettings['postfinance_hash_signature_in']['value']); $server = $arrSettings['postfinance_use_testserver']['value'] ? 'test' : 'prod'; $charset = CONTREXX_CHARSET == 'UTF-8' ? '_utf8' : ''; $hiddenFields = ''; foreach ($arrFields as $name => $value) { $hiddenFields .= Html::getHidden($name, $value); } $autoSubmit = !$autopost ? '' : ' <script type="text/javascript"> /* <![CDATA[ */ document.yellowpay.submit(); /* ]]> */ </script> '; $form = $_ARRAYLANG['TXT_ORDER_LINK_PREPARED'] . '<br/><br/>' . '<form name="yellowpay" method="post" action="https://e-payment.postfinance.ch/ncol/' . $server . '/orderstandard' . $charset . '.asp">' . $hiddenFields . '<input type="submit" name="go" value="' . $submitValue . '" />' . '</form>' . $autoSubmit; return $form; }