I am using the fedex api to generate a guide, from my web application. When running the example script from the browser or from the command line, it sends me the following message and does not generate the guide. The example I downloaded came with version 21 and I had to switch to version 23 in ->setMajor(23) . I'm doing the tests with the php version 7.2 .
Thanks.
Message sent to me:
object(FedEx\ShipService\ComplexType\ProcessShipmentReply)[34]
protected 'name' => string 'ProcessShipmentReply' (length=20)
protected 'values' =>array (size=3) 'HighestSeverity' => string 'ERROR' (length=5) 'Notifications' => array (size=1) 0 => object(FedEx\ShipService\ComplexType\Notification)[54] ... 'Version' => object(FedEx\ShipService\ComplexType\VersionId)[84] protected 'name' => string 'VersionId' (length=9) protected 'values' => array (size=4) ...
My code:
use FedEx\ShipService;
use FedEx\ShipService\ComplexType;
use FedEx\ShipService\SimpleType;
$userCredential = new ComplexType\WebAuthenticationCredential();
$userCredential
->setKey(FEDEX_KEY)
->setPassword(FEDEX_PASSWORD);
$webAuthenticationDetail = new ComplexType\WebAuthenticationDetail();
$webAuthenticationDetail->setUserCredential($userCredential);
$clientDetail = new ComplexType\ClientDetail();
$clientDetail
->setAccountNumber(FEDEX_ACCOUNT_NUMBER)
->setMeterNumber(FEDEX_METER_NUMBER);
$version = new ComplexType\VersionId();
$version
->setMajor(23)
->setIntermediate(0)
->setMinor(0)
->setServiceId('ship');
$shipperAddress = new ComplexType\Address();
$shipperAddress
->setStreetLines(['Address Line 1'])
->setCity('Austin')
->setStateOrProvinceCode('TX')
->setPostalCode('73301')
->setCountryCode('US');
$shipperContact = new ComplexType\Contact();
$shipperContact
->setCompanyName('Company Name')
->setEMailAddress('[email protected]')
->setPersonName('Person Name')
->setPhoneNumber(('123-123-1234'));
$shipper = new ComplexType\Party();
$shipper
->setAccountNumber(FEDEX_ACCOUNT_NUMBER)
->setAddress($shipperAddress)
->setContact($shipperContact);
$recipientAddress = new ComplexType\Address();
$recipientAddress
->setStreetLines(['Address Line 1'])
->setCity('Herndon')
->setStateOrProvinceCode('VA')
->setPostalCode('20171')
->setCountryCode('US');
$recipientContact = new ComplexType\Contact();
$recipientContact
->setPersonName('Contact Name')
->setPhoneNumber('1234567890');
$recipient = new ComplexType\Party();
$recipient
->setAddress($recipientAddress)
->setContact($recipientContact);
$labelSpecification = new ComplexType\LabelSpecification();
$labelSpecification
->setLabelStockType(new SimpleType\LabelStockType(SimpleType\LabelStockType::_PAPER_7X4POINT75))
->setImageType(new SimpleType\ShippingDocumentImageType(SimpleType\ShippingDocumentImageType::_PDF))
->setLabelFormatType(new SimpleType\LabelFormatType(SimpleType\LabelFormatType::_COMMON2D));
$packageLineItem1 = new ComplexType\RequestedPackageLineItem();
$packageLineItem1
->setSequenceNumber(1)
->setItemDescription('Product description')
->setDimensions(new ComplexType\Dimensions(array(
'Width' => 10,
'Height' => 10,
'Length' => 25,
'Units' => SimpleType\LinearUnits::_IN
)))
->setWeight(new ComplexType\Weight(array(
'Value' => 2,
'Units' => SimpleType\WeightUnits::_LB
)));
$shippingChargesPayor = new ComplexType\Payor();
$shippingChargesPayor->setResponsibleParty($shipper);
$shippingChargesPayment = new ComplexType\Payment();
$shippingChargesPayment
->setPaymentType(SimpleType\PaymentType::_SENDER)
->setPayor($shippingChargesPayor);
$requestedShipment = new ComplexType\RequestedShipment();
$requestedShipment->setShipTimestamp(date('c'));
$requestedShipment->setDropoffType(new SimpleType\DropoffType(SimpleType\DropoffType::_REGULAR_PICKUP));
$requestedShipment->setServiceType(new SimpleType\ServiceType(SimpleType\ServiceType::_FEDEX_GROUND));
$requestedShipment->setPackagingType(new SimpleType\PackagingType(SimpleType\PackagingType::_YOUR_PACKAGING));
$requestedShipment->setShipper($shipper);
$requestedShipment->setRecipient($recipient);
$requestedShipment->setLabelSpecification($labelSpecification);
$requestedShipment->setRateRequestTypes(array(new SimpleType\RateRequestType(SimpleType\RateRequestType::_PREFERRED)));
$requestedShipment->setPackageCount(1);
$requestedShipment->setRequestedPackageLineItems([
$packageLineItem1
]);
$requestedShipment->setShippingChargesPayment($shippingChargesPayment);
$processShipmentRequest = new ComplexType\ProcessShipmentRequest();
$processShipmentRequest->setWebAuthenticationDetail($webAuthenticationDetail);
$processShipmentRequest->setClientDetail($clientDetail);
$processShipmentRequest->setVersion($version);
$processShipmentRequest->setRequestedShipment($requestedShipment);
$shipService = new ShipService\Request();
$shipService->getSoapClient()->__setLocation('https://ws.fedex.com:443/web-services/ship');
$result = $shipService->getProcessShipmentReply($processShipmentRequest);
var_dump($result);
// Save .pdf label
// file_put_contents('/path/to/label.pdf', $result->CompletedShipmentDetail->CompletedPackageDetails[0]->Label->Parts[0]->Image);
var_dump($result->CompletedShipmentDetail->CompletedPackageDetails[0]->Label->Parts[0]->Image);
For help here I leave the solution to this question. What was happening is that in the configuration of the shipment it was international and it had to be national. What you have to do is change the shipping method in the next line.
Current:
Modified: