示例#1
0
    private function makeRefund() {
        $this->debug('2checkout refund started');
        $transaction = new Pap_Db_Transaction();
        $transaction->setOrderId($this->getSubscriptionID());
        try{
            $collection = $transaction->loadCollection(array(Pap_Db_Table_Transactions::ORDER_ID));
        } catch (Gpf_Exception $e) {
            $this->debug('2checkout refund failed - Error in loading transactions: '.$e->getMessage());
            return;
        }

        if($collection->getSize() == 0) {
            $this->debug('2checkout refund failed: No transactions with order id: '.$this->getSubscriptionID());
            return;
        }

        foreach($collection as $transactionDb) {
            $transaction = new Pap_Common_Transaction();
            $transaction->processRefundChargeback($transactionDb->getId(), $transactionDb->getType());
            $this->debug('2checkout refunded transaction with id '.$transactionDb->getId());
        }
    }
    protected function insertTransaction($record) {
    	$obj = new Pap_Db_Transaction();
    	
    	$obj->setId($record->get('transid'));
    	$obj->setUserId($record->get('affiliateid'));
    	$obj->setCampaignId($record->get('campaignid'));
		$obj->setDateInserted($record->get('dateinserted'));
		if($record->get('dateapproved') != '') {
			$obj->setDateApproved($record->get('dateapproved'));
		}
		$obj->setSystemNote("Migrated from PAP3");
		$obj->set('countrycode', $record->get('countrycode'));
		$obj->set('ip', $record->get('ip'));
		$obj->set('refererurl', $record->get('refererurl'));
		$obj->set('browser', $record->get('browser'));
		$obj->setCommission($record->get('commission'));
		$obj->set('data1', $record->get('data1'));
		$obj->set('data2', $record->get('data2'));
		$obj->set('data3', $record->get('data3'));
		$obj->setFixedCost(0);
		$obj->setTotalCost($record->get('totalcost'));
		$obj->setOrderId($record->get('orderid'));
		$obj->setProductId($record->get('productid'));
		$obj->setAllowFirstClickData(GPF::YES);
		$obj->setAllowLastClickData(GPF::YES);
		if($record->get('payoutstatus') == 2) {
			$obj->setPayoutStatus('P');
		} else {
			$obj->setPayoutStatus('U');
		}
		$obj->setClickCount(1);
		$obj->setStatus(Pap3Compatibility_Migration_Pap3Constants::translateStatus($record->get('rstatus')));
		$obj->setType(Pap3Compatibility_Migration_Pap3Constants::translateTransType($record->get('transtype')));

		$transKind = $record->get('transkind');
		if($transKind > Pap3Compatibility_Migration_Pap3Constants::TRANSKIND_SECONDTIER) {
			$tier = $transKind - Pap3Compatibility_Migration_Pap3Constants::TRANSKIND_SECONDTIER;
		} else {
			$tier = 1;
		}
		$obj->setTier($tier);
		$obj->set('bannerid', $record->get('bannerid'));
		$obj->set('commtypeid', $record->get('campcategoryid'));
		if($record->get('accountingid') != '') {
			$obj->set('payouthistoryid', $record->get('accountingid'));
		}
    	$obj->save();
    	
//bannerid               char(8)              utf8_general_ci  YES     MUL     (NULL)           select,insert,update,references
//parentbannerid         varchar(8)           utf8_general_ci  YES     MUL     (NULL)           select,insert,update,references
//parenttransid          char(8)              utf8_general_ci  YES     MUL     (NULL)           select,insert,update,references
//recurringcommid        char(8)              utf8_general_ci  YES             (NULL)           select,insert,update,references
//firstclicktime         datetime             (NULL)           YES             (NULL)           select,insert,update,references
//firstclickreferer      varchar(250)         utf8_general_ci  YES             (NULL)           select,insert,update,references
//firstclickip           varchar(15)          utf8_general_ci  YES             (NULL)           select,insert,update,references
//firstclickdata1        varchar(40)          utf8_general_ci  YES             (NULL)           select,insert,update,references
//firstclickdata2        varchar(40)          utf8_general_ci  YES             (NULL)           select,insert,update,references
//lastclicktime          datetime             (NULL)           YES             (NULL)           select,insert,update,references
//lastclickreferer       varchar(250)         utf8_general_ci  YES             (NULL)           select,insert,update,references
//lastclickip            varchar(15)          utf8_general_ci  YES             (NULL)           select,insert,update,references
//lastclickdata1         varchar(40)          utf8_general_ci  YES             (NULL)           select,insert,update,references
//lastclickdata2         varchar(40)          utf8_general_ci  YES             (NULL)           select,insert,update,references
//trackmethod            char(1)              utf8_general_ci  YES             U                select,insert,update,references
//commtypeid             char(8)              utf8_general_ci  YES     MUL     (NULL)           select,insert,update,references
//payouthistoryid        char(8)              utf8_general_ci  YES     MUL     (NULL)           select,insert,update,references
    	
    	$this->countSales++;
    }
示例#3
0
 public function finishTransaction($newStatus) {      
     $transaction = new Pap_Db_Transaction();
     $transaction->setOrderId($_POST['LMI_PAYMENT_NO']);
     $transaction->setData5($_POST['LMI_SYS_TRANS_NO']);
     try {
         $transaction->loadFromData(array(Pap_Db_Table_Transactions::ORDER_ID, Pap_Db_Table_Transactions::DATA5));
     } catch (Gpf_DbEngine_NoRowException $e) {
         $this->debug('No such transaction with order id: ' . $transaction->getOrderId() . ' and data5: ' . $transaction->getData5() . '. Changing status ended.');
         return;
     }
     $transaction->setStatus($newStatus);
     $transaction->update();
 }
 protected function addRefundChargeback(Pap_Db_Transaction $refundChargeback, $type, $note = '', $orderId = '', $fee = 0) {
     foreach ($this as $name => $value) {
         $refundChargeback->set($name, $value);
     }
     $refundChargeback->setId(Gpf_Common_String::generateId());
     $refundChargeback->setCommission(($this->getCommission() * -1) - $fee);
     $refundChargeback->setType($type);
     if ($orderId != '') {
         $refundChargeback->setOrderId($orderId);
     }
     $refundChargeback->setParentTransactionId($this->getId());
     $refundChargeback->setDateInserted(Gpf_Common_DateUtils::now());
     $refundChargeback->setPayoutStatus(Pap_Common_Constants::PSTATUS_UNPAID);
     $refundChargeback->setMerchantNote($note);
     if ($refundChargeback->getStatus() == Pap_Common_Constants::STATUS_APPROVED) {
         $refundChargeback->setDateApproved($refundChargeback->getDateInserted());
     } else {
         $refundChargeback->setDateApproved('');
     }
     $refundChargeback->insert();
 }