Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fedex API. Shipping Label. Multiple-Package Shipments

Tags:

php

fedex

I'm using FeDex API to Shipping Labels printing. Label for 1 package prints successfull, but when I trying print multiple-package I get an error:

stdClass Object
(
[Severity] => ERROR
[Source] => ship
[Code] => 2463
[Message] => The number of RequestedPackages in the RequestedShipment must be equal to 1
[LocalizedMessage] => The number of RequestedPackages in the RequestedShipment must be    equal to 1
)

In request I included TotalWeight, PackageCount, but it's helpn't

$request['WebAuthenticationDetail'] = array('UserCredential' =>array('Key' => $auth['key'], 'Password' => $auth['password']));
$request['ClientDetail'] = array('AccountNumber' => $auth['accountNumber'], 'MeterNumber' => $auth['meterNumber']);
$request['TransactionDetail'] = array('CustomerTransactionId' => '*** Ground Domestic Shipping Request v12 using PHP ***');
$request['Version'] = array('ServiceId' => 'ship', 'Major' => '12', 'Intermediate' => '1', 'Minor' => '0');
$request['RequestedShipment'] = array('ShipTimestamp' => date('c'),
                                      'DropoffType' => 'REGULAR_PICKUP', // valid values REGULAR_PICKUP, REQUEST_COURIER, DROP_BOX, BUSINESS_SERVICE_CENTER and STATION
                                      'ServiceType' => 'FEDEX_GROUND', // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
                                      'PackagingType' => 'YOUR_PACKAGING', // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
                                      'Shipper' => $this->addShipper(),
                                      'Recipient' => $this->recipient,
                                      'ShippingChargesPayment' => $this->addShippingChargesPayment(),
                                      'LabelSpecification' => $this->addLabelSpecification(), 
                                      'RateRequestTypes' => array('LIST'), // valid values ACCOUNT and LIST
                                      'PackageCount' => count($this->packages),
                                      'TotalWeight' => array('Value' => array_sum($this->packages), 'Units' => 'LB'),
                                      'TotalShipmentWeight' => array('Value' => array_sum($this->packages), 'Units' => 'LB'),
                                      'PackageDetail' => 'INDIVIDUAL_PACKAGES',                                        
                                      'RequestedPackageLineItems' => $this->packageLineItem//array('0' => $this->packageLineItem)
);      


$this->packageLineItem[] = array('SequenceNumber'=>$i,
              'GroupPackageCount' => count($this->packages),
              'MasterTrackingID' => '123123123123',
              'TotalShipmentWeight' => array('Value' => array_sum($this->packages), 'Units' => 'LB'),
              'Weight' => array('Value' => $this->packages[$i-1], //weight!!!!!!!!!!!!!
                                'Units' => 'LB'),
              'CustomerReferences' => array('0' => array('CustomerReferenceType' => 'CUSTOMER_REFERENCE', 
                                                         'Value' => 'GR4567892'), // valid values CUSTOMER_REFERENCE, INVOICE_NUMBER, P_O_NUMBER and SHIPMENT_INTEGRITY
                                            '1' => array('CustomerReferenceType' => 'INVOICE_NUMBER', 
                                                         'Value' => 'INV4567892'),
                                            '2' => array('CustomerReferenceType' => 'P_O_NUMBER', 
                                                         'Value' => 'PO4567892')),
              'SpecialServicesRequested' => array('SpecialServiceTypes' => array('COD'),
                                                  'CodDetail' => array('CodCollectionAmount' => array('Currency' => 'USD', 'Amount' => 150),
                                                                       'CollectionType' => 'ANY')// ANY, GUARANTEED_FUNDS
                                                 )
 );

Does anyone know how to be a valid request?

like image 222
stan Avatar asked Dec 26 '12 11:12

stan


People also ask

Can you use the same FedEx label for multiple packages?

Using the same label to ship multiple shipments is fraudulent and could result in additional billing charges, along with the cancellation of your FedEx account number.

Can you use 1 shipping label for multiple packages?

If you only have 1 label, it is likely due to all of your items currently being listed on 1 order (1 box). In order to receive multiple shipping labels, you will need to create a new transaction for one of the items. This will generate a second shipping label.

Can you do batch shipping with FedEx?

Using the Hold File is ideal when you're waiting on more information, or when you do repeat shipments and batch processing. Now you can Batch-Edit with FedEx SmartPost® shipments. Batch-Edit enables you to use the Batch-Edit shipping method when cre- ating shipping labels from the Hold File.


1 Answers

There is a difference between the FedEx Rate API and the FedEx Shipping API. You can rate multiple packages using one SOAP request; however, to ship an Multiple Pieces Shipment (MPS), you have to perform a shipping request for each one of the packages.

The first package (the package in the first request), will be your Master containing the master tracking number. Once you have this master tracking number, you have to attach it to the shipping request of the remaining packages. Please, refer to the latest FedEx Developer Guide for more information about MPS shipments and download the example of performing an Express domestic MPS shipment from the FedEx developer portal.

Something to watch out is that the shipping process does not occur as a transaction, so if you are trying to ship 3 packages, and package 1 and 2 are submitted successfully, but package 3 fails for so unknown reason, you are responsible for canceling package 1 and 2 or resubmitting package 3. I would recommend anyone to validate the shipment (using the same shipping API) before creating the actual shipment.

Best!

like image 119
Ozzy Garcia Avatar answered Sep 17 '22 19:09

Ozzy Garcia