I found the solution after contacting to the FedEx support team for generating ETD.I just override the Mage_Usa_Model_Shipping_Carrier_Fedex model to my custom module LR_Additional_Model_Usa_Shipping_Carrier_Fedex by
<usa>
<rewrite>
<shipping_carrier_fedex>LR_Additional_Model_Usa_Shipping_Carrier_Fedex</shipping_carrier_fedex>
</rewrite>
</usa>
then edited the function _formShipmentRequest and added some xml elements which are meant for ETD element after the line - 1406. by following codes:
$europianUnionCountryCodes = Mage::getStoreConfig('general/country/eu_countries');
$euCountryCode = array();
if($europianUnionCountryCodes){
$euCountryCode = explode(',',$europianUnionCountryCodes);
}
if (($request->getShipperAddressCountryCode() != $request->getRecipientAddressCountryCode()) &&
(!in_array($request->getRecipientAddressCountryCode(),$euCountryCode) && !in_array($request->getShipperAddressCountryCode(),$euCountryCode))) {
/*Etd element section starts here */
$requestClient['RequestedShipment']['SpecialServicesRequested'] = array(
'SpecialServiceTypes' => 'ELECTRONIC_TRADE_DOCUMENTS',
'EtdDetail' => array(
'RequestedDocumentCopies' => 'COMMERCIAL_INVOICE'
)
);
$requestClient['RequestedShipment']['ShippingDocumentSpecification'] = array(
'ShippingDocumentTypes' => 'COMMERCIAL_INVOICE',
'CommercialInvoiceDetail' => array(
'Format' => array(
'ImageType' => 'PDF',
'StockType' => 'PAPER_LETTER',
)
)
);
$requestClient['RequestedShipment']['EdtRequestType'] = 'ALL';
/*Etd element section ends here */
$requestClient['RequestedShipment']['CustomsClearanceDetail'] =
array(
'CustomsValue' =>
array(
'Currency' => $order->getOrderCurrencyCode(),
'Amount' => $customsValue,
),
'DutiesPayment' => array(
'PaymentType' => $paymentType,
'Payor' => array(
'AccountNumber' => $this->getConfigData('account'),
'CountryCode' => Mage::getStoreConfig(
Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID,
$request->getStoreId()
)
)
),
'Commodities' => array(
'Weight' => array(
'Units' => $weightUnits,
'Value' => $request->getPackageWeight()
),
'NumberOfPieces' => 1,
'CountryOfManufacture' => implode(',', array_unique($countriesOfManufacture)),
'Description' => implode(', ', $itemsDesc),
'Quantity' => ceil($itemsQty),
'QuantityUnits' => 'pcs',
'UnitPrice' => array(
'Currency' => $request->getBaseCurrencyCode(),
'Amount' => $unitPrice
),
'CustomsValue' => array(
'Currency' => $request->getBaseCurrencyCode(),
'Amount' => $customsValue
),
)
);
}
The solution I have made in Magento ver. 1.7.0.2 only I am not sure for other versions of magento. Also magento doesn't have functionality to accept ETD label. It only accept Shipping label and save that shipping label into sales_flat_shipment in column shipping_label . So for invoice label I have managed in another way like fetch that label from the response comes from FedEx Api and save with my custom table as it is vast answer so I am not explaining everything. I am just explaining only possibilities that I have done.
Magento generally fetch the label by:
$shippingLabelContent = $response->CompletedShipmentDetail->CompletedPackageDetails->Label->Parts->Image;
In same way I have fetched the invoice label by:
$lr_invoice_label_content = $response->CompletedShipmentDetail->ShipmentDocuments->Parts->Image;