Ejemplo n.º 1
0
    public function displayAffiliateTrackingCode(Pap_Contexts_Action $context) {
         
         
        if ($context->getDoCommissionsSave() == false) {
            $context->debug('AffiliateTrackingCode: commissions were not saved. stopping');
            return;
        }
        $commissionType = $context->getCommissionTypeObject();
        $affiliate = $context->getUserObject();
        if ($commissionType == null || $affiliate == null) {
            $context->debug('AffiliateTrackingCode: no affiliate or commission type. stopping');
            return;
        }
        if ($context->getTransactionObject()->getTransactionId() == '') {
            $context->debug('AffiliateTrackingCode: no transaction saved for affiliate: ' . $affiliate->getId() . '. stopping');
            return;
        }
        try {
            $affiliateTrackingCode = $this->loadAffiliateTrackingCode($commissionType, $affiliate);
        } catch (Gpf_Exception $e) {
            $context->debug('AffiliateTrackingCode: no approved code for this affiliate');
            return $context;
        }

        $affiliateTrackingCode->setCode($this->replaceTransactionConstants($affiliateTrackingCode->getCode(), $context->getTransactionObject()));

        $this->printAffiliateTrackingCode($affiliateTrackingCode);
    }
Ejemplo n.º 2
0
 public function getCommissionType(Pap_Contexts_Action $context) {
     $context->debug("Begin recognizing country specific commission type");
     if(!strlen($context->getTransactionObject()->getCountryCode())) {
         $context->debug("STOPPING recognizing country specific commission type eneded: country code not recognized or empty");
         return;
     }
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->addAll(Pap_Db_Table_CommissionTypes::getInstance());
     $select->from->add(Pap_Db_Table_CommissionTypes::getName());
     $select->where->add(Pap_Db_Table_CommissionTypes::PARENT_COMMISSIONTYPE_ID, '=', $context->getCommissionTypeObject()->getId());
         
     $compoundContext = new Gpf_Data_Record(array(Pap_Db_Table_RawImpressions::IP, Pap_Db_Table_Impressions::COUNTRYCODE), array($context->getVisit()->getIp(), ''));
     $this->getCountryCode($compoundContext);
     $countryCode = $compoundContext->get(Pap_Db_Table_Impressions::COUNTRYCODE);
     if (!strlen($countryCode)) {
         $context->debug("STOPPING recognizing country specific commission type eneded: country code not recognized or empty");
         return;
     }
         
     $select->where->add(Pap_Db_Table_CommissionTypes::COUNTRYCODES, 'LIKE', '%'.$countryCode.'%');
     try {
         $commType = new Pap_Db_CommissionType();
         $collection = $commType->loadCollectionFromRecordset($select->getAllRows());
         $context->setCommissionTypeObject($collection->get(0));
     } catch (Gpf_DbEngine_NoRowException $e) {
         $context->debug("Recognizing country specific commission type eneded - no country secpific commission defined");
         return;
     } catch (Gpf_DbEngine_TooManyRowsException $e) {
         $context->debug("STOPPING ecognizing country specific commission type eneded: more than one commision type is defined for country " . $context->getTransactionObject()->getCountryCode());
         return;
     } catch (Gpf_Exception $e) {
         $context->debug("STOPPING recognizing country specific commission type eneded: " . $e->getMessage());
     }
 }
Ejemplo n.º 3
0
 	private function saveReferral(Pap_Contexts_Action $context) {
 		$transactionObject = $context->getTransactionObject();
 		if($transactionObject == null) {
 			$context->debug('  Transaction object is null');
 			return;
 		}

 		$identifier = $this->getIdentifier($context);
 		if($identifier == null || $identifier == '') {
 			$context->debug("  Identifier (data1) is empty, stopping");
 			return;
 		}

 		$userId = $transactionObject->get(Pap_Db_Table_Transactions::USER_ID);

        $context->debug("  User is '$userId'");

 		$context->debug("  Identifier (data1) is '$identifier'");

 		$lifetimeCommission = new Pap_Db_LifetimeCommission();
 		$lifetimeCommission->setIdentifier($identifier);
 		$lifetimeCommission->setUserId($userId);

 		try {
 			$lifetimeCommission->loadFromData(array(Pap_Db_Table_LifetimeCommissions::IDENTIFIER));
 			$context->debug("  Lifetime referral: identifier '$identifier' already exists for user: "******"  New lifetime referral: identifier '$identifier' <-> user '$userId' inserted");
 		}
 	}
    /**
     * Sets status of transaction to declined and sets it's message
     *
     * @param Pap_Contexts_Action $context
     * @param string $checkMessage
     */
    private function declineAction(Pap_Contexts_Action $context, $message) {
        $context->setFraudProtectionStatus(Pap_Db_ClickImpression::STATUS_DECLINED);
        $transactionsObject = $context->getTransactionObject();

        if($message != '') {
            $transactionsObject->setSystemNote($message);
        }
    }