christoph-schaeffer / dhl-business-shipping

An unofficial library for the DHL business shipping soap API (Version 3.3) and the dhl shipment tracking rest API written in PHP.
MIT License
29 stars 8 forks source link

Endorsement for International Packages (V53WPAK) #8

Closed Flaschenzug closed 3 years ago

Flaschenzug commented 3 years ago

Hi, I try to add dhl labels for international packages (Product-code "V53WPAK"). But when I try that, i get the following message:

[message] => Ein Unbekannter Fehler ist aufgetreten [messageRaw] => Bitte beachten Sie, dass der Service Vorausverfügung für Sendungen mit DHL Paket International verpflichtend ist.

Looking at the SoapUI examples from DHL I tried to add the endorsement like this: $shipmentOrder->Shipment->ShipmentDetails->Service->Endorsement = "IMMEDIATE";

Do you have an idea how to solve the problem? It looks like they changed the settings for that beginning of 2021.

Thanks.

wolfgangmauer commented 3 years ago

I have to set these values to get it work: $shipmentOrder->Shipment->ShipmentDetails->product = ShipmentDetails::PRODUCT_INTERNATIONAL; $shipmentOrder->Shipment->ShipmentDetails->Service->Endorsement->active = true; $shipmentOrder->Shipment->ShipmentDetails->Service->Endorsement->type = Endorsement::INTERNATIONAL_RETURN_IMMEDIATELY; $shipmentOrder->Shipment->ShipmentDetails->accountNumber = .....

Am 14.05.2021 um 16:26 schrieb Flaschenzug:

Hi, I try to add dhl labels for international packages (Product-code "V53WPAK"). But when I try that, i get the following message:

[message] => Ein Unbekannter Fehler ist aufgetreten [messageRaw] => Bitte beachten Sie, dass der Service Vorausverfügung für Sendungen mit DHL Paket International verpflichtend ist.

Looking at the SoapUI examples from DHL I tried to add the endorsement like this: $shipmentOrder->Shipment->ShipmentDetails->Service->Endorsement = "IMMEDIATE";

Do you have an idea how to solve the problem? It looks like they changed the settings for that beginning of 2021.

Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/christoph-schaeffer/dhl-business-shipping/issues/8, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGVIUPAS5U62EXL224CNOKLTNUXINANCNFSM444Q3FMQ.

christoph-schaeffer commented 3 years ago

Hello @Flaschenzug ,

yes you are right, the endorsement service is now required for international shipping.

Wolfgang has already answered with the solution.

Additionally to the type you also have to activate it first.

Flaschenzug commented 3 years ago

Thanks to the two of you for the fast response.

How do I use this with php? $shipmentOrder->Shipment->ShipmentDetails->Service->Endorsement->type = Endorsement::INTERNATIONAL_RETURN_IMMEDIATELY;

If I use it like the code above, I get the following response/fatal error: Uncaught Error: Class 'Endorsement'

Flaschenzug commented 3 years ago

Okay, it might work like that:

$shipmentOrder->Shipment->ShipmentDetails->Service->Endorsement->active = true;
$shipmentOrder->Shipment->ShipmentDetails->Service->Endorsement->type = 'IMMEDIATE';
christoph-schaeffer commented 3 years ago

You need to autoload the Endorsement class to use it. here is an example:

<?php
use ChristophSchaeffer\Dhl\BusinessShipping\Resource\ShipmentOrder\Shipment\ShipmentDetails\Service\Endorsement;

class MyClass {
     public function myFunc() {
          $shipmentOrder->Shipment->ShipmentDetails->Service->Endorsement->type = Endorsement::INTERNATIONAL_RETURN_IMMEDIATELY;
     }
}

there are other type constants aswell. Such as Endorsement::ABANDONMENT and Endorsement::AFTER_DEADLINE

just setting the string yourself works, too though. Those constants are meant to be helpful if you don't know what exactly can be set there and what not. For Example there were other constants in an older version which are now flagged as deprecated. This way you will notice that in your code aswell.

Flaschenzug commented 3 years ago

okay, thanks :-).

And how about using "packstation"? Do I have to autoload something too?

I tried the following ... $shipmentOrder->Shipment->Receiver->Packstation->postNumber = ""; $shipmentOrder->Shipment->Receiver->Packstation->packstationNumber = ""; $shipmentOrder->Shipment->Receiver->Packstation->zip = ""; $shipmentOrder->Shipment->Receiver->Packstation->city = ""; $shipmentOrder->Shipment->Receiver->Packstation->Origin->countryISOCode = "";

But get this response:

Bitte geben Sie eine Straße an.

Thanks

wolfgangmauer commented 3 years ago

Packstation looks good, work for me, remember that the "packstationNumber" is just the number, not "Packstation xxx" !

Am 01.06.2021 um 14:44 schrieb Flaschenzug:

okay, thanks :-).

And how about using "packstation"? Do I have to autoload something too?

I tried the following ... $shipmentOrder->Shipment->Receiver->Packstation->postNumber = ""; $shipmentOrder->Shipment->Receiver->Packstation->packstationNumber = ""; $shipmentOrder->Shipment->Receiver->Packstation->zip = ""; $shipmentOrder->Shipment->Receiver->Packstation->city = ""; $shipmentOrder->Shipment->Receiver->Packstation->Origin->countryISOCode = "";

But get this response:

Bitte geben Sie eine Straße an.

Thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/christoph-schaeffer/dhl-business-shipping/issues/8#issuecomment-852093680, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGVIUPGJWQJSPAQPXIJAYZTTQTIZDANCNFSM444Q3FMQ.

Flaschenzug commented 3 years ago

It's working perfectly, I was just stupid ... Thanks Wolfgang.

Magellanth commented 3 years ago

I hope its ok to add this here:

The DHL Documentation says about Endorsement values: This service defines the handling of parcels that cannot be delivered. There are two options: IMMEDIATE (Sending back to sender), ABANDONMENT (Abandonment of parcel at the hands of sender (free of charge).

In the Endorsement.php Class there is another possible value "AFTER_DEADLINE" and the comments seem to be switched between ABANDONMENT and AFTER_DEADLINE.

 /**
     * Sending back immediately to sender after expiration of time.
     */
    const ABANDONMENT = 'ABANDONMENT';
    /**
     * Sending back immediately to sender.
     */
    const IMMEDIATE = 'IMMEDIATE';
    /**
     * Abandonment of parcel at the hands of sender (free of charge)
     */
    const AFTER_DEADLINE = 'AFTER_DEADLINE';

The DHL API responds to the AFTER_DEADLINE value with an Code 9999 unknown error and messageRaw: 'Bitte beachten Sie, dass die Vorausverfügungsoption "AFTER_DEADLINE (Rücksendung an den Absender nach Ablauf der Frist)" entfällt. Ihre Sendung erhält die Option "IMMEDIATE (sofortige Rücksendung an den Absender)".'

So it seems this value is deprecated.

christoph-schaeffer commented 3 years ago

Hello @Magellanth,

you are right this value has been deprecated recently. Thanks for posting it here!

I will deprecate it in the next release and will add the Status.

Im also closing this Issue since the initial question seems to be resolved aswell