booni3 / dhl-express-rest
DHL Express REST API
0.6.2
2023-08-10 11:54 UTC
Requires
- php: ^7.4|^8.0
- nesbot/carbon: ^2.0
Requires (Dev)
- phpunit/phpunit: ^7.0
README
Package to work with the DHL Express Rest API (v2). This package is currently in development.
Installation
You can install the package via composer:
composer require booni3/dhl-express-rest
Usage
Domestic Shipments
$dto = new ShipmentCreator(); $dto->setShipperAccountNumber(954103895); $dto->setShipper( (new CustomerDetails('John Smith','21 Apple Drive','Malmesbury','Wiltshire', 'Malmesbury','SN16 4TB','GB','My Awesome Company','071111111112','a@b.com', )) ->addVat('GB1234') ->addEORI('GB1234') ); $dto->setProductCode('N'); // GB $dto->setReceiver(new Address('Helen Jones', '4 Drive', 'London', 'E14 8DW', 'GB')); $dto->addReference('123456-custom-ref'); $dto->addPackage(new Package(12.5, 20, 10, 10, 'Jumpers', 'order-ref-1244')); $dhl = DHL::make([ 'user' => 'DHLUSER', 'pass' => 'dsdfsedf', 'sandbox' => true, // false or remove for production ]); $res = $dhl->shipments()->create($dto); $res->trackingUrl; // tracking number $res->trackingNumber; // url for api tracking $res->labelData(); // decoded label data
Customs Declarable Shipments
Additional details needed
Note: setting the DDP account number, automatically sets the shipment up for DDP (delivery duty paid). Leave this blank/null to send DAP.
$dto->setCustomsDeclarable($declerable = true, $paperless = true, $ddpAccountNumber = 12345678); $dto->setInvoice('PS-1234', now(), 'Adam Lambert'); $dto->setExportDeclaration('sale', 'GBP'); $dto->addExportLineItem(new LineItem('Red Jumper', 12.99, 1, 12456, 'GB', 12)); $dto->addExportLineItem(new LineItem('Blue Jumper', 12.99, 1, 12456, 'GB', 12));
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email adam@profilestudio.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.