Giter Site home page Giter Site logo

alfallouji / dhl-api Goto Github PK

View Code? Open in Web Editor NEW
190.0 33.0 147.0 188 KB

This library provides a PHP client for the DHL XML Services. DHL XML Services is an online web services integration capability that provides DHL’s service availability, transit times, rates, shipment and courier pickup booking along with shipment tracking from over 140 countries around the world. Using DHL’s XML Services, customers can incorporate DHL shipping functionality into their websites, customer service applications or order processing systems.

PHP 100.00%

dhl-api's Introduction

Authors & contact

Al-Fallouji Bashar - [email protected]

Documentation and download

Latest version is available on github at : - http://github.com/alfallouji/DHL-API/

License

This Code is released under the GNU LGPL

Please do not change the header of the file(s).

This library is free software; you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation; either version 2 of the License, or 
(at your option) any later version.

This library is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU Lesser General Public License for more details.

Description

This library is a PHP Oriented Object client for the DHL XML API Services. DHL XML Services is an online web services integration capability that provides DHL’s service availability, transit times, rates, shipment and courier pickup booking along with shipment tracking from over 140 countries around the world. Using DHL’s XML Services, customers can incorporate DHL shipping functionality into their websites, customer service applications or order processing systems.

Setup

You can use composer to use this library.

{
    "require": {
		"alfallouji/dhl_api": "*"
    }
}

Usage

This client does not rely or depend on any framework and it should be fairly easy to integrate with your own code. You can use the autloader that is provided or your own autoloading mechanism.

The sample folder contains examples on how to use the client and perform requests to DHL XML API, such as track a shipment, create a shipment, request a pickup or print labels.

In order to have the samples working, you will need to create a DHL staging account. You can do that by going to that URL : http://www.dhl.com.au/en/express/resource_center/integrated_shipping_solutions/integrating_xml_services.html

Then, you need to copy the conf/config.sample.php to conf/config.php (that file is loaded init.php). You need to edit the dhl settings defined in the config/config.php file and provide your account id and password. The samples use those credentials.

return array(
	'dhl' => array(
		'id' => 'Your_DHL_ID',
		'pass' => 'Your_DHL_Password',
		'shipperAccountNumber' => 'Your_Number',
		'billingAccountNumber' => 'Your_Number',
		'dutyAccountNumber' => 'Your_Number',
	),
);

Example

Request a shipment

use DHL\Entity\GB\ShipmentResponse;
use DHL\Entity\GB\ShipmentRequest;
use DHL\Client\Web as WebserviceClient;
use DHL\Datatype\GB\Piece;
use DHL\Datatype\GB\SpecialService;

// You may use your own init script, as long as it takes care of autoloading
require(__DIR__ . '/init.php');

// DHL settings
$dhl = $config['dhl'];

// Test a ShipmentRequest using DHL XML API
$sample = new ShipmentRequest();

// Assuming there is a config array variable with id and pass to DHL XML Service
$sample->SiteID = $dhl['id'];
$sample->Password = $dhl['pass'];

// Set values of the request
$sample->MessageTime = '2001-12-17T09:30:47-05:00';
$sample->MessageReference = '1234567890123456789012345678901';
$sample->RegionCode = 'AM';
$sample->RequestedPickupTime = 'Y';
$sample->NewShipper = 'Y';
$sample->LanguageCode = 'en';
$sample->PiecesEnabled = 'Y';
$sample->Billing->ShipperAccountNumber = $dhl['shipperAccountNumber'];
$sample->Billing->ShippingPaymentType = 'S';
$sample->Billing->BillingAccountNumber = $dhl['billingAccountNumber'];
$sample->Billing->DutyPaymentType = 'S';
$sample->Billing->DutyAccountNumber = $dhl['dutyAccountNumber'];
$sample->Consignee->CompanyName = 'Ssense';
$sample->Consignee->addAddressLine('333 Chabanel West, #900');
$sample->Consignee->City = 'Montreal';
$sample->Consignee->PostalCode = 'H3E1G6';
$sample->Consignee->CountryCode = 'CA';
$sample->Consignee->CountryName = 'Canada';
$sample->Consignee->Contact->PersonName = 'Bashar Al-Fallouji';
$sample->Consignee->Contact->PhoneNumber = '0435 336 653';
$sample->Consignee->Contact->PhoneExtension = '123';
$sample->Consignee->Contact->FaxNumber = '506-851-7403';
$sample->Consignee->Contact->Telex = '506-851-7121';
$sample->Consignee->Contact->Email = '[email protected]';
$sample->Commodity->CommodityCode = 'cc';
$sample->Commodity->CommodityName = 'cn';
$sample->Dutiable->DeclaredValue = '200.00';
$sample->Dutiable->DeclaredCurrency = 'USD';
$sample->Dutiable->ScheduleB = '3002905110';
$sample->Dutiable->ExportLicense = 'D123456';
$sample->Dutiable->ShipperEIN = '112233445566';
$sample->Dutiable->ShipperIDType = 'S';
$sample->Dutiable->ImportLicense = 'ALFAL';
$sample->Dutiable->ConsigneeEIN = 'ConEIN2123';
$sample->Dutiable->TermsOfTrade = 'DTP';
$sample->Reference->ReferenceID = 'AM international shipment';
$sample->Reference->ReferenceType = 'St';
$sample->ShipmentDetails->NumberOfPieces = 2;

$piece = new Piece();
$piece->PieceID = '1';
$piece->PackageType = 'EE';
$piece->Weight = '5.0';
$piece->DimWeight = '600.0';
$piece->Width = '50';
$piece->Height = '100';
$piece->Depth = '150';
$sample->ShipmentDetails->addPiece($piece);

$piece = new Piece();
$piece->PieceID = '2';
$piece->PackageType = 'EE';
$piece->Weight = '5.0';
$piece->DimWeight = '600.0';
$piece->Width = '50';
$piece->Height = '100';
$piece->Depth = '150';
$sample->ShipmentDetails->addPiece($piece);

$sample->ShipmentDetails->Weight = '10.0';
$sample->ShipmentDetails->WeightUnit = 'L';
$sample->ShipmentDetails->GlobalProductCode = 'P';
$sample->ShipmentDetails->LocalProductCode = 'P';
$sample->ShipmentDetails->Date = date('Y-m-d');
$sample->ShipmentDetails->Contents = 'AM international shipment contents';
$sample->ShipmentDetails->DoorTo = 'DD';
$sample->ShipmentDetails->DimensionUnit = 'I';
$sample->ShipmentDetails->InsuredAmount = '1200.00';
$sample->ShipmentDetails->PackageType = 'EE';
$sample->ShipmentDetails->IsDutiable = 'Y';
$sample->ShipmentDetails->CurrencyCode = 'USD';
$sample->Shipper->ShipperID = '751008818';
$sample->Shipper->CompanyName = 'IBM Corporation';
$sample->Shipper->RegisteredAccount = '751008818';
$sample->Shipper->addAddressLine('1 New Orchard Road');
$sample->Shipper->addAddressLine('Armonk');
$sample->Shipper->City = 'New York';
$sample->Shipper->Division = 'ny';
$sample->Shipper->DivisionCode = 'ny';
$sample->Shipper->PostalCode = '10504';
$sample->Shipper->CountryCode = 'US';
$sample->Shipper->CountryName = 'United States Of America';
$sample->Shipper->Contact->PersonName = 'Mr peter';
$sample->Shipper->Contact->PhoneNumber = '1 905 8613402';
$sample->Shipper->Contact->PhoneExtension = '3403';
$sample->Shipper->Contact->FaxNumber = '1 905 8613411';
$sample->Shipper->Contact->Telex = '1245';
$sample->Shipper->Contact->Email = '[email protected]';

$specialService = new SpecialService();
$specialService->SpecialServiceType = 'A';
$sample->addSpecialService($specialService);

$specialService = new SpecialService();
$specialService->SpecialServiceType = 'I';
$sample->addSpecialService($specialService);

$sample->EProcShip = 'N';
$sample->LabelImageFormat = 'PDF';

// Call DHL XML API
$start = microtime(true);

// Display the XML that will be sent to DHL
echo $sample->toXML();

// DHL webservice client using the staging environment
$client = new WebserviceClient('staging');

// Call the DHL service and display the XML result
echo $client->call($sample);
echo PHP_EOL . 'Executed in ' . (microtime(true) - $start) . ' seconds.' . PHP_EOL;

How to display or store the PDF label ?

The label is encoded using base64 encoding.

If you would like to get the binary version in order to store it as .PDF or to display it on the browser, you will need to decode it.

For example, the image label is returned in the LabelImage->OutputImage node.

<req:ShipmentResponse>

....

<LabelImage>
  <OutputFormat>PDF</OutputFormat
 <OutputImage>......JVBERi0xLjQKJ.....</OutputImage>
</LabelImage>
</req:ShipmentResponse>

In PHP, you will need to do the following in order to decode the string.

// We already built our DHL request object, we can call DHL XML API
$client = new WebserviceClient('staging');
$xml = $client->call($request);
$response = new ShipmentResponse();
$response->initFromXML($xml);

// Store it as a . PDF file in the filesystem
file_put_contents('dhl-label.pdf', base64_decode($response->LabelImage->OutputImage));

// If you want to display it in the browser
$data = base64_decode($response->LabelImage->OutputImage);
if ($data)
{
    header('Content-Type: application/pdf');
    header('Content-Length: ' . strlen($data));
    echo $data;
}

How to get quotations for a shipment ?

You can use the getQuote or getCapability service for that. Here is an example.

use DHL\Entity\AM\GetQuote;
use DHL\Datatype\AM\PieceType;
use DHL\Client\Web as WebserviceClient;

require(__DIR__ . '/../../init.php');

// DHL Settings
$dhl = $config['dhl'];

// Test a getQuote using DHL XML API
$sample = new GetQuote();
$sample->SiteID = $dhl['id'];
$sample->Password = $dhl['pass'];


// Set values of the request
$sample->MessageTime = '2001-12-17T09:30:47-05:00';
$sample->MessageReference = '1234567890123456789012345678901';
$sample->BkgDetails->Date = date('Y-m-d');

$piece = new PieceType();
$piece->PieceID = 1;
$piece->Height = 10;
$piece->Depth = 5;
$piece->Width = 10;
$piece->Weight = 10;
$sample->BkgDetails->addPiece($piece);
$sample->BkgDetails->IsDutiable = 'Y';
$sample->BkgDetails->QtdShp->QtdShpExChrg->SpecialServiceType = 'WY';
$sample->BkgDetails->ReadyTime = 'PT10H21M';
$sample->BkgDetails->ReadyTimeGMTOffset = '+01:00';
$sample->BkgDetails->DimensionUnit = 'CM';
$sample->BkgDetails->WeightUnit = 'KG';
$sample->BkgDetails->PaymentCountryCode = 'CA';
$sample->BkgDetails->IsDutiable = 'Y';

// Request Paperless trade
$sample->BkgDetails->QtdShp->QtdShpExChrg->SpecialServiceType = 'WY';

$sample->From->CountryCode = 'CA';
$sample->From->Postalcode = 'H3E1B6';
$sample->From->City = 'Montreal';

$sample->To->CountryCode = 'CH';
$sample->To->Postalcode = '1226';
$sample->To->City = 'Thonex';
$sample->Dutiable->DeclaredValue = '100.00';
$sample->Dutiable->DeclaredCurrency = 'CHF';

// Call DHL XML API
$start = microtime(true);
echo $sample->toXML();
$client = new WebserviceClient('staging');
$xml = $client->call($sample);
echo PHP_EOL . 'Executed in ' . (microtime(true) - $start) . ' seconds.' . PHP_EOL;
echo $xml . PHP_EOL;

dhl-api's People

Contributors

alfallouji avatar buinguyenkhoa avatar repat avatar tiagojdf avatar yunmoxue 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dhl-api's Issues

Using with composer autoloader

Hi

I have issues with using your package via autoloader provided by composer.
It's dead simple as following:

{
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": {
            "": "src/"
        }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.3.*",
        "doctrine/orm": "^2.4.8",
        "doctrine/doctrine-bundle": "~1.2",
        "twig/extensions": "~1.0",
        "symfony/assetic-bundle": "~2.3",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~2.3",
        "sensio/framework-extra-bundle": "^3.0.2",
        "sensio/generator-bundle": "~2.3",
        "incenteev/composer-parameter-handler": "~2.0",
        "alfallouji/dhl_api": "^0.2.6"
    },
    "scripts": {
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ]
    },
    "config": {
        "bin-dir": "bin",
        "platform": {
            "php": "5.3.3"
        }
    },
    "minimum-stability": "stable",
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "2.3-dev"
        }
    }
}

This is typical symfony startup project. I just call a method in controller on a button press to run DHL related code. But PHP crashes on the very first line:

    $shipmentRequest = new ShipmentRequest();

saying it cannot locate class:

FatalErrorException: Error: Class 'DHL\Entity\GB\ShipmentRequest' not found in /home/kraplax/dhl_test/src/AppBundle/Controller/DhlController.php line 30

Is there a solution?

Cannot determine destination service

Fatal error: Uncaught exception 'Exception' with message 'Error returned from DHL webservice : SV011c : Cannot determine destination service. Check recipient postal code, city and country or complete an airwaybill manually. For assistance call DHL customer services.' in C:\xampp\htdocs\dhl\DHL\Entity\Base.php:230 Stack trace: #0 C:\xampp\htdocs\dhl\samples\GB\ShipmentRequest.php(150): DHL\Entity\Base->initFromXML('<?xml version="...') #1 {main} thrown in C:\xampp\htdocs\dhl\DHL\Entity\Base.php on line 230

AddressLine issue

Hi Al-fallouji
I try to use multiple line address to shipment request, but it's not work.
It's a sample (sample/GB/ShipmentRequest.php)
There are two address line on your sample code.
$sample->Shipper->AddressLine = '1 New Orchard Road';
$sample->Shipper->AddressLine = 'Armonk';

The result of XML only one line => Armonk

How can i use the multiple line of address?

Thank you for your time.

Sincerely,

Alan Sun

Multiple pieces in shipment request

Hello,

Congratulations on DHL-APi, very nice work.
One question. How can you add multiple shipment pieces in shipment request.
For example:

$sample->ShipmentDetails->NumberOfPieces = '2';
$sample->ShipmentDetails->Pieces->Piece->PieceID = '1';
$sample->ShipmentDetails->Pieces->Piece->PackageType = 'EE';
$sample->ShipmentDetails->Pieces->Piece->Weight = '10.0';
$sample->ShipmentDetails->Pieces->Piece->DimWeight = '1200.0';
$sample->ShipmentDetails->Pieces->Piece->Width = '100';
$sample->ShipmentDetails->Pieces->Piece->Height = '200';
$sample->ShipmentDetails->Pieces->Piece->Depth = '300';
$sample->ShipmentDetails->Pieces->Piece->PieceID = '2';
$sample->ShipmentDetails->Pieces->Piece->PackageType = 'EE';
$sample->ShipmentDetails->Pieces->Piece->Weight = '15.0';
$sample->ShipmentDetails->Pieces->Piece->DimWeight = '1100.0';
$sample->ShipmentDetails->Pieces->Piece->Width = '50';
$sample->ShipmentDetails->Pieces->Piece->Height = '50';
$sample->ShipmentDetails->Pieces->Piece->Depth = '100';

But it accepts only one piece. How can I add another one?

Thank you for your time.

Sincerely,

Marko Jovanovic

Issue in geeting Cost for DHL shipping services

The issue is when I am sending the request to DHL for getting cost of services provided by DHL like Express Domestic, Express Worldwide etc then I am getting the response as " System Unavailable:DCT webservice host is not reachable " most of the times, also sometimes I got the shipping charges and offered services details too.

That's why It is creating issue.

/rest/v2/Label

"Input validation failed : Unable to process label request.Please provide correct request messag

Not working GB/BookPURequest function

Hi. Dear
Now BookPuRequest xml sechma upgarde 3.0
So current it's not working.
I have just upload changed source code.
Pls upgrade friendly.
Kind regards.

How to display a PDF label ?

Received the following email :

Hi Bashar,

Your DHL library on GIT will certainly help a lot of folks like me, thanks.

Have a question as when do a Validation request, upon success the XML generated gives binary of barcode and images - do you have any idea how I could show this on a proper PDF file ?

Thanks in advance.

best regards,

Biplov gautam

getQuote - all methods at once?

Hi!
Is there a way to get the quote for some particular method?
I don't understand what am I getting in the response. In is a node per method? I see there is one LocalProductName -> MEDICAL EXPRESS and then another for EXPRESS WORLDWIDE.

thanks for the answer

Lack of type "6X4_PDF,8X4_PDF" in Datatype/*/Label

'LabelTemplate' => array( 'type' => 'LabelTemplate', 'required' => false, 'subobject' => false, 'comment' => 'LabelTemplate', 'enumeration' => '8X4_A4_PDF,8X4_thermal,8X4_A4_TC_PDF,6X4_A4_PDF,6X4_PDF,8X4_PDF, ![a](https://cloud.githubusercontent.com/assets/6942348/26087037/15a14b64-3a21-11e7-85fb-9f5ad4a74745.png) 6X4_thermal,8X4_CI_PDF,8X4_CI_thermal', ),

PickUp example

Hi alfallouji,
thanks very much for your awesome work!
Can you show an example for PickUp? I've tried it for many hours but i did not succeed.

Thanks,
Carlo

Pick Sample

hello there,
thank you very much for your good job!
can you put an example of PickUp please?
thank you
Nizar

Fatal error

There is a PHP fatal error when 『$response->initFromXML($xml);』 on the ShipmentRequest.php.
PHP Fatal error: Call to a member function children() on a non-object in /Users/alansun/Sites/DHL-API/DHL/Entity/Base.php on line 191

Add DocImages node

hi!
how to add a DocImages node?
$docimage = new DocImage();
$docimage->Type = 'CIN';
$docimage->Image = '';
$docimage->ImageFormat = 'PDF';
$sample->DocImages->addDocImage($docimage);
don't work
Ps: sorry for my english

How to get the credential

Hi ,

I want to use the DHL api shipment tracking service from gemany.

How can I create account : I mean

return array(
'dhl' => array(
'id' => 'Your_DHL_ID',
'pass' => 'Your_DHL_Password',
'shipperAccountNumber' => 'Your_Number',
'billingAccountNumber' => 'Your_Number',
'dutyAccountNumber' => 'Your_Number',
),
);

Here what is 'id' => 'Your_DHL_ID' and password
I tried to create an account as mentioned in the doc. But I git a mail saying that

http://www.dhl.com/en/express/resource_center/integrated_shipping_solutions.html
Just click on “Start developing with DHL XML Services” and select your country. Then, select “Request DHL Integration Solutions Toolkit / Developer Guides” and choose your country again under “Choose a Location”.

But when I go to this link there is no option to select select “Request DHL Integration Solutions Toolkit / Developer Guides”

Can someone help here ?

How to retrieve 6x4 labels

Thanks for providing a class that undoubtedly has been of great use to many.

I need to retrieve the label in the 6x4 format which is suported using the DHL 4.0 spec. Is it just a case of changing the 'LabelTemplate' enumerator values in the Label.php classes to include 6X4_PDF (seems to work). If so would it be possible to include this in your classes?

Thanks

getting error while hit ShipmentRequest from sample

Notice: Trying to get property 'ConditionCode' of non-object in /home/shashi/projects/dhl-api/DHL/Entity/Base.php on line 235

Fatal error: Uncaught InvalidArgumentException: Field : Barcodes is not defined for DHL\Entity\GB\ShipmentResponse in /home/shashi/projects/dhl-api/DHL/Datatype/Base.php:272 Stack trace: #0 /home/shashi/projects/dhl-api/DHL/Entity/Base.php(256): DHL\Datatype\Base->__get('Barcodes') #1 /home/shashi/projects/dhl-api/ShipmentRequest.php(158): DHL\Entity\Base->initFromXML(Object(SimpleXMLElement)) #2 {main} thrown in /home/shashi/projects/dhl-api/DHL/Datatype/Base.php on line 272
ShipmentRequest.zip

how to track the order information?

hello alfallouji !
when i use the DHL-API,There is no corresponding method to track the order information !
Can you give an example? thank you !

Trying to get property of non-object

When using the initFromXML method as below :-

$client = new WebserviceClient('staging');
$xml = $client->call($request);
$response = new ShipmentResponse();
$response->initFromXML($xml);

The line - $response->initFromXML($xml);
gives :-

• Error in Base.php line 227
• at HandleExceptions->handleError('8', 'Trying to get property of non-object', '/var/www/dlogistics/vendor/alfallouji/dhl_api/DHL/Entity/Base.php', '227', array('xml' => object(SimpleXMLElement), 'this' => object(ShipmentResponse))) in Base.php line 227

I believe the code in the Base.php class

    if ((string) $xml->Response->Status->Condition->ConditionCode != '')
    {
        $errorMsg = ((string) $xml->Response->Status->Condition->ConditionCode) . ' : ' . ((string) $xml->Response->Status->Condition->ConditionData);
        throw new \Exception('Error returned from DHL webservice : ' . $errorMsg);
    }

Is failing because the entity “Condition code” does not exist in the XML returned by DHL (no errors).

Sample XML for request and response attached (label and licenceplates removed to avoid bloat).

XML.txt

ShipmentValidationRequest XML issue

Hi Al-fallouji,
Thank you for providing this, its been extremely helpful!

I ran into an issue while using the ShipmentValidateRequest object. Whenever I try to convert this object into XML, I get an XML piece element placed in another XML piece element.The XML in question. I am using the ShipmentValidateRequest located in Entity/AM folder.

     <Pieces>
         <Piece>
            <Piece>
               <PieceID>1</PieceID>
               <PackageType>CP</PackageType>
               <Weight>2</Weight>
               <Width>1</Width>
               <Height>1</Height>
               <Depth>1</Depth>
               <PieceContents>box</PieceContents>
            </Piece>
         </Piece>
      </Pieces>

the code in question I'm using to add pieces to the object:

foreach ($this->packages as $package) {
 $piece = new Piece();
 $piece->PieceID = $package->id;
 $piece->PackageType = 'CP'; 
 $piece->Weight = ceil($package->weight);
 $piece->Width = ceil($package->width);
 $piece->Height = ceil($package->height);
 $piece->Depth = ceil($package->length);

 $shipmentConfirmationRequest->ShipmentDetails->addPiece($piece);
}

I don't know if its an issue with the toXML function that your client is using, or if its another issue. Any help would be appreciated.

Thank you for your time,

Jason

PickUp

hello,
thank you very much for your good job!
can you put an example of PickUp please?
thank you
Nizar

Multiple SpecialServiceType for the shipment validation request is not working as expected

The following sample code from the file ShipmentRequest.php is accepting only one type, in this case just "I".

$sample->SpecialService->SpecialServiceType = 'A';
$sample->SpecialService->SpecialServiceType = 'I';

I need the output to be like this

<specialservice>
    <specialservicetype>A</specialservicetype>
</specialservice>

<specialservice>
    <specialservicetype>I</specialservicetype>
</specialservice>

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.