Wednesday, 28 August 2013

FedEx API request with Residential Status in Magento

FedEx API request with Residential Status in Magento

In our Magento application we need to Residential Status with the FedEx
API request.
We overrided the Fedex.php with custom module...
This is the function for the FedEx API request:
public function _formRateRequest($purpose)
{
//die('function called');
$r = $this->_rawRequest;
$ratesRequest = array(
'WebAuthenticationDetail' => array(
'UserCredential' => array(
'Key' => $r->getKey(),
'Password' => $r->getPassword()
)
),
'ClientDetail' => array(
'AccountNumber' => $r->getAccount(),
'MeterNumber' => $r->getMeterNumber()
),
'Version' => $this->getVersionInfo(),
'RequestedShipment' => array(
'DropoffType' => $r->getDropoffType(),
'ShipTimestamp' => date('c'),
'PackagingType' => $r->getPackaging(),
'TotalInsuredValue' => array(
'Amount' => $r->getValue(),
'Currency' => $this->getCurrencyCode()
),
'Shipper' => array(
'Address' => array(
'PostalCode' => $r->getOrigPostal(),
'CountryCode' => $r->getOrigCountry()
)
),
'Recipient' => array(
'Address' => array(
'PostalCode' => $r->getDestPostal(),
'CountryCode' => $r->getDestCountry(),
'Residential' =>
(bool)$this->getConfigData('residence_delivery')
)
),
'ShippingChargesPayment' => array(
'PaymentType' => 'SENDER',
'Payor' => array(
'AccountNumber' => $r->getAccount(),
'CountryCode' => $r->getOrigCountry()
)
),
'CustomsClearanceDetail' => array(
'CustomsValue' => array(
'Amount' => $r->getValue(),
'Currency' => $this->getCurrencyCode()
)
),
'RateRequestTypes' => 'LIST',
'PackageCount' => '1',
'PackageDetail' => 'INDIVIDUAL_PACKAGES',
'RequestedPackageLineItems' => array(
'0' => array(
'Weight' => array(
'Value' => (float)$r->getWeight(),
'Units' => 'LB'
),
'GroupPackageCount' => 1,
)
)
)
);
if ($purpose == self::RATE_REQUEST_GENERAL) {
$ratesRequest['RequestedShipment']['RequestedPackageLineItems'][0]['InsuredValue']
= array(
'Amount' => $r->getValue(),
'Currency' => $this->getCurrencyCode()
);
} else if ($purpose == self::RATE_REQUEST_SMARTPOST) {
$ratesRequest['RequestedShipment']['ServiceType'] =
self::RATE_REQUEST_SMARTPOST;
$ratesRequest['RequestedShipment']['SmartPostDetail'] = array(
'Indicia' => ((float)$r->getWeight() >= 1) ?
'PARCEL_SELECT' : 'PRESORTED_STANDARD',
'HubId' => $this->getConfigData('smartpost_hubid')
);
}
return $ratesRequest;
}
So we want to know the work flow of FedEx when we ship to Residential or
Business address...
When we refer this link, there is status to set Residential Status, but
how can i put it in our code.....

No comments:

Post a Comment