public function validate(GatewayType $adapter, $normalized, &$errors) { if (!isset($normalized['amount']) || !isset($normalized['currency_code'])) { // Not enough info to validate return; } if (isset($errors['currency_code'])) { // Already displaying an error return; } $value = $normalized['amount']; if (self::isZeroIsh($value)) { $errors['amount'] = DataValidator::getErrorMessage('amount', 'not_empty', $normalized['language']); return; } $currency = $normalized['currency_code']; $min = self::convert($adapter->getGlobal('PriceFloor'), $currency); $max = self::convert($adapter->getGlobal('PriceCeiling'), $currency); if (!is_numeric($value) || $value < 0) { $errors['amount'] = WmfFramework::formatMessage('donate_interface-error-msg-invalid-amount'); } else { if ($value > $max) { // FIXME: should format the currency values in this message $errors['amount'] = WmfFramework::formatMessage('donate_interface-bigamount-error', $max, $currency, $adapter->getGlobal('MajorGiftsEmail')); } else { if ($value < $min) { $locale = $normalized['language'] . '_' . $normalized['country']; $formattedMin = self::format($min, $currency, $locale); $errors['amount'] = WmfFramework::formatMessage('donate_interface-smallamount-error', $formattedMin); } } } }
public static function onInitialFilter(GatewayType $gateway_adapter, Gateway_Extras_CustomFilters $custom_filter_object) { if (!$gateway_adapter->getGlobal('EnableReferrerFilter') || !count($gateway_adapter->getGlobal('CustomFiltersRefRules'))) { return true; } $gateway_adapter->debugarray[] = 'referrer onFilter!'; return self::singleton($gateway_adapter, $custom_filter_object)->filter(); }
public static function onPostProcess(GatewayType $gateway_adapter) { if (!$gateway_adapter->getGlobal('EnableConversionLog')) { return true; } $gateway_adapter->debugarray[] = 'conversion log onPostProcess!'; return self::singleton($gateway_adapter)->post_process(); }
/** * @param GatewayType $gateway_adapter The adapter context to log under * * @return bool Filter chain termination on FALSE. Also indicates that the cURL transaction * should not be performed. */ public static function onProcessorApiCall(GatewayType $gateway_adapter) { if (!$gateway_adapter->getGlobal('EnableSessionVelocityFilter')) { return true; } $gateway_adapter->debugarray[] = 'Session Velocity onFilter hook!'; return self::singleton($gateway_adapter)->filter(); }
/** * Retrieve a profiler instance which saves communication statistics * if the adapter's SaveCommStats global is set to true. * @param GatewayType $adapter * @return DonationProfiler */ public static function getProfiler(GatewayType $adapter) { if ($adapter->getGlobal('SaveCommStats')) { $commLogger = self::getLogger($adapter, '_commstats'); } else { $commLogger = null; } return new DonationProfiler(self::getLogger($adapter), $commLogger, $adapter->getGatewayName()); }
public function testTooMuchBbd() { $this->normalized['currency_code'] = 'BBD'; $this->normalized['amount'] = '201.00'; $this->validate(); $this->assertNotEmpty($this->errors, 'No error for excessive amount (BBD)'); $expected = WmfFramework::formatMessage('donate_interface-bigamount-error', 200, 'BBD', $this->adapter->getGlobal('MajorGiftsEmail')); $this->assertEquals($expected, $this->errors['amount'], 'Wrong error message for excessive amount (BBD)'); }
public function stage(GatewayType $adapter, $normalized, &$stagedData) { // This isn't smart enough to grab a new value here; // Late-arriving values have to trigger a restage via addData or // this will always equal the risk_score at the time of object // construction. Still need the formatting, though. if (isset($normalized['risk_score'])) { // Cap the score we send to Adyen since they automatically // decline any transaction with offset > 100 $maximumScore = $adapter->getGlobal('MaxRiskScore'); $stagedScore = min($normalized['risk_score'], $maximumScore); $stagedData['risk_score'] = (string) round($stagedScore); } }
/** * Run the Minfraud filter if it is enabled * * @param GatewayType $gateway_adapter * @param Gateway_Extras_CustomFilters $custom_filter_object * * @return true */ public static function onFilter(GatewayType $gateway_adapter, Gateway_Extras_CustomFilters $custom_filter_object) { if (!$gateway_adapter->getGlobal('EnableMinfraud')) { return true; } $gateway_adapter->debugarray[] = 'minfraud onFilter!'; return self::singleton($gateway_adapter, $custom_filter_object)->filter(); }
/** * Get the URL for a page to show donors who cancel their attempt * @param GatewayType $adapter instance to use for logger and settings * @return string full URL of the cancel page */ public static function getCancelPage(GatewayType $adapter) { $cancelPage = $adapter->getGlobal('CancelPage'); if (empty($cancelPage)) { return ''; } return self::appendLanguageAndMakeURL($cancelPage, $adapter->getData_Unstaged_Escaped('language')); }
/** * Generate a hash of some data * @param string $data the data to hash * @return string The hash of the data */ protected function generate_hash($data) { $salt = $this->gateway_adapter->getGlobal('Salt'); return hash("sha512", $salt . $data); }
public function stage(GatewayType $adapter, $normalized, &$stagedData) { if (empty($stagedData['email'])) { $stagedData['email'] = $adapter->getGlobal('DefaultEmail'); } }
public static function onPostProcess(GatewayType $gateway_adapter) { if (!$gateway_adapter->getGlobal('EnableIPVelocityFilter')) { return true; } $gateway_adapter->debugarray[] = 'IP Velocity onPostProcess!'; return self::singleton($gateway_adapter)->postProcess(); }
public static function onGatewayReady(GatewayType $gateway_adapter) { if (!$gateway_adapter->getGlobal('EnableCustomFilters')) { return true; } $gateway_adapter->debugarray[] = 'custom filters onGatewayReady!'; return self::singleton($gateway_adapter)->validate(self::PHASE_INITIAL); }
/** * This is the class's entry point. * * @param GatewayType $gatewayAdapter */ public static function onGatewayReady(GatewayType $gatewayAdapter) { if ($gatewayAdapter->getGlobal('EnableBannerHistoryLog')) { self::singleton($gatewayAdapter)->queueAssociationOfIds(); } }