Reputation: 23
I am doing Integration with Kashflow using PHP on one of my clients wordpress website and it was running great till PHP5.6 but the issue arrives when i had upgraded the website to PHP7.1, SO below is the error i am getting, Fatal error : Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: SoapVar has no 'enc_type' property
Below is my Kashflow class code:
public function insertInvoice(KashflowInvoice $invoice)
{
$lines = $this->prepareInvoiceLines($invoice->getLines());
$parameters['Inv'] = array
(
"InvoiceDBID" => 0,
"InvoiceNumber" => $invoice->getInvoiceNumber(),
"InvoiceDate" => $invoice->getInvoiceDate(),
"DueDate" => $invoice->getDueDate(),
"Customer" => "",
"CustomerID" => $invoice->getKashflowCustomerId(),
"Paid" => 1,
"CustomerReference" => "",
"EstimateCategory" => "",
"SuppressTotal" => 1,
"ProjectID" => 0,
"CurrencyCode" => "GBP",
"ExchangeRate" => 1,
"ReadableString" => "",
"Lines" => $lines,
"NetAmount" => $invoice->getNet(),
"VATAmount" => $invoice->getTax(),
"AmountPaid" => 0,
"CustomerName" => "",
"UseCustomDeliveryAddress" => 0
);
print_r($parameters);
return $this->makeRequest("InsertInvoice",$parameters);
}
private function prepareInvoiceLines($invoice_lines)
{
if(NULL == $invoice_lines)
return array();
$lines = NULL;
foreach($invoice_lines as $invoice_line)
{
$line = array(
"LineID" => 0,
"Quantity" => $invoice_line['qty'],
"Description" => $invoice_line['description'],
"Rate" => $invoice_line['unit_net'],
"ChargeType" => $invoice_line['nominal_id'],
"VatAmount" => $invoice_line['qty'] * $invoice_line['unit_tax'],
"VatRate" => $invoice_line['tax_rate'],
"Sort" => 1,
"ProductID" => 0,
"ProjID" => $invoice_line['project_id']
);
// Lines is an array of InvoiceLine as anyType.
$lines[] = new SoapVar($line,0,"InvoiceLine","KashFlow");
}
return $lines;
}
I debugged this code and it is creative invoice if i comment the "$lines[] = new SoapVar($line,0,"InvoiceLine","KashFlow");" SO i am not sure what to change on this line.
Your help will be appreciated.
Thanks in advance.
Upvotes: 2
Views: 315
Reputation: 1236
Instead of 0 replace with SOAP_ENC_OBJECT
, it's work for me php version 7.0
$lines[] = new SoapVar($line,SOAP_ENC_OBJECT,"InvoiceLine","KashFlow");
Upvotes: 1
Reputation: 708
$lines[] = new SoapVar($line,0,"InvoiceLine","KashFlow");
Second argument should be a constant. Try using SOAP_ENC_OBJECT for example. More information can be found in php documentation: http://php.net/manual/en/soapvar.soapvar.php see example #1. List of constants that you can try is here: http://php.net/manual/en/soap.constants.php. Valid ones are staring with XSD_ for basic types and SOAP_ENC_*. If this fail please post wsdl file.
Upvotes: 1