/** * Draws the credit-card form * * @param UserTable $user User * @param cbpaidPaymentBasket $paymentBasket paymentBasket object * @param string $cardType CC-brand if no choice * @param string $postUrl URL for the <form> * @param string $payButtonText Text for payment text (if basket allows single-payments) * @param string $subscribeButtonText Text for subscribe button (if basket allows auto-recurring subscriptions) * @param string|null $chosenCard * @return string */ private function _drawCCform( &$user, &$paymentBasket, $cardType, $postUrl, $payButtonText, $subscribeButtonText, $chosenCard = null ) { global $_CB_framework, $ueConfig; $params =& cbpaidApp::settingsParams(); $sealCode = $params->get( 'security_logos_and_seals' ); // keep $param, it's a global setting ! $drawCCV = $params->get( 'show_cc_ccv', 1 ); // keep $param, it's a global setting ! $drawAVS = $this->getAccountParam( 'show_cc_avs', 0 ); // keep $param, it's a global setting ! if ( in_array( $ueConfig['name_style'], array( 2, 3 ) ) ) { $oFirstName = htmlspecialchars( $user->firstname ); $oLastName = htmlspecialchars( $user->lastname ); } else { $posLname = strrpos( $user->name, ' ' ); if ( $posLname !== false ) { $oFirstName = htmlspecialchars( substr( $user->name, 0, $posLname ) ); $oLastName = htmlspecialchars( substr( $user->name, $posLname + 1 ) ); } else { $oFirstName = ''; $oLastName = htmlspecialchars( $user->name ); } } $txtHiddenInputs = '<input type="hidden" name="' . $this->_getPagingParamName( 'basket' ) . '" value="' . $paymentBasket->id . "\" />\n" .'<input type="hidden" name="' . $this->_getPagingParamName( 'shopuser' ) . '" value="' . $this->shopuserParam( $paymentBasket ) . "\" />\n" .'<input type="hidden" name="' . $this->_getPagingParamName( 'paymenttype' ) . "\" value=\"0\" />\n"; $txtVisibleInputs = array( 'number' => '<input class="inputbox" size="20" maxlength="20" type="text" autocomplete="off" name="' . $this->_getPagingParamName( 'number' ) . '" value="" />', 'firstname' => '<input class="inputbox" size="20" maxlength="50" type="text" autocomplete="off" name="' . $this->_getPagingParamName( 'firstname' ) . '" value="' . $oFirstName . '" />', 'lastname' => '<input class="inputbox" size="20" maxlength="50" type="text" autocomplete="off" name="' . $this->_getPagingParamName( 'lastname' ) . '" value="' . $oLastName . '" />' ); if ( $drawCCV ) { $txtVisibleInputs['cvv'] = '<input class="inputbox" size="6" maxlength="4" type="text" autocomplete="off" name="' . $this->_getPagingParamName( 'cvv' ) . '" value="" />'; } if ( ! $cardType ) { $cardSelector = $this->_drawCCSelector( $user, $paymentBasket, $chosenCard ); $txtVisibleInputs['cardtype'] = $cardSelector; } else { $txtVisibleInputs['cardtype'] = $this->_renderCCimg( $cardType, 'big' ); $txtHiddenInputs .= '<input type="hidden" name="' . $this->_getPagingParamName( 'cardtype' ) . '" value="' . $cardType . "\" />\n"; } $months = array(); $months[] = moscomprofilerHTML::makeOption( '', 'MM' ); for ( $i=1; $i <= 12; $i++ ) { $months[] = moscomprofilerHTML::makeOption( $i, sprintf( '%00d', $i ) ); } $txtVisibleInputs['expmonth'] = moscomprofilerHTML::selectList( $months, $this->_getPagingParamName( 'expmonth' ), 'class="inputbox" size="1"', 'value', 'text', '' ); $years = array(); $years[] = moscomprofilerHTML::makeOption( '', 'YYYY' ); $yearNow = date('Y'); $monthNow = date('m'); for ( $i = ( ( $monthNow == 1 ) ? -1 : 0 ) ; $i < $this->ccYearsInAdvance; $i++ ) { $years[] = moscomprofilerHTML::makeOption( $yearNow + $i, sprintf( '%0000d', $yearNow + $i ) ); } $txtVisibleInputs['expyear'] = moscomprofilerHTML::selectList( $years, $this->_getPagingParamName( 'expyear' ), 'class="inputbox" size="1"', 'value', 'text', '' ); if ( $drawAVS ) { if ( $drawAVS >= 2 ) { /** @var $user cbpaidUserWithSubsFields */ $txtVisibleInputs['address'] = '<input class="inputbox" size="40" maxlength="60" type="text" autocomplete="off" name="' . $this->_getPagingParamName( 'address' ) . '" value="' . htmlspecialchars( $user->cb_subs_inv_address_street ) . '" />'; } $txtVisibleInputs['zip'] = '<input class="inputbox" size="10" maxlength="20" type="text" autocomplete="off" name="' . $this->_getPagingParamName( 'zip' ) . '" value="' . htmlspecialchars( $user->cb_subs_inv_address_zip ) . '" />'; $allCountriesSelect = array(); $countries = new cbpaidCountries(); foreach ( $countries->twoLetterIsoCountries() as $countryName) { $allCountriesSelect[] = moscomprofilerHTML::makeOption( $countryName, CBPTXT::T( $countryName ) ); } $txtVisibleInputs['country'] = moscomprofilerHTML::selectList( $allCountriesSelect, $this->_getPagingParamName( 'country' ), 'class="inputbox" size="1"', 'value', 'text', $user->cb_subs_inv_address_country ); } $txtButton = '<div class="cbregCCbutton" style="min-height:38px;vertical-align:middle;">'; if ( $payButtonText ) { $txtButton .= '<button type="submit" name="cbPayNow" id="cbPayNow" value="' . htmlspecialchars( $payButtonText ) . '" title="' . htmlspecialchars( CBPTXT::T("Pay now") ) . '">' . $payButtonText . '</button>'; $js = '$("#cbPayNow").click( function() {' . 'if(cbCCformSubmitbutton(this.form)) {' . '$("#cbsubsCCform input[name=\'' . $this->_getPagingParamName( 'paymenttype' ) . '\']").val("1");' . '$(this).parent().fadeOut("slow", function() { $("#cbpayWheel").fadeIn("slow"); } );' . '$(this.form).submit();' . '}' . ' } );' ; $_CB_framework->outputCbJQuery( $js ); } if ( $payButtonText && $subscribeButtonText ) { $txtButton .= '<br /> ' .CBPTXT::T("or") . ' <br /> '; } if ( $subscribeButtonText ) { $txtButton .= '<button type="submit" name="cbSubscribeNow" id="cbSubscribeNow" value="' . htmlspecialchars( $subscribeButtonText ) . '" title="' . htmlspecialchars( CBPTXT::T("Subscribe to payments now") ) . '">' . $subscribeButtonText . '</button>'; $js = '$("#cbSubscribeNow").click( function() {' . 'if(cbCCformSubmitbutton(this.form)) {' . '$("#cbsubsCCform input[name=\'' . $this->_getPagingParamName( 'paymenttype' ) . '\']").val("2");' . '$(this).parent().fadeOut("slow", function() { $("#cbpayWheel").fadeIn("slow"); } );' . '$(this.form).submit();' . '}' . ' } );' ; $_CB_framework->outputCbJQuery( $js ); } $txtButton .= '</div>'; $txtButton .= '<div id="cbpayWheel" style="display:none;margin:4px 25px;"><img src="' . $this->baseClass->getPluginLIvePath() . '/icons/hot/wheel_pay.gif" alt="spinning wheel" /></div>' . "\n"; $ret = ''; $this->_renderCCvalidation( '#cbsubsCCform' ); $ret .= '<form action="' . $postUrl . '" method="post" autocomplete="off" id="cbsubsCCform" name="cbsubsCCform" class="cb_form">' . "\n"; ob_start(); $this->_renderCCform( $cardType, $txtVisibleInputs, $txtButton ); $ret .= ob_get_contents(); ob_end_clean(); $ret .= $txtHiddenInputs; $ret .= "</form>\n"; ob_start(); $this->_renderCCsealCode( $sealCode ); $ret .= ob_get_contents(); ob_end_clean(); return $ret; }