/** * Constructor */ public function __construct() { // this 'if' above is added for compatibility during update over CBSubs 1.0.x cbpaidApp::getBaseClass($this); parent::__construct(); cbpaidApp::loadLang(); }
/** * Draws the subscription for registrations and profile views * * @param int $invoicesNumber array of cbpaidPaymentBasket of Completed and Pending baskets * @param UserTable $user reflecting the user being displayed (here null) * @param boolean $itsmyself user is logged in user * @param string $periodText if non-empty, text of the period showing invoices * @return string */ public function drawInvoicesList($invoicesNumber, $user, $itsmyself, $periodText) { $this->user = $user; $this->plansTitle = $this->_invoicesTitle($invoicesNumber, $user, $itsmyself, $periodText); $params = cbpaidApp::settingsParams(); $this->show_invoice_numbers = $params->get('invoice_number_format') && $params->get('show_invoices'); $baseClass = cbpaidApp::getBaseClass(); foreach ($this->_model as $i) { $this->invoicesUrls[$i->id] = $baseClass->getInvoiceUrl($i); } return $this->display('default'); }
/** * Constructor */ public function __construct( ) { if ( is_callable( array( 'cbpaidApp', 'getBaseClass' ) ) ) { // this 'if' above is added for compatibility during update over CBSubs 1.0.x cbpaidApp::getBaseClass( $this ); parent::__construct(); cbpaidApp::loadLang(); } else { // old method for CBSubs 1.0.3 classes during upgrade: parent::__construct(); /** @noinspection PhpUndefinedCallbackInspection */ call_user_func_array( array( $this, '_loadLang' ), array() ); // phplint-safe: $this->_loadLang(); } }
/** * View for <param type="private" class="cbpaidParamsExt" method="currencyconvertercheck">... * * @param string $value Stored Data of Model Value associated with the element * @param ParamsInterface $pluginParams Main settigns parameters of the plugin * @param string $name Name attribute * @param CBSimpleXMLElement $param This XML node * @param string $control_name Name of the control * @param string $control_name_name css id-encode of the names of the controls surrounding this node * @param boolean $view TRUE: view, FALSE: edit * @param cbpaidTable $modelOfData Data of the Model corresponding to this View * @param cbpaidTable[] $modelOfDataRows Displayed Rows if it is a table * @param int $modelOfDataRowsNumber Total Number of rows * @return null|string */ public function currencyconvertercheck($value, &$pluginParams, $name, &$param, $control_name, $control_name_name, $view, &$modelOfData, &$modelOfDataRows, &$modelOfDataRowsNumber) { global $_CB_framework; $baseClass = cbpaidApp::getBaseClass(); $cid = (int) $baseClass->getPluginId(); $url = $_CB_framework->backendUrl('index.php?option=com_comprofiler&view=pluginmenu&pluginid=' . $cid . '&menu=curconvcheck', false, 'raw'); // &start_debug=1'; $id = 'chkcur' . $param->attributes('name'); $this->_ajaxContent($url, '#' . $id); return '<div id="' . $id . '" style="display:none;text-align:center;"> </div>'; /* $ret = null; $_CBPAY_CURRENCIES = cbpaidApp::getCurrenciesConverter(); $secondaryPrice = $_CBPAY_CURRENCIES->convertCurrency( 'EUR', 'USD', 1.0 ); if ( $secondaryPrice === null ) { $ret = $this->_outputGreenRed( '', false, '', $_CBPAY_CURRENCIES->getError() ); } return $ret; */ }
/** * USED by XML interface ONLY !!! Renders invoice * * @param string $value * @param ParamsInterface $params * @return string HTML to display */ public function renderInvoice( $value, &$params ) { global $_CB_framework; if ( ( $_CB_framework->getUi() == 2 ) && ( $_CB_framework->myId() != 0 ) ) { if ( cbpaidApp::getBaseClass() === null ) { //TODO: check if this is even needed: $pseudoPlugin = new getcbpaidsubscriptionsTab(); $pseudoPlugin->params =& $params; cbpaidApp::getBaseClass( $pseudoPlugin ); } $baseClass =& cbpaidApp::getBaseClass(); $itsmyself = true; // simulate user's view of invoice. $baseClass->outputRegTemplate(); if ( strpos( cbGetParam( $_GET, 'invoice' ), ',') === false ) { if ( $this->load( (int) $value ) ) { $user = CBuser::getUserDataInstance( (int) $this->user_id ); } return $this->displayInvoice( $user, $itsmyself, true ); } else { $html = '<div class="cbregmultipage">'; foreach ( explode( ',', cbGetParam( $_GET, 'invoice' ) ) as $basketId ) { $paymentBasket = new self(); if ( $paymentBasket->load( (int) $basketId ) ) { $user = CBuser::getUserDataInstance( (int) $paymentBasket->user_id ); } $html .= $paymentBasket->displayInvoice( $user, $itsmyself, false ) . '<hr class="cbregpagebreak" />'; if ( is_callable( array( 'CBuser', 'unsetUsersNotNeeded' ) ) ) { // CB 1.8+: CBuser::unsetUsersNotNeeded( array( (int) $paymentBasket->user_id ) ); } unset( $paymentBasket, $user ); } $html .= '</div>'; } return $html; } return null; }
/** * Gets the name input parameter for search and other functions * * @param string $name name of parameter of plugin * @param string $postfix postfix for identifying multiple pagings/search/sorts (optional) * @return string value of the name input parameter */ protected function _getPagingParamName( $name="search", $postfix="" ) { return cbpaidApp::getBaseClass()->_getPagingParamName( $name, $postfix ); }
/** * display basket and payment buttons or redirect for payment depending if multiple payment choices or intro text present: * * @param UserTable $user * @param cbpaidPaymentBasket $paymentBasket * @param string $introText * @param boolean $ajax TRUE if AJAX refresh inside #cbregPayMethodsChoice, FALSE: wraps in <div id="cbregPayMethodsChoice"> * @return string HTML (or DOES REDIRECT if $redirectNow = ! ( ( $nbClasses != 1 ) || $introText ) == TRUE) */ public function getPaymentBasketPaymentForm( &$user, &$paymentBasket, $introText, $ajax = false ) { global $_PLUGINS; $result = null; $params = cbpaidApp::settingsParams(); $invoicingAddressQuery = $params->get( 'invoicing_address_query' ); $basket_requiredterms = $params->get( 'basket_requiredterms' ); $basket_requiredtermserror = $params->get( 'basket_requiredtermserror' ); $payment_method_selection_type = $params->get( 'payment_method_selection_type', 'buttons' ); $allow_select_currency = $params->get( 'allow_select_currency', '0' ); $redirectNow = null; $payChoicesArray = $this->getPaymentMethodsParams( $user, $paymentBasket, $introText, $redirectNow ); $chosenPaymentMethod = $paymentBasket->gateway_account ? $paymentBasket->gateway_account . '-' . $paymentBasket->payment_type : ''; // cbGetParam( $_POST, 'payment_method' ); $payChoicesHtmlRadiosArray = array(); $chosenPaymentSelector = null; $payChoicesHtmlBottomArray = $this->_renderPayChoicesArray( $payChoicesArray, $paymentBasket, $redirectNow, $chosenPaymentMethod, $payChoicesHtmlRadiosArray, $chosenPaymentSelector ); if ( $redirectNow == 'redirect' && is_string( $payChoicesHtmlBottomArray ) ) { cbRedirect( $payChoicesHtmlBottomArray ); } $subscriptionsGUI = new cbpaidControllerUI(); $subscriptionsGUI->addcbpaidjsplugin(); if ( ( $payment_method_selection_type == 'radios') && ( $chosenPaymentMethod != '' ) && $chosenPaymentSelector ) { // Select button to draw: $payChoicePayButton = $this->getPayMethodButton( $user, $paymentBasket, $paymentBasket->gateway_account, $paymentBasket->payment_type, $chosenPaymentSelector ); /** @var $chosenPaymentSelector cbpaidGatewaySelector */ $this->modifyAspectPayMethodButton( $payChoicePayButton, $chosenPaymentSelector->paymentType ); $dummy = null; $payChoicePayButtonHtmlArray = $this->_renderPayChoicesArray( array( $payChoicePayButton ), $paymentBasket, 'buttons', $chosenPaymentMethod, $payChoicesHtmlRadiosArray, $dummy ); $payChoicesHtmlBottomArray = array_merge( $payChoicesHtmlBottomArray, $payChoicePayButtonHtmlArray ); } if ( true ) { // always add cancel link cbpaidApp::import( 'processors.cancelpay.cancelpay' ); $cancelmethod = new cbpaidGatewayAccountcancelpay(); $payClass = $cancelmethod->getPayMean(); $payChoicesHtmlBottomArray[] = $payClass->getPaymentBasketProcess( $user, $paymentBasket, 'buttons' ); // never redirectNow a cancel link :D ! } $basketHtml = $paymentBasket->displayBasket(); if ( $allow_select_currency == 2 ) { $currencySelector = $this->displayCurrencySelector( $paymentBasket ); } else { $currencySelector = null; } $txtConclusion = $params->get('conclusion_text'); $txtFinal = $params->get('final_text'); $txtTerms = null; if ( $basket_requiredterms == 1 ) { global $_CB_database, $_CB_framework; $query = 'SELECT ' . $_CB_database->NameQuote( 'params' ) . "\n FROM " . $_CB_database->NameQuote( '#__comprofiler_fields' ) . "\n WHERE " . $_CB_database->NameQuote( 'name' ) . " = " . $_CB_database->Quote( 'acceptedterms' ); $_CB_database->setQuery( $query ); $tcParams = new Registry( $_CB_database->loadResult() ); $termsOutput = $tcParams->get( 'terms_output', 'url' ); $termsDisplay = $tcParams->get( 'terms_display', 'modal' ); $termsURL = $tcParams->get( 'terms_url', null ); $termsText = $tcParams->get( 'terms_text', null ); $termsWidth = (int) $tcParams->get( 'terms_width', 400 ); $termsHeight = (int) $tcParams->get( 'terms_height', 200 ); if ( ! $termsHeight ) { $termsHeight = 200; } if ( ( ( $termsOutput == 'url' ) && $termsURL ) || ( ( $termsOutput == 'text' ) && $termsText ) ) { if ( $termsDisplay == 'iframe' ) { if ( $termsOutput == 'url' ) { $txtTerms .= '<iframe class="cbTermsFrameURL" height="' . $termsHeight . '" width="' . ( $termsWidth ? $termsWidth : '100%' ) . '" src="' . htmlspecialchars( $termsURL ) . '"></iframe>'; } else { $txtTerms .= '<div class="cbTermsFrameText" style="height:' . $termsHeight . 'px;width:' . ( $termsWidth ? $termsWidth . 'px' : '100%' ) . ';overflow:auto;">' . CBPTXT::T( $termsText ) . '</div>'; } } if ( $termsDisplay != 'iframe' ) { $attributes = ' class="cbTermsLink"'; if ( ( $termsOutput == 'text' ) && ( $termsDisplay == 'window' ) ) { $termsDisplay = 'modal'; } if ( $termsDisplay == 'modal' ) { if ( ! $termsWidth ) { $termsWidth = 400; } if ( $termsOutput == 'url' ) { $tooltip = '<iframe class="cbTermsModalURL" height="' . $termsHeight . '" width="' . $termsWidth . '" src="' . htmlspecialchars( $termsURL ) . '"></iframe>'; } else { $tooltip = '<div class="cbTermsModalText" style="height:' . $termsHeight . 'px;width:' . $termsWidth . 'px;overflow:auto;">' . CBPTXT::T( $termsText ) . '</div>'; } $url = 'javascript:void(0);'; $attributes .= ' ' . cbTooltip( $_CB_framework->getUi(), $tooltip, CBPTXT::T( 'Terms and Conditions' ), 'auto', null, null, null, 'data-cbtooltip="true" data-modal="true"' ); } else { $url = htmlspecialchars( $termsURL ); $attributes .= ' target="_blank"'; } $txtTerms .= CBPTXT::P( 'I have read and approve the <a href="[url]"[attributes]>Terms and Conditions</a>', array( '[url]' => $url, '[attributes]' => $attributes ) ); } else { $txtTerms .= CBPTXT::T( 'I have read and approve the above Terms and Conditions.' ); } } } elseif ( $basket_requiredterms == 2 ) { $txtTerms = $params->get( 'basket_termsandconditions' ); } if ($introText) { $result .= '<div class="cbregIntro">' . CBPTXT::Th( $introText ) . "</div>\n"; } $result .= $basketHtml; if ( $allow_select_currency == 2 ) { $result .= $currencySelector; } if ( $invoicingAddressQuery > 0 ) { $errorMsg = $paymentBasket->checkAddressComplete(); if ( $errorMsg && ( $invoicingAddressQuery == 2 ) ) { $result = ''; $introAddrNeeded = $params->get('invoicing_address_required_into_text'); if ($introAddrNeeded) { $result .= '<div class="cbregIntro">' . CBPTXT::Th( $introAddrNeeded ) . "</div>\n"; } $result .= $paymentBasket->renderInvoicingAddressForm( $user ); // $xmlController->handleAction( 'action', 'editinvoiceaddress' ); return $result; } else { if ( $errorMsg ) { cbpaidApp::getBaseClass()->_setErrorMSG( $errorMsg ); } $result .= '<div class="cbregInvoicingAddress">' . $paymentBasket->renderInvoicingAddressFieldset() . '</div>'; } // display current invoicing address with a link to change/edit it with a back link to the payment basket id // if the address is not mandatory. // If it is mandatory, check that it is complete (and later also screened), // if not display instead of this the invoicing address edit page ! } $integrationsResults = $_PLUGINS->trigger( 'onCbSubsAfterPaymentBasket', array( $paymentBasket, &$result, &$txtTerms ) ); foreach ( $integrationsResults as $intRes ) { if ( is_string( $intRes ) ) { $result .= $intRes; } } if ( $txtConclusion ) { $result .= '<div class="cbregConcl">' . CBPTXT::Th( $txtConclusion ) . "</div>\n"; } if ( count( $payChoicesHtmlRadiosArray ) > 0 ) { $radios_intro_html = CBPTXT::Th( $params->get( 'radios_intro_html' ) ); $radios_conclusion_html = CBPTXT::Th( $params->get( ( $chosenPaymentMethod != null ) ? 'radios_selected_conclusion_html' : 'radios_unselected_conclusion_html' ) ); $htmlList = '<ul class="cbregPaymentMethodChoiceList">' . "\n"; foreach ( $payChoicesHtmlRadiosArray as $selHtmlArr ) { if ( $selHtmlArr[0] ) { $htmlList .= '<li class="cbregCCradioLi cbregCCradioSelected">'; } else { $htmlList .= '<li class="cbregCCradioLi">'; //LATER: class="cbpaidCCradio cbpaidRadio_<?php echo htmlspecialchars( $this->payNameForCssClass ); " id="<?php echo htmlspecialchars( $this->butId ); } $htmlList .= '<div class="cbregCCradioLiBg"></div>' // This allows to use the CSS trick for highlighting as explained here: http://www.commentcamarche.net/forum/affich-3898635-transparance-du-fond-uniquement . $selHtmlArr[1] . "</li>\n"; } $htmlList .= "</ul>\n"; $methodsHTML = '<div class="cbregPaymentMethodChoice ' . ( ( $chosenPaymentMethod != null ) ? 'cbregPMselected' : 'cbregPMunselected' ) . '">' . ( $radios_intro_html ? '<h2 class="contentheading cbregPaymenMethodChoiceIntro">' . $radios_intro_html . '</h2>' : '' ) . $htmlList . '<span class="cb_button_wrapper">' . '<button type="submit" id="cbregSelectPayment">' . CBPTXT::Th("Change Payment Method") . '</button>' . '</span>' . ( $radios_conclusion_html ? '<div class="cbregPaymenMethodChoiceConclusion">' . $radios_conclusion_html . '</div>' : '' ) . "</div>\n" ; $getParams = $paymentBasket->getSetBasketPaymentMethodUrl( $user ); $ajaxGetParams = cbUnHtmlspecialchars( $paymentBasket->getSetBasketPaymentMethodUrl( $user, 'raw' ) ); $formHiddens = array( cbpaidApp::getBaseClass()->_getPagingParamName('act') => 'setbsktpmtmeth', 'ajaxurl' => bin2hex( $ajaxGetParams ) ); $result .= '<div class="cbregPaymentMethodsSelect">' . $subscriptionsGUI->drawForm( $methodsHTML, null, $formHiddens, $getParams ) . "</div>\n"; $termsCanBeDisplayed = ( $payment_method_selection_type != 'radios' ) || ( $chosenPaymentMethod != null ); } else { $termsCanBeDisplayed = true; } if ( $txtTerms ) { if ( $termsCanBeDisplayed ) { $accepted = ( cbGetParam( $_POST, 'terms_accepted', 0 ) == 1 ); $settings = '<div class="cbregTermsAccept"><input type="checkbox" class="required" name="terms_accepted" id="terms_accepted" value="1"' . ( $accepted ? ' checked="checked" disabled="disabled" ' : '' ) . '/> ' . '<label for="terms_accepted">' . $txtTerms . '</label></div>' ; if ( ! $accepted ) { $settings .= '<span class="cb_button_wrapper">' . '<button type="submit" id="cbTermsAccept" title="' . htmlspecialchars( CBPTXT::T( $basket_requiredtermserror ) ) . '">' . CBPTXT::Th("Accept Terms") . '</button>' . '</span>' ; } $getParams = $accepted ? '#' : $paymentBasket->getShowBasketUrl( false ); $formHiddens = $accepted ? array( 'terms_accepted' => 1 ) : array(); $result .= '<div class="cbregTerms">' . $subscriptionsGUI->drawForm( $settings, null, $formHiddens, $getParams ) . "</div>\n"; } else { $accepted = false; } } else { $accepted = true; } $result .= '<div class="cbpayChoices cbclearboth"' . ( $termsCanBeDisplayed && $txtTerms && ! $accepted ? ' style="display:none;"' : '' ) . ">\n " . implode ( "\n ", $payChoicesHtmlBottomArray ) . "\n</div>\n"; if ( $txtFinal ) { $result .= '<div class="cbregFinalText">' . CBPTXT::Th( $txtFinal ) . "</div>\n"; } $result = '<div class="cbpayBasketView">' . $result . '</div>'; if ( ! $ajax ) { $result = '<div id="cbpayOrderContainer">' // Needed for Javascript delegated binding . $result . '</div>'; } return $result; }
/** * Constructor */ public function __construct( ) { $this->params = cbpaidApp::settingsParams(); $this->base = cbpaidApp::getBaseClass(); }
/** * Fetches XML file from currency server and parses currency results * @access private * * @param string $sourceURL URL * @param string $source Text to store as source of currency conversion rate * @param string $source_currency Main currency of the source for rates * @param string $tag Main path to XML * @param string $subtag Sub-tag to XML * @param string $dateAttr tag-name for date * @param string $subsubtag sub-sub tag for XML of currency * @param string $currAttr attribute for currency name * @param string $rateAttr attribute for currency rate */ private function _readCurrencies($sourceURL = 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml', $source = 'European Central Bank', $source_currency = 'EUR', $tag = 'Cube/Cube', $subtag = 'Cube', $dateAttr = 'time', $subsubtag = 'Cube', $currAttr = 'currency', $rateAttr = 'rate') { global $_CB_framework, $_CB_database; $now = $_CB_framework->now(); $xmlText = $this->_fetch_http_file($sourceURL); if ($xmlText && substr($xmlText, 0, 5) == '<?xml') { // handles limitations of SimpleXML: $xmlText = str_replace('gesmes:', '', $xmlText); try { $xdoc = new SimpleXMLElement($xmlText, LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0)); } catch (Exception $e) { cbpaidApp::getBaseClass()->setLogErrorMSG(3, null, "ECB Currency conversion XML result invalid" . ": " . $e->getMessage() . ': Received reply: ' . $xmlText, null); $xdoc = null; } if ($xdoc && count($xdoc->children()) > 0) { // get the currencies element /** @var $currencies_element SimpleXMLElement */ $currencies_element = $xdoc->getElementByPath($tag); if ($currencies_element) { $last_updated_date = $currencies_element->attributes($dateAttr); if (count($currencies_element->children()) > 0) { /** @var $xCu SimpleXMLElement */ foreach ($currencies_element->children() as $xCu) { if ($xCu->getName() == $subtag) { $currency = $xCu->attributes($currAttr); $rate = $xCu->attributes($rateAttr); if ($currency && $rate) { $currObj = new cbpaidCurrency($_CB_database); $currObj->setCurrencyRate($source_currency, $currency, $rate, $source, $last_updated_date, $now); } } } $currObj = new cbpaidCurrency($_CB_database); $currObj->setCurrencyRate($source_currency, $source_currency, 1.0, 'CB', $last_updated_date, $now); } } } } }
/** *** From UNSUBSCRIBE_CONFIRM in frontend: * Shows an unsubscription confirmation form * * @param UserTable $user * @param string $introText * @param int $planId * @param int $subscriptionId * @return bool|mixed|null|string * @access private */ public static function doUnsubscribeConfirm( &$user, $introText, $planId, $subscriptionId ) { $result = null; $paidSomethinMgr =& cbpaidSomethingMgr::getInstance(); $subscription =& $paidSomethinMgr->loadSomething( $planId, $subscriptionId ); if ( $subscriptionId && $subscription && ( $subscription->user_id == $user->id ) ) { $result = $subscription->stopAutoRecurringPayments(); if ( is_string( $result ) ) { cbpaidApp::getBaseClass()->_setErrorMSG( $result ); $result = false; } if ( $result !== false ) { $subscription->deactivate( $user, 'C' ); // cancelled if ( strpos( $introText, '%s' ) !== false ) { $planName = $subscription->getPlanAttribute( 'name' ); $result = str_replace( '%s', $planName, $introText ); } else { $result = $introText; } } } else { $params =& cbpaidApp::settingsParams(); $subTxt = CBPTXT::T( $params->get( 'subscription_name', 'subscription' ) ); cbpaidApp::getBaseClass()->_setErrorMSG( sprintf( CBPTXT::T("No %s found"), $subTxt ) ); $result = false; } // if ( $result === false ) { // $result = cbpaidApp::getBaseClass()->getErrorMSG( '<br />' ); // } return $result; }
/** * Validates and computes business status on payment invoice save * * @param cbpaidPaymentBasket $paymentBasket * @param cbpaidsalestaxTotalizertype $salestaxTotalizerType */ public function validateInvoiceAddress( $paymentBasket, $salestaxTotalizerType ) { static $cache = array(); $country_code = $paymentBasket->address_country_code; $vatCountryCode = strtoupper( substr( $paymentBasket->vat_number, 0, 2 ) ); $cleanVatNumber = $this->cleanVatNumber( $paymentBasket->vat_number ); if ( $this->checkCountryInEU( $country_code ) ) { if ( ! ( $paymentBasket->payer_business_name && $paymentBasket->vat_number ) ) { $paymentBasket->is_business = 0; } elseif ( $this->checkCountryMatch( $country_code, $vatCountryCode ) ) { if ( $cleanVatNumber !== false ) { $viesArgs = array( 'countryCode' => $vatCountryCode, 'vatNumber' => $cleanVatNumber, 'traderName' => $paymentBasket->payer_business_name, // 'traderCompanyType' => 'GB-1', // ? 'traderStreet' => $paymentBasket->address_street, 'traderPostcode' => $paymentBasket->address_zip, 'traderCity' => $paymentBasket->address_city, ); // check if we want to transmit the seller VAT number (to get the requestIdentifier in return as proof of request): $seller_taxnumber = $salestaxTotalizerType->seller_taxnumber; if ( $seller_taxnumber ) { $viesArgs['requesterCountryCode'] = substr( $seller_taxnumber, 0, 2 ); $viesArgs['requesterVatNumber'] = substr( $seller_taxnumber, 2 ); } $k = implode( '|', $viesArgs ); if ( ! array_key_exists( $k, $cache ) ) { $paymentBasket->is_business = $this->checkVatApprox( $viesArgs, $paymentBasket, $paymentBasket->vat_verification ); $cache[$k] = $paymentBasket->is_business; } } else { // VAT number is not of correct format: $userMessage = CBPTXT::T("Invalid EU VAT Number. EU VAT numbers start with country code and must be valid."); cbpaidApp::getBaseClass()->_setErrorMSG( $userMessage ); $paymentBasket->is_business = 0; } } else { // country code and VAT number prefix missmatch: $userMessage = CBPTXT::T("Invalid VAT Number. VAT numbers start with country code and must match invoice address country."); cbpaidApp::getBaseClass()->_setErrorMSG( $userMessage ); $paymentBasket->is_business = 0; } } else { // country not in EU: do nothing here ! } }
/** * Validates tax rate's business status * * @param cbpaidPaymentBasket $paymentBasket * @param cbpaidsalestaxTotalizertype $tax * @param $buyerCountry * @param $buyerProvince * @param $sellerCountry * @param $sellerProvince * @return bool */ public function validateTaxRateBusinessStatus( &$paymentBasket, $tax, $buyerCountry, $buyerProvince, $sellerCountry, $sellerProvince ) { global $_CB_framework, $_PLUGINS; $taxrateApplies = true; if ( $tax->business_check ) { $absoluteValidationsPath = $_CB_framework->getCfg('absolute_path') . '/'. $_PLUGINS->getPluginRelPath( cbpaidApp::getBaseClass()->getPluginObject() ) . '/plugin/cbsubstax/validations/' . $tax->business_check; $valphp = $absoluteValidationsPath . '/validation.php'; if ( is_readable( $valphp ) ) { /** @noinspection PhpIncludeInspection */ include_once $valphp; $className = 'cbpaidValidate_' . $tax->business_check; if ( is_callable( array( $className, 'validateInvoiceAddress' ) ) ) { /** @var $validator cbpaidValidate */ $validator = new $className(); $validator->validateInvoiceAddress( $paymentBasket, $tax ); $businessStatusGeoValues = array( 1, ( $paymentBasket->is_business == 1 ? 3 : 2 ) ); if ( $sellerCountry == $buyerCountry ) { $taxrateApplies = in_array( $tax->tax_inside_of_country, $businessStatusGeoValues ); // $sql .= "\n AND ( r." . $tax->_db->NameQuote( 'tax_inside_of_country' ) . ' = 1 OR r.' . $tax->_db->NameQuote( 'tax_inside_of_country' ) . ' = ' . ( $buyerIsBusiness ? 3 : 2 ) . ' )'; if ( $taxrateApplies && $sellerProvince ) { if ( ( $sellerProvince == $buyerProvince ) || ( $buyerProvince == '' ) ) { $taxrateApplies = in_array( $tax->tax_inside_of_state, $businessStatusGeoValues ); // $sql .= "\n AND ( r." . $tax->_db->NameQuote( 'tax_inside_of_state' ) . ' = 1 OR r.' . $tax->_db->NameQuote( 'tax_inside_of_state' ) . ' = ' . ( $buyerIsBusiness ? 3 : 2 ) . ' )'; } else { $taxrateApplies = in_array( $tax->tax_outside_of_state, $businessStatusGeoValues ); // $sql .= "\n AND ( r." . $tax->_db->NameQuote( 'tax_outside_of_state' ) . ' = 1 OR r.' . $tax->_db->NameQuote( 'tax_outside_of_state' ) . ' = ' . ( $buyerIsBusiness ? 3 : 2 ) . ' )'; } } } else { $taxrateApplies = in_array( $tax->tax_outside_of_country, $businessStatusGeoValues ); // $sql .= "\n AND ( r." . $tax->_db->NameQuote( 'tax_outside_of_country' ) . ' = 1 OR r.' . $tax->_db->NameQuote( 'tax_outside_of_country' ) . ' = ' . ( $buyerIsBusiness ? 3 : 2 ) . ' )'; } } } } return $taxrateApplies; }
/** * Outputs the product's template CSS * * @return string Template name */ public function getTemplateOutoutCss( ) { static $defaultTemplate = null; if ( ! $defaultTemplate ) { $defaultTemplate = cbpaidApp::settingsParams()->get( 'template', 'default' ); } $template = $this->get( 'template' ); if ( $template == '' ) { $template = $defaultTemplate; } elseif ( $template != $defaultTemplate ) { cbpaidApp::getBaseClass()->outputRegTemplate( $template ); } return $template; }
/** * Gets html for slip page * * @param cbpaidPaymentBasket $paymentBasket * @return string */ private function _outputSlip($paymentBasket) { global $_CB_framework; $slip_html_title = CBPTXT::Th($this->getAccountParam('slip_html_title', "Payment Slip No. ")); $slip_html_for_site = CBPTXT::Th($this->getAccountParam('slip_html_for_site', "For website:")); $slip_html_for_url = $this->getAccountParam('slip_site_url', 1); $slip_html_for_item = CBPTXT::Th($this->getAccountParam('slip_html_for_item', "For item:")); $slip_html_for_member = CBPTXT::Th($this->getAccountParam('slip_html_for_member', "For member:")); $slip_html_reference = CBPTXT::Th($this->getAccountParam('slip_html_reference', "Important: include our reference with your payment:")); $slip_reference_site = $this->getAccountParam('slip_reference_site', 1); $slip_html_conclusion = CBPTXT::Th($this->getAccountParam('slip_html_conclusion', "If you pay by check, please print and enclose this page with your check.")); $slip_html_pure = $this->getAccountParam('slip_html_pure', 0); $slip_popup_window = $this->getAccountParam('slip_popup_window', 1); $slip_print_button = $this->getAccountParam('slip_print_button', 1); outputCbTemplate(); $this->_outputRegTemplate(); $ret = '<div class="cbpaidPaymentSlip">'; if ($slip_html_pure) { $vars = array('[order_id]' => $paymentBasket->id, '[item_number]' => $paymentBasket->item_number, '[item_description]' => $paymentBasket->item_name, '[user_id]' => $paymentBasket->user_id, '[username]' => $paymentBasket->username, '[address_name]' => $paymentBasket->address_name, '[address_street]' => $paymentBasket->address_street, '[address_city]' => $paymentBasket->address_city, '[address_state]' => $paymentBasket->address_state, '[address_zip]' => $paymentBasket->address_zip, '[address_country]' => $paymentBasket->address_country, '[address_country_code]' => $paymentBasket->address_country_code, '[first_name]' => $paymentBasket->first_name, '[last_name]' => $paymentBasket->last_name, '[order_table]' => $paymentBasket->displayBasket(), '[sitename]' => $_CB_framework->getCfg('sitename'), '[live_site]' => preg_replace("/^(https?:\\/\\/)/i", '', $_CB_framework->getCfg('live_site'))); $default_html = '<h2>Payment Slip No. [order_id]</h2>' . '<h3 id="cbpaidWebsite">For website: [sitename]</h3>' . '<p id="cbpaidAddress"><address>[live_site]</address></p>' . '<h3 id="cbpaidItem">For item: [item_number]</h3>' . '<h3 id="cbpaidUser">For member: [first_name] [last_name]</h3>' . '<div>[order_table]</div>' . '<p id="cbpaidReference"><strong>Important: include our reference with your payment: <u style=\\"font-size:125%\\">Number [order_id] / [live_site]</u></strong></p>' . '<p id=\\"cbpaidCheck\\">If you pay by check, please print and enclose this page with your check.</p>'; $slip_html_custom = CBPTXT::Th($this->getAccountParam('slip_html_custom', $default_html)); $ret .= strtr($slip_html_custom, $vars); } else { if ($slip_html_title) { $ret .= '<h2>' . $slip_html_title . ' ' . $paymentBasket->id . "</h2>\n"; } if ($slip_html_for_site) { $ret .= "<h3 id=\"cbpaidWebsite\">" . $slip_html_for_site . ' ' . $_CB_framework->getCfg('sitename') . "</h3>\n"; } if ($slip_html_for_url) { $ret .= "<p id=\"cbpaidAddress\"><address>" . $_CB_framework->getCfg('live_site') . "</address></p>\n"; } if ($slip_html_for_item) { $ret .= "<h3 id=\"cbpaidItem\">" . $slip_html_for_item . ' ' . $paymentBasket->item_number . "</h3>\n"; } if ($slip_html_for_member) { $ret .= "<h3 id=\"cbpaidUser\">" . $slip_html_for_member . ' ' . $paymentBasket->first_name . ' ' . $paymentBasket->last_name . "</h3>\n"; } $ret .= $paymentBasket->displayBasket(); if ($slip_html_reference) { $ret .= "<p id=\"cbpaidReference\"><strong>" . $slip_html_reference . " <u style=\"font-size:125%\">" . CBPTXT::T("Number") . ' ' . $paymentBasket->id; if ($slip_reference_site) { $ret .= " / " . preg_replace("/^(https?:\\/\\/)/i", '', $_CB_framework->getCfg('live_site')); } $ret .= "</u></strong></p>\n"; } if ($slip_html_conclusion) { $ret .= "<p id=\"cbpaidCheck\">" . $slip_html_conclusion . "</p>\n"; } } if ($slip_popup_window) { $ret .= "<div id=\"cbpaidPrint\" style=\"width:100%;text-align:center;\"><p><a href=\"javascript:void(window.print())\">" . CBPTXT::Th("PRINT") . "</a></p></div>\n"; $ret .= "<div id=\"cbpaidClose\" style=\"width:100%;text-align:center;\"><p><a href=\"javascript:void(window.close())\">" . CBPTXT::Th("CLOSE") . "</a></p></div>\n"; } else { if ($slip_print_button) { $slip_urlHtmlSpecialchared = $this->_getSlipUrlHtmlSpecialchared($paymentBasket, true); $ret .= "<div id=\"cbpaidPrint\" style=\"width:100%;text-align:center;\"><p><a href=\"" . $slip_urlHtmlSpecialchared . "\" " . 'onclick="window.open(\'' . $slip_urlHtmlSpecialchared . '\', \'payslip\', \'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no\'); return false;" ' . 'target="_blank" ' . '>' . CBPTXT::Th("PRINT") . "</a></p></div>\n"; } } $recordPaymentUrl = cbpaidApp::getBaseClass()->getRecordPaymentUrl($paymentBasket); if ($recordPaymentUrl) { $ret .= '<div id="cbpaidRecordPayment"><a href="' . $recordPaymentUrl . '" title="' . htmlspecialchars(CBPTXT::T("Record the offline payment now")) . '">' . CBPTXT::Th("RECORD OFFLINE PAYMENT") . '</a></div>'; } $ret .= "</div>"; return $ret; }
/** * Sets the text of the last error and logs it to the history logger * * @param int $log_priority Priority of message (UNIX-type): 0: Emergency, 1: Alert, 2: Critical, 3: Error, 4: Warning, 5: Notice, 6: Info, 7: Debug * @param cbpaidTable|null $object Object stored in database, so that table name of table and id of key can be stored with the error * @param string $logMessagePrefix Error message prefix for the logged message (simple non-html text only): will be prepended with ': ' * @param string $userMessage Error message for user (simple non-html text only) */ public static function setLogErrorMSG($log_priority, $object, $logMessagePrefix, $userMessage) { global $_CB_database; $logObject = new cbpaidHistory($_CB_database); $logText = $logMessagePrefix ? $logMessagePrefix . ($userMessage ? ': ' . $userMessage : '') : $userMessage; $logObject->logError($log_priority, $logText, $object); if ($userMessage) { cbpaidApp::getBaseClass()->_setErrorMSG($userMessage); } }
/** * Redirects expired user to the re-subscription screen. * @access private * @param int $userId */ protected function _redirectExpiredMembership($userId) { global $_CB_framework; $params = cbpaidApp::settingsParams(); $paidUserExtension = cbpaidUserExtension::getInstance($userId); $expiredSubscriptions = $paidUserExtension->getUserSubscriptions('X'); // check if there is any expired extensions for the text if (count($expiredSubscriptions) > 0) { $textMessage = $params->get('subscriptionExpiredText', "Your membership has expired."); $expiredRedirectLink = $params->get('subscriptionExpiredRedirectLink'); } else { $textMessage = $params->get('subscriptionNeededText', "A membership is needed for access."); $expiredRedirectLink = $params->get('subscriptionNeededRedirectLink'); } if (!$expiredRedirectLink) { $baseClass = cbpaidApp::getBaseClass(); if ($baseClass) { $expiredRedirectLink = $baseClass->_getAbsURLwithParam(array('Itemid' => 0, 'account' => 'expired', 'user' => (int) $userId), 'pluginclass', false); } else { // without baseClass, as baseClass is not loaded in case of cbpaidsubsbot: $cbpPrefix = 'cbp'; $expiredRedirectLink = 'index.php?option=com_comprofiler&task=pluginclass&plugin=cbpaidsubscriptions&' . $cbpPrefix . 'account=expired&user='******'index.php?option=com_comprofiler&task=pluginclass&plugin=cbpaidsubscriptions&do=display_subscriptions'; // &Itemid= ??? } if ($userId) { $_SESSION['cbsubs']['expireduser'] = $userId; } } if ($_CB_framework->getRequestVar('option') != 'com_comprofiler' || $_CB_framework->getRequestVar('task') != 'pluginclass' || $_CB_framework->getRequestVar('plugin') != 'cbpaidsubscriptions') { cbRedirect(cbSef($expiredRedirectLink, false), CBPTXT::T($textMessage), 'warning'); } }
/** * Renders and ECHOs the credit-card form HTML * @param string $cardType CC-brand, NULL if no choice * @param string[] $txtVisibleInputs All input values of the form * @param string $txtButton Text for button */ protected function _renderCCform( /** @noinspection PhpUnusedParameterInspection */ $cardType, $txtVisibleInputs, $txtButton ) { global $_CB_framework; ?> <div class="cbregCCnumexp"> <div class="cbregCCtype"> <label class="cbregLabel" for="<?php echo cbpaidApp::getBaseClass()->_getPagingParamName( 'cardtype' ) . '0'; ?>"><?php echo CBPTXT::Th("Card Type") . ':'; ?></label> <div class="cbregField"><?php echo $txtVisibleInputs['cardtype']; ?></div> </div> <div id="cbregCardDetails"> <div class="cbregCCnum"> <label for="<?php echo $this->baseClass->_getPagingParamName('number'); ?>" class="cbregLabel"><?php echo CBPTXT::Th("Card Number") . ':'; ?></label> <div class="cbregField"><?php echo $txtVisibleInputs['number']; ?></div> </div> <fieldset class="cbregCCexp"> <legend class="cbregLabel"><?php echo CBPTXT::Th("Expires") . ':'; ?></legend> <label for="<?php echo $this->baseClass->_getPagingParamName('expmonth'); ?>" class="cbregLabel"><?php echo CBPTXT::Th("Card Expiration Month"); ?></label> <label for="<?php echo $this->baseClass->_getPagingParamName('expyear'); ?>" class="cbregLabel"><?php echo CBPTXT::Th("Card Expiration Year") . ':'; ?></label> <div class="cbregField"><?php echo $txtVisibleInputs['expmonth'] . ' / ' . $txtVisibleInputs['expyear']; ?></div> </fieldset> <?php if ( $txtVisibleInputs['cvv'] ) { ?> <div class="cbregCCcvv"> <label for="<?php echo $this->baseClass->_getPagingParamName('cvv'); ?>" class="cbregLabel"><?php echo CBPTXT::Th("Card Validation Code") . ':'; ?></label> <div class="cbregField"><?php echo $txtVisibleInputs['cvv']; ?> <?php if ( file_exists( $_CB_framework->getCfg( 'absolute_path') . '/components/com_comprofiler/plugin/user/plug_cbpaidsubscriptions/icons/cards/cc_cvv2.gif' ) ) { ?> <img src="<?php echo $_CB_framework->getCfg( 'live_site' ) . '/components/com_comprofiler/plugin/user/plug_cbpaidsubscriptions/icons/cards/cc_cvv2.gif'; ?>" alt="<?php echo CBPTXT::T("Visa CVV2 / Mastercard CVC2 / Discover: last 3 digits on back. American Express CID: 4 digits in front."); ?>" title="<?php echo CBPTXT::T("Visa CVV2 / Mastercard CVC2 / Discover: last 3 digits on back. American Express CID: 4 digits in front."); ?>" /> <?php } ?> </div> </div> <?php } ?> <div class="cbclearboth"> <div class="cbregCCfirstname"> <label for="<?php echo $this->baseClass->_getPagingParamName('firstname'); ?>" class="cbregLabel"><?php echo CBPTXT::Th("First name on card") . ':'; ?></label> <div class="cbregField"><?php echo $txtVisibleInputs['firstname']; ?></div> </div> <div class="cbregCClastname"> <label for="<?php echo $this->baseClass->_getPagingParamName('lastname'); ?>" class="cbregLabel"><?php echo CBPTXT::Th("Last name on card") . ':'; ?></label> <div class="cbregField"><?php echo $txtVisibleInputs['lastname']; ?></div> </div> </div> <?php if ( isset( $txtVisibleInputs['country'] ) ) { ?> <fieldset class="cbregCCinvoicingaddress"> <legend class="cbregLabel"><?php echo CBPTXT::Th("Card invoicing address") . ':'; ?></legend> <?php if ( isset( $txtVisibleInputs['address'] ) ) { ?> <div class="cbregCCaddress cb_form_line"> <label for="<?php echo $this->baseClass->_getPagingParamName('address'); ?>" class="cbregLabel"><?php echo CBPTXT::Th("Street address") . ':'; ?></label> <div class="cbregField cb_field"><?php echo $txtVisibleInputs['address']; ?></div> </div> <?php } if ( isset( $txtVisibleInputs['zip'] ) ) { ?> <div class="cbregCCzip cb_form_line"> <label for="<?php echo $this->baseClass->_getPagingParamName('zip'); ?>" class="cbregLabel"><?php echo CBPTXT::Th("ZIP code") . ':'; ?></label> <div class="cbregField"><?php echo $txtVisibleInputs['zip']; ?></div> </div> <?php } ?> <div class="cbregCCcountry cb_form_line"> <label for="<?php echo $this->baseClass->_getPagingParamName('country'); ?>" class="cbregLabel"><?php echo CBPTXT::Th("Country") . ':'; ?></label> <div class="cbregField"><?php echo $txtVisibleInputs['country']; ?></div> </div> </fieldset> <?php } ?> </div> <div class="cbregCCbutton"> <?php echo $txtButton; ?> </div> </div> <?php }