API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

How to call public e-conomic webservices in opencart

0
Hi to all,
I want to call e-conomic web services in opencart /opt/lampp/upload/catalog/controller/checkout/success.php
By using Soap .
But i am trying to use this i got different types of errors,those are
1)Notice: Undefined variable: system in /opt/lampp/htdocs/shop/opencart-1.5.5.1/upload/catalog/controller/checkout/success.php on line 95

2)Undefined index: in /opt/lampp/lib/php/Economic.php on line 46Notice: Undefined index: in /opt/lampp/lib/php/Economic.php on line 47

Economic.php:: file  

i dont know this is file is correct or not ,
if i want to put this file ilibrary file n the prog , am i create objects for EconomicSession class



?
/**
*
* universelle E-Conomic Anbindungs-Klasse
* Author: Stefan Warnat ich@stefanwarnat.de
* Version: 2012-05-18
*

Changelog:
2011-08-04
    - Start Changelog
2011-08-08
    - added BookWithNumber($handle, $number) methode
2011-11-01
    - added getInvoice Method
2011-11-23
    - Performance-Fix getNextDebtorNr
2012-05-18
    - Internationalisierung
**/

class Economic {
     private $access = false;

    private $_client = false;
   
    private $_bridge = false;
   
    private $_invoiceData = array();
   
    private $_config = false;
   
    public function activateBridge($bridge) {
       
        $this-_bridge = $bridge;
       
    }
   
    public function __construct($system) {
        require_once(config.inc.php);
        echo 'in constructor of economic page';
       
        $this-_config = $config[$system];           
        $this-access = $config[$system][access];           
    }
   
    public function __destruct() {
        if($this-_client !== false)
            $this-_client-Disconnect();

    }
    /**
        Funktion stellt Verbindung zu E-Conomic her
    **/
    private function connect() {
        $this-_client = new SoapClient(https://www.e-conomic.com/secure/api1/EconomicWebservice.asmx?WSDL, array(trace = 1, exceptions = 1));

        $this-_client-Connect($this-access);           
    }
    // Existiert ein Kunde im System
    public function debtorExist($kundenNr) {
        if($this-_client === false) $this-connect();

        $result = $this-_client-Debtor_FindByNumber(array(number = $kundenNr));

        if(!isset($result-Debtor_FindByNumberResult)) {
            return false;
        }
        return true;
    }
    public function productExists($artNr) {
        if($this-_client === false) $this-connect();
       
        $result = $this-_client-Product_FindByNumber(array(number = $artNr));
       
        if(!isset($result-Product_FindByNumberResult)) {
            $result = $this-_client-Product_FindByNumber(array(number = str_pad($artNr, 6, 0, STR_PAD_LEFT)));
           
            if(!isset($result-Product_FindByNumberResult)) {
                return false;
            } else {
                return 2;
            }
        }           
        return true;           
    }
   
    public function getKundenNrByPartialName($name) {
        if($this-_client === false) $this-connect();
       
        $result = $this-_client-Debtor_FindByPartialName(array(partialName = *.$name.*));

        if(!isset($result-Debtor_FindByPartialNameResult-DebtorHandle)) {
            return array();
        }
       
        $kundenNr = array();
       
        if(count($result-Debtor_FindByPartialNameResult-DebtorHandle) == 1) {
            $kundenNr[] = $result-Debtor_FindByPartialNameResult-DebtorHandle-Number;
        } else {

            foreach($result-Debtor_FindByPartialNameResult-DebtorHandle as $value) {
                $kundenNr[] = (int)($value-Number);
            }
        }       
       
        return $kundenNr;
        # return (int)($result-Debtor_FindByNameResult-DebtorHandle-Number);       
    }
   
    public function getInvoice($rechnungs_nummer) {
        if($this-_client === false) $this-connect();
       
        $data = $this-_client-Invoice_GetData(array(entityHandle = array(Number = $rechnungs_nummer)));
       
        return $data-Invoice_GetDataResult;
    }
   
    public function getStammDatenByKundenNr($kundenNr) {
        if($this-_client === false) $this-connect();
       
        $result = $this-_client-Debtor_GetData(array(entityHandle = array(Number = $kundenNr)));
        $result = $result-Debtor_GetDataResult;
       
        $daten = array(
            Nummer = $kundenNr,
            Name = utf8_decode($result-Name),
            Address = utf8_decode($result-Address),
            PostalCode = $result-PostalCode,
            City = utf8_decode($result-City),
            Country = utf8_decode($result-Country),
            Email = utf8_decode($result-Email)
        );
       
        return $daten;
    }
   
    public function getKundenNrByName($name) {
        if($this-_client === false) $this-connect();
       
        $result = $this-_client-Debtor_FindByName(array(name = $name));

        return (int)($result-Debtor_FindByNameResult-DebtorHandle-Number);       
    }
   
    public function getNextDebtorNumber($kn = false) {
        if($this-_client === false) $this-connect();
        if($kn === false) $kn = 25300;
       
        while($this-debtorExist($kn)) {
            $kn++;
        }
       
        #$number = $this-_client-Debtor_GetNextAvailableNumber();
        #$kundenNr = $number-Debtor_GetNextAvailableNumberResult;
        return $kn;

        return $kundenNr;
    }
   
    public function createDebtor($name, $address, $postalcode, $city, $country, $groupHandle = 1, $kundenNr = 0, $email = ) {
        if($this-_client === false) $this-connect();
       
        if(empty($kundenNr)) {
            $kundenNr = $this-getNextDebtorNumber();
        }
       
        $newDebtorHandle = $this-_client-Debtor_CreateFromData( array(data = array(
             'Number'            = $kundenNr,
             'CurrencyHandle'     = array(
                Code = EUR
             ),
             'DebtorGroupHandle' = array(
                'Number' = $groupHandle
             ),
             TermOfPaymentHandle = array(Id = 7),
             LayoutHandle = array(Id = 2),
             
             'Name'              = $name,
             Address             = $address,
             PostalCode          = $postalcode,
             City              = $city,
             Country             = $country,
             'VatZone'           = 'EU',
             IsAccessible      = 1,
             Email             = $email
         )))-Debtor_CreateFromDataResult;

        return $newDebtorHandle-Number;
    }
   
    /**
    * Gibt Rechnungs-Handle der neuen Rechnung zurück
    *
    * ExtData-Array:
        $contact = array(
            company = array(
                name = ,
                email = ,
                website = ,
                tel =
            )
        );   
    **/
    public function createInvoice($kundenNr, $rechnungAdresse, $lieferAdresse = false, $invoiceTitle = Buchung, $date = false, $contact = array()) {
        if($this-_client === false) $this-connect();

        try
        {   
            // Wenn Kunde noch nicht existiert, dann ERROR
            if(!$this-debtorExist($kundenNr) || empty($kundenNr)) {
                return 1;
            }
       
           
            $result = $this-_client-CurrentInvoice_CreateFromData(array(data = array(
                LayoutHandle = array(Id = $this-_config[BillLayoutHandle]),
               
                DebtorHandle = array(Number = $kundenNr),
                DebtorName = $rechnungAdresse[name],
                DebtorAddress = $rechnungAdresse[address],
                DebtorPostalCode = $rechnungAdresse[postalcode],
                DebtorCity = $rechnungAdresse[city],
                DebtorCountry = $rechnungAdresse[country],
               
                Date = date(Y-m-d\TH:i:s, ($date !== false?strtotime($date):time())),
                TermOfPaymentHandle = array(Id = $this-_config[BillTermOfPaymentHandle]),
                CurrencyHandle = array(Code = $this-_config[BillCurrencyHandle]),
                ExchangeRate = 1,
                IsVatIncluded = 1,
                NetAmount = 0,
                VatAmount = 0,
                GrossAmount = 0,
                Margin = 0,
                MarginAsPercent = 0,
                Heading = $invoiceTitle
            )));           
           
        } catch(Exception $exception)
        {
            print(pi . $exception-getMessage() . /i/p);       
            $client-Disconnect();
        }
       
       
        # Wenn vTiger Bridge aktiviert ist
        if($this-_bridge !== false) {
            $resultTMP = $this-_bridge-getCustomer($kundenNr, $rechnungAdresse, $lieferAdresse, $contact);
       
            $this-_invoiceData[$result-CurrentInvoice_CreateFromDataResult-Id] = array(user = $resultTMP, data = array(
                LayoutHandle = array(Id = 3),
               
                DebtorHandle = array(Number = $kundenNr),
                DebtorName = $rechnungAdresse[name],
                DebtorAddress = $rechnungAdresse[address],
                DebtorPostalCode = $rechnungAdresse[postalcode],
                DebtorCity = $rechnungAdresse[city],
                DebtorCountry = $rechnungAdresse[country],
               
                Date = date(Y-m-d\TH:i:s, ($date !== false?strtotime($date):time())),
                TermOfPaymentHandle = array(Id = 7),
                CurrencyHandle = array(Code = EUR),
                ExchangeRate = 1,
                IsVatIncluded = 1,
                NetAmount = 0,
                VatAmount = 0,
                GrossAmount = 0,
                Margin = 0,
                MarginAsPercent = 0,
                Heading = $invoiceTitle
            ));           
        }
           
        return $result-CurrentInvoice_CreateFromDataResult;
    }
   
    public functio
created Feb 19, 2013 by sudheerphp
22% Accept Rate
Q 14 A 10 C 0

Visma e-conomic A/S
...