/** * Triggers autorecurring payments scheduled in cbpaidScheduler * * @return null|string NULL: no tasks done. String: result or error to forward to admins. */ public function triggerScheduledAutoRecurringPayment( ) { $schedule = cbpaidScheduler::getInstance( $this ); $newAttempt = false; if ( $schedule->attemptScheduledTask() ) { if ( $this->gateway_account ) { $payAccount = cbpaidControllerPaychoices::getInstance()->getPayAccount( $this->gateway_account ) ; if ( $payAccount ) { $payClass = $payAccount->getPayMean(); if ( $payClass ) { $return = null; $transientErrorDoReschedule = false; $success = $payClass->processAutoRecurringPayment( $this, $return, $transientErrorDoReschedule ); if ( $success === true ) { $another = $schedule->attemptScheduledTaskSuccessful(); } elseif ( $success === false) { $another = $schedule->attemptScheduledTaskFailed( $transientErrorDoReschedule ); } elseif ( $success === null ) { $another = false; } else { $another = false; trigger_error( sprintf( "Unexpected return value from processAutoRecurringPayment on %s", $payClass->getPayName() ), E_USER_WARNING ); } if ( $another ) { $return .= ' ' . sprintf( CBPTXT::T("The next payment reattempt is scheduled on %s"), $this->scheduler_next_maturity ); } } else { $newAttempt = $schedule->attemptScheduledTaskFailed( true ); $return = sprintf( CBPTXT::T("Auto-Recurring payment of Basket %s could not be done, because the payment gateway account %s (id %s) class does not have method processAutoRecurringPayment."), $this->id, $this->payment_method, $this->gateway_account ); } } else { $newAttempt = $schedule->attemptScheduledTaskFailed( true ); $return = sprintf( CBPTXT::T("Auto-Recurring payment of Basket %s could not be done, because the payment gateway account %s (id %s) is not existent and active."), $this->id, $this->payment_method, $this->gateway_account ); } } else { $newAttempt = $schedule->attemptScheduledTaskFailed( true ); $return = sprintf( CBPTXT::T("Auto-Recurring payment of Basket %s could not be done, because the basket has no payment gateway account set (method: %s)."), $this->id, $this->payment_method ); } } else { $return = CBPTXT::P("Error in last scheduled taks for this Basket [BASKET_ID] or error in payment scheduling table: Unexpected state (e.g. already executing) or cannot store. This state will be cleared automatically after 3 cron jobs so that a retry can automatically occur.", array( '[BASKET_ID]' => $this->id ) ); } if ( $newAttempt ) { $return .= ' ' . CBPTXT::T("A new auto-recurring payment attempt has been scheduled."); } return $return; }
/** * When triggered, before starting to make changes this method should be called * Transition: -> E{$substate} * * @param string $substate * @return boolean TRUE: got lock to perform scheduled task, FALSE: no scheduling needed here (and no transition made) */ public function attemptScheduledTask( $substate = '' ) { if ( substr( $this->_baseObject->scheduler_state, 0, 1 ) == 'E' ) { // It was Executing: check for iterations before resetting to 'S' (with error log). if ( strlen( $this->_baseObject->scheduler_state ) == 1 ) { // Backwards compatibility: $this->_baseObject->scheduler_state .= '1'; } $iteration = (int) $this->_baseObject->scheduler_state[1]; if ( ++$iteration <= $this->maxExecWaitIterations ) { $this->_baseObject->scheduler_state[1] = (string) $iteration; $this->_baseObject->store(); } else { $this->_baseObject->scheduler_state = 'S'; cbpaidApp::setLogErrorMSG( 4, $this->_baseObject, CBPTXT::P("Scheduler for this basket has stayed in execution state for [NUMBER_OF_CRONS] cron cycles. Resetting execution state.", array( '[NUMBER_OF_CRONS]' => $this->maxExecWaitIterations ) ), null ); } } // Now normal case: if ( $this->_baseObject->scheduler_state == 'S' ) { // it was scheduled: $this->_baseObject->scheduler_state = 'E1' . $substate; // Executing return $this->_baseObject->store(); } return false; }
/** * If table key (id) is NULL : inserts a new row * otherwise updates existing row in the database table * * Can be overridden or overloaded by the child class * * @param boolean $updateNulls TRUE: null object variables are also updated, FALSE: not. * @return boolean TRUE if successful otherwise FALSE */ public function store($updateNulls = false) { if (!cbpaidApp::authoriseAction('cbsubs.refunds')) { $this->setError(CBPTXT::T("Not authorized")); return false; } // 1) check: if (!in_array($this->payment_status, array('Completed', 'Pending', 'Partially-Refunded'))) { $this->setError(CBPTXT::T("This payment is not completed, pending or partially refunded.")); return false; } if ($this->txn_id == '') { $this->txn_id = 'None'; // needed for updatePayment to generate payment record. } $payment = new cbpaidPayment(); if (!$payment->load((int) $this->id)) { $this->setError(CBPTXT::T("This payment does not exist.")); return false; } $paymentBasket = new cbpaidPaymentBasket(); if (!$paymentBasket->load($this->payment_basket_id)) { $this->setError(CBPTXT::T("This payment has no associated payment basket and cannot be refunded from here. Maybe from your PSP online terminal ?")); return false; } if (!$this->gateway_account) { $this->setError(CBPTXT::T("This payment has no gateway associated so can not be refunded.")); return false; } $payAccount = cbpaidControllerPaychoices::getInstance()->getPayAccount($this->gateway_account); if (!$payAccount) { $this->setError(CBPTXT::T("This payment's payment basket's associated gateway account is not active, so can not be refunded from here.")); return false; } $payClass = $payAccount->getPayMean(); $returnText = null; $amount = sprintf('%.2f', (double) $this->refund_gross); if (is_callable(array($payClass, 'refundPayment'))) { $success = $payClass->refundPayment($paymentBasket, $payment, null, $this->refund_is_last, $amount, $this->refund_reason, $returnText); } else { $success = false; } $user = CBuser::getUserDataInstance($paymentBasket->user_id); $username = $user ? $user->username : '******'; $replacements = array('[REFUNDAMOUNT]' => $payment->mc_currency . ' ' . $amount, '[PAYMENTID]' => $payment->id, '[PAYMENTAMOUNT]' => $payment->mc_currency . ' ' . $payment->mc_gross, '[BASKETID]' => $paymentBasket->id, '[ORDERID]' => $paymentBasket->sale_id, '[FULLNAME]' => $paymentBasket->first_name . ' ' . $paymentBasket->last_name, '[USERNAME]' => $username, '[USERID]' => $paymentBasket->user_id, '[PAYMENTMETHOD]' => $payClass->getPayName(), '[TXNID]' => $payment->txn_id, '[AUTHID]' => $payment->auth_id, '[ERRORREASON]' => $paymentBasket->reason_code); if ($success) { // Success Message ? // $returnText = CBPTXT::P("Refunded [REFUNDAMOUNT] for payment id [PAYMENTID] of [PAYMENTAMOUNT] for basket id [BASKETID], Order id [ORDERID] of [FULLNAME] (username [USERNAME] - user id [USERID]) using [PAYMENTMETHOD] with txn_id [TXNID] and auth_id [AUTHID].", $replacements ); } else { $this->setError(CBPTXT::T($payClass->getErrorMSG()) . '. ' . CBPTXT::P("Refund request of [REFUNDAMOUNT] for payment id [PAYMENTID] of [PAYMENTAMOUNT] for basket id [BASKETID], Order id [ORDERID] of [FULLNAME] (username [USERNAME] - user id [USERID]) using [PAYMENTMETHOD] with txn_id [TXNID] and auth_id [AUTHID] failed for reason: [ERRORREASON].", $replacements)); return false; } return true; }
/** * perform anti fraud checks on ipn values * * @param cbpaidPaymentNotification $ipn * @param cbpaidPaymentBasket $paymentBasket * @return bool|string */ private function _validateIPN( $ipn, $paymentBasket ) { global $_CB_database; $matching = true; if ( in_array( $ipn->payment_status, array( 'Completed', 'Processed', 'Canceled_Reversal' ) ) ) { if ( $ipn->txn_type == 'subscr_payment' ) { $payments = $paymentBasket->getPaymentsTotals( $ipn->txn_id ); if ( ( $paymentBasket->mc_amount1 != 0 ) && ( $payments->count == 0 ) ) { $amount = $paymentBasket->mc_amount1; } else { $amount = $paymentBasket->mc_amount3; } if ( sprintf( '%.2f', $ipn->mc_gross ) != sprintf( '%.2f', $amount ) ) { if ( ( sprintf( '%.2f', $ipn->mc_gross ) < sprintf( '%.2f', $amount ) ) || ( sprintf( '%.2f', ( $ipn->mc_gross - $ipn->tax ) ) != sprintf( '%.2f', $amount ) ) ) { if ( ( ! ( ( $paymentBasket->mc_amount1 != 0 ) && ( $payments->count == 0 ) ) ) && ( ( (float) sprintf( '%.2f', ( $ipn->mc_gross - abs( $ipn->tax ) ) ) ) < ( (float) sprintf( '%.2f', $amount ) ) ) ) { $matching = CBPTXT::P( 'amount mismatch on recurring_payment: $amount: [amount] != IPN mc_gross: [gross] or IPN mc_gross - IPN tax: [net] where IPN tax = [tax]', array( '[amount]' => $amount, '[net]' => ( $ipn->mc_gross - $ipn->tax ), '[gross]' => $ipn->mc_gross, '[tax]' => $ipn->tax ) ); } } } } else { if ( sprintf( '%.2f', $ipn->mc_gross ) != sprintf( '%.2f', $paymentBasket->mc_gross ) ) { if ( ( sprintf( '%.2f', $ipn->mc_gross ) < sprintf( '%.2f', $paymentBasket->mc_gross ) ) || ( sprintf( '%.2f', $ipn->mc_gross - $ipn->tax ) != sprintf( '%.2f', $paymentBasket->mc_gross ) ) ) { $matching = CBPTXT::P( 'amount mismatch on webaccept: BASKET mc_gross: [basket_gross] != IPN mc_gross: [gross] or IPN mc_gross - IPN tax: [net] where IPN tax = [tax]', array( '[basket_gross]' => $paymentBasket->mc_gross, '[net]' => ( $ipn->mc_gross - $ipn->tax ), '[gross]' => $ipn->mc_gross, '[tax]' => $ipn->tax ) ); } } } } if ( in_array( $ipn->txn_type, array( 'subscr_signup', 'subscr_modify', 'subscr_eot', 'subscr_cancel', 'subscr_failed', 'subscr_payment' ) ) ) { if ( ! $paymentBasket->isAnyAutoRecurring() ) { $matching = CBPTXT::P( 'paypal subscription IPN type [txn_type] for a basket without auto-recurring items', array( '[txn_type]' => $ipn->txn_type ) ); } } if ( ! in_array( $ipn->txn_type, array( 'subscr_signup', 'subscr_modify', 'subscr_eot', 'subscr_cancel', 'subscr_failed' ) ) ) { if ( ( $ipn->txn_id === '' ) || ( $ipn->txn_id === 0 ) || ( $ipn->txn_id === null ) ) { $matching = CBPTXT::T( 'illegal transaction id' ); } else { $countBaskets = $paymentBasket->countRows( "txn_id = '" . $_CB_database->getEscaped( $ipn->txn_id ) . "' AND payment_status = 'Completed'" ); if ( ( $countBaskets == 1 ) && ( $paymentBasket->txn_id != $ipn->txn_id ) || ( $countBaskets > 1 ) ) { $matching = CBPTXT::P( 'transaction already used for [count] other already completed payment(s)', array( '[count]' => $countBaskets ) ); } } } return $matching; }
/** * 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; }
/** * Evaluates $results depending on the ACK value * * @param array $specificVars * @param array $results * @param string $text * @return bool */ protected function evaluateResults( $specificVars, $results, $text ) { $ret = false; if ( $results ) { if ( isset( $results['ACK'] ) ) { switch ( $results['ACK'] ) { case 'SuccessWithWarning': $detailsForAdmin = null; $this->decodeErrorsToStrings( $results, $detailsForAdmin ); $this->setError( 6, null, sprintf( 'Paypal API %s: Successful but with warning: %s.', $this->_formatVars( $specificVars ), $detailsForAdmin ), CBPTXT::P("[APIMETHODD] successful, but notice returned by gateway.", array( '[APIMETHODD]' => $text ) ) . ' ' . CBPTXT::T("Please ask administrator to check his error log for details.") ); $ret = true; break; case 'Success': $ret = true; break; case 'FailureWithWarning': case 'Failure': default: $detailsForAdmin = null; $error = $this->decodeErrorsToStrings( $results, $detailsForAdmin ); $this->setError( 3, null, sprintf( 'Paypal API %s: Failed with error: %s. REQUEST: %s, REPLY: %s', $this->_formatVars( $specificVars ), $detailsForAdmin, var_export( $specificVars, true ), var_export( $results, true ) ), CBPTXT::P("[APIMETHODD] failed: [ERRORMESSAGE]", array( '[APIMETHODD]' => $text, '[ERRORMESSAGE]' => $error ) ) ); $ret = false; break; } } } return $ret; }
/** * Returns text 'using your xxxx account no....' displayed after successful payment. * This gives opportunity to personalize with gateway-specific text. * * @param cbpaidPaymentBasket $paymentBasket * @return string Text */ public function getTxtUsingAccount($paymentBasket) { //FIXME: in future this should be $payment and NOT basket! return ' ' . CBPTXT::P('using [PAYMENTMETHOD]', array('[PAYMENTMETHOD]' => CBPTXT::T($paymentBasket->payment_type))); }