Estoy usando, la api de fedex para generar una guía, desde mi aplicación web. Al ejecutar el script de ejemplo desde el navegador o desde la línea de comando, me envía el siguiente mensaje y no me genera la guía. El ejemplo que descargue venia con la versión 21 y tuve que cambiar a la versión 23 en ->setMajor(23). La pruebas la estoy haciendo con la versión de php 7.2.
Gracias.
Mensaje que me envía:
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) ...
Mi código:
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);
protected 'values' => array (size=4) ...
¿? Las trazas de error son un tesoro en la resolución de problemas, ahí debe aparecer la causa del error. No la cortes, aunque sea larga, ponla completa.