public function __construct(Pap_Common_Transaction $transaction) {
     try {
         $user = $this->loadUser($transaction->getUserId());
         $this->setAttributes($user->getName(), $user->getEmail(), $transaction);
     } catch (Gpf_DbEngine_NoRowException $e) {
         Gpf_Log::warning('User with userid=' . $transaction->getUserId() . ' was not found!');
         $this->setAttributes($this->_('Unknown user'), $this->_('Unknown email'), $transaction);
     }
 }
예제 #2
0
 public function afterSaveTransactionSendAffiliateNotification(Pap_Common_Transaction $transaction) {
     if ($transaction->getTier() != '1' || $transaction->getStatus() != Pap_Common_Constants::STATUS_APPROVED || ($transaction->getType() != Pap_Common_Constants::TYPE_SALE && $transaction->getType() != Pap_Common_Constants::TYPE_ACTION)) {
         return;
     }
     $user = Pap_Affiliates_User::loadFromId($transaction->getUserId());
     if ($user->getStatus() != Pap_Common_Constants::STATUS_APPROVED || !$this->isUserAutomaticallyRegistered($user)) {
         return;
     }
     if (!$this->isRegistrationEmailSent($user) || (!$this->wasUserLoggedIn($user) && Gpf::YES == Gpf_Settings::get(Pap_Features_AutoRegisteringAffiliates_Config::REGISTRATION_NOTIFICATION_EVERY_SALE))) {
         Gpf_Log::info('AutoRegisteringAffiliates - afterSaveFirstApprovedTransaction - sendApprovedAffiliateFirstSaleEmail to userid: ' . $user->getId() . ' (' . $user->getUserName() .')' );
         $this->sendApprovedAffiliateFirstSaleEmail($user);
     }
 }
 protected function getUser(Pap_Common_Transaction $transaction) {
     return Pap_Common_User::getUserById($transaction->getUserId());
 }
예제 #4
0
    public function readRequestVariables() {
        $input = $this->readXmlData();

        if (Gpf_Settings::get(Recurly_Config::RESEND_URL) != "") {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, Gpf_Settings::get(Recurly_Config::RESEND_URL));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_TIMEOUT, 60);
            //curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars['HTTP_USER_AGENT']);
            curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $input);
            curl_exec($ch);

            /*
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, Gpf_Settings::get(Recurly_Config::RESEND_URL));
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_TIMEOUT, 60);
             curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
             curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
             curl_exec($ch);
             */
        }

        $this->debug("Input get: " . $input);
        try {
            $xml = new SimpleXMLElement($input);
        } catch (Exception $e) {
            $this->setPaymentStatus("Failed");
            $this->debug('Wrong XML format!');
            return false;
        }

        // read last tag to find out what kind of request this is, e.g. </new_subscription_notification>
        $status = strrpos($input,"</");
        $status = substr($input,$status+2,strlen($input)-1);
        $status = substr($status,0,strrpos($status,">"));

        $this->setType($status);

        if ($this->getType() == self::NEWPAYMENT) {
            $totalcost_name = "amount_in_cents";
            $this->setData1((string)$xml->{"transaction"}->{"invoice_number"});
        }
        else {
            $totalcost_name = "total_amount_in_cents";
            $this->setProductID((string)$xml->{"transaction"}->{"plan_code"});
        }
        $this->setTransactionID((string)$xml->{"account"}->{"account_code"});
        $this->setTotalCost((string)$xml->{"transaction"}->{$totalcost_name}/100)*(((string)$xml->{"transaction"}->{"quantity"})?(string)$xml->{"transaction"}->{"quantity"}:1);

        // get original Affiliate
        $status = array(Pap_Common_Constants::STATUS_APPROVED, Pap_Common_Constants::STATUS_PENDING);
        $types = array(Pap_Common_Constants::TYPE_SALE, Pap_Common_Constants::TYPE_ACTION, Pap_Common_Constants::TYPE_LEAD);

        $select = new Gpf_SqlBuilder_SelectBuilder();
        $select->select->addAll(Pap_Db_Table_Transactions::getInstance());
        $select->from->add(Pap_Db_Table_Transactions::getName());
        $select->where->add(Pap_Db_Table_Transactions::ORDER_ID, "=", $this->getOrderID());
        $select->where->add(Pap_Db_Table_Transactions::R_TYPE, "IN", $types);
        $select->where->add(Pap_Db_Table_Transactions::R_STATUS, "IN", $status);
        $transaction = new Pap_Common_Transaction();
        $transaction->fillFromSelect($select);

        if (($transaction->getUserId() == null) OR ($transaction->getUserId() == "")) {
            $this->debug('No affiliate found for order ID: '.$this->getOrderID());
        }
        else {
            $this->setAccountId($transaction->getAccountId());
            $this->setAffiliateID($transaction->getUserId());
            $this->setProductID($transaction->getProductId());
            $this->setCampaignId($transaction->getCampaignId());
        }
    }
 private function hashTransaction(Pap_Common_Transaction $transaction) {
     return $transaction->getUserId(). $transaction->getCampaignId(). $transaction->getBannerId(). $transaction->getChannel() .
     $transaction->getStatus() . $transaction->getTier(). $transaction->getType(). $transaction->getPayoutStatus() . $this->dateTimeToDate($transaction->getDateInserted() . $transaction->getCountryCode());
 }