Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] UPS XML Tracking


heliosquare

Recommended Posts

I've been meaning to look into multiple package support but haven't had the time yet. It's been a while since I've looked at the UPS xml data but there are a couple of things that the ups tracking page can do that simply aren't possible using their xml gateway because it doesn't return that information. I'm gonna take another look at it tomorrow (hopefully) to see if they return multiple tracking codes based on the tracking code used to search...

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

  • 3 weeks later...
  • Replies 324
  • Created
  • Last Reply

Top Posters In This Topic

Hey everybody,

 

I'm wondering how in the world I'm getting this error message because no one else seems to be getting it. Let me try and explain:

 

I'm running a OSC MS2 install on a server that supports everything needed to run this. It appears that I am getting the "This module supports only xpci version 1.0001 of the UPS Tracking Interface. Please contact the webmaster for additional assistance." message when I go to the tracking page. I tried commenting out the lines that make the display of this message possible and I get a "10001: The XML document is not well formed" message.

 

So I decided to investigate a little. I saw that it was checking the Xpci version value on the XML document using the getValueByPath method. I checked the method in the code in xmldocument.php and found that a couple of debug commands were commented out so I uncommented them and got the following output on my tracking page:

Looking for TrackResponse

Looking for Response

Found Response

Looking for TransactionReference

Found TransactionReference

Looking for XpciVersion

Looking for TrackResponse

Looking for Response

Found Response

Looking for ResponseStatusCode

Found ResponseStatusCode

Looking for TrackResponse

Looking for Response

Found Response

Looking for Error

Found Error

Looking for ErrorCode

Found ErrorCode

Looking for TrackResponse

Looking for Response

Found Response

Looking for Error

Found Error

Looking for ErrorDescription

Found ErrorDescription

Looking for TrackResponse

Looking for Shipment

Looking for Package

Looking for Activity

Looking for Status

Looking for StatusType

Looking for Code

Looking for TrackResponse

Looking for Shipment

Looking for ShipTo

Looking for Address

Looking for City

Looking for TrackResponse

Looking for Shipment

Looking for ShipTo

Looking for Address

Looking for StateProvinceCode

Looking for TrackResponse

Looking for Shipment

Looking for PickupDate

Looking for TrackResponse

Looking for Shipment

Looking for ScheduledDeliveryDate

Looking for TrackResponse

Looking for Shipment

Looking for Service

Looking for Description

Looking for TrackResponse

Looking for Shipment

Looking for Package

Looking for PackageWeight

Looking for UnitOfMeasure

Looking for Code

Looking for TrackResponse

Looking for Shipment

Looking for Package

Looking for PackageWeight

Looking for UnitOfMeasure

Looking for Code

I don't know enough about XML or the UPS module to figure this one out.

 

If you want to see the rest of my work, just go to http://www.directsnow.com . :D

 

Thanks a bunch,

 

-Aaron

Link to comment
Share on other sites

Hey Aaron,

can you confirm that the version of cURL compiled is in fact compiled with SSL support? Have a look at your php_info() to check (Admin > Tools > Server Info) There should be a curl header and beneath it you should something like "libcurl 7.9.5 (OpenSSL 0.9.6b) (ipv6 enabled)"

 

You should obviously be seeing Looking for xxx followed by Found xxx for each of the items in the response. The error you are seeing is generated by the fact that the XpciVersion is never found.

 

I can't say for sure that this is an SSL (or lack of) issue but it is a starting point...

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

Helio,

 

I have checked the PHP info and the read out is:

CURL support? enabled?

CURL Information? libcurl 7.9.5 (OpenSSL 0.9.6b) (ipv6 enabled)?

So it looks like everything should work. And I did notice that there was no "Found Xpci Version." Does anybody know how to fix that? I would appreciate any input!

 

So when it says "Looking for XpciVersion," which XML document is it using the getValueByPath method on?

 

-Aaron

Edited by aedmonds
Link to comment
Share on other sites

Are there any known issues when trying to communicate with the UPS servers from an https:// domain? I've got the module installed and I'm trying to test it, the window pops up and where the tracking information should be there's a message that says:

 

There seems to be a communication error with the UPS servers. Please contact the webmaster of this site to report this error.

 

Username, password and accesscode are all in the tracking.php file. I've looked in the code and what seems to be the problem is that a valid xml response is not coming back. Will an invalid username/pass/key combination generate an xml error? I've seen other people with different errors coming from libcurl not being installed right so I don't think that's the problem. error_reporting(0); is commented out.

 

Steve, many thanks for the contribution. It looks like a great app. I really hope I can get it working. Any help would be greatly appreciated.

Link to comment
Share on other sites

Helio,

 

I have checked the PHP info and the read out is:

CURL support? enabled?

CURL Information? libcurl 7.9.5 (OpenSSL 0.9.6b) (ipv6 enabled)?

So it looks like everything should work. And I did notice that there was no "Found Xpci Version." Does anybody know how to fix that? I would appreciate any input!

 

So when it says "Looking for XpciVersion," which XML document is it using the getValueByPath method on?

 

-Aaron

Aaron,

In tracking.php try adding the following line in the post() function:

 

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

 

let us know what happens...if anything...

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

If the above doens't work you can try to send a request to UPS using the command line and see if you get a full response back. If you do then the problem might be with libcurl and you would need to talk to your webmaster to figure out what it might be. To send a request using the command line do the following:

 

create a file called test.xml and put the following into it (you'll need to edit parts):

<?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
<AccessLicenseNumber>***key***</AccessLicenseNumber>
<UserId>***id***</UserId>
<Password>&***password***</Password>
</AccessRequest>
<?xml version="1.0"?>
<TrackRequest xml:lang="en-US">
<Request>
<TransactionReference>
<CustomerContext>UPS Package Tracking</CustomerContext>
<XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<RequestAction>Track</RequestAction>
<RequestOption>none</RequestOption>
</Request>
<TrackingNumber>***insert tracking code ***</TrackingNumber>
</TrackRequest>

 

ftp the test.xml to your webserver

ssh or telnet into your server and go to the directory where you put test.xml

run the following command on the command line:

curl -d @test.xml https://www.ups.com/ups.app/xml/Track

 

wade through the response (if you get one) and see if it is complete...

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

I'm getting very close...and very frustrated...

 

Helio, I did what you told me to do and found that it will works through the command line. So I was trying to figure out what was the difference between the two XML docs that were being sent using cUrl. Basically what's it come down to is that the XML document that I am currently sending using the tracking script is not "Well Formed." But some how, when I send the external file, it is ok. I noticed the only difference between the two is that the external file has the correct camel caps notation (AccessLicenseNumber) where as the script leaves it all as lower case (accesslicensenumber). This apparently is a problem because I've put all the neccessary info in the external XML file and used a file_get_contents() function to read in the document and send it using cUrl and it works!!!

 

So your probably thinking, "Aaron! You're such a retard! Why don't you just change the script to have the camel caps?" Well...I've already tried that and for some reason it keeps on being sent as lower case. But the thing is, it's being changed to lower case before it is even sent!

	$accessRequestHeader =
    "<?xml version=\"1.0\"?>\n".
    "<AccessRequest xml:lang=\"en-US\">\n".
    "   <AccessLicenseNumber>". $access_key ."</AccessLicenseNumber>\n".
    "   <UserId>". $userid ."</UserId>\n".
    "   <Password>". $pass ."</Password>\n".
    "</AccessRequest>\n";
$trackingServiceSelectionRequestHeader =
    "<?xml version=\"1.0\"?>\n".
    "<TrackRequest xml:lang=\"en-US\">\n".
    "  <Request>\n".
    "    <TransactionReference>\n".
    "      <CustomerContext>UPS Package Tracking</CustomerContext>\n".
    "      <XpciVersion>1.0001</XpciVersion>\n".
    "    </TransactionReference>\n".
    "    <RequestAction>Track</RequestAction>\n".
    "    <RequestOption>" . $activity . "</RequestOption>\n".
    "  </Request>\n".
    "  <TrackingNumber>" . $tracknum . "</TrackingNumber>\n" .
    "</TrackRequest>\n";

$xmlRequest = $accessRequestHeader . $trackingServiceSelectionRequestHeader;

echo $xmlRequest;

 $xmlResult = post($protocol, $host, $port, $path, $version, $timeout, $xmlRequest);

The "echo $xmlRequest" will return all lower case values. I don't know if I'm just being stupid and completely missing something but I really need some help. I would appreciate any input (preferably constructive :D ).

 

Thanks,

 

-Aaron

Link to comment
Share on other sites

The "echo $xmlRequest" will return all lower case values. I don't know if I'm just being stupid and completely missing something but I really need some help. I would appreciate any input (preferably constructive  :D  ).

 

Thanks,

 

-Aaron

if you echo $xmlRequest you should be getting back "values" not lowercase <tags>

 

in other words that echo should be displaying the values of the variables in the xmlRequest ($access_key, $userid, $pass, UPS Package Tracking, 1.0001, Track, $activity, $tracknum)

 

I don't understand what you mean by "I was trying to figure out what was the difference between the two XML docs that were being sent using cUrl." There is only one request being sent followed by one response.

 

what script needs to have the caps changed? I'm not following...

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

if you echo $xmlRequest you should be getting back "values" not lowercase <tags>

 

in other words that echo should be displaying the values of the variables in the xmlRequest ($access_key, $userid, $pass, UPS Package Tracking, 1.0001, Track, $activity, $tracknum)

 

I don't understand what you mean by "I was trying to figure out what was the difference between the two XML docs that were being sent using cUrl."  There is only one request being sent followed by one response.

 

what script needs to have the caps changed?  I'm not following...

Sorry, I forgot to say that I looked at the source code for the page after I echoed the $xmlRequest. It will just output the values in the browser but if you look at the source it will show you the whole XML doc. Looking at what is being sent, all of the tags are lower case. I hope that makes sense.

 

And when I said that I was checking between the two XML docs means that I had that test.xml document that I sent using the command line (remember how you told me how to do that?) and the other document is the one being sent in the classes->tracking.php. Does that make sense? One document is the test.xml document that you told me to make and the other "document" is the one that is sent using the tracking file and that I can see using the "echo $xmlRequest" command.

 

Sorry for all of the confusion!

 

-Aaron

Link to comment
Share on other sites

Sorry, I forgot to say that I looked at the source code for the page after I echoed the $xmlRequest. It will just output the values in the browser but if you look at the source it will show you the whole XML doc. Looking at what is being sent, all of the tags are lower case. I hope that makes sense.

ok, now I understand and I am also totally stumped. I echoed $xmlRequest on my site and got back perfectly formatted XML in the source. Are you totally positive that the command line method worked completely? Did you see actual package progress data in the response? If so I would suggest having libcurl recompiled/reinstalled. In my mind a faulty/corrupt libcurl can be the only culprit.

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

How can I remove some of shipping options?

Next Day Air Early AM

Next Day Air

Next Day Air Saver

2nd Day Air

3 Day Select

dude, how many times are you going to ask that question? This is the UPS TRACKING contrib. not the UPS SHIPPING contrib.

 

ask your question here:

Click Me

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

When I try to track with a valid tracking number, I get this response on both tracking.php and the popup:

This module supports only xpci version 1.0001 of the UPS Tracking Interface. Please contact the webmaster for additional assistance.

 

I am using the defailt variables in /includes/classes/tracking.php with the exception of my own login, password, and access key.

 

Anybody have any idea what I am doing wrong?

My advice comes in two flavors- Pick the one that won't offend you.

 

Hard and Cynical: How to Make a Horrible osCommerce Site

 

Warm and Fuzzy: How to Make an Awesome osCommerce Site

Link to comment
Share on other sites

Take a look at this post and see what happens when you try to send a request to UPS using the command line:

Click Here

If it works then you are in the same boat as aedmonds. He seems to be getting valid responses using the command line but not through libcurl. We dont have an answer for that one yet. I thought maybe he had a corrupt make of libcurl but if you both have the same problem then there may be something in the configuration of your servers that is unknown at this point.

 

You should also look at /classes/xmldocument.php and uncomment the "print" lines in the getDocumentByPath function to see if you are getting a full response back from UPS. aedmonds is not receiving the xpciversion number (among other things) in the xml response which is why the tracking script is failing and he/(you?) is getting that error...

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

I assume you are talking about the tracking.php file in classes.

Yes it is, and as I said, if we manually input a tracking # on the tracking.php page it works. When we click the track button on the account_history or account_history_info pages, we get the error. My guess is that it is not pulling the tracking number from the database. I just don't understand php well enough to see what's wrong by looking in the code.

Link to comment
Share on other sites

Sorry I didn't know how to edit my last post as I said I think the code is not pulling the tracking # from the database. Here are the pertinent lines from account_history and account_history info .

 

account_history

<?php

echo ' <td class="main" width="10%"><a href="java script:popupTrackerWindow(\'' . tep_href_link(FILENAME_POPUP_TRACKER, 'action=track&tracknum=' . $code) . '\')">' . tep_image_button('small_upstrack.gif') . '</a></td>' . "\n";

?>

 

account_history info

<td class="main"><a href="java script:popupTrackerWindow('<?php echo tep_href_link(FILENAME_POPUP_TRACKER, 'action=track&tracknum=' . $order->info['ups_track_num']);?>')"><?php echo $order->info['ups_track_num']; ?></a></td>

 

Another reason I believe this is a problem is I had to comment the follwing line out of account_history info in order to get the tracking table to show on the page

 

if ($order->info['ups_track_num'] == NULL)

 

Again, I can put the tracking number in admin and it shows up in the database. It just does not seem to pull up with this code.

Link to comment
Share on other sites

double check that the field in your orders table is named 'ups_track_num'

 

do you have a URL I can look at? Or can you send the whole page of code?

Do you ship UPS?

Give your customers order tracking without leaving your site. Track multi-package shipments. XML, cURL

 

Download the contribution here:

UPS Tracking

Link to comment
Share on other sites

  • 2 weeks later...

I am having some trouble with this contrib. I am tracking based on reference number. Submitted a reference number will sometimes display correct tracking information, but if I resubmit again, it will display incorrectly (large sections of XML will be displayed usually in the location field).

 

When I click on details on a delivered package, the scheduled Delivery date is incorrect. When I view the returned XML at the command line, there is no 'TrackResponse/Shipment/ScheduledDeliveryDate'.

 

Thanks for any ideas!

Link to comment
Share on other sites

Good evening @ all,

 

i have installed this great contribution and fixed the bugs as know in this post. i have read all of it but i do not get an idea how to fix my problem on a oscommere 2.2 ms2 systems:

 

The problem i have is that the /catalog/tracking.php/ is always refreshing me from the this site when iam hit the submit button on this page. Before i hit this button iam still loged in. after it the page logged me off from my account. I have turned off my SESURLs but still the same. Can anybody help me please.

 

 

 

the second error which appears is in my /catalog/account_histroy_info.php iam getting still the blank popup window! i have tried to fix it but no result:

 

 

 

in account_history_info:

 

change this:

<a href="java script:popupTrackerWindow('<?php echo tep_href_link(FILENAME_POPUP_TRACKER, 'action=track&tracknum=' . $order->info['ups_track_num']); ?>')">

 

change to:

<a href="java script:popupTrackerWindow('popup_tracker.php?action=track&tracknum=<?php echo $order->info['ups_track_num']; ?>')">

 

my /catalog/account_histroy.php looks good after this mod here:

 

change this:

<a href="java script:popupTrackerWindow(\'' . tep_href_link(FILENAME_POPUP_TRACKER, 'action=track&tracknum=' . $code) . '\')">

 

change to:

<a href="java script:popupTrackerWindow(\'popup_tracker.php?action=track&tracknum=' . $code . '\')">

 

 

 

do anybody know a solution for the above 2 probs?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...