PHP code example of smart-dato / dhl-parcel-returns-sdk
1. Go to this page and download the library: Download smart-dato/dhl-parcel-returns-sdk 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/ */
smart-dato / dhl-parcel-returns-sdk example snippets
use SmartDato\DhlParcelReturns\Data\Orders\ContactAddressData;
use SmartDato\DhlParcelReturns\Data\Orders\ReturnOrderData;
use SmartDato\DhlParcelReturns\Data\Orders\ValueData;
use SmartDato\DhlParcelReturns\Data\Orders\WeightData;
use SmartDato\DhlParcelReturns\Enums\Currency;
use SmartDato\DhlParcelReturns\Enums\LabelType;
use SmartDato\DhlParcelReturns\Enums\WeightUom;
use SmartDato\DhlParcelReturns\Facades\DhlParcelReturns;
$confirmation = DhlParcelReturns::orders()->create(
data: new ReturnOrderData(
receiverId: 'deu',
shipper: new ContactAddressData(
name1: 'Max Mustermann',
addressStreet: 'Charles-de-Gaulle Str.',
addressHouse: '20',
postalCode: '53113',
city: 'Bonn',
email: '[email protected]',
),
customerReference: 'Order #12345',
itemWeight: new WeightData(WeightUom::Kilograms, 1),
itemValue: new ValueData(value: 10, currency: Currency::Eur),
),
labelType: LabelType::Both,
);
$confirmation->shipmentNo; // "999991587211"
$confirmation->label->b64; // base64-encoded shipment label
$confirmation->qrLabel?->b64; // base64-encoded QR label (when requested)
$confirmation->qrLink; // deep link to import the QR code into the Post & DHL app
$confirmation->routingCode; // "40327653113+99000933090010"
use SmartDato\DhlParcelReturns\Data\Orders\CommodityData;
use SmartDato\DhlParcelReturns\Data\Orders\CustomsDetailsData;
use SmartDato\DhlParcelReturns\Enums\CountryOfOrigin;
$confirmation = DhlParcelReturns::orders()->create(
data: new ReturnOrderData(
receiverId: 'che',
shipper: $shipper,
itemWeight: new WeightData(WeightUom::Grams, 1200),
itemValue: new ValueData(value: 1012.99),
customsDetails: new CustomsDetailsData(
items: [
new CommodityData(
itemDescription: 'T-Shirt',
packagedQuantity: 1,
itemWeight: new WeightData(WeightUom::Grams, 500),
itemValue: new ValueData(value: 1000),
countryOfOrigin: CountryOfOrigin::FRA,
hsCode: '61099090',
),
],
),
),
);
use SmartDato\DhlParcelReturns\Enums\Country;
use SmartDato\DhlParcelReturns\Facades\DhlParcelReturns;
$receivers = DhlParcelReturns::locations()->get(
country: Country::Deu,
postalCode: '53113',
maxResult: 10,
);
foreach ($receivers as $receiver) {
$receiver->receiverId;
$receiver->billingNumber;
$receiver->receiverAddress->city;
}