コード例 #1
0
ファイル: Main.class.php プロジェクト: AmineCherrai/rostanvo
 public function process(Pap_Contexts_Action $context) {
     $context->debug('Started checking md5 checksums');
     $checksum = $context->getExtraDataFromRequest(Gpf_Settings::get(SaleFraudProtection_Config::PARAM_NAME));
 
     $myChecksum = $this->createCheckSum($context->getTotalCostFromRequest(), $context->getOrderIdFromRequest());
     if ($checksum == $myChecksum) {
         $context->debug('Checkings md5 checksums finished. Checksums equals.');
         return;
     }
     $context->debug('Checking md5 checksums failed. Transaction not saved. Checksums: '.$checksum.' - '.$myChecksum);
     $context->setDoCommissionsSave(false);
 }
コード例 #2
0
    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());
        }
    }
コード例 #3
0
    /**
     * checks for duplicate records with same OrderID
     *
     * @param Pap_Contexts_Action $context
     * @return string
     */
    private function checkMultipleSalesWithSameOrderID(Pap_Contexts_Action $context) {
        $checkIt = Gpf_Settings::get(Pap_Settings::DUPLICATE_ORDERS_ID_SETTING_NAME);
        if($checkIt != Gpf::YES) {
            $context->debug('    Check for duplicate sales / leads with the same OrderID is not turned on');
            return true;
        }

        $context->debug('    Checking duplicate sales / leads with the same OrderID started');

        $checkPeriod = Gpf_Settings::get(Pap_Settings::DUPLICATE_ORDER_ID_HOURS_SETTING_NAME);
        $checkAction = Gpf_Settings::get(Pap_Settings::DUPLICATE_ORDERS_ID_ACTION_SETTING_NAME);
        if($checkPeriod == '' || $checkPeriod == '0' || !is_numeric($checkPeriod)) {
            $context->debug("Checking period is not correct: '$checkPeriod'");
            return true;
        }
        if($checkAction != self::ACTION_DECLINE && $checkAction != self::ACTION_DONTSAVE) {
            $context->debug("Action after check is not correct: '$checkAction'");
            return true;
        }

        $orderId = $context->getOrderIdFromRequest();
        $transactionsObject = $context->getTransactionObject();

        if(trim($orderId) == '') {
            $applyToEmptyOrderIDs = Gpf_Settings::get(Pap_Settings::APPLY_TO_EMPTY_ID_SETTING_NAME);
            if($applyToEmptyOrderIDs != Gpf::YES) {
                $context->debug('      Order ID is empty, we do not aply fraud protection to empty order IDs');
                return false;
            }
        }

        $transactionType = $this->getTransactionType($context);
        $parentTransactionId = $context->getParentTransactionId();
        $recordsCount = $transactionsObject->getNumberOfRecordsWithSameOrderId($orderId, $transactionType, $checkPeriod, $parentTransactionId, $context->getVisitDateTime());
        $context->debug("Getting number of transactions orderId=$orderId, type=$transactionType, not older than $checkPeriod hours, and not with parent transaction with id=$parentTransactionId returned $recordsCount");
        if($recordsCount > 0) {
            if($checkAction == self::ACTION_DONTSAVE) {
                $context->debug("    STOPPING (setting setDoCommissionsSave(false), found another sales / leads from the same OrderID '$orderId' within $checkPeriod hours");
                $context->setDoCommissionsSave(false);
                $context->debug('      Checking duplicate sales / leads with the same OrderID endeded');
                return false;

            } else {
                $context->debug("  DECLINING, found another sales / leads with the same OrderID '$orderId' within $checkPeriod hours");

                $message = Gpf_Settings::get(Pap_Settings::DUPLICATE_ORDERS_ID_MESSAGE_SETTING_NAME);

                $this->declineAction($context, $message);

                $context->debug('      Checking duplicate sales / leads with the same OrderID endeded');
                return true;
            }
        } else {
            $context->debug("    No duplicate sales / leads with the same OrderID '$orderId' found");
        }

        $context->debug('      Checking duplicate sales / leads with the same OrderID endeded');
        return true;
    }