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); } }
public function getTransactionFieldValue($code) { if($this->transaction == null) { throw new Gpf_Exception("You have to set Transaction before getting transaction fields value!"); } if($code == self::TRANSACTIONID) { return $this->transaction->get(Pap_Db_Table_Transactions::TRANSACTION_ID); } else if($code == self::COMMISSION) { return $this->transaction->getCommissionAsText(); } else if($code == self::TOTALCOST) { return $this->transaction->getTotalCostAsText(); } else if($code == self::ORDERID) { return $this->transaction->getOrderId(); } else if($code == self::PRODUCTID) { return $this->transaction->getProductId(); } else if($code == self::TIER) { return $this->transaction->getTier(); } else if($code == self::CAMPAIGNID) { return $this->transaction->getCampaignId(); } else if($code == self::CAMPAIGNNAME) { return $this->getCampaignName($this->transaction->getCampaignId()); } else if($code == self::STATUS) { return $this->getStatus($this->transaction->getStatus()); } else if($code == self::STATUSCODE) { return $this->transaction->getStatus(); } else if($code == self::TYPE) { return $this->getType($this->transaction->getType()); } else if($code == self::RAWTYPE) { return $this->transaction->getType(); } else if($code == self::ACTIONNAME) { return $this->getActionName($this->transaction->getType(), $this->transaction->getCommissionTypeId()); } else if($code == self::SALEDATA1) { return $this->transaction->getData1(); } else if($code == self::SALEDATA2) { return $this->transaction->getData2(); } else if($code == self::SALEDATA3) { return $this->transaction->getData3(); } else if($code == self::SALEDATA4) { return $this->transaction->getData4(); } else if($code == self::SALEDATA5) { return $this->transaction->getData5(); } else if($code == self::ORIGINALCURRENCY) { return $this->getOriginalCurrencyName($this->transaction->get(Pap_Db_Table_Transactions::ORIGINAL_CURRENCY_ID)); } try { return $this->transaction->get($code); } catch (Gpf_Exception $e) { } return ''; }
public function sendOnChangeStatusNotification() { try { $user = $this->getUser($this->transaction); } catch (Gpf_DbEngine_NoRowException $e) { Gpf_Log::error('User with userid=' . $this->transaction->getUserId() . 'can not be loaded and mail can not be send.'); Gpf_Log::debug('Sending notification to affiliate ended'); return; } $isNotify = $this->isNotify($user, Pap_Settings::AFF_NOTIFICATION_ON_CHANGE_COMMISSION_STATUS_DEFAULT_SETTING_NAME, Pap_Settings::AFF_NOTIFICATION_ON_CHANGE_COMMISSION_STATUS_ENABLED_SETTING_NAME, 'aff_notification_on_change_comm_status', $this->transaction->getStatus(), Pap_Settings::AFF_NOTIFICATION_ON_CHANGE_COMMISSION_STATUS_OPTION_STATUS); if ($isNotify <> Gpf::YES) { Gpf_Log::debug('Sending change status notification to affiliate ended. Affiliate '.$user->getId().': '.$user->getName().' does not have change status notification turned on'); return; } if(Gpf_Settings::get(Pap_Settings::NOTIFICATION_ON_COMMISSION_APPROVED) == Gpf::YES && $this->transaction->getStatus() == Pap_Common_Constants::STATUS_APPROVED){ $this->sendEmail(new Pap_Mail_MerchantOnCommissionApproved(), $user, $this->transaction, $this->getMerchantEmail()); } $disableChangeStatusNotificationEmail = new Gpf_Plugins_ValueContext(false); $disableChangeStatusNotificationEmail->setArray(array($user)); Gpf_Plugins_Engine::extensionPoint('Pap_Tracking_Action_SendTransactionNotificationEmails.sendOnChangeStatusNotificationToAffiliate', $disableChangeStatusNotificationEmail); if($disableChangeStatusNotificationEmail->get()) { Gpf_Log::debug('Sending change status notification to affiliate ended by any feature or plugin. Affiliate '.$user->getId().': '.$user->getName().'.'); return; } $this->sendEmail(new Pap_Mail_AffiliateChangeCommissionStatus(), $user, $this->transaction, $user->getEmail()); Gpf_Log::debug('Sending notification to affiliate ended'); }
public function getStatus() { $constants = new Pap_Common_Constants(); return $constants->getStatusAsText($this->transaction->getStatus()); }
private function changeTransactionStatus($transactionId, $status, $note, $forOnlyPendingTransactions = false) { $transaction = new Pap_Common_Transaction(); $transaction->setId($transactionId); $transaction->load(); if ($transaction->getStatus() == $status) { return true; } if ($forOnlyPendingTransactions && $transaction->getStatus() != Pap_Common_Constants::STATUS_PENDING) { return false; } try { Gpf_Plugins_Engine::extensionPoint('PostAffiliate.TransactionForm.changeTransactionStatus', $transaction); } catch (Gpf_Exception $e) { return false; } $transaction->setStatus($status); $transaction->setMerchantNote($note); $transaction->update(array(Pap_Db_Table_Transactions::R_STATUS, Pap_Db_Table_Transactions::MERCHANTNOTE, Pap_Db_Table_Transactions::DATE_APPROVED)); return true; }
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()); }