Follow Me:
Showing posts with label Api Integration. Show all posts
Showing posts with label Api Integration. Show all posts

Monday 11 February 2013

FedEx Web Services is the next generation API for integrating software applications with FedEx Systems. Web services represent the future application integration because they offer the following:
  • Inter-operability: Any Web service can interact with any other Web service and can be written in any language.
  • Ubiquity: Web services communicate using HTTP and XML--So any connected device that supports these technologies can both host and access Web Services.
  • Low Barrier to Entry: The concepts behind Web services are easy to understand, and developers can quickly create and deploy them using many tool-kits available on the web.
  • Industry Support: Major content providers and vendors are supporting the Web services movement.



View the Demo

Fedex Shipping Integration For International priority

The international priority for FedEx Shipping Codes is given below:
Codings:

<?php

// Copyright 2009, FedEx Corporation. All rights reserved.
// Version 12.0.0
require_once('../../../library/fedex-common.php5');
//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "../../../wsdl/ShipService_v12.wsdl";


// PDF label file. Change to file-extension .pdf for creating a PDF label
define('SHIP_LABEL', 'shipexpresslabel.pdf');  
ini_set("soap.wsdl_cache_enabled", "0");

// Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$client = new SoapClient($path_to_wsdl, array('trace' => 1)); 

$request['WebAuthenticationDetail'] = array(
 'UserCredential' =>array(
 'Key' => getProperty('key'), 
 'Password' => getProperty('password')
 )
);

$request['ClientDetail'] = array(
 'AccountNumber' => getProperty('shipaccount'), 
 'MeterNumber' => getProperty('meter')
);

$request['TransactionDetail'] = array('CustomerTransactionId' => '
*** Express International 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',
 'ServiceType' => 'INTERNATIONAL_PRIORITY', 
 'PackagingType' => 'YOUR_PACKAGING', 
 'Shipper' => addShipper(),
 'Recipient' => addRecipient(),
 'ShippingChargesPayment' => addShippingChargesPayment(),
 'CustomsClearanceDetail' => addCustomClearanceDetail(),                                                                                                       
 'LabelSpecification' => addLabelSpecification(),
 'CustomerSpecifiedDetail' => array(
  'MaskedData'=> 'SHIPPER_ACCOUNT_NUMBER'
 ), 
 'RateRequestTypes' => array('ACCOUNT'), // valid values ACCOUNT and LIST
 'PackageCount' => 1,
 'RequestedPackageLineItems' => array(
  '0' => addPackageLineItem1()
 ),
 'CustomerReferences' => array(
  '0' => array(
   'CustomerReferenceType' => 'CUSTOMER_REFERENCE', 
   'Value' => 'TC007_07_PT1_ST01_PK01_SNDUS_RCPCA_POS'
  )
 )
);

try
{
 if(setEndpoint('changeEndpoint'))
 {
  $newLocation = $client->__setLocation(setEndpoint('endpoint'));
 }
 // FedEx web service invocation
 $response = $client->processShipment($request); 
 if($response->HighestSeverity 
!= 'FAILURE' && $response->HighestSeverity != 'ERROR')
 {
  printSuccess($client, $response);
  // Create PNG or PDF label
  // Set LabelSpecification.ImageType to 'PDF' for generating a PDF label
  $fp = fopen(SHIP_LABEL, 'wb');   
  fwrite($fp, ($response->CompletedShipmentDetail->CompletedPackageDetails
->Label->Parts->Image));
  fclose($fp);
  echo 'Label <a href="./'.SHIP_LABEL.'">'.SHIP_LABEL.'</a> was generated.';            
 }
 else
 {
  printError($client, $response);
 }
 writeToLog($client);    // Write to log file
} catch (SoapFault $exception) {
 printFault($exception, $client);
}

function addShipper(){
 $shipper = array(
  'Contact' => array(
   'PersonName' => 'Sender Name',
   'CompanyName' => 'Sender Company Name',
   'PhoneNumber' => '1234567890'
  ),
  'Address' => array(
   'StreetLines' => array('Address Line 1'),
   'City' => 'Austin',
   'StateOrProvinceCode' => 'TX',
   'PostalCode' => '73301',
   'CountryCode' => 'US'
  )
 );
 return $shipper;
}

function addRecipient(){
 $recipient = array(
  'Contact' => array(
   'PersonName' => 'Recipient Name',
   'CompanyName' => 'Company Name',
   'PhoneNumber' => '1234567890'
  ),
  'Address' => array(
   'StreetLines' => array('Address Line 1'),
   'City' => 'Richmond',
   'StateOrProvinceCode' => 'BC',
   'PostalCode' => 'V7C4V4',
   'CountryCode' => 'CA',
   'Residential' => false
  )
 );
 return $recipient;                                    
}

function addShippingChargesPayment(){
 $shippingChargesPayment = array(
  'PaymentType' => 'SENDER',
  'Payor' => array(
   'ResponsibleParty' => array(
    'AccountNumber' => getProperty('billaccount'),
    'Contact' => null,
    'Address' => array('CountryCode' => 'US')
   )
  )
 );
 return $shippingChargesPayment;
}

function addLabelSpecification(){
 $labelSpecification = array(
  'LabelFormatType' => 'COMMON2D', // valid values COMMON2D, LABEL_DATA_ONLY
  'ImageType' => 'PDF',  // valid values DPL, EPL2, PDF, ZPLII and PNG
  'LabelStockType' => 'PAPER_7X4.75');
 return $labelSpecification;
}

function addSpecialServices(){
 $specialServices = array(
  'SpecialServiceTypes' => array('COD'),
  'CodDetail' => array(
  'CodCollectionAmount' => array('Currency' => 'USD', 'Amount' => 150),
  'CollectionType' => 'ANY')// ANY, GUARANTEED_FUNDS
 );
 return $specialServices; 
}

function addCustomClearanceDetail(){
 $customerClearanceDetail = array(
  'DutiesPayment' => array(
   'PaymentType' => 'SENDER', //valid values RECIPIENT,SENDER and THIRD_PARTY
   'Payor' => array(
    'ResponsibleParty' => array(
     'AccountNumber' => getProperty('dutyaccount'),
     'Contact' => null,
     'Address' => array('CountryCode' => 'US')
    )
   )
  ),
  'DocumentContent' => 'NON_DOCUMENTS',                                                                                            
  'CustomsValue' => array(
   'Currency' => 'USD', 
   'Amount' => 100.0
  ),
  'Commodities' => array(
   '0' => array(
    'NumberOfPieces' => 1,
    'Description' => 'Books',
    'CountryOfManufacture' => 'US',
    'Weight' => array(
     'Units' => 'LB', 
     'Value' => 1.0
    ),
    'Quantity' => 4,
    'QuantityUnits' => 'EA',
    'UnitPrice' => array(
     'Currency' => 'USD', 
     'Amount' => 100.000000
    ),
    'CustomsValue' => array(
     'Currency' => 'USD', 
     'Amount' => 400.000000
    )
   )
  ),
  'ExportDetail' => array(
   'B13AFilingOption' => 'NOT_REQUIRED'
  )
 );
 return $customerClearanceDetail;
}

function addPackageLineItem1(){
 $packageLineItem = array(
  'SequenceNumber'=>1,
  'GroupPackageCount'=>1,
  'Weight' => array(
  'Value' => 20.0,
  'Units' => 'LB'),
  'Dimensions' => array(
  'Length' => 20,
  'Width' => 20,
  'Height' => 10,
  'Units' => 'IN')
 );
 return $packageLineItem;
}
?>

Download the below Documents:

FedEx Intergrations Codings

More link:

http://www.codingslover.com/search/label/Api%20Integration