简体   繁体   中英

Fedex Web Services (SOAP): Pickup Service

I'm trying to schedule pickup using Pickup Service. First I send Pickup Availability request to get cutoff time, then use the result I get in Pickup Request. But after that I get error "Ready Time after Cutoff Time" for the time that is obviously before the cutoff time. In my example cutoff time returned is 16:00 but the latest time I can schedule pickup for is 11:00. Part of pickup availability response:

<v3:ScheduleDay>SAME_DAY</v3:ScheduleDay>
<v3:Available>true</v3:Available>
<v3:PickupDate>2013-04-02</v3:PickupDate>
<v3:CutOffTime>16:00:00</v3:CutOffTime>

Part of schedule pickup request that produces error:

<ns1:ReadyTimestamp>2013-04-02T13:00:00</ns1:ReadyTimestamp>
<ns1:CompanyCloseTime>20:00:00</ns1:CompanyCloseTime>

Here's full request/response code for two requests: http://pastebin.com/jqtfsRFc

UPD : More details according to the discussion in comments

That's what written about ReadyTimestamp The time must be no later than the CutOffTime, which can be discovered with the PickupAvailabilityRequest.

So I make a pickup availability request and see the reply:

<v3:ScheduleDay>SAME_DAY</v3:ScheduleDay>
<v3:Available>true</v3:Available>
<v3:PickupDate>2013-04-09</v3:PickupDate>
<v3:CutOffTime>16:00:00</v3:CutOffTime>

Documentation says that timestamps for Pickup Availability are used according to the local TZ (taken from zip code). Out local TZ is PST which has -07:00 offset from UTC. There's also a line in Pickup Availability reply that indicates the time when my Pickup Availability request was processed. I checked and see that it is also in PST so this step looks working fine: <v3:RequestTimestamp>2013-03-26T11:58:37</v3:RequestTimestamp>

So I got cutoff time 16:00 PST and the next step is to schedule actual pickup for the time that will not be later than cutoff time using Create Pickup request. For this request ReadyTimestamp should contain TZ info so I tried different date/time formats. So if I want to create pickup for 14:00 PST I try 2013-04-09T21:00:00 , 2013-04-09T21:00:00.000Z , 2013-04-09T21:00:00+00:00 , and 2013-04-09T14:00:00-07:00 . In all of these cases I get error Ready Time after Cutoff Time . I tried many different values and discovered that the latest time it works for is 04:00 PST (same as 11:00 UTC). So 04:00 gives me success and 04:01 gives Ready Time after Cutoff Time and it works this way with any date/time format.

Have you noticed that the ReadyTimestamp in the Example CreatePickupRequest on page 76

<q0:ReadyTimestamp>2011-08-02T08:00:18.282Z</q0:ReadyTimestamp>
<q0:CompanyCloseTime>17:00:00</q0:CompanyCloseTime>

Is given with the timezone code .

UPD. You can check php fedex api wrapper from github or fedex api wrapper from phpclasses.

If you want to pass Date in WebService request, The DateTime Data type for WSDL is

class DateTime2 extends DateTime {
    function __toString() { 
        return $this->format("Y-m-d\TH:i:s.000\Z");
    }
}

$date = new DateTime2();

$client = new SoapClient(
    "http://www.myos.it/sp/smartphonelayer.asmx?wsdl", 
    array("trace" => 1)
);

$result = $client->SetReservation(array("RDescription"=>"Giuseppe Silvestri",
                                        "RNumber"=>2,
                                        "RPhoneNumber"=>"3286026817",
                                        "RDate"=>$date.""));

echo "REQUEST:".$client->__getLastRequest()."<br>"; 

print_r($result);

ReadyTimestamp in createPickup request takes timestamp as value

example: 'ReadyTimestamp': '1404891463'

This will work

you must have a difference between: a- when the package is ready b- cutoff time c- company close time.

consequently, if your zip code has a cutoff time of 16:00, your package must be ready before that time, and your company must be open up to a couple of hours later.

my suggestion. place the company close time at 19:00, fedex latest pickup time usually is at 17hs for all zip codes. those 2 your is because when you request a pickup the van courier has 2 hours to go to that place, if your company close time is only 1 hour from the pickup request you will experience problems.

hope it helps.

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