public function checkActionFraudProtection(Pap_Contexts_Action $context) { $checkIt = Gpf_Settings::get(Pap_Settings::GEOIP_SALES); if($checkIt != Gpf::YES) { $context->debug(' PapGeoip: Check for blacklisted countries is not turned on'); return true; } $context->debug(' PapGeoip: Check if origin country of visitor related to action is not blacklisted started '); $blacklistedCountries = str_replace(' ', ',', trim(strtoupper(Gpf_Settings::get(Pap_Settings::GEOIP_SALES_BLACKLIST)))); $checkAction = Gpf_Settings::get(Pap_Settings::GEOIP_SALES_BLACKLIST_ACTION); if($blacklistedCountries == '') { $context->debug("PapGeoip: No country is blacklisted."); return true; } if($checkAction != Pap_Tracking_Click_FraudProtection::ACTION_DECLINE && $checkAction != Pap_Tracking_Click_FraudProtection::ACTION_DONTSAVE) { $context->debug("PapGeoip: Action after check is not correct: '$checkAction'"); return true; } $countryCode = strtoupper($context->getCountryCode()); if (!strlen($countryCode)) { $context->debug(" PapGeoip: Origin country was not recognized."); return true; } $arrBlacklist = explode(',', $blacklistedCountries); if(in_array($countryCode, $arrBlacklist)) { if($checkAction == Pap_Tracking_Click_FraudProtection::ACTION_DONTSAVE) { $context->debug(" PapGeoip: STOPPING (setting setDoCommissionsSave(false), country $countryCode is blacklisted"); $context->setDoCommissionsSave(false); $context->debug(' PapGeoip: Check if origin country of visitor related to action is not blacklisted endeded'); return false; } else { $context->debug(" PapGeoip: DECLINING, country $countryCode is blacklisted"); $this->declineAction($context, $this->_('PapGeoip: Country %s is blacklisted', $countryCode)); $context->debug(' PapGeoip: Check if origin country of visitor related to action is not blacklisted endeded'); return true; } } else { $context->debug(" Country is not blacklisted"); } $context->debug(' PapGeoip: Check if origin country of visitor related to action is not blacklisted endeded'); return true; }
protected function prepareContextForSave(Pap_Contexts_Action $context) { $transaction = $context->getTransaction(); $transaction->setOrderId($context->getOrderIdFromRequest()); $transaction->setProductId($context->getProductIdFromRequest()); $transaction->setTotalCost($context->getRealTotalCost()); $transaction->setFixedCost($context->getFixedCost()); $transaction->setCountryCode($context->getCountryCode()); if($context->getChannelObject() !== null) { $transaction->setChannel($context->getChannelObject()->getId()); } if($context->getBannerObject() !== null) { $transaction->setBannerId($context->getBannerObject()->getId()); } $transaction->setData1($context->getExtraDataFromRequest(1)); $transaction->setData2($context->getExtraDataFromRequest(2)); $transaction->setData3($context->getExtraDataFromRequest(3)); $transaction->setData4($context->getExtraDataFromRequest(4)); $transaction->setData5($context->getExtraDataFromRequest(5)); $transaction->setDateInserted($context->getVisitDateTime()); $transaction->setVisitorId($context->getVisitorId()); $transaction->setTrackMethod($context->getTrackingMethod()); $transaction->setIp($context->getIp()); try { $transaction->setRefererUrl($context->getVisitorAffiliate()->getReferrerUrl()); } catch (Gpf_Exception $e) { $transaction->setRefererUrl($context->getReferrerUrl()); } try { $visitorId = $context->getVisitorAffiliate()->getVisitorId(); } catch (Exception $e) { $visitorId = $this->_('unknown'); } try { $this->setFirstAndLastClick($transaction, $this->getVisitorAffiliatesCollection($context)); } catch (Gpf_Exception $e) { $context->debug('First and Last click can not be recognized for visitorId: ' . $visitorId . '. ' . $e->getMessage()); } }