bernhardk/laravel-dpd

Laravel package for using DPD Webservices to submit shipment to dpd und retrieve its label and tracking information.

v1.7.0 2023-11-28 18:33 UTC

This package is auto-updated.

Last update: 2024-05-28 19:30:42 UTC


README

Latest Stable Version GitHub issues GitHub license Packagist Twitter

This is a laravel package for the DPD Webservices based on Michiel Meertens' "DPD Webservice" (https://github.com/meertensm/DPD).

Installation

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.

Features

  • Submit a shipment to the dpd webservice and retrieve it's label and tracking information
  • Retrieve parcel status information

Requirements

DPD Webservice versions

Webservice Version
Login Service 2.0
Shipment Service 4.4
Parcel Life Cycle Service 2.0

Basic shipment usage

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();

Basic tracking usage

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');

Support

If you have any questions or problems please open a new issue.

License

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.