PHP code example of flooris / dpd-shipper-laravel
1. Go to this page and download the library: Download flooris/dpd-shipper-laravel 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/ */
flooris / dpd-shipper-laravel example snippets
// Borsigstraße 20-22, 44145 Dortmund, Duitsland
// https://goo.gl/maps/FoKHQ4DwEEiY9ift5
$countryIso = 'DE';
$postalCode = '44145';
$parcelCount = 1;
$email = '[email protected] ';
$mobilePhone = '0612345678';
$shipmentProduct = new DpdShipmentProduct($countryIso, $postalCode);
$predict = $shipmentProduct->getPredict($countryIso, $email, $mobilePhone);
$parcels = new DpdParcels();
$parcels->setCustomerReferenceNumber1('TEST12345');
$parcels->setWeight(1);
$recipient = new DpdRecipient(
name1: 'John Doe',
street: 'Borsigstraße',
houseNumber: '20-22',
countryIso: 'DE',
postalCode: $postalCode,
city: 'Dortmund',
email: $email
);
try {
$shipmentLabel = $this->dpdShipperConnector->shipmentService()->createShipment(
shipmentProduct: $shipmentProduct,
parcelCount: $parcelCount,
parcels: $parcels,
sender: $this->dpdSender,
recipient: $recipient,
dpdPredict: $predict
);
$mpsId = $shipmentLabel->mpsId;
$barcodeCollection = $shipmentLabel->getBarcodes();
$pdfData = $shipmentLabel->fileData;
} catch (DpdShipmentResponseException $e) {
} catch (\SoapFault $e) {
throw $e;
}
bash
php artisan vendor:publish --tag=dpd-shipper-config
nano config/dpd-shipper.php