Giter Site home page Giter Site logo

petschko / dhl-php-sdk Goto Github PK

View Code? Open in Web Editor NEW
92.0 25.0 50.0 345 KB

Unofficial DHL PHP SDK based on the DHL API - Updated to API-Version 2

License: MIT License

PHP 100.00%
dhl dhl-sdk php api-client api soap-client soap php-soap-api dhl-api dhl-api-version-2

dhl-php-sdk's Introduction

INACTIVE Repo

** This REPO is out of support ** Please checkout other repos or request examples from DHL

In case you still have questions, you can send me an E-Mail or visit this Project on Gitlab.com

DHL PHP SDK

This unofficial library is wrapping some functions of the DHL SOAP API in order to easy create/delete shipments and labels.

Requirements

  • You need a DHL developer Account and - as long as you want to use the API in production systems - a DHL Intraship Account.
  • PHP-Version 5.4 or higher (It may work on older Versions, but I don't offer Support for these)
  • PHP-SOAP-Client installed + enabled on your Server. More information on php.net

Installation

Composer

You can use Composer to install the package to your project:

composer require petschko/dhl-php-sdk

The classes are then added to the autoloader automatically.

Without Composer

If you can't use Composer (or don't want to), you can also use this SDK without it.

To initial this SDK, just require the _nonComposerLoader.php-File from the /includes/ directory.

require_once(__DIR__ . '/includes/_nonComposerLoader.php');

Compatibility

This Project is written for the DHL-SOAP-API Version 2 or higher.

API Version 3.0

This Project is currently not available for Version 3.0+, I plan to update it soon! Please don't send me any E-Mails about this! If you want to talk about Version 3.0, please use the Issue for it: #64

Use BETA for Version 3.0

You can still try out the dev-branch of this repo for Version 3:

composer require petschko/dhl-php-sdk:dev-dev

Version 1

Version 1 Methods are marked as deprecated and will removed soon. Please upgrade to the API-Version 2 as soon as possible.

Usage / Getting started

Please have a look at the examples Directory. There you can find how to use this SDK also with Code-Examples, else check the (Doxygen) Documentation for deeper knowledge.

Code Documentation

You find Code-Examples with explanations in the examples Directory. I also explain how it works.

You can find a Code-Reference here: (Doxygen) http://docs.petschko.org/dhl-php-sdk/index.html

Motivation

I had a lot of pain studying and programming the DHL SOAP API - just to wrap some bits in a lot of XML. There is a lot, but not very helpful, documentation to the API. So I decided to create some functions in an easy to use and understand library.

There is also a lot of old stuff in the Documentation, so that you can not sure if it is right...

Credits

All these Persons helped to create this SDK for the DHL-API:

  • aschempp - For the help with the Notification E-Mail
  • cedricziel - For turning this Project into a Composer-Package
  • Dakror - For the ProductInfo-Class
  • octlabs - For adding some missing Documentation
  • Petschko - Initially created this Project and decided to share it for free
  • tobias-redmann - For the setFullStreet method and the PHP-DHL-Example-Project for Version 1 (This helped a lot to understand how the API works)

Donate

If you like this Project may consider to Donate. I usually do this Project in my spare time and it's completely free. So I appreciate anything, which helps the Project (Pull-Requests, Bug Report etc), these are more worth than Donations but I'm happy for every amount as well. ^.^

Contact

  • You can E-Mail me if you have Questions or whatever (No Bug-Reporting please!): [email protected]
  • You can Chat with me in Telegram @petschkoo
  • You can Report Bugs here in the "Issue"-Section of the Project.
    • Of course you can also ask any stuff there, feel free for that!
    • If you want to use German, you can do it. Please keep in mind that not everybody can speak German, so it's better to use english =)

dhl-php-sdk's People

Contributors

aschempp avatar cedricziel avatar dakror avatar dasistdaniel avatar klimser avatar nastymadecode avatar petschko avatar tobias-redmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dhl-php-sdk's Issues

Unauthorized

Hi! I am trying to create a new shipment through the API Using the code in test.php...
The Problem is, that i always get an error, when creating a shipment: Unauthorized. The login credentials are correct (Dev ID and Password) and I can login just fine with them on the website.

`<?php
require_once(DIR . '/dhl-php-sdk/includes/_nonComposerLoader.php');

use Petschko\DHL\BusinessShipment;
use Petschko\DHL\Credentials;
use Petschko\DHL\Receiver;
use Petschko\DHL\ReturnReceiver;
use Petschko\DHL\Sender;
use Petschko\DHL\Service;
use Petschko\DHL\ShipmentOrder;
use Petschko\DHL\ShipmentDetails;

//$testMode = Credentials::DHL_BUSINESS_TEST_USER_THERMO; // Uses the thermo-printer test user
$reference = '1'; // You can use anything here (max 35 chars)

$credentials = new Credentials(Credentials::TEST_NORMAL);
var_dump($credentials);
echo '<br>';

// Set your API-Login
$credentials->setApiUser('#######');			// Test-Mode: Your DHL-Dev-Account (Developer-ID NOT E-Mail!!) | Production: Your Applications-ID
$credentials->setApiPassword('##########');
var_dump($credentials);
echo '<br>';

$sender = new Sender();
//Address replaced for privacy..
$sender->setName((string) 'ABC'); // Can be a Person-Name or Company Name

$sender->setStreetName((string) 'ABC');
$sender->setStreetNumber((string) '5'); // A Number is ALWAYS needed

$sender->setZip((string) '12345');
$sender->setCity((string) 'ABC');
$sender->setCountry((string) 'Germany');
$sender->setCountryISOCode((string) 'DE'); // 2 Chars ONLY

$shipmentDetails = new ShipmentDetails($credentials->getEkp(10) . '0101');

//Getting userdata fro DB cut out...

// receiver details
$receiver = new Receiver();
$receiver->setName($firstname . ' ' . $lastname);
$receiver->setStreetName($str);
$receiver->setStreetNumber($number);
$receiver->setZip($plz);
$receiver->setCity($town);
$receiver->setCountry('Germany');
$receiver->setCountryISOCode('DE');


$dhl = new BusinessShipment($credentials);
echo '<br>';
var_dump($dhl);
echo '<br>';

$shipmentOrder = new ShipmentOrder();
$shipmentOrder->setSequenceNumber($reference); // Just needed to identify the shipment if you do multiple
$shipmentOrder->setSender($sender);
$shipmentOrder->setReceiver($receiver); // You can set these Object-Types here: DHL_Filial, DHL_Receiver & DHL_PackStation
$shipmentOrder->setShipmentDetails($shipmentDetails);
$shipmentOrder->setLabelResponseType(BusinessShipment::RESPONSE_TYPE_URL);

$dhl->addShipmentOrder($shipmentOrder);
$response = $dhl->createShipment();


if($response !== false) {
	echo 'Erfolg! Klicke <a href="' . $response["label_url"] . '">hier</a> um das Label anzuzeigen.<br><br>';
	var_dump($response);
  
} else {
	var_dump($dhl->getErrors());
}

?>`

[Feature-Request] Api-Method validateShipment

Hello,
first of all thank you very much for this great library!

I'm currently integrating it for a online shop and wondered if there was a way to add the functionality of validating shipments before creating them, by using the DHL function validateShipment, like $business_shipment->validate() which would not use the createShipmentOrder SOAP call but rather validateShipment in order to see what values are invalid and so on...

If you don't want to or can't implement it i'll maybe submit a PR after eventually implementing it myself :)

Grüße aus München

DHL SDK also for international shipping

Did anybody use this SDK for sending packages to ParcelShops in Austria? I was not able to figure out the right approach. I suppose for European pickup points there should be a new class ParcelShop with propper data in it?

Composer require is not work

Hi. My name is Pavel.
I'm trying install this package via composer, but I have this responce:
"Could not find package petschko/dhl-php-sdk at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability"

Typo

$obj = new Product(ShipmentDetails::PRODUCT_TYPE_AUSTRIA_INTERNATIONAL_PACKAGE);
$obj->setName('DHL Paket International');

I would say, setName should add 'Austria' too for this Product. For Austria Connect too.

Btw. Service PersonalHandover is obsolote, it has been replaced with namedPersonOnly.

validateShipment returning statuscode 1 or 0 on refresh

Hey,

I am trying to test the validateShipment function doing this:

$response = $dhl->validateShipment($shipmentOrder);

and I got an object with the data which I can use to validate, so then I do this:

$status_text = $response->getStatusText();
$status_code = $response->getStatusCode();

if($status_text == "ok" && $status_code == 0){

  echo "success";

}

But curiously, when I refresh the page, sometimes I get $status_code = 0 and sometimes I get $status_code = 1. Why is that? Here is the response object when everything works well.

object(Petschko\DHL\Response)#943 (8) { ["manifestData":"Petschko\DHL\Response":private]=> NULL ["statusCode":"Petschko\DHL\Response":private]=> int(0) ["statusText":"Petschko\DHL\Response":private]=> string(2) "ok" ["statusMessage":"Petschko\DHL\Response":private]=> string(45) "Der Webservice wurde ohne Fehler ausgeführt." ["labelData":"Petschko\DHL\Response":private]=> array(1) { [0]=> object(Petschko\DHL\LabelData)#944 (12) { ["statusCode":"Petschko\DHL\LabelData":private]=> int(0) ["statusText":"Petschko\DHL\LabelData":private]=> string(2) "ok" ["statusMessage":"Petschko\DHL\LabelData":private]=> string(45) "Der Webservice wurde ohne Fehler ausgeführt." ["sequenceNumber":"Petschko\DHL\LabelData":private]=> string(1) "1" ["shipmentNumber":"Petschko\DHL\LabelData":private]=> NULL ["label":"Petschko\DHL\LabelData":private]=> NULL ["returnLabel":"Petschko\DHL\LabelData":private]=> NULL ["exportDoc":"Petschko\DHL\LabelData":private]=> NULL ["codLabel":"Petschko\DHL\LabelData":private]=> NULL ["version":"Petschko\DHL\Version":private]=> string(3) "2.2" ["mayor":"Petschko\DHL\Version":private]=> int(2) ["minor":"Petschko\DHL\Version":private]=> int(2) } } ["version":"Petschko\DHL\Version":private]=> string(3) "2.2" ["mayor":"Petschko\DHL\Version":private]=> int(2) ["minor":"Petschko\DHL\Version":private]=> int(2) }

And here is the object when the status code is 1:

object(Petschko\DHL\Response)#943 (8) { ["manifestData":"Petschko\DHL\Response":private]=> NULL ["statusCode":"Petschko\DHL\Response":private]=> int(1) ["statusText":"Petschko\DHL\Response":private]=> string(26) "Some Shipments had errors." ["statusMessage":"Petschko\DHL\Response":private]=> string(48) "ok;Der Webservice wurde ohne Fehler ausgeführt." ["labelData":"Petschko\DHL\Response":private]=> array(1) { [0]=> object(Petschko\DHL\LabelData)#944 (12) { ["statusCode":"Petschko\DHL\LabelData":private]=> int(0) ["statusText":"Petschko\DHL\LabelData":private]=> string(2) "ok" ["statusMessage":"Petschko\DHL\LabelData":private]=> string(45) "Der Webservice wurde ohne Fehler ausgeführt." ["sequenceNumber":"Petschko\DHL\LabelData":private]=> string(1) "1" ["shipmentNumber":"Petschko\DHL\LabelData":private]=> NULL ["label":"Petschko\DHL\LabelData":private]=> NULL ["returnLabel":"Petschko\DHL\LabelData":private]=> NULL ["exportDoc":"Petschko\DHL\LabelData":private]=> NULL ["codLabel":"Petschko\DHL\LabelData":private]=> NULL ["version":"Petschko\DHL\Version":private]=> string(3) "2.2" ["mayor":"Petschko\DHL\Version":private]=> int(2) ["minor":"Petschko\DHL\Version":private]=> int(2) } } ["version":"Petschko\DHL\Version":private]=> string(3) "2.2" ["mayor":"Petschko\DHL\Version":private]=> int(2) ["minor":"Petschko\DHL\Version":private]=> int(2) }

Do you know the reason of this? am I missing any other setting? Should I just pay attention to the labeldata array? because there it seems to always display the correct code (notice that I am using a correct address for sender and receiver but I am testing with the sender in this case).

Thanks.

return bool false

I just came back to my code which worked fine, but now I only get "false" returned by $dhl->createShipment();
I already took a look into the code but can't find a single reason to just return "false".
The SoapClient looks like this:

object(SoapClient)#386 (7) {
  ["location"]=>
  string(43) "https://cig.dhl.de/services/production/soap"
  ["_login"]=>
  string(13) "api_user"
  ["_password"]=>
  string(30) "api_user_password"
  ["trace"]=>
  int(1)
  ["_soap_version"]=>
  int(1)
  ["sdl"]=>
  resource(950) of type (Unknown)
  ["__default_headers"]=>
  array(1) {
    [0]=>
    object(SoapHeader)#362 (4) {
      ["namespace"]=>
      string(32) "http://dhl.de/webservice/cisbase"
      ["name"]=>
      string(16) "Authentification"
      ["data"]=>
      array(3) {
        ["user"]=>
        string(17) "dhl_user"
        ["signature"]=>
        string(16) "dhl_user_password"
        ["type"]=>
        int(0)
      }
      ["mustUnderstand"]=>
      bool(false)
    }
  }
}

My $dhl object looks like this:

object(Petschko\DHL\BusinessShipment)#15 (20) {
  ["soapClient":"Petschko\DHL\BusinessShipment":private]=>
  NULL
  ["errors":"Petschko\DHL\BusinessShipment":private]=>
  array(0) {
  }
  ["test":"Petschko\DHL\BusinessShipment":private]=>
  bool(false)
  ["log":"Petschko\DHL\BusinessShipment":private]=>
  bool(false)
  ["credentials":"Petschko\DHL\BusinessShipment":private]=>
  object(Petschko\DHL\Credentials)#270 (5) {
    ["user":"Petschko\DHL\Credentials":private]=>
    string(17) "dhl_user"
    ["signature":"Petschko\DHL\Credentials":private]=>
    string(16) "dhl_user_password"
    ["epk":"Petschko\DHL\Credentials":private]=>
    string(10) "EKP"
    ["api_user":"Petschko\DHL\Credentials":private]=>
    string(13) "api_user"
    ["api_password":"Petschko\DHL\Credentials":private]=>
    string(30) "api_user_password"
  }
  ["shipmentDetails":"Petschko\DHL\BusinessShipment":private]=>
  object(Petschko\DHL\ShipmentDetails)#470 (11) {
    ["product":"Petschko\DHL\ShipmentDetails":private]=>
    string(6) "V01PAK"
    ["accountNumber":"Petschko\DHL\ShipmentDetails":private]=>
    string(14) "EKP0101"
    ["customerReference":"Petschko\DHL\ShipmentDetails":private]=>
    NULL
    ["shipmentDate":"Petschko\DHL\ShipmentDetails":private]=>
    NULL
    ["returnAccountNumber":"Petschko\DHL\ShipmentDetails":private]=>
    NULL
    ["returnReference":"Petschko\DHL\ShipmentDetails":private]=>
    NULL
    ["weight":"Petschko\DHL\ShipmentDetails":private]=>
    int(1)
    ["length":"Petschko\DHL\ShipmentDetails":private]=>
    NULL
    ["width":"Petschko\DHL\ShipmentDetails":private]=>
    NULL
    ["height":"Petschko\DHL\ShipmentDetails":private]=>
    NULL
    ["packageType":"Petschko\DHL\ShipmentDetails":private]=>
    string(2) "PK"
  }
  ["service":"Petschko\DHL\BusinessShipment":private]=>
  object(Petschko\DHL\Service)#339 (38) {
    ["dayOfDeliveryEnabled":"Petschko\DHL\Service":private]=>
    NULL
    ["dayOfDeliveryDate":"Petschko\DHL\Service":private]=>
    NULL
    ["deliveryTimeframeEnabled":"Petschko\DHL\Service":private]=>
    NULL
    ["deliveryTimeframe":"Petschko\DHL\Service":private]=>
    NULL
    ["preferredTimeEnabled":"Petschko\DHL\Service":private]=>
    NULL
    ["preferredTime":"Petschko\DHL\Service":private]=>
    NULL
    ["individualSenderRequiredmentsEnabled":"Petschko\DHL\Service":private]=>
    NULL
    ["individualSenderRequiredmentsText":"Petschko\DHL\Service":private]=>
    NULL
    ["packagingReturn":"Petschko\DHL\Service":private]=>
    NULL
    ["returnImmediatlyIfShipmentFailed":"Petschko\DHL\Service":private]=>
    NULL
    ["noticeNonDeliverability":"Petschko\DHL\Service":private]=>
    NULL
    ["shipmentHandlingEnabled":"Petschko\DHL\Service":private]=>
    NULL
    ["shipmentHandlingType":"Petschko\DHL\Service":private]=>
    NULL
    ["endorsementEnabled":"Petschko\DHL\Service":private]=>
    NULL
    ["endorsementType":"Petschko\DHL\Service":private]=>
    NULL
    ["visualCheckOfAgeEnabled":"Petschko\DHL\Service":private]=>
    NULL
    ["visualCheckOfAgeType":"Petschko\DHL\Service":private]=>
    NULL
    ["preferredLocationEnabled":"Petschko\DHL\Service":private]=>
    NULL
    ["preferredLocationDetails":"Petschko\DHL\Service":private]=>
    NULL
    ["preferredNeighbourEnabled":"Petschko\DHL\Service":private]=>
    NULL
    ["preferredNeighbourText":"Petschko\DHL\Service":private]=>
    NULL
    ["preferredDayEnabled":"Petschko\DHL\Service":private]=>
    NULL
    ["preferredDayText":"Petschko\DHL\Service":private]=>
    NULL
    ["goGreen":"Petschko\DHL\Service":private]=>
    NULL
    ["perishables":"Petschko\DHL\Service":private]=>
    NULL
    ["personalHandover":"Petschko\DHL\Service":private]=>
    NULL
    ["disableNeighbourDelivery":"Petschko\DHL\Service":private]=>
    NULL
    ["namedPersonOnly":"Petschko\DHL\Service":private]=>
    NULL
    ["returnReceipt":"Petschko\DHL\Service":private]=>
    NULL
    ["premium":"Petschko\DHL\Service":private]=>
    NULL
    ["cashOnDeliveryEnabled":"Petschko\DHL\Service":private]=>
    NULL
    ["cashOnDeliveryAddFee":"Petschko\DHL\Service":private]=>
    NULL
    ["cashOnDeliveryAmount":"Petschko\DHL\Service":private]=>
    NULL
    ["additionalInsuranceEnabled":"Petschko\DHL\Service":private]=>
    NULL
    ["additionalInsuranceAmount":"Petschko\DHL\Service":private]=>
    NULL
    ["bulkyGoods":"Petschko\DHL\Service":private]=>
    NULL
    ["identCheckEnabled":"Petschko\DHL\Service":private]=>
    NULL
    ["identCheckObj":"Petschko\DHL\Service":private]=>
    NULL
  }
  ["bank":"Petschko\DHL\BusinessShipment":private]=>
  NULL
  ["sender":"Petschko\DHL\BusinessShipment":private]=>
  object(Petschko\DHL\Sender)#414 (15) {
    ["name":"Petschko\DHL\SendPerson":private]=>
    string(28) "Sender"
    ["name2":"Petschko\DHL\SendPerson":private]=>
    NULL
    ["name3":"Petschko\DHL\SendPerson":private]=>
    NULL
    ["phone":"Petschko\DHL\SendPerson":private]=>
    string(11) "phonenumber"
    ["email":"Petschko\DHL\SendPerson":private]=>
    string(26) "email.de"
    ["contactPerson":"Petschko\DHL\SendPerson":private]=>
    string(0) ""
    ["street_name":"Petschko\DHL\Address":private]=>
    string(17) "Street"
    ["street_number":"Petschko\DHL\Address":private]=>
    string(2) "1337"
    ["address_addition":"Petschko\DHL\Address":private]=>
    NULL
    ["dispatchingInfo":"Petschko\DHL\Address":private]=>
    NULL
    ["zip":"Petschko\DHL\Address":private]=>
    string(5) "12345"
    ["location":"Petschko\DHL\Address":private]=>
    string(10) "City"
    ["country":"Petschko\DHL\Address":private]=>
    string(7) "germany"
    ["countryISOCode":"Petschko\DHL\Address":private]=>
    string(2) "DE"
    ["state":"Petschko\DHL\Address":private]=>
    NULL
  }
  ["receiver":"Petschko\DHL\BusinessShipment":private]=>
  object(Petschko\DHL\Receiver)#129 (15) {
    ["name":"Petschko\DHL\SendPerson":private]=>
    string(12) "Foo Bar"
    ["name2":"Petschko\DHL\SendPerson":private]=>
    NULL
    ["name3":"Petschko\DHL\SendPerson":private]=>
    NULL
    ["phone":"Petschko\DHL\SendPerson":private]=>
    NULL
    ["email":"Petschko\DHL\SendPerson":private]=>
    NULL
    ["contactPerson":"Petschko\DHL\SendPerson":private]=>
    NULL
    ["street_name":"Petschko\DHL\Address":private]=>
    string(8) "Street"
    ["street_number":"Petschko\DHL\Address":private]=>
    string(1) "2"
    ["address_addition":"Petschko\DHL\Address":private]=>
    NULL
    ["dispatchingInfo":"Petschko\DHL\Address":private]=>
    NULL
    ["zip":"Petschko\DHL\Address":private]=>
    string(5) "98765"
    ["location":"Petschko\DHL\Address":private]=>
    string(11) "City"
    ["country":"Petschko\DHL\Address":private]=>
    string(7) "germany"
    ["countryISOCode":"Petschko\DHL\Address":private]=>
    string(2) "DE"
    ["state":"Petschko\DHL\Address":private]=>
    NULL
  }
  ["returnReceiver":"Petschko\DHL\BusinessShipment":private]=>
  NULL
  ["exportDocument":"Petschko\DHL\BusinessShipment":private]=>
  NULL
  ["sequenceNumber":"Petschko\DHL\BusinessShipment":private]=>
  string(1) "1"
  ["receiverEmail":"Petschko\DHL\BusinessShipment":private]=>
  NULL
  ["printOnlyIfReceiverIsValid":"Petschko\DHL\BusinessShipment":private]=>
  NULL
  ["labelResponseType":"Petschko\DHL\BusinessShipment":private]=>
  string(3) "URL"
  ["customAPIURL":"Petschko\DHL\BusinessShipment":private]=>
  NULL
  ["version":"Petschko\DHL\Version":private]=>
  string(3) "2.2"
  ["mayor":"Petschko\DHL\Version":private]=>
  int(2)
  ["minor":"Petschko\DHL\Version":private]=>
  int(2)
}

However .. calling $dhl->createShipment(); now only returns bool(false)

Any clue how to debug this?

Auto assign EKP-Ending depending on need

I've think about assigning the last 4 digits of the EKP automaticly depending on which Product is used (and if a Return-Lebel is needed)...

But I'm a bit unsure if this is a good idea, feel free to tell me what you think about it!

How to set up GoGreen?

Hy folks, i tried to add GoGreen Support, but on the label it's not showing:

$service = new DHL_Service();
$service->setGoGreen(1);
$service->setPremium(1);
...
$dhl->setService($service);

Premium is working though and uses the same semantic. A closer look (my php skill is not the best) let me to DHL_Service.php line 1155:

if($this->getPremium() !== null) {
	$class->Premium = new StdClass;
	$class->Premium->active = (int) $this->getPremium();
}

this kind of definition is missing for GoGreen, but adding the same for green doesnt seem to solve the problem:


if($this->getGoGreen() !== null) {
	$class->GoGreen = new StdClass;
	$class->GoGreen->active = (int) $this->getGoGreen();
}

Any idea? Am i missing something ?

Add update Shipment method

I saw, that the updateShipmentOrder Method is missing in the SDK as well. It should not be complicated to include this method, since its the same syntax like createShipmentOrder

Unable to setup exportDocPosition values

Hy @Petschko ,
thanks for that great plugin!

I have a hard time to get the values set for the exportDocPosition, like setAmount etc, which is mandatory for international shipping. Could some one explain how to achieve that?

i have tried so far in my setup.php

$export = new DHL_ExportDocument();
$export->setExportType('OTHER');
$export->setExportTypeDescription('Test descr');
$export->setAdditionalFee('20');

and later called it with:

$dhl->setExportDocument($export);

which works as expected. How to setup the values for DHL_ExportDocPosition now?

Thx

Authorization required

Does the credentials for https://xmlportal.dhl.com/login also work in your sdk? and why it gives me syntax error or http 500 error on this line:

$credentials = new \Petschko\DHL\Credentials(Credentials::TEST_NORMAL);

I have got only test credentials for dhl xml web services but i keep getting authorization required when i use it like this $credentials = new \Petschko\DHL\Credentials();
And in above case using TEST_NORMAL OR any other test mode i get syntax error????
please help me as quickly as possible thank you so much.

SOAP-ERROR: Parsing WSDL: Couldn't load [...]

Hey Guys,

just did all the steps from readme but getting following error:

[Symfony\Component\Debug\Exception\FatalErrorException]                                                              
  SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://cig.dhl.de/cig-wsdls/com/dpdhl/wsdl/geschaeftskundenversand-a  
  pi/2.2/geschaeftskundenversand-api-2.2.wsdl' : failed to load external entity "https://cig.dhl.de/cig-wsdls/com/dpd  
  hl/wsdl/geschaeftskundenversand-api/2.2/geschaeftskundenversand-api-2.2.wsdl" 

When I try to fetch WDSL URL in Browser it works fine.

Logging

Hi, for logging purposes we would like to log als the complete request sent to DHL.
Currently all methods/properties are private.
Does it make sense to create a pull request to get the last sent data or something similar?

Alex

Return-Label

Hello,

I was not able to test if the Return-Label works (no Test-Data found) - Please test it, if you can...

If you know Test-Data for Return-Label, please write them here, so that I can include them (or do it by yourself =))

Missing the API Method getVersion()

I would like to use the getVersion() Method of DHL as a simple check whether the user has entered valid API credentials.
I will implement it myself for my software, but a more robust and more coherent to the style of the library implementation would be appreciated. The request itself is very straightforward.

Any other easy implementation of a simple credentials validation check would be just as fine. I just suggested the getVersion method since it's an easy request that does not need parameters

setAddressAddition ignored for national shipments

Hi,

first of all, a huge thanks for this library. It has saved me hours of painful work.

Now, when I try to add a additional line to the receiver address, it does not show up on the shipping-label.
The DHL-Docs say, the addressAddition field is for international shipments only.

Are there any other possibilities? Sometimes the address additional is required, otherwise the shipment cannot be delivered and is returned.

Call of getLabel after getShipmentLabel returns null instead of label

When trying to request an already created shipment label via $dhl->getShipmentLabel and then calling $response->getLabel() the method returns null.

My solution was to simply add the label response type to the creation of the DHL_Response object in the method getShipmentLabel definition (DHL_BusinessShipment.php:940)

Add "PackStation" for Shipment

I've encountered this Problem after a customer uses a Pack-Station as Address... I just forget to implement this feature. I think its important to have. So I will implement it soon!

validateShipment: StatusCode 1 but everything is Ok

Hi,
i'm trying to validate my adresses before i send them create a label, but sometimes i get
some wrong information back.

StatusCode: 1
StatusText: Some Shipments had errors.
StatusMsg: ok;Der Webservice wurde ohne Fehler ausgeführt.

If i try to validate it again it works and gives me the correct Status:

StatusCode: 0
StatusText: ok
statusMsg: Der Webservice wurde ohne Fehler ausgeführt.

In the following Screenshot you see some test javascript,
which gets the data from my test.php.

The entries were all tested with the same adress.
github_dhl
(every request is about 10-30 seconds apart)

Implement API-Version 1 methods (Low Prio)

I want to have backwarts compatibility, but I can't find a Documentation for the old Version (1)...

If someone knows how Version 1 work and/or have a Documentation, you can provide a Link or complete the functions by yourself =)

The Version 1 functions are named like this: {functionname}_v1 . Some of them are done, if they are not implemented, they are marked with a "todo"...

Request several labels in one call

The DHL API allows to create up to 30 shipment labels per SOAP call. In test.php there's only one label generated. Is it possible to create several labels in one call?

Label output size

I've got a Feature-Request about adjusting the size for the output Label.

I never read anything about it in the DHL-Dokumentation, if someone knows anything about it please tell me. (Like if there is such a feature)

If there is such a function to adjust the Label-Size for printing, I will implement it as soon as possible =)

Multiple Items in Shipment

First of all - thaks for your great package, it helped me a lot. I have found feature which is probably missing in your package (or i didn't find the way how to do it). I need to created Shipment with multiple instances of ShipmentItem. Could you please provide possible solution?

Check if local WSDL-Files are up-to-date

DHL say we should store the WSDL-Files local (improved performance, less traffic & better for DHL-Servers), thats done with this SDK. But I didn't implement the feature where the SDK checks (for example once a day), if the File(s) is(/are) up-to-date...

Unknown error | International-Shippings

hello,
we test your php sdk and have on problem.
We look if a national or international shipping.
If de = national V01PAK and epk is .....0102
else = international V53WPAK and epk is .....0302


if($utf_landcode == 'DE'){    
    $credentials->setEpk('xxxxxxxxxxxx102');
    $shipmentDetails->setProduct((string) DHL_ShipmentDetails::{V01PAK});
} else {
    $credentials->setEpk('xxxxxxxxxxxx302');
    $shipmentDetails->setProduct((string) DHL_ShipmentDetails::{V53WPAK});
}

is not working.

Does export-document still work?

I've merged the changes, that multi-labels work now. #52

But I was not able to test if the export-document still work... Please let me know if you use this function and test if it gives you the export-documents... Here is a checklist:

  • * createShipment works with "ExportDocument"
  • * createShipment shows the "ExportDocument" in Response
  • createShipment works with "COD (Cash on delivery)"
  • createShipment shows the "COD (Cash on delivery)" label in response
  • * getExportDoc still works
  • * getExportDoc works with multiple elements
  • * getExportDoc shows the result(s) in Response

Thanks for anyone, who is willing to share their test-results =)

Return-Label only

Hi there!

I'd like to build an application for a customer.

Is there a way to get the normal label in the first step and only if its nessesary to get der return-label?

In my case the function $dhl->getReturnLabel() is not working.

Thanks!

Better address support

Hy folks, recently i spotted a problem with the address validation aka full street address. Its works fine for Germany but really bad for anything else. I found that php address checker, which parses the address through google: http://www.jayjohnston.com/php/parse-addresses-in-php-using-google-geocoding

I changed the address check in line 295/Addresses.php:

public final function setFullStreet($street) {
  
$url = 'http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address='.urlencode($street); 
  $results = json_decode(file_get_contents($url),1); 
  $parts = array( 
    'street'=>array('route'), 
    'number'=>array('street_number')
  ); 
  if (!empty($results['results'][0]['address_components'])) { 
    $ac = $results['results'][0]['address_components']; 
    foreach($parts as $need=>&$types) { 
      foreach($ac as &$a) { 
        if (in_array($a['types'][0],$types)) $address_out[$need] = $a['short_name']; 
        elseif (empty($address_out[$need])) $address_out[$need] = ''; 
      } 
    } 
  }
	
$this->setStreetName($address_out['street']);
$this->setStreetNumber($address_out['number']);
	
}

Hope it helps somebody :D

Authorization Required for test mode

While using the test.php and test mode I'm only getting Authorization Required
The only things I provided are $credentials->setApiUser("[email protected]"); and $credentials->setApiPassword("password"); using my DHL dev account data.

XML:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:ns1="http://dhl.de/webservice/cisbase" 
    xmlns:ns2="http://dhl.de/webservices/businesscustomershipping">
    <SOAP-ENV:Header>
        <ns1:Authentification>
            <ns1:user>2222222222_01</ns1:user>
            <ns1:signature>pass</ns1:signature>
        </ns1:Authentification>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns2:CreateShipmentOrderRequest>
            <Version>
                <majorRelease>2</majorRelease>
                <minorRelease>2</minorRelease>
            </Version>
            <ShipmentOrder>
                <sequenceNumber>1</sequenceNumber>
                <Shipment>
                    <ShipmentDetails>
                        <product>V01PAK</product>
                        <ns1:accountNumber>22222222220101</ns1:accountNumber>
                        <shipmentDate>2018-04-04</shipmentDate>
                        <ShipmentItem>
                            <weightInKG>5</weightInKG>
                        </ShipmentItem>
                        <Service/>
                    </ShipmentDetails>
                    <Shipper>
                        <Name>
                            <ns1:name1>Peter Muster</ns1:name1>
                        </Name>
                        <Address>
                            <ns1:streetName>Test Straße</ns1:streetName>
                            <ns1:streetNumber>12a</ns1:streetNumber>
                            <ns1:zip>21037</ns1:zip>
                            <ns1:city>Hamburg</ns1:city>
                            <ns1:Origin>
                                <ns1:country>germany</ns1:country>
                                <ns1:countryISOCode>DE</ns1:countryISOCode>
                            </ns1:Origin>
                        </Address>
                        <Communication/>
                    </Shipper>
                    <Receiver>
                        <ns1:name1>Test Empfänger</ns1:name1>
                        <Address>
                            <ns1:streetName>Test Straße</ns1:streetName>
                            <ns1:streetNumber>23b</ns1:streetNumber>
                            <ns1:zip>21037</ns1:zip>
                            <ns1:city>Hamburg</ns1:city>
                            <ns1:Origin>
                                <ns1:country>germany</ns1:country>
                                <ns1:countryISOCode>DE</ns1:countryISOCode>
                            </ns1:Origin>
                        </Address>
                        <Communication/>
                    </Receiver>
                </Shipment>
                <labelResponseType>URL</labelResponseType>
            </ShipmentOrder>
        </ns2:CreateShipmentOrderRequest>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Return label shipment number

Can you please help me how to get shipment number of return label?
Function getShipmentNumber() return number of package which goes to receiver but i need also to save number of the return package...

Cannot print label trough webservice after `doManifest`

Hi,

I'm currently trying to print a label after manifesting a shipment by number, which works.

Right after manifesting the shipment, I cant print the label anymore - neither through the old url, nor by using $dhl->getShipmentLabel($shipmentNumber)`.

Is this a limitation of the sandbox or a mishandling of the API through the library?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.