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

International Shipment #18

Closed Tobias-Keller closed 2 years ago

Tobias-Keller commented 2 years ago

Hi! I have some trouble to make it work with international Shipments. Here is a example of the validation states (replaced personal data):

 {
   "ValidationStates":[
      {
         "sequenceNumber":"1",
         "Status":[
            {
               "code":9999,
               "text":"Unknown error occurred",
               "message":"Ein Unbekannter Fehler ist aufgetreten",
               "messageRaw":"Bitte beachten Sie, dass der Service Vorausverf\u00fcgung f\u00fcr Sendungen mit DHL Paket International verpflichtend ist."
            }
         ]
      }
   ],
   "request":{
      "ShipmentOrder":[
         {
            "Shipment":{
               "Receiver":{
                  "Address":{
                     "city":"Barcelona",
                     "Origin":{
                        "countryISOCode":"ES"
                     },
                     "streetName":"Avenida Diagonal",
                     "streetNumber":"1",
                     "zip":"08019"
                  },
                  "name1":"Lookfamed GmbH"
               },
               "ShipmentDetails":{
                  "ShipmentItem":{
                     "weightInKG":"1.2"
                  },
                  "accountNumber":"XXXXX",
                  "product":"XXXX",
                  "shipmentDate":"2022-01-07"
               },
               "Shipper":{
                  "Address":{
                     "city":"Teststraße",
                     "Origin":{
                        "countryISOCode":"DE"
                     },
                     "streetName":"Teststraße",
                     "streetNumber":"12",
                     "zip":"12345"
                  },
                  "Name":{
                     "name1":"XXXXX"
                  }
               }
            },
            "PrintOnlyIfCodeable":{
               "active":0
            },
            "sequenceNumber":1
         }
      ],
      "combinedPrinting":0,
      "groupProfileName":"STANDARD_GRUPPENPROFIL",
      "labelResponseType":"URL",
      "Version":{
         "majorRelease":3,
         "minorRelease":1
      }
   },
   "Status":[
      {
         "code":0,
         "text":"Weak validation error occured.",
         "message":"Es ist ein leichter Fehler aufgetreten.",
         "messageRaw":"Weak validation error occured."
      }
   ],
   "Version":{
      "majorRelease":"3",
      "minorRelease":"0"
   },
   "rawRequest":null,
   "rawResponse":{
      "Version":{
         "majorRelease":"3",
         "minorRelease":"0"
      },
      "Status":{
         "statusCode":0,
         "statusText":"Weak validation error occured.",
         "statusMessage":null
      },
      "ValidationState":{
         "sequenceNumber":"1",
         "Status":{
            "statusCode":0,
            "statusText":"Weak validation error occured.",
            "statusMessage":[
               "Bitte beachten Sie, dass der Service Vorausverf\u00fcgung f\u00fcr Sendungen mit DHL Paket International verpflichtend ist."
            ]
         }
      }
   }
}

What must i do by "Bitte beachten Sie, dass der Service Vorausverfügung für Sendungen mit DHL Paket International verpflichtend ist." ? Thanks for your time.

christoph-schaeffer commented 2 years ago

Hello,

it's weird that you get an unknown error, but. The error basically says that the service "endorsement" is required for international shipments. I don't know why DHL want this to be required, but i get that error aswell when i try to send something to an international address.

you can set it as follows:

$shipmentOrder->Shipment->ShipmentDetails->Service->Endorsement->active = true; $shipmentOrder->Shipment->ShipmentDetails->Service->Endorsement->type = Endorsement::IMMEDIATE;

There are several types which set what will happen if the recipient is not met. immediate means ins send to back to the sender after the recipient wasnt there. You can find the constants in the Endorsement Class.

I hope i could help.

Tobias-Keller commented 2 years ago

thanks, works now!