mardi 26 février 2019

XERO - Larael Integration

I installed the package using composer, and created a app/fascades/Xeroapi.php file. (https://github.com/calcinai/xero-php).

When I run the site, I get this error Argument 1 passed to XeroPHP\Application\PrivateApplication::__construct() must be of the type array, null given, called in: C:\xampp\htdocs\assignment_Sem1\app\Facades\XeroApi.php on line 76.

I have also created the demo App in the Xero and have my Private/Public key. The app created here is the private and have also uploaded the certificate file to Xero.

Not sure how to do this, as I am trying Laravel with Xero for the first time.

config.php

'xero_base_config' => [

    'xero' => [
        // API versions can be overridden if necessary for some reason.
        //'core_version'     => '2.0',
        //'payroll_version'  => '1.0',
        //'file_version'     => '1.0'
    ],
    'oauth' => [
        'callback'    => 'http://sz.com',
        'consumer_key'      => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        'consumer_secret'   => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        //If you have issues passing the Authorization header, you can set it to append to the query string
        //'signature_location'    => \XeroPHP\Remote\OAuth\Client::SIGN_LOCATION_QUERY
        //For certs on disk or a string - allows anything that is valid with openssl_pkey_get_(private|public)
          'rsa_private_key'  => 'file://ABSOLUTE_PATH_TO_YOUR_PROJECT/html/certs/privatekey.pem'
    ],
    //These are raw curl options.  I didn't see the need to obfuscate these through methods
    'curl' => [
        CURLOPT_USERAGENT   => 'XeroPHP Test App',
        //Only for partner apps - unfortunately need to be files on disk only.
        //CURLOPT_CAINFO          => 'certs/ca-bundle.crt',
        //CURLOPT_SSLCERT         => 'certs/entrust-cert-RQ3.pem',
        //CURLOPT_SSLKEYPASSWD    => '1234',
        //CURLOPT_SSLKEY          => 'certs/entrust-private-RQ3.pem'
    ]

app/controller/test

  public function testing(){


      $transaction = rand(1111,9999); # random for me
    $data = array(
            "Type" => "ACCREC", # Accounting received.
            "AmountType" => "Inclusive",
            "InvoiceNumber" => "LD".$transaction,
            "Reference" => "LD".$transaction." - Some reference", # small description ref
            "DueDate" => date('Y-m-d'), # date('Y-m-d', strtotime("+3 days")),
            "Status" => "AUTHORISED",
            "LineItems"=> array(
                                         # add some arrays with items. Now just one.
                    array(
                        "Description" => "Just another test invoice",
                        "Quantity" => "2.00",
                        "UnitAmount" => "250.00",
                        "AccountCode" => "200",
                        "TaxType" => 'OUTPUT2' # Tax in New Zealand
                    )
                )
        );

    # before create a invoice, you MUST TO CREATE A CONTACT
        $xero_tests = XeroApi::createInvoice('contact@email.com', $data);

        dd($xero_tests);


      }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire