PHP code example of bernhardk / laravel-dpd

1. Go to this page and download the library: Download bernhardk/laravel-dpd library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bernhardk / laravel-dpd example snippets


app()->dpdShipment

// Enable DPD B2C delivery method
app()->dpdShipment->setPredict([
    'channel' => 'email',
    'value' => '[email protected]',
    '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' => '[email protected]',
    '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();

app()->dpdTracking

// Retrieve the parcel's status by it's awb number
$parcelStatus = app()->dpdTracking->getStatus('09981122330100');