This is a laravel package for the DPD Webservices based on Michiel Meertens' "DPD Webservice" (https://github.com/meertensm/DPD).
You can install the package via composer with the following command into an existing laravel project. Please note the requirements below.
$ composer require bernhardk/laravel-dpd
After that you need to publish the config-file with the following command:
$ php artisan vendor:publish --provider="BernhardK\Dpd\DpdServiceProvider" --tag="config"
As soon you have configured the credentials in /config/dpd.php you are ready to use the package as described below.
- Submit a shipment to the dpd webservice and retrieve it's label and tracking information
- Retrieve parcel status information
- PHP SOAP extension needs to be installed (https://stackoverflow.com/questions/2509143/how-do-i-install-soap-extension/41518256)
- Edit configuration parameters in /config/dpd.php. All parameters are described.
Webservice | Version |
---|---|
Login Service | 2.0 |
Shipment Service | 4.4 |
Parcel Life Cycle Service | 2.0 |
The package registers a class that can be directly used:
app()->dpdShipment
The following code describes a sample usage and returns a PDF file.
// Enable DPD B2C delivery method
app()->dpdShipment->setPredict([
'channel' => 'email',
'value' => 'someone@mail.com',
'language' => 'EN'
]);
// ATTENTION: Cause of privacy reasons transmitting clients email address is only allowed if client agreed.
// Set the general shipmentdata
app()->dpdShipment->setGeneralShipmentData([
'product' => 'CL',
'mpsCustomerReferenceNumber1' => 'Test shipment'
]);
// Set the sender's address
app()->dpdShipment->setSender([
'name1' => 'Your Company',
'street' => 'Street 12',
'country' => 'NL',
'zipCode' => '1234AB',
'city' => 'Amsterdam',
'email' => 'contact@yourcompany.com',
'phone' => '1234567645'
]);
// Set the receiver's address
app()->dpdShipment->setReceiver([
'name1' => 'Joh Doe',
'name2' => null,
'street' => 'Street',
'houseNo' => '12',
'zipCode' => '1234AB',
'city' => 'Amsterdam',
'country' => 'NL',
'contact' => null,
'phone' => null,
'email' => null,
'comment' => null
]);
// Add as many parcels as you want
app()->dpdShipment->addParcel([
'weight' => 3000, // In gram
'height' => 10, // In centimeters
'width' => 10,
'length' => 10
]);
app()->dpdShipment->addParcel([
'weight' => 5000,
'height' => 0, // In centimeters
'width' => 0,
'length' => 0 // All parameters need to be given. Enter 0 if you have no value
]);
// Submit the shipment
app()->dpdShipment->submit();
// Get the trackingdata
$trackinglinks = app()->dpdShipment->getParcelResponses();
// Show the pdf label
header('Content-Type: application/pdf');
echo app()->dpdShipment->getLabels();
The package registers a class that can be directly used:
app()->dpdTracking
The following code describes a sample usage and returns the Tracking-Status.
// Retrieve the parcel's status by it's awb number
$parcelStatus = app()->dpdTracking->getStatus('09981122330100');
If you have any questions or problems please open a new issue.
This package is licensed under the MIT license. The package is based on Michiel Meertens' "DPD Webservice" (https://github.com/meertensm/DPD), which is also licensed under the MIT license.