/**
  * recognizes commission type for campaign
  *
  * @param Pap_Plugins_Tracking_Action_Context $context
  */
 public function getCommissionType(Pap_Contexts_Action $context) {
     $campaign = $context->getCampaignObject();
     
     $context->debug('Recognizing commission type started');
     $actionCode = $context->getActionCodeFromRequest();
     if ($actionCode == null || $actionCode == '') {
         $type = Pap_Common_Constants::TYPE_SALE;
     } else {
         $type = Pap_Common_Constants::TYPE_ACTION;
     }
     
     try {
         $context->debug('    Checking commission type : '.$type.' is in campaign');
         $commissionType = $campaign->getCommissionTypeObject($type, $context->getActionCodeFromRequest(), $context->getVisit()->getCountryCode());
     } catch (Pap_Tracking_Exception $e) {          
         $context->debug("    STOPPING, This commission type is not supported by current campaign or is NOT enabled! ");
         throw $e;
     }
     $context->setCommissionTypeObject($commissionType);
     
     $context->getTransaction(1)->setType($type);
     $context->debug('    Commission type set to: '.$type.', ID: '.$commissionType->getId());
     $context->debug('Recognizing commission type ended');
     $context->debug("");
 }    
Пример #2
0
    protected function getCommission($tier, Pap_Contexts_Action $context) {
        $commissionPercentage = $this->getFixedCommissionPercentage($context->getTransaction()->getCommissionTypeId());
        if ($commissionPercentage == TopLevelAffiliateFixedCommision_Config::UNDEFINED_PERCENTAGE) {
            $context->debug('TopLevelAffiliateFixedCommision undefined for this commission group.');
            return null;
        }

        $context->debug('TopLevelAffiliateFixedCommision defined '.$commissionPercentage.' for this commission group.');
        return new Pap_Tracking_Common_Commission($tier, Pap_Db_CommissionType::COMMISSION_PERCENTAGE,
        $commissionPercentage);
    }
Пример #3
0
 private function setRecognizedParams(Pap_Contexts_Action $context) {
     $context->setUserObject($this->affiliate);
     $context->setBannerObject($this->banner);
     $context->setCampaignObject($this->campaign);
     $context->setAccountId($this->campaign->getAccountId(), Pap_Contexts_Tracking::ACCOUNT_RECOGNIZED_FROM_CAMPAIGN);
     $context->setTrackingMethod(Pap_Common_Transaction::TRACKING_METHOD_COUPON);
     $context->getTransaction()->setCouponId($this->coupon->getId());
     $context->getTransaction()->set(Pap_Db_Table_Transactions::BANNER_ID, $this->banner->getId());
 }
    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());
        }
    }
 private function isSendMailContextStatus(Pap_Contexts_Action $context) {
     return strstr(Gpf_Settings::get(Pap_Features_SplitCommissions_Definition::NOTIFICATION_ON_SALE_SUMMARY_STATUS),
     $context->getTransaction()->getStatus()) !== false;
 }