Add the package in your composer.json by executing the command.
composer require webidentity/laravel-gls-printing-service
First initialise the config file by running this command:
php artisan vendor:publish
With this command, initialize the configuration and modify the created file, located under config/gls-printing-service.php
.
return [
'logger' => Webidentity\GLSPrintingService\BaseLogger::class,
'log-http-communication' => true,
'credentials' => [
'username' => '...',
'password' => '...',
'senderid' => '...',
],
'printer_templates' => [
'A6' => 'A6 format, blank label',
'A6_PP' => 'A6 format, preprinted label',
'A6_ONA4' => 'A6 format, printed on A4',
'A4_2x2' => 'A4 format, 4 labels on layout 2x2',
'A4_4x1' => 'A4 format, 4 labels on layout 4x1',
],
'url' => 'SK',
'soap_urls' => [
'HU' => 'https://online.gls-hungary.com/webservices/soap_server.php?wsdl',
'SK' => 'http://online.gls-slovakia.sk/webservices/soap_server.php?wsdl',
'CZ' => 'http://online.gls-czech.com/webservices/soap_server.php?wsdl',
'RO' => 'http://online.gls-romania.ro/webservices/soap_server.php?wsdl',
'SI' => 'http://connect.gls-slovenia.com/webservices/soap_server.php?wsdl',
'HR' => 'http://online.gls-croatia.com/webservices/soap_server.php?wsdl',
]
];
U may call any endpoint against GLS api provided in wsdl file. You need pass array args which key is parameter name with values.
GLSPrintingService::printlabel([
'parameter_name' => 'value'
]);
$data = array_merge(config('gls-printing-service.credentials'), [
'sender_name' => '...',
'sender_address' => '...',
'sender_city' => '...',
'sender_zipcode' => '...',
'sender_country' => '...',
'sender_contact' => '...',
'sender_phone' => '...',
'sender_email' => '...',
'consig_name' => '...',
'consig_address' => '...',
'consig_city' => '...',
'consig_zipcode' => '...',
'consig_country' => '...',
'consig_contact' => '...',
'consig_phone' => '...',
'consig_email' => '...',
'pcount' => 1,
'pickupdate' => '...',
'content' => '',
'clientref' => '',
'codamount' => '',
'codref' => '',
'services' => [],
'printertemplate' => 'A4_2x2',
'printit' => true,
], ['timestamp' => GLSPrintingService::getTimestamp()]
);
$data['hash'] = GLSPrintingService::getglshash($data);
$response = GLSPrintingService::printlabel($data)
//pdfdata
echo base64_decode($response->pdfdata)
GLSPrintingService::deletelabels(array_merge(
config('gls-printing-service.credentials'), ['pclids' => $pclids]
));
There is enabled logging (request and response) by default. U may follow these logs by executing the command
tail -f storage/logs/laravel.log
- XML serializer for endpoints which needs to work with xml