Ejemplo n.º 1
0
    protected function executeCurl($xmlRequest, $headers) {
        $url = '';
        if (!$this->containsProtocol(Gpf_Settings::get(BusinessCatalyst_Config::BC_DOMAIN_NAME))) {
            $url = 'http://';
        }

        $url .= Gpf_Settings::get(BusinessCatalyst_Config::BC_DOMAIN_NAME);

        if (!$this->endsWithSlash($url)) {
            $url .= '/';
        }

        $url .= 'catalystwebservice/catalystcrmwebservice.asmx';

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER  ,1);

        $response = curl_exec($ch);
        if ($response === false) {
            Pap_Contexts_Action::getContextInstance()->debug('Error in communication with bc: ' . curl_error($ch));
            throw new Gpf_Exception(curl_error($ch));
        }
        return $response;
    }
Ejemplo n.º 2
0
    /**
     * registers all created sales
     */
    public function register() {
        if(!is_array($this->actionInstances)) {
            return;
        }

        $context = Pap_Contexts_Action::getContextInstance();

        if(count($this->actionInstances) <= 0) {
            $context->debug('No sales to register, create sale using createSale() function first!');
            return;
        }

        $this->track();
    }
Ejemplo n.º 3
0
    private function getEntityVisitorId($xml, $customFieldName) {
        $fieldName = '<fieldName>'.$customFieldName.'</fieldName>';
        $fieldValueLength = strlen('<fieldValue>');

        //no visitor ID in this XML response:
        if (strpos(strtolower($xml), strtolower($fieldName)) === false) {
            Pap_Contexts_Action::getContextInstance()->debug('BusinessCatalyst: no VisitorID found');
            return;
        }

        $begin = strpos(strtolower($xml), strtolower($fieldName)) + strlen($fieldName) + strlen('<fieldValue>');

        $end = strpos(strtolower($xml), strtolower('</fieldValue>'), $begin);

        $fieldValue = substr($xml, $begin, $end - $begin);

        if (($visitorIdEnd = strpos($fieldValue, ';')) !== false) {
            $fieldValue = substr($fieldValue, 0, $visitorIdEnd);
        }

        return $fieldValue;
    }
Ejemplo n.º 4
0
 /**
  *  @return Pap_Tracking_Request
  */
 protected function getRequestObject() {
     return Pap_Contexts_Action::getContextInstance()->getRequestObject();
 }
Ejemplo n.º 5
0
    private function parseVisitorId($xml, $customFieldName) {
        $fieldName = '<fieldName>'.$customFieldName.'</fieldName>';

        if (strpos(strtolower($xml), strtolower($fieldName)) === false) { //no custom field found in this XML
            Pap_Contexts_Action::getContextInstance()->debug('BusinessCatalyst: no custom field found');
            return '';
        }

        if (!strstr($xml, '<fieldValue>') && strstr($xml, '<fieldValue/>')) {
            Pap_Contexts_Action::getContextInstance()->debug('BusinessCatalyst: custom field value is empty');
            return '';
        }

        $begin = strpos(strtolower($xml), strtolower($fieldName)) + strlen($fieldName);
        $begin = strpos(strtolower($xml), strtolower('<fieldValue>'), $begin) + strlen('<fieldValue>');
        $end = strpos(strtolower($xml), strtolower('</fieldValue>'), $begin);
        $fieldValue = substr($xml, $begin, $end - $begin);

        if (($visitorIdEnd = strpos($fieldValue, ';')) !== false) {
            $fieldValue = substr($fieldValue, 0, $visitorIdEnd);
        }

        return $fieldValue;
    }
 public function debug($message) {
     if($message == "") {
         Pap_Contexts_Action::getContextInstance()->debug("");
     } else {
         Pap_Contexts_Action::getContextInstance()->debug($this->getTrackerName().': '.$message);
     }
 }
 protected function getContexts() {
     return Pap_Contexts_Action::getContextInstance();
 }
Ejemplo n.º 8
0
    public function readRequestVariables() {
        $request = Pap_Contexts_Action::getContextInstance()->getRequestObject();

        // assign posted variables to local variables
        $this->setCookie(stripslashes($request->getRequestParameter('M_aid')));
        $this->setTotalCost($request->getRequestParameter('amount'));
        $this->setTransactionID($request->getRequestParameter('transId'));
        $this->setProductID($request->getRequestParameter('M_ProductID'));
        $this->setDescription($request->getRequestParameter('desc'));
        $this->setCurrency($request->getRequestParameter('authCurrency'));
        if ($this->parseFuturePayIdFromDescription($request->getRequestParameter('desc'))===false) {
            $this->setData5($request->getRequestParameter('futurePayId'));
        } else {
            $this->setData4($this->parseFuturePayIdFromDescription($request->getRequestParameter('desc')));
            $this->setData3($this->parsePaymentNumberFromDescription($request->getRequestParameter('desc')));
        }
    }
Ejemplo n.º 9
0
    public function processRefundChargeback($id, $type, $note = '', $orderId = '', $fee = 0, $refundTiers = false) {
        Pap_Contexts_Action::getContextInstance()->debug('Process refund on transaction: '.$id);
        $childTansactions = $this->getTransactionsByParent($refundTiers, $id);    

        $transaction = $this->getTransaction($id);
        try {
            $transaction->refundChargeback($type, $note, $orderId, $fee);
        } catch (Gpf_Exception $e) {
            Pap_Contexts_Action::getContextInstance()->debug($e->getMessage());
        } 
        
        if (!$refundTiers) {
            Pap_Contexts_Action::getContextInstance()->debug('No MultiTier children transactions refunds set');            
            return;
        }      
        
        foreach ($childTansactions as $childTransaction) {
            $this->processRefundChargeback($childTransaction->getId(), $type, $note, $orderId, $fee, true);
        }        
    }