Site icon EcomPlugins Blog

FedEx Freight Shipping Rates with Different origin and billing address Rest API.

To implement FedEx Freight Shipping Rates with different origin and billing addresses using the FedEx REST API, you need to interact with the FedEx Rate API which supports freight shipments, including Freight LTL (Less than Truckload) services. This allows you to retrieve shipping rates while specifying separate origin (shipper) and billing addresses.

Steps for Implementing the FedEx Freight Shipping Rates API:

1. Register and Get FedEx API Credentials

Before using the API, you must sign up for a FedEx Developer Account and generate API credentials for accessing the FedEx APIs. After registration, you will obtain:

These credentials will authenticate your requests.

2. Base URL and Endpoint for FedEx Freight API (REST)

FedEx provides different APIs for their various services. To get freight shipping rates, you will use the FedEx Rates API endpoint:

POST https://apis-sandbox.fedex.com/rate/v1/rates/quotes

(You’ll switch to the production endpoint after testing.)

3. Constructing the API Request

You’ll send a JSON payload to this endpoint with the required information, including shipper address (origin), recipient address (destination), and billing details.

Here’s a breakdown of the key fields for your request:

Here’s an example JSON request:

{
  "accountNumber": {
    "value": "YourAccountNumber"
  },
  "requestedShipment": {
    "shipper": {
      "address": {
        "streetLines": ["123 Origin St"],
        "city": "Origin City",
        "stateOrProvinceCode": "CA",
        "postalCode": "90001",
        "countryCode": "US"
      }
    },
    "recipient": {
      "address": {
        "streetLines": ["456 Destination Ave"],
        "city": "Destination City",
        "stateOrProvinceCode": "TX",
        "postalCode": "73301",
        "countryCode": "US"
      }
    },
    "rateRequestType": ["ACCOUNT"],
    "requestedPackageLineItems": [
      {
        "weight": {
          "units": "LB",
          "value": 500
        },
        "dimensions": {
          "length": 40,
          "width": 48,
          "height": 60,
          "units": "IN"
        },
        "freightClass": "CLASS_050"
      }
    ],
    "freightShipmentDetail": {
      "fedExFreightAccountNumber": "YourFreightAccountNumber",
      "role": "SHIPPER",
      "totalHandlingUnits": 1,
      "palletWeight": {
        "units": "LB",
        "value": 500
      },
      "handlingUnitDescription": "PALLET",
      "totalHandlingUnits": 1
    },
    "payor": {
      "responsibleParty": {
        "accountNumber": {
          "value": "BillingAccountNumber"
        },
        "contact": {
          "personName": "John Doe",
          "phoneNumber": "1234567890"
        },
        "address": {
          "streetLines": ["789 Billing St"],
          "city": "Billing City",
          "stateOrProvinceCode": "NY",
          "postalCode": "10001",
          "countryCode": "US"
        }
      }
    },
    "serviceType": "FEDEX_FREIGHT_ECONOMY",
    "packagingType": "YOUR_PACKAGING",
    "pickupType": "REGULAR_PICKUP"
  }
}

Key Fields Explained:

4. Handle API Response

The API will return a response containing rate information, including shipping costs and estimated delivery dates. Example response:

{
  "rateReplyDetails": [
    {
      "serviceType": "FEDEX_FREIGHT_ECONOMY",
      "ratedShipmentDetails": [
        {
          "totalNetCharge": {
            "amount": 350.00,
            "currency": "USD"
          }
        }
      ]
    }
  ]
}

5. Testing and Moving to Production

FedEx provides a sandbox environment for testing purposes. After thoroughly testing your integration, you can switch to the production endpoint to use live rates.

Summary

To implement FedEx Freight Shipping Rates with different origin and billing addresses via the REST API:

Would you like further help with API testing or implementation in a specific environment?

You can use readymade magento 2 plugin https://www.ecomplugins.com/magento2-fedexfreight-shipping-carrier-with-rest-api

Exit mobile version