Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development update #1

Merged
merged 4 commits into from
Apr 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed docs/capability.md
Empty file.
53 changes: 53 additions & 0 deletions docs/pickup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Example request:
```php
$pickup = new BookPURequest();
$pickup->SiteID = 'ACCOUNT_NUMBER';
$pickup->Password = 'PASSWORD';
$pickup->MessageTime = Carbon::now()->format(Carbon::ATOM);
$pickup->MessageReference = 'reference_28_to_32_characters';

$pickup->Requestor->AccountNumber = 'SHIPPER_ACCOUNT';
$pickup->Requestor->AccountType = 'D';
$pickup->Requestor->CompanyName = $address->organisation;
$pickup->Requestor->RequestorContact->PersonName = $address->contact_name;
$pickup->Requestor->RequestorContact->Phone = $address->contact_phone;

// DHL REGION based on the Toolkit documentation for the pickup country
$pickup->RegionCode = $dhl_region;

$pickup->Place->LocationType = 'B';
$pickup->Place->CompanyName = $address->organisation;
$pickup->Place->Address1 = $address->address1;
$pickup->Place->Address2 = $address->address2;
$pickup->Place->PackageLocation = 'Ask receptionist';
$pickup->Place->City = $address->city;
$pickup->Place->CountryCode = $address->country;
$pickup->Place->PostalCode = $address->postcode;

$pickup->Pickup->PickupDate = $pickup_time;
$pickup->Pickup->ReadyByTime = '13:00';
$pickup->Pickup->CloseTime = '17:00';

$pickup->PickupContact->PersonName = $address->contact_name;
$pickup->PickupContact->Phone = $address->contact_phone;

$pickup->ShipmentDetails->AccountType = 'D';
$pickup->ShipmentDetails->AccountNumber = 'SHIPPER_ACCOUINT';
$pickup->ShipmentDetails->BillToAccountNumber = 'BILLING_ACCOUNT';

$pickup->ShipmentDetails->AWBNumber = $tracking_number;
$pickup->ShipmentDetails->NumberOfPieces = $package_count;
$pickup->ShipmentDetails->GlobalProductCode = $shipment_product_code;
$pickup->ShipmentDetails->Weight = $package_weight;
$pickup->ShipmentDetails->WeightUnit = 'K';
$pickup->ShipmentDetails->DoorTo = 'DD';
$pickup->ShipmentDetails->DimensionUnit = 'C';

$client = new Web($this->getEnvironment());
$xml_response = $client->call($pickup);
```

If you need XML request for the DHL certification you can obtain by calling the following code
```php
$request_xml = $pickup->toXml();
```
20 changes: 20 additions & 0 deletions docs/quote.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Example request:
```php
$tracking = new KnownTrackingRequest();
$tracking->SiteID = 'ACCOUNT_NUIMBER';
$tracking->Password = 'PASSWORD';
$tracking->MessageReference = 'reference_28_to_32_chars';
$tracking->MessageTime = Carbon::now()->format(Carbon::ATOM);
$tracking->LanguageCode = 'en';
$tracking->AWBNumber = $tracking_number;
$tracking->LevelOfDetails = 'ALL_CHECK_POINTS';
$tracking->PiecesEnabled = 'S';

$client = new Web($this->getEnvironment());
$xml_response = $client->call($tracking);
```

If you need XML request for the DHL certification you can obtain by calling the following code
```php
$request_xml = $tracking->toXml();
```
28 changes: 28 additions & 0 deletions docs/route.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Example request:
```php
$router = new RouteRequest();
$router->MessageTime = Carbon::now()->format(Carbon::ATOM);
$router->MessageReference = 'reference_28_to_30_chars';
$router->SiteID = 'SITE_ID';
$router->Password = 'PASSWORD';
$router->OriginCountryCode = 'GB';
$router->RequestType = 'O';

$router->Address1 = 'mtc media, Unit 35';
$router->Address2 = 'Shed 26, City Quay';
$router->Address3 = '';
$router->PostalCode = 'DD1 3JA';
$router->City = 'Dundee';
$router->Division = '';
$router->CountryCode = 'GB';
$router->RegionCode = 'EU';
$router->CountryName = 'United Kingdom';

$client = new Web('staging/production');
$xml_response = $client->call($router);
```

If you need XML request for the DHL certification you can obtain by calling the following code
```php
$request_xml = $router->toXml();
```
103 changes: 103 additions & 0 deletions docs/shipment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
Example request:
```php
$shipment = new ShipmentRequest();
$shipment->SiteID = $order->auth->account_number;
$shipment->Password = $order->auth->password;
$shipment->MessageTime = Carbon::now()->format(Carbon::ATOM);
$shipment->MessageReference = substr($reference, 0, 30);
$shipment->LanguageCode = 'en';
$shipment->PiecesEnabled = 'Y';
$shipment->Reference->ReferenceID = $client->account . '-' . $order->id;

$shipment->Billing->ShipperAccountNumber = $order->auth->shipper_account;
$shipment->Billing->ShippingPaymentType = 'S';
$shipment->Billing->BillingAccountNumber = $order->auth->billing_account;

// Outside EU changes Tax info
if (!Country::isEu($shipping_address->country)) {
$shipment->Billing->DutyPaymentType = 'R';
}

$contact_name = $shipping_address->first_name . ' ' . $shipping_address->last_name;
$shipment->Consignee->CompanyName = $shipping_address->organisation ?? '--';
$shipment->Consignee->Contact->PersonName = $contact_name;
$shipment->Consignee->addAddressLine(substr($shipping_address->address1, 0, 35));
$shipment->Consignee->addAddressLine(substr($shipping_address->address2, 0, 35));
$shipment->Consignee->City = $shipping_address->city;
$shipment->Consignee->PostalCode = $shipping_address->postcode;
$shipment->Consignee->Division = $shipping_address->state ?? '';
$shipment->Consignee->CountryCode = $shipping_address->country;
$shipment->Consignee->CountryName = Country::getNameFromCode($shipping_address->country);
$shipment->Consignee->Contact->PhoneNumber = $order->info->contact_no;
$shipment->Consignee->Contact->Email = $order->info->email;
$shipment->Consignee->Contact->PhoneExtension = '';
$shipment->Consignee->Contact->FaxNumber = '';
$shipment->Consignee->Contact->Telex = '';
$shipment->RegionCode = Country::getDHLRegionCode($shipping_address->country);

$order_value = $order->order_cost - $order->delivery_cost > 0 ? $order->order_cost - $order->delivery_cost : 1.0;
$shipment->Dutiable->DeclaredValue = $order_value;
$shipment->Dutiable->DeclaredCurrency = 'GBP';
$shipment->Dutiable->TermsOfTrade = 'DDP';

$shipment->Shipper->ShipperID = $order->auth->shipper_id;
$shipment->Shipper->RegisteredAccount = $order->auth->shipper_account_number;
$shipment->Shipper->CompanyName = $collection_address->organisation;
$shipment->Shipper->addAddressLine($collection_address->address1);
$shipment->Shipper->addAddressLine($collection_address->address2);
$shipment->Shipper->City = $collection_address->city;
$shipment->Shipper->PostalCode = $collection_address->postcode;
$shipment->Shipper->CountryCode = $collection_address->country;
$shipment->Shipper->CountryName = Country::getNameFromCode($collection_address->country);

$shipment->Shipper->Contact->PersonName = $collection_address->contact_name;
$shipment->Shipper->Contact->PhoneNumber = $collection_address->contact_phone;
$shipment->Shipper->Contact->Email = $collection_address->contact_email;
$shipment->Shipper->Contact->PhoneExtension = '';
$shipment->Shipper->Contact->FaxNumber = '';
$shipment->Shipper->Contact->Telex = '';

// Delivery Service is obtained via Quote request which will find valid services for shipment
$shipment->ShipmentDetails->GlobalProductCode = $delivery_service->code;
$shipment->ShipmentDetails->LocalProductCode = $delivery_service->format;

if (Country::isEu($shipping_address->country) === false) {
$shipment->ShipmentDetails->DoorTo = 'DD';
}
$shipment->ShipmentDetails->Contents = 'Shipment Description';
$shipment->ShipmentDetails->CurrencyCode = 'GBP';
$shipment->ShipmentDetails->WeightUnit = 'K';
$shipment->ShipmentDetails->Weight = collect($packages)->sum('weight');
$shipment->ShipmentDetails->Date = Carbon::now()->format('Y-m-d');
$shipment->ShipmentDetails->DimensionUnit = 'C';
$shipment->ShipmentDetails->InsuredAmount = $order->insurance_total ?? 0;
$shipment->ShipmentDetails->PackageType = $order->package_type ?? 'PA';
$shipment->ShipmentDetails->IsDutiable = Country::isEu($shipping_address->country) ? 'Y' : 'N';

$shipment->ShipmentDetails->AdditionalProtection = new AdditionalProtection();
$shipment->ShipmentDetails->DOSFlag = 'N';
$shipment->ShipmentDetails->CustData = $contact_name;

// Information about Packages in shipment
$shipment->ShipmentDetails->NumberOfPieces = count($packages);
foreach ($packages as $package_id => $package) {
$piece = new Piece();
$piece->PieceID = $client->account . $order->id . $package_id;
$piece->PackageType = $order->package_type ?? 'CP';
$piece->Weight = $package['weight'];
$piece->DimWeight = $package['weight'];
$shipment->ShipmentDetails->addPiece($piece);
}

$shipment->EProcShip = 'N';
$shipment->LabelImageFormat = 'PDF';
$shipment->Label->LabelTemplate = '8X4_PDF';

$client = new Web($this->getEnvironment());
$xml_response = $client->call($shipment);
```

If you need XML request for the DHL certification you can obtain by calling the following code
```php
$request_xml = $shipment->toXml();
```
Empty file removed docs/shipment_validation.md
Empty file.
Empty file removed docs/test_pack.md
Empty file.
48 changes: 48 additions & 0 deletions docs/tracking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Example request:
```php
$sample = new GetQuote();
$sample->SiteID = 'ACCOUNT_NUMBER';
$sample->Password = 'PASSWORD';
$sample->MessageTime = Carbon::now()->format(Carbon::ATOM);
$sample->MessageReference = 'reference_28_to_32_chars';

$sample->BkgDetails->Date = date('Y-m-d');
$sample->BkgDetails->PaymentCountryCode = 'GB';
$sample->BkgDetails->DimensionUnit = 'CM';
$sample->BkgDetails->WeightUnit = 'KG';
$sample->BkgDetails->ReadyTime = 'PT10H21M';
$sample->BkgDetails->ReadyTimeGMTOffset = '+01:00';
$sample->BkgDetails->PaymentAccountNumber = 'SHIPPER_ACCOUNT_NUMBER';

foreach ($packages as $index => $package) {
$piece = new PieceType();
$piece->PieceID = $index + 1;
$piece->Height = $package['height'];
$piece->Depth = $package['length'];
$piece->Width = $package['width'];
$piece->Weight = $package['weight'];
$sample->BkgDetails->addPiece($piece);
}

$sample->From->CountryCode = 'GB';
$sample->From->Postalcode = 'DD13JA';

$sample->To->City = $address->city;
$sample->To->Postalcode = $address->postcode;
$sample->To->CountryCode = $address->country;
$sample->BkgDetails->IsDutiable = Country::isEu($address->country) ? 'N' : 'Y';

if (!Country::isEu($address->country)) {
$order_value = $order->order_cost - $order->delivery_cost > 0 ? $order->order_cost - $order->delivery_cost : 1.0;
$sample->Dutiable->DeclaredValue = $order_value;
$sample->Dutiable->DeclaredCurrency = 'GBP';
}

$client = new Web($this->getEnvironment());
$xml_response = $client->call($sample);
```

If you need XML request for the DHL certification you can obtain by calling the following code
```php
$request_xml = $sample->toXml();
```
19 changes: 14 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,24 @@ Package requires a php min version of 7.0, however it has has been developed and

## Usage

[Shipment Validation](docs/shipment_validation.md)
You will need Sandbox account to start setup.
You can request your unique credentials by registering for the XML Portal https://xmlportal.dhl.com/register

[Shipment Requests](docs/shipment.md)
DHL Documentation: http://xmlpitest-ea.dhl.com/toolkit/Toolkit.zip

[Tracking Requests](docs/tracking.md)
DHL XML Services Test Harness: https://xmlpi-validation.dhl.com/serviceval/jsps/main/Main_menu.jsp

[Capability Requests](docs/capability.md)
DHL XML Services Test server for customer certification: https://xmlpitest-ea.dhl.com/XMLShippingServlet

[DHL Test Pack](docs/test_pack.md)
[Quote Requests (v6.1)](docs/quote.md)

[Route Requests (v1.0)](docs/route.md)

[Shipment Requests (v6.2)](docs/shipment.md)

[Pickup Request (v1.0)](docs/pickup.md)

[Tracking Requests (v1.0)](docs/tracking.md)


## Contributing
Expand Down
5 changes: 5 additions & 0 deletions src/Datatype/GB/OriginServiceArea.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
*/
class OriginServiceArea extends \Mtc\Dhl\Datatype\AM\OriginServiceArea
{
/**
* Is this object a subobject
* @var boolean
*/
protected $_isSubobject = true;

/**
* Parameters of the datatype
Expand Down
41 changes: 41 additions & 0 deletions src/Datatype/GB/Pickup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Mtc\Dhl\Datatype\GB;

use Mtc\Dhl\Datatype\Base;

/**
* Class Shipment
*
* @package Mtc\Dhl
*/
class Pickup extends Base
{
/**
* Parameters of the datatype
* @var array
*/
protected $params = [
'PickupDate' => [
'type' => 'string',
'required' => true,
'subobject' => false,
'comment' => 'Date Y-m-d',
'maxLength' => '10',
],
'ReadyByTime' => [
'type' => 'string',
'required' => true,
'subobject' => false,
'comment' => 'Time HH:MM',
'maxLength' => '5',
],
'CloseTime' => [
'type' => 'string',
'required' => true,
'maxLength' => '5',
'comment' => 'Time HH:MM',
'subobject' => false,
],
];
}
41 changes: 41 additions & 0 deletions src/Datatype/GB/PickupContact.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Mtc\Dhl\Datatype\GB;

use Mtc\Dhl\Datatype\Base;

/**
* Class Shipment
*
* @package Mtc\Dhl
*/
class PickupContact extends Base
{
/**
* Parameters of the datatype
* @var array
*/
protected $params = [
'PersonName' => [
'type' => 'PersonName',
'required' => true,
'subobject' => false,
'comment' => 'Name',
'maxLength' => '35',
],
'Phone' => [
'type' => 'PhoneNumber',
'required' => true,
'subobject' => false,
'comment' => 'Phone Number',
'maxLength' => '25',
],
'PhoneExtension' => [
'type' => 'PhoneExtension',
'required' => false,
'subobject' => false,
'comment' => '',
'maxLength' => '5',
],
];
}
Loading