/** * DonationData constructor * @param GatewayAdapter $gateway * @param mixed $data An optional array of donation data that will, if * present, circumvent the usual process of gathering the data from various * places in the request, or 'false' to gather the data the usual way. * Default is false. */ function __construct(GatewayType $gateway, $data = false) { $this->gateway = $gateway; $this->gatewayID = $this->gateway->getIdentifier(); $this->logger = DonationLoggerFactory::getLogger($gateway, '', $this); $this->populateData($data); }
/** * Stage: payment_product and a few minor tweaks * Stages the payment product ID for GC. * Not what I had in mind to begin with, but this *completely* blew up. */ public function stage(GatewayType $adapter, $normalized, &$stagedData) { $logger = DonationLoggerFactory::getLogger($adapter); // FIXME: too much variable management if (empty($normalized['payment_method'])) { $stagedData['payment_method'] = ''; $stagedData['payment_submethod'] = ''; return; } $payment_method = $normalized['payment_method']; $payment_submethod = $normalized['payment_submethod']; // We might support a variation of the submethod for this country. //TODO: Having to front-load the country in the payment submethod is pretty lame. //If we don't have one deliberately set... if (!$payment_submethod) { $trythis = $payment_method . '_' . strtolower($normalized['country']); if (array_key_exists($trythis, $adapter->getPaymentSubmethods())) { $payment_submethod = $trythis; $stagedData['payment_submethod'] = $payment_submethod; } } // Lookup the payment product ID. if ($payment_submethod) { try { $submethod_data = $adapter->getPaymentSubmethodMeta($payment_submethod); if (isset($submethod_data['paymentproductid'])) { $stagedData['payment_product'] = $submethod_data['paymentproductid']; } } catch (OutOfBoundsException $ex) { // Already logged. We don't have the heart to abort here. } } else { $logger->debug("payment_submethod found to be empty. Probably okay though."); } switch ($payment_method) { case 'dd': $stagedData['date_collect'] = gmdate('Ymd'); $stagedData['direct_debit_text'] = 'Wikimedia Foundation'; break; case 'ew': $stagedData['descriptor'] = 'Wikimedia Foundation/Wikipedia'; break; } // Tweak transaction type switch ($payment_submethod) { case 'dd_nl': $stagedData['transaction_type'] = '01'; break; case 'dd_gb': $stagedData['transaction_type'] = '01'; break; } }
public function setGateway(GatewayType $gateway) { $this->gateway = $gateway; $this->logger = DonationLoggerFactory::getLogger($gateway); $gateway_errors = $this->gateway->getAllErrors(); // @codeCoverageIgnoreStart if (!is_array($gateway_errors)) { $gateway_errors = array(); } // @codeCoverageIgnoreEnd $this->form_errors = array_merge(DataValidator::getEmptyErrorArray(), $gateway_errors); }
/** * Show the special page * * @param $par Mixed: parameter passed to the page or null */ public function execute($par) { global $wgContributionTrackingFundraiserMaintenance, $wgContributionTrackingFundraiserMaintenanceUnsched; // FIXME: Deprecate "language" param. $language = $this->getRequest()->getVal('language'); if ($language) { $this->getContext()->setLanguage($language); global $wgLang; $wgLang = $this->getContext()->getLanguage(); // BackCompat } $gatewayName = $this->getGatewayIdentifier(); $className = DonationInterface::getAdapterClassForGateway($gatewayName); try { $this->adapter = new $className(); $this->logger = DonationLoggerFactory::getLogger($this->adapter); $this->getOutput()->addModuleStyles('donationInterface.styles'); $this->getOutput()->addModules('donationInterface.skinOverride'); } catch (Exception $ex) { if (!$this->logger) { $this->logger = DonationLoggerFactory::getLoggerForType($className, $this->getLogPrefix()); } $this->logger->error("Exception setting up GatewayPage with adapter class {$className}: " . "{$ex->getMessage()}\n{$ex->getTraceAsString()}"); // Setup scrambled, no point in continuing $this->displayFailPage(); return; } if ($this->adapter->getGlobal('Enabled') !== true) { $this->logger->info('Displaying fail page for disabled gateway'); $this->displayFailPage(); return; } if ($wgContributionTrackingFundraiserMaintenance || $wgContributionTrackingFundraiserMaintenanceUnsched) { $this->getOutput()->redirect(Title::newFromText('Special:FundraiserMaintenance')->getFullURL(), '302'); return; } if ($this->adapter->getFinalStatus() === FinalStatus::FAILED) { $this->logger->info('Displaying fail page for failed GatewayReady checks'); $this->displayFailPage(); return; } Hooks::register('MakeGlobalVariablesScript', array($this->adapter, 'setClientVariables')); try { $this->handleRequest(); } catch (Exception $ex) { $this->logger->error("Displaying fail page for exception: " . $ex->getMessage()); $this->displayFailPage(); return; } }
/** * // TODO: don't do anything in the constructor. */ public function __construct() { // Have to turn this off here, until we know it's using the user's ip, and // not 127.0.0.1 during the batch process. Otherwise, we'll immediately // lock ourselves out when processing multiple charges. global $wgDonationInterfaceEnableIPVelocityFilter; $wgDonationInterfaceEnableIPVelocityFilter = false; // Fetch configuration $this->target_execute_time = $this->getOrphanGlobal('target_execute_time'); $this->time_buffer = $this->getOrphanGlobal('time_buffer'); $className = DonationInterface::getAdapterClassForGateway('globalcollect_orphan'); $this->adapter = new $className(); $this->logger = DonationLoggerFactory::getLogger($this->adapter); }
/** * Constructor * * @param GatewayType $gateway_adapter Gateway adapter instance * @param Gateway_Extras_CustomFilters $custom_filter_object Instance of Custom filter object * @param string $license_key The license key. May also be set in $wgMinFraudLicenseKey * @throws RuntimeException */ protected function __construct(GatewayType $gateway_adapter, Gateway_Extras_CustomFilters $custom_filter_object, $license_key = NULL) { parent::__construct($gateway_adapter); $this->fraud_logger = DonationLoggerFactory::getLogger($gateway_adapter, '_fraud'); $this->cfo = $custom_filter_object; global $wgMinFraudLicenseKey; // set the minfraud license key, go no further if we don't have it if (!$license_key && !$wgMinFraudLicenseKey) { throw new RuntimeException("minFraud license key required but not present."); } $this->minfraudLicenseKey = $license_key ? $license_key : $wgMinFraudLicenseKey; // Set the action range $gateway_ranges = $gateway_adapter->getGlobal('MinFraudActionRanges'); if (!is_null($gateway_ranges)) { $this->action_ranges = $gateway_ranges; } // Set the minFraud API servers $minFraudServers = $gateway_adapter->getGlobal('MinFraudServers'); if (!empty($minFraudServers) && is_array($minFraudServers)) { $this->minFraudServers = $minFraudServers; } }
/** * Get the URL for a page to show donors after a failed donation without * requiring an adapter instance. * @param string $adapterType adapter class to use for settings and logger * e.g. AdyenGateway * @param string $logPrefix identifier used to associate log lines with * related requests * @return string full URL of the fail page */ public static function getFailPageForType($adapterType, $logPrefix = '') { return self::getFailPageFromParams(false, $adapterType::getGlobal('FailPage'), array('gateway' => $adapterType::getIdentifier(), 'payment_method' => '', 'payment_submethod' => ''), DonationLoggerFactory::getLoggerForType($adapterType, $logPrefix)); }
protected function __construct(GatewayType $gateway_adapter) { $this->gateway_adapter = $gateway_adapter; $this->transaction_logger = DonationLoggerFactory::getLogger($this->gateway_adapter, '_trxn'); $this->gateway_logger = DonationLoggerFactory::getLogger($this->gateway_adapter); }
protected function __construct(GatewayType $gateway_adapter) { parent::__construct($gateway_adapter); $this->fraud_logger = DonationLoggerFactory::getLogger($this->gateway_adapter, '_fraud'); }
/** * Add a hit to this IP's history for a toxic card. This is designed to be * called outside of the usual filter callbacks so we record nasty attempts * even when the filters aren't called. * @param GatewayType $gateway adapter instance with user_ip set */ public static function penalize(GatewayType $gateway) { $logger = DonationLoggerFactory::getLogger($gateway); $logger->info('IPVelocityFilter penalizing IP address ' . $gateway->getData_Unstaged_Escaped('user_ip') . ' for toxic card attempt.'); $velocity = Gateway_Extras_CustomFilters_IP_Velocity::singleton($gateway, Gateway_Extras_CustomFilters::singleton($gateway)); if ($velocity->connectToMemcache()) { $velocity->addNowToMemcachedValue(null, false, true); } }
/** * Constructor * * @param array $options * OPTIONAL - You may set options for testing * - external_data - array, data from unusual sources (such as test fixture) * - api_request - Boolean, this is an api request, do not perform UI actions * * @see DonationData */ public function __construct($options = array()) { $defaults = array('external_data' => null, 'api_request' => false); $options = array_merge($defaults, $options); if (array_key_exists('batch_mode', $options)) { $this->batch = $options['batch_mode']; unset($options['batch_mode']); } $this->logger = DonationLoggerFactory::getLogger($this); $this->payment_init_logger = DonationLoggerFactory::getLogger($this, '_payment_init'); $this->profiler = DonationLoggerFactory::getProfiler($this); $this->logger->info("Creating a new adapter of type: [{$this->getGatewayName()}]"); // so we know we can skip all the visual stuff. if ($options['api_request']) { $this->setApiRequest(); } // The following needs to be set up before we initialize DonationData. // TODO: move the rest of the initialization here $this->loadConfig(); $this->defineOrderIDMeta(); $this->defineDataConstraints(); $this->definePaymentMethods(); $this->defineDataTransformers(); $this->session_resetOnSwitch(); // Need to do this before creating DonationData // FIXME: this should not have side effects like setting order_id_meta['final'] $this->dataObj = new DonationData($this, $options['external_data']); $this->setValidationErrors($this->getOriginalValidationErrors()); $this->unstaged_data = $this->dataObj->getDataEscaped(); $this->staged_data = $this->unstaged_data; // checking to see if we have an edit token in the request... $this->posted = $this->dataObj->wasPosted() && !is_null(WmfFramework::getRequestValue('wmf_token', null)); $this->findAccount(); $this->defineAccountInfo(); $this->defineTransactions(); $this->defineErrorMap(); $this->defineVarMap(); $this->defineReturnValueMap(); $this->setGatewayDefaults($options); $this->stageData(); BannerHistoryLogIdProcessor::onGatewayReady($this); Gateway_Extras_CustomFilters::onGatewayReady($this); if ($this->getValidationAction() !== 'process') { $this->finalizeInternalStatus(FinalStatus::FAILED); $error = array('general' => array('internal-0001' => $this->getErrorMapByCodeAndTranslate('internal-0001'))); $this->addManualError($error); } }
protected function tearDown() { $this->resetAllEnv(); DonationLoggerFactory::$overrideLogger = null; parent::tearDown(); }
public function __construct() { $this->logger = DonationLoggerFactory::getLoggerForType('TestingGenericAdapter'); //nothing! }
function __construct() { $this->logger = DonationLoggerFactory::getLoggerForType('GatewayAdapter', 'FormChooser'); parent::__construct('GatewayFormChooser'); }
protected function __construct(GatewayType $gatewayAdapter) { $this->gatewayAdapter = $gatewayAdapter; $this->logger = DonationLoggerFactory::getLogger($gatewayAdapter, '_banner_history'); }