kashflow api script keeps failing to connect - php

The problem I have is with the script that connects to kashflow from our website, when a customer enters their order and finalises the checkout the site is supposed to connect to kashflow but instead gives the following error.
Notice: Undefined index: $Name in
/home/expressn/public_html/ajax/kashflow/includes/kashflow.inc.php on
line 73
Unhandled exception: Customer name cannot be empty
It's been narrowed down to the following code we hope as Customer Name is apparently a blank string?
Would anyone be kind enough to tell me what needs to be done to solve this problem?
public function insertCustomer($customer){
$parameters['custr'] = array(
"CustomerID" => 0,
"Code" => '',
"Name" => $customer['Name'],
"Contact" => '',
"Telephone" => $customer['Telephone'],
"Mobile" => '',
"Fax" => '',
"Email" => $customer['Email'],
"Address1" => $customer['Address1'],
"Address2" => $customer['Address2'],
"Address3" => $customer['Address3'],
"Address4" => $customer['Address4'],
"Postcode" => $customer['Postcode'],
"Website" => '',
"EC" => 0,
"OutsideEC" => 0,
"Notes" => '',
"Source" => $this->m_source,
"Discount" => 0,
"ShowDiscount" => 0,
"PaymentTerms" => 0,
"ExtraText1" => '',
"ExtraText2" => '',
"ExtraText3" => '',
"ExtraText4" => '',
"ExtraText5" => '',
"ExtraText6" => '',
"ExtraText7" => '',
"ExtraText8" => '',
"ExtraText9" => '',
"ExtraText10" => '',
"ExtraText11" => '',
"ExtraText12" => '',
"ExtraText13" => '',
"ExtraText14" => '',
"ExtraText15" => '',
"ExtraText16" => '',
"ExtraText17" => '',
"ExtraText18" => '',
"ExtraText19" => '',
"ExtraText20" => '',
"CheckBox1" => 0,
"CheckBox2" => 0,
"CheckBox3" => 0,
"CheckBox4" => 0,
"CheckBox5" => 0,
"CheckBox6" => 0,
"CheckBox7" => 0,
"CheckBox8" => 0,
"CheckBox9" => 0,
"CheckBox10" => 0,
"CheckBox11" => 0,
"CheckBox12" => 0,
"CheckBox13" => 0,
"CheckBox14" => 0,
"CheckBox15" => 0,
"CheckBox16" => 0,
"CheckBox17" => 0,
"CheckBox18" => 0,
"CheckBox19" => 0,
"CheckBox20" => 0,
"Created" => date( "Y-m-d\TH:i:s"),
"Updated" => date( "Y-m-d\TH:i:s"),
"CurrencyID" => 0,
"ContactTitle" => '',
"ContactFirstName" => '',
"ContactLastName" => '',
"CustHasDeliveryAddress" => 1,
"DeliveryAddress1" => $customer['delAddress1'],
"DeliveryAddress2" => $customer['delAddress2'],
"DeliveryAddress3" => $customer['delAddress3'],
"DeliveryAddress4" => $customer['delAddress4'],
"DeliveryPostcode" => $customer['delPostcode'],
"VATNumber" => ''
);
return $this->makeRequest("InsertCustomer",$parameters);
}

Hello I know it has been a while now but I also ran into this problem.
From my experience the mandatory params are:
'CustomerID'=>0,
'EC'=>0,
'OutsideEC'=>0,
'Source'=>0,
'Discount'=>0,
'ShowDiscount'=>0,
'PaymentTerms'=>0,
'CheckBox1'=>0,
'CheckBox2'=>0,
'CheckBox3'=>0,
'CheckBox4'=>0,
'CheckBox5'=>0,
'CheckBox6'=>0,
'CheckBox7'=>0,
'CheckBox8'=>0,
'CheckBox9'=>0,
'CheckBox10'=>0,
'CheckBox11'=>0,
'CheckBox12'=>0,
'CheckBox13'=>0,
'CheckBox14'=>0,
'CheckBox15'=>0,
'CheckBox16'=>0,
'CheckBox17'=>0,
'CheckBox18'=>0,
'CheckBox19'=>0,
'CheckBox20'=>0,
'Created'=> '',
'Updated'=>'',
'CurrencyID'=>0,
'Name'=>''
The case that you use for the keys is also important so "EC" is not the same as "ec". The api also returns a blank object if you are not authenticated, this can make it seem as if it is working when it is not.
So one thing to check is that you are giving 'UserName' & 'Password' not 'username' & 'password' just another thing is that I found https://securedwebapp.com/api/service.asmx << this doc is much better than http://www.kashflow.com/developers/soap-api/ << this doc for detailing how to call the APIs.

Related

SOAP-ERROR: Encoding: object has no 'verify_bool' property

After updating my SSL certificate Letsencrypt on server (Linux Ubuntu), I am getting error "SOAP-ERROR: Encoding: object has no 'verify_bool' property" when sending SOAP request. I am using SoapClient.php in Laravel application. Before updating the certificate it worked fine.
My code is here:
$soap_client = new \SoapClient("https://.....?WSDL", array(
'local_cert' => app_path('Services/my.pem'),
'passphrase' => 'mypasphrase')
);
$auth = $soap_client->AuthenticateUser(array(
'aName' => '777.SSL.888',
'aPassword' => 'password'
));
$session_id = $auth->AuthenticateUserResult->SessionID;
$data = $soap_client->getClientsByKeyFields(array(
'aSessionID' => $session_id,
'aClient' => array(
'ID' => 0,
'Natural_Person_Bool' => 1,
'Class_ID' => 10,
'Sex_ID' => 0,
'SETTLEMENT_ID' => 0,
'DOCUMENT_TYPE_ID' => 0,
'ACTIVITY_KIND_ID' => 0,
'RESIDENT_BOOL' => 1,
'ECONOMICS_SECTOR_ID' => 0,
'COUNTRY_ID' => 0,
'IIN' => $iin)
));
Solution was simple. I just needed to add "verify_bool" item to the array for 'aClient' in "getClientsByKeyFields()" function with default value, so my edited code for $data is
$data = $soap_client->getClientsByKeyFields(array(
'aSessionID' => $session_id,
'aClient' => array(
'ID' => 0,
'Natural_Person_Bool' => 1,
'Class_ID' => 10,
'Sex_ID' => 0,
'SETTLEMENT_ID' => 0,
'DOCUMENT_TYPE_ID' => 0,
'ACTIVITY_KIND_ID' => 0,
'RESIDENT_BOOL' => 1,
'ECONOMICS_SECTOR_ID' => 0,
'COUNTRY_ID' => 0,
'IIN' => $iin,
'verify_bool' => 1)
));

exif_read_data on PHP 7.2 doesn't return all metadata

On PHP 7.2, the built-in function exif_read_data returns different information to PHP 7.1
This is what I get when I use 7.2:
php -r 'var_export(exif_read_data("x.jpg", "ANY_TAG"));'
array (
'FileName' => 'x.jpg',
'FileDateTime' => 1543144462,
'FileSize' => 3564506,
'FileType' => 2,
'MimeType' => 'image/jpeg',
'SectionsFound' => 'ANY_TAG, IFD0, EXIF',
'COMPUTED' =>
array (
'html' => 'width="3968" height="2976"',
'Height' => 2976,
'Width' => 3968,
'IsColor' => 1,
'ByteOrderMotorola' => 1,
),
'ImageWidth' => 3968,
'ImageLength' => 2976,
'BitsPerSample' =>
array (
0 => 8,
1 => 8,
2 => 8,
),
'ImageDescription' => 'ptr',
'Make' => 'HUAWEI',
'Model' => 'STF-L09',
'Orientation' => 0,
'XResolution' => '72/1',
'YResolution' => '72/1',
'ResolutionUnit' => 2,
'Software' => 'STF-L09C432B120',
'DateTime' => '2018:11:24 15:11:58',
'YCbCrPositioning' => 1,
)
But when I run the exact same code on 7.1, I get much more EXIF data:
array (
'FileName' => 'x.jpg',
'FileDateTime' => 1543144462,
'FileSize' => 3564506,
'FileType' => 2,
'MimeType' => 'image/jpeg',
'SectionsFound' => 'ANY_TAG, IFD0, THUMBNAIL, EXIF, GPS, INTEROP',
'COMPUTED' =>
array (
'html' => 'width="3968" height="2976"',
'Height' => 2976,
'Width' => 3968,
'IsColor' => 1,
'ByteOrderMotorola' => 1,
'ApertureFNumber' => 'f/2.2',
'Thumbnail.FileType' => 2,
'Thumbnail.MimeType' => 'image/jpeg',
'Thumbnail.Height' => 384,
'Thumbnail.Width' => 512,
),
'ImageWidth' => 3968,
'ImageLength' => 2976,
'BitsPerSample' =>
array (
0 => 8,
1 => 8,
2 => 8,
),
'ImageDescription' => 'ptr',
'Make' => 'HUAWEI',
'Model' => 'STF-L09',
'Orientation' => 0,
'XResolution' => '72/1',
'YResolution' => '72/1',
'ResolutionUnit' => 2,
'Software' => 'STF-L09C432B120',
'DateTime' => '2018:11:24 15:11:58',
'YCbCrPositioning' => 1,
'Exif_IFD_Pointer' => 280,
'GPS_IFD_Pointer' => 8454,
'DeviceSettingDescription' => 'ipp' . "\0" . '',
'THUMBNAIL' =>
array (
'ImageWidth' => 512,
'ImageLength' => 384,
'Compression' => 6,
'Orientation' => 0,
'XResolution' => '72/1',
'YResolution' => '72/1',
'ResolutionUnit' => 2,
'JPEGInterchangeFormat' => 8802,
'JPEGInterchangeFormatLength' => 31647,
),
'DocumentName' => NULL,
'ExposureTime' => '30000000/1000000000',
'FNumber' => '220/100',
'ExposureProgram' => 2,
'ISOSpeedRatings' => 320,
'ExifVersion' => '0210',
'DateTimeOriginal' => '2018:11:24 15:11:58',
'DateTimeDigitized' => '2018:11:24 15:11:58',
'ComponentsConfiguration' => '' . "\0" . '',
'ShutterSpeedValue' => '298973/10000',
'ApertureValue' => '227/100',
'BrightnessValue' => '0/1',
'ExposureBiasValue' => '0/10',
'MeteringMode' => 5,
'LightSource' => 1,
'Flash' => 0,
'FocalLength' => '3950/1000',
'MakerNote' => 'Auto',
'SubSecTime' => '405238',
'SubSecTimeOriginal' => '405238',
'SubSecTimeDigitized' => '405238',
'FlashPixVersion' => '0100',
'ColorSpace' => 1,
'ExifImageWidth' => 3968,
'ExifImageLength' => 2976,
'InteroperabilityOffset' => 8424,
'SensingMethod' => 2,
'FileSource' => '',
'SceneType' => '',
'CustomRendered' => 1,
'ExposureMode' => 0,
'WhiteBalance' => 0,
'DigitalZoomRatio' => '100/100',
'FocalLengthIn35mmFilm' => 27,
'SceneCaptureType' => 0,
'GainControl' => 0,
'Contrast' => 0,
'Saturation' => 0,
'Sharpness' => 0,
'SubjectDistanceRange' => 0,
'GPSVersion' => '' . "\0" . '' . "\0" . '',
'GPSLatitudeRef' => 'N',
'GPSLatitude' =>
array (
0 => '51/1',
1 => '8/1',
2 => '49994201/1000000',
),
'GPSLongitudeRef' => 'W',
'GPSLongitude' =>
array (
0 => '2/1',
1 => '42/1',
2 => '59101467/1000000',
),
'GPSAltitudeRef' => '' . "\0" . '',
'GPSAltitude' => '7162/100',
'GPSTimeStamp' =>
array (
0 => '15/1',
1 => '11/1',
2 => '58/1',
),
'GPSProcessingMode' => 'GPS' . "\0" . '',
'GPSDateStamp' => '2018:11:24',
'InterOperabilityIndex' => 'R98',
'InterOperabilityVersion' => '0100',
)
Are there any modules or extensions or changes that I can make to get the full EXIF data when using 7.2? I'm on a shared Linux host, so have some limitations on what I can do.
This appears to be a bug in PHP - https://bugs.php.net/bug.php?id=72682 and https://abi-laboratory.pro/index.php?view=changelog&l=php&v=7.2.3
The only answer is to downgrade - or upgrade - to a version which doesn't have the bug.

phpexcel - add new row in existing excel file using phpexcel

All data in array like this
<?php
$sub_arr = array();
$sub_arr[] = array(
'sr_nm' => 1,
'recept_number' => 3019,
'adm_number' => 3434,
'student_name' => 'amit',
'class' => 'LKG',
'pay' => 'online',
'cheq_nm' => '',
'adm_fee' => '',
'consolidated' => '',
'sec.fee' => '',
'dev.charge' => 5000,
'school_fee' => 1300,
'subling' => '-3400',
'transport' => 2300,
'late_fee' =>'total' => 35006
);
$sub_arr[] = array('sr_nm' => 1,
'recept_number' => 3019,
'adm_number' => 3434,
'student_name' => 'amit',
'class' => 'LKG',
'pay' => 'online',
'cheq_nm' => '',
'adm_fee' => '',
'consolidated' => '',
'sec.fee' => '',
'dev.charge' => 5000,
'school_fee' => 1300,
'subling' => '-3400',
'transport' => 2300,
'late_fee' => '',
'total' => 35006
);
And my excel file:
I want to insert new data from A4 shell after loading the file.

Wrong pattern in WP rewrite_rules_array hook

The following code chunk will be well known by WP coders working with permalinks.
add_filter('rewrite_rules_array', array($this, 'insert_rewrite_rules'));
function insert_rewrite_rules($rules)
{
// $link_cloaking_text is properly set
$newrules = array();
$newrules['([^\/]*)/\b'.$link_cloaking_text.'\b/(\d*)$'] =
'index.php?pagename=$matches[1]&link_cloaking_id=$matches[2]';
return $newrules + $rules;
}
Problem: I can't get pagename and link_cloaking_id values (query_vars hook and $wp_rewrite->flush_rules() are correctly used)
$newrules['([^\/]*)/\b'.$link_cloaking_text.'\b/(\d*)$'] =
'index.php?pagename=$matches[1]&link_cloaking_id=$matches[2]';
debug:
WP_Query::__set_state(array(
'query_vars' =>
array (
'error' => '404',
'm' => 0,
'p' => 0,
'post_parent' => '',
'subpost' => '',
'subpost_id' => '',
'attachment' => '',
'attachment_id' => 0,
'name' => '',
'static' => '',
'pagename' => '', // empty
'page_id' => 0,
But if I replace $matches[1] with a constant my_pagename, then works:
$newrules['([^\/]*)/\b'.$link_cloaking_text.'\b/(\d*)$'] =
'index.php?pagename=my_pagename&link_cloaking_id=$matches[2]';
debug:
WP_Query::__set_state(array(
'query_vars' =>
array (
'pagename' => 'my_pagename', // correct
'link_cloaking_id' => '8', // correct
'error' => '',
'm' => 0,
'p' => 0,
'post_parent' => '',
What am I doing wrong??

PHP Multi-Dimensional Arrays Issue

Ok I have a mult-dimensional array which has the following structure...
0 =>
array (
'membership' =>
array (
'member' =>
array (
'name' => '',
'landline' => '',
'libcard' => '',
'mobile' => '',
'email' => '',
),
'updated_at' => '',
'member_id' => 12345,
'starts_at' => '',
'id' => 14,
'group_id' => 280,
'optional_field_values' =>
array (
0 =>
array (
'optional_field' =>
array (
'name' => '',
'updated_at' => '',
'id' => 1,
'group_id' => 280,
'description' => '',
'created_at' => '',
),
'updated_at' => '',
'optional_field_id' => 1,
'membership_id' => 14,
'id' => 4,
'value' => '12539267',
'created_at' => '',
),
),
'ends_at' => '',
'joining_fee' => 0,
'created_at' => '',
),
),
Now I can access everything inside Membership and inside Member using code like...
$member[0]['membership']['member']['name']
or
$member[0]['membership']['joining_fee']
But when ever I try to access stuff inside optional_field_values I get nothing returned...
Any ideas why this is not working?
Edit:
Trying to access the field using code like...
$member[0]['membership']['optional_field_values']['value']
$member[0]['membership']['optional_field_values'][0]['value']
^ Should work...
(Edited to match OP's edit)
How about :
$member[0]['membership']['optional_field_values'][0]['value']
You can iterate over all optional field values like this :
foreach ($member[0]['membership']['optional_field_values'] as $field)
echo $field['value'];

Categories