简体   繁体   中英

How get FEDEX_ONE_RATE API using php

How get FEDEX_ONE_RATE API using php

I tried to get by JeremyDunn/php-fedex-api-wrapper but not use standard rates comes good, when I tried to 'FEDEX_ONE_RATE' nothing change.

Try 1

$rateRequest->ShipmentSpecialServicesRequested->SpecialServiceTypes = 'FEDEX_ONE_RATE';

Try 2

$rateRequest->VariableOptions = array(SimpleType\ServiceOptionType::_FEDEX_ONE_RATE);

The above both method it's request are appended the parameter but results are nothing changed.

Any one help me.

Difficult to say without looking at your exact request, but assuming that your are submitting a RateRequest , then you need to:

  1. Specify FEDEX_ONE_RATE as a ServiceOptionType in the RateRequest.VariableOptions .
  2. Specify one of the supported Packaging Types ( FEDEX_SMALL_BOX , FEDEX_MEDIUM_BOX , FEDEX_LARGE_BOX , FEDEX_EXTRA_LARGE_BOX , FEDEX_PAK , FEDEX_TUBE , FEDEX_ENVELOPE ).
  3. Specify a US origin and a US destination.

See the FedEx documentation for all the details.

For example, using the following request:

<RateRequest>
  <WebAuthenticationDetail>
    <UserCredential>
      <Key>...</Key>
      <Password>...</Password>
    </UserCredential>
  </WebAuthenticationDetail>
  <ClientDetail>
    <AccountNumber>...</AccountNumber>
    <MeterNumber>...</MeterNumber>
  </ClientDetail>
  <Version>
    <ServiceId>crs</ServiceId>
    <Major>28</Major>
    <Intermediate>0</Intermediate>
    <Minor>0</Minor>
  </Version>
  <VariableOptions>FEDEX_ONE_RATE</VariableOptions>
  <RequestedShipment>
    <DropoffType>REGULAR_PICKUP</DropoffType>
    <PackagingType>FEDEX_SMALL_BOX</PackagingType>
    <Shipper>
      <Address>
        <StateOrProvinceCode>TN</StateOrProvinceCode>
        <PostalCode>38017</PostalCode>
        <CountryCode>US</CountryCode>
        <Residential>false</Residential>
      </Address>
    </Shipper>
    <Recipient>
      <Address>
        <StateOrProvinceCode>CA</StateOrProvinceCode>
        <PostalCode>90028</PostalCode>
        <CountryCode>US</CountryCode>
        <Residential>false</Residential>
      </Address>
    </Recipient>
    <ShippingChargesPayment>
      <PaymentType>SENDER</PaymentType>
      <Payor>
        <ResponsibleParty>
          <AccountNumber>...</AccountNumber>
        </ResponsibleParty>
      </Payor>
    </ShippingChargesPayment>
    <RateRequestTypes>LIST</RateRequestTypes>
    <PackageCount>1</PackageCount>
    <RequestedPackageLineItems>
      <GroupPackageCount>1</GroupPackageCount>
      <Weight>
        <Units>LB</Units>
        <Value>10.00</Value>
      </Weight>
    </RequestedPackageLineItems>
  </RequestedShipment>
</RateRequest>

The corresponding response would be (I've omitted a lot of the details in order to highlight the important parts):

<RateReply>
  <HighestSeverity>SUCCESS</HighestSeverity>
  <Notifications>
    <Severity>SUCCESS</Severity>
    <Source>crs</Source><Code>0</Code>
    <Message>Request was successfully processed. </Message>
    <LocalizedMessage>Request was successfully processed. </LocalizedMessage>
  </Notifications>
  <Version>
    <ServiceId>crs</ServiceId>
    <Major>28</Major>
    <Intermediate>0</Intermediate>
    <Minor>0</Minor>
  </Version>
  <RateReplyDetails>
    <ServiceType>FIRST_OVERNIGHT</ServiceType>
      ...
    <PackagingType>FEDEX_SMALL_BOX</PackagingType>
    <DestinationAirportId>BUR</DestinationAirportId>
    <ActualRateType>PAYOR_ACCOUNT_PACKAGE</ActualRateType>
    <RatedShipmentDetails>
      ...
    </RatedShipmentDetails>
  </RateReplyDetails>
  <RateReplyDetails>
    <ServiceType>FIRST_OVERNIGHT</ServiceType>
      ...
    <PackagingType>FEDEX_SMALL_BOX</PackagingType>
    <AppliedOptions>FEDEX_ONE_RATE</AppliedOptions>
    <DestinationAirportId>BUR</DestinationAirportId>
    <ActualRateType>PAYOR_ACCOUNT_PACKAGE</ActualRateType>
    <RatedShipmentDetails>
      <ShipmentRateDetail>
        <SpecialRatingApplied>FEDEX_ONE_RATE</SpecialRatingApplied>
        ...
      </ShipmentRateDetail>
      ...
    </RatedShipmentDetails>
  </RateReplyDetails>
</RateReply>

Ie for each ServiceType (eg FIRST_OVERNIGHT ) two set of rates are returned: one without and one with the FEDEX_ONE_RATE applied (as highlighted by the presence of the AppliedOptions and SpecialRatingApplied elements in the RateReplyDetails ).

Finally I got Resolved
This is the working code for postman (SOAP Request)

$url = 'https://ws.fedex.com:443/web-services/rate'; //SAND BOX
$url = 'https://wsbeta.fedex.com:443/web-services/rate'; // LIVE

$xml = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://fedex.com/ws/rate/v28"> <SOAP-ENV:Body>
<RateRequest>
<WebAuthenticationDetail>
<UserCredential>
<Key>.....</Key>
<Password>....</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>....</AccountNumber>
<MeterNumber>....</MeterNumber>
</ClientDetail>
<Version>
<ServiceId>crs</ServiceId>
<Major>28</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<VariableOptions>FEDEX_ONE_RATE</VariableOptions>
<RequestedShipment>
<DropoffType>REGULAR_PICKUP</DropoffType>
<PackagingType>FEDEX_SMALL_BOX</PackagingType>
<Shipper>
<Address>
<StateOrProvinceCode>TN</StateOrProvinceCode>
<PostalCode>38017</PostalCode>
<CountryCode>US</CountryCode>
<Residential>false</Residential>
</Address>
</Shipper>
<Recipient>
<Address>
<StateOrProvinceCode>CA</StateOrProvinceCode>
<PostalCode>90028</PostalCode>
<CountryCode>US</CountryCode>
<Residential>false</Residential>
</Address>
</Recipient>
<ShippingChargesPayment>
<PaymentType>SENDER</PaymentType>
<Payor>
<ResponsibleParty>
<AccountNumber>.....</AccountNumber>
</ResponsibleParty>
</Payor>
</ShippingChargesPayment>
<RateRequestTypes>LIST</RateRequestTypes>
<PackageCount>1</PackageCount>
<RequestedPackageLineItems>
<GroupPackageCount>1</GroupPackageCount>
<Weight>
<Units>LB</Units>
<Value>10.00</Value>
</Weight>
</RequestedPackageLineItems>
</RequestedShipment>
</RateRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM