Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Canada Post Automatic Labels


greasemonkey

Recommended Posts

Hi all, for those using Canada Post Automatic Labels, I preusme any version??? Canada Post did a major update over the weekend of Jan 5th 2013 and many of the est addresses have changed.

 

I have spoke to Canada Post tech support last night and I'm waiting for a reply/fix/new est form addresses.

 

This is causing Automatic Labels at fail step 3.

 

Is anybody (or everybody) having this same problem?

 

It would seem any address starting with "https://est" could be affected. What they referred to as EST Online Link to ship addresses.

 

Example from line 365 of admin/ship_canadapost.php

 

 $response = cp_get_page($ch, 'https://est-oee.canadapost-postescanada.ca/shipping/estShipping.jsp?locale=en_CA&formId=' . $form_prefix . '0&isV1=true');

 

There is also similar code/addresses on lines; 457, 532, 664, 731, 751, 755, 777

Link to comment
Share on other sites

Hi all, for those using Canada Post Automatic Labels, I preusme any version??? Canada Post did a major update over the weekend of Jan 5th 2013 and many of the est addresses have changed.

 

I have spoke to Canada Post tech support last night and I'm waiting for a reply/fix/new est form addresses.

 

This is causing Automatic Labels at fail step 3.

 

Is anybody (or everybody) having this same problem?

 

It would seem any address starting with "https://est" could be affected. What they referred to as EST Online Link to ship addresses.

 

Example from line 365 of admin/ship_canadapost.php

 

$response = cp_get_page($ch, 'https://est-oee.canadapost-postescanada.ca/shipping/estShipping.jsp?locale=en_CA&formId=' . $form_prefix . '0&isV1=true');

 

There is also similar code/addresses on lines; 457, 532, 664, 731, 751, 755, 777

 

I am experienceing the same issue. Been bouncing back and forth to their help desk as well.

Link to comment
Share on other sites

Same problem here too. Anxiously hoping someone will post an update. I'm guessing it will change again this weekend when they add and remove some services for shipping to the US. It sucks having to enter everything manually. =)

Link to comment
Share on other sites

I'm still waiting for a response for Can Post tech support... My inquire has now been forwarded via email to second level tech support.

 

My guess is they may try and force everyone to there new webservices platform (as Fedex did this past spring).

 

There is lots of info, but to my knowledge no working OsC contribution. Here are links to some of the info I've found on the webservices platform;

 

http://www.oscommerce.com/forums/topic/386546-new-canada-post-e-commerce-shipping-solution-integration/

http://seanzhuang.wordpress.com/2012/10/12/oscommerce-canada-post-shipping-service-rest-soap-module/

www.canadapost.ca/WebServices

 

I'll let everyone know if I get any details for CP.

Link to comment
Share on other sites

I spoke to Fabien Clermont at CanadaPost. He is the one addressing this issue. It sounds like they will want everyone to go over to the web services system eventually but I am trying to work out a solution so we can get our current code working and then move on to an update for the web services for a future upgrade.

 

They are going to send over the new URL's and formats. I will try to apply to the existing code to get it working. I'll post any results and findings.

Link to comment
Share on other sites

OK, what seems to have happened is they have added a new page to the interface - https://est.canadapost.ca/esto/ - if you type that in when you do a manual login then it takes to you a page that looks like this:

 

 

CanadaPostChoicePage.png

While that looks OK in edit mode it may not work for you (doesn't for me) so the link to the image is

 

http://www.flippers.com/images/CanadaPostChoicePage.png

 

And the links are now:

 

Ship Canada : https://est.canadapost.ca/esto/app/shipment/domestic

Ship US: https://est.canadapost.ca/esto/app/shipment/us

Ship International: https://est.canadapost.ca/esto/app/shipment/international

 

Hope this helps solve this. I am working on the changes and will post here if I find them!

Edited by Pinball
Link to comment
Share on other sites

Hey Pinball, thanks for the update... If it's anyhelp I had already tried;

 

 // 3. START SHIPPING

 $form_prefix = '';
 if ($delivery_country_iso_code_2 == 'CA') {
   $form_prefix = 'domestic';
 } elseif ($delivery_country_iso_code_2 == 'US') {
   $form_prefix = 'us';
 } else {
   $form_prefix = 'international';
 }

 $response = cp_get_page($ch, 'https://est.canadapost.ca/esto/app/shipment/' . $form_prefix . '?execution=e1s1');

 

Without sucess....

Link to comment
Share on other sites

That returns (turning on the full feedback) from CanPost:

Step 2. Logged in.

--STEP--3https://est.canadapost.ca/esto/app/shipment/international?execution=e1s1

HTTP/1.1 302 Moved Temporarily

Server: Web Server

Date: Fri, 11 Jan 2013 00:43:50 GMT

Set-cookie: SSID_PRD10_UI_EST=R1542851588; path=/

Set-cookie: ESTO_JSESSIONID=7WLpQvgHnndFd1QZDSCG9TV7SBp9gctP2hZ1zSrqCx2NHNYKx2Sc!-1870811261; expires=Fri, 11-Jan-2013 01:43:51 GMT; path=/; HttpOnly

Set-cookie: est_lang=en; expires=Sat, 11-Jan-2014 00:43:51 GMT; path=/esto

Proxy-agent: Proxy 10_1

Location: https://www.canadapost.ca/cpid/login.jsp?~language=en&SSO_REFERRER_URL=https%3A%2F%2Fwww.canadapost.ca%2Fcpid%2Fapps%2Fprocesstoken%3Ftarget_url%3Dhttps%3A%2F%2Fest.canadapost.ca%2Festo%2Fssoprocesstoken

X-powered-by: Web Server 10_1

Via: 1.1 https-canadapost

Transfer-encoding: chunked

 

HTTP/1.1 200 OK

Server: Web Server

X-powered-by: Web Server 10_1

Content-Type: text/html; charset=UTF-8

Proxy-agent: Proxy 10_1

Date: Fri, 11 Jan 2013 00:43:51 GMT

Content-Length: 914

Connection: keep-alive

Set-Cookie: CPO_SSID_PRD10_UI_CPO=R2961973849; path=/

 

 

 

 

<!-- SSO Build Info: @@sso_BUILD_PREFIX@@@sso_BUILD_ID@ on @@sso_BUILD_DATE@ -->

<!-- Redirect the user back to the referrer -->

<html>

<body>

 

 

<form name="goNext" action="https://www.canadapost.ca/cpid/apps/processtoken?target_url=https://est.canadapost.ca/esto/ssoprocesstoken" method="POST">

 

<input type="hidden" name="SSO_USERID" value="xxxxxxxx">

<input type="hidden" name="SSO_CUSTOMER_NUMBER" value="zzzzzzzzz,">

<input type="hidden" name="~language" value="en">

<input type="hidden" name="SSO_SECURITY_TOKEN" value="">

<input type="hidden" name="SSO_PASSWORD" value="cccccccccccccccccccccccccccc">

 

</form>

</body>

<script>

d = document.forms["goNext"];

d.submit();

</script>

</html>

 

https%3A%2F%2Fwww.canadapost.ca%2Fcpid%2Fapps%2Fprocesstoken%3Ftarget_url%3Dhttps%3A%2F%2Fest.canadapost.ca%2Festo%2Fssoprocesstoken X-powered-by: Web Server 10_1 Via: 1.1 https-canadapost Transfer-encoding: chunked HTTP/1.1 200 OK Server: Web Server X-powered-by: Web Server 10_1 Content-Type: text/html; charset=UTF-8 Proxy-agent: Proxy 10_1 Date: Fri, 11 Jan 2013 00:43:51 GMT Content-Length: 914 Connection: keep-alive Set-Cookie: CPO_SSID_PRD10_UI_CPO=R2961973849; path=/

 

Step 3. Error: Start Shipping Failed check in /usr/www/users/flip/catalog/sl1mbox2/ship_canadapost.php at line 423. This most likely means that Canada Post has changed their user interface. You need to update your Canada Post Automatic Shipping Labels module.

 

I edited the CanadaPost.php responses so they make more sense to my employees when something goes wrong - so Error 3 is now "Start Shipping Failed" instead of "Failed check in" which doesn't mean much. Handy for the dimension and payment errors too...

 

What is the "?execution=e1s1" bit? I am no PHP expert!

Link to comment
Share on other sites

Ya, I'm no expert either... However, I think we may have an issue with the login urls... first....

 

I pulled this address from my temp internet files after loging in manually... I think this may be the key?

 

https://www.canadapost.ca/cpid/login.jsp?~language=EN&SSO_REFERRER_URL=https://obc.canadapost.ca/zcpb2b/b2b/init.do?language=EN&SSO_USERID=*********&APP_ID=B2B&shop=CPENCOMM&EXT_REF_URL=https%3A%2F%2Fwww.canadapost.ca%2Fcpid%2Fapps%2Fprocesstoken%3Ftarget_url%3Dhttps%3A%2F%2Fest.canadapost.ca%2Festo%2Fssoprocesstoken

 

Getting this to fit here;

 

// 2. LOG IN
$response = cp_get_page($ch, 'https://www.canadapost.ca/cpid/login.jsp?SSO_REFERRER_URL=https://www.canadapost.ca');

$response = cp_get_page($ch, 'https://www.canadapost.ca/cpid/apps/signIn?LOCALE=en');

$query_string = 'cpidSignIn:signIn.x=46&cpidSignIn:signIn.y=11&cpidSignIn_SUBMIT=1'
		 . '&cpidSignIn:j_username=' . urlencode($cp_user)
		 . '&cpidSignIn:j_password=' . urlencode($cp_password)
		 . '&cpidSignIn:rememberUserName=true'
		 . '&destination=https://obc.canadapost.ca/zcpb2b/b2b/init.do';

$response = cp_post_page($ch, 'https://www.canadapost.ca/cpid/apps/signIn?execution=e1s1', $query_string);

$query_string = 'SHOP=CPFRCOMM&SSO_ITS_URL=%2Fcpid%2Flogin.jsp&SSO_ACTION=0&P_SHOP=CPFRCOMM'
		 . '&login_type=2&password_length=0&%7Elanguage=EN&APP_ID=B2B'
		 . '&SSO_USERID=' . urlencode($cp_user)
		 . '&SSO_PASSWORD=' . urlencode($cp_password);

$response = cp_post_page($ch, 'https://www.canadapost.ca/cpid/login/redirect', $query_string);

Edited by greasemonkey
Link to comment
Share on other sites

Hi GM,

 

Login isn't the problem, the system works up to the point where it tells Canada Post (CP) to switch between Canada, US or International address entry screens. As I understand it this originally was written to behave as if a human was manually entering the information. So the point where it is breaking down is after the start of section 3 - the Start Shipping section. It looks like the address is accepted by CP, and a redirect occurs, but shortly after that it all breaks down.

 

Oh, and a quick search on "?execution=e1s1" shows that "if you include the execution key you will be taken to the state and flow execution that is encoded in the key. e1 indicates the flow execution, and s1 indicates the state.". Not quite sure what that all means, but it is clearing up as I get back into it.

 

I really should have taken that UBC PHP course in December 2012...

Link to comment
Share on other sites

Hmm, well, now that I look at the original code I see that it actually did almost work correctly. If you read the CP log you will see that the page: https://est.canadapost.ca/esto/ is actually built and once it gets to the bottom the system waits for input, but as ship_canadapost.php wasn't expecting this page, and you end up with the error message. See the following log and compare to the image I provided a link to above in message #7:

 

 

 

--STEP--3https://est-oee.canadapost-postescanada.ca/shipping/estShipping.jsp?locale=en_CA&formId=international0&isV1=true

HTTP/1.1 302 Moved Temporarily

Server: Web Server

Date: Fri, 11 Jan 2013 06:57:56 GMT

Location: https://est.canadapost.ca/esto/

Content-length: 0

Proxy-agent: Proxy 3225

X-powered-by: Proxy 3225

 

HTTP/1.1 200 OK

Server: Web Server

Date: Fri, 11 Jan 2013 06:57:56 GMT

Proxy-agent: Proxy 10_1

Set-cookie: SSID_PRD10_UI_EST=R4282218949; path=/

Set-cookie: ESTO_JSESSIONID=9TJvQv3V2RQf3Gvvx7tj5vj2VGKryRh1g152tNNGYVfsKK3nZvlM!346958228; expires=Fri, 11-Jan-2013 07:57:57 GMT; path=/; HttpOnly

Content-type: text/html; charset=UTF-8

Content-language: en-CA

X-powered-by: Web Server 10_1

Transfer-encoding: chunked

Via: 1.1 https-canadapost

 

<head><link type="text/css" rel="stylesheet" href="/esto/app/javax.faces.resource/theme.css?ln=primefaces-cpc" />

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>EST On-line</title>

<link rel="stylesheet" href="/esto/styles/expediterNavigation.css?version=1301.10.109" type="text/css" /></head><body>

 

<table width="750" style="border: solid thin #336699;" cellspacing="0" align="center">

<tr>

<td colspan="2" align="center">

<a href="http://www.canadapost.ca"><img src="/esto/images/mailposte.gif" name="logo" border="0" /></a>

</td>

</tr>

<tr>

<td width="375" align="center" valign="top">

<table>

<tr>

<td class="blueHeading" align="center">Welcome</td>

</tr>

<tr>

<td class="blueHeading" align="center">Electronic Shipping Tools</td>

</tr>

<tr>

<td align="center">

<table cellpadding="0" cellspacing="0" border="0" bgcolor="#336699">

<tr>

<td align="center" width="200">

 

<table width="240" border="0" cellpadding="4" cellspacing="1" bgcolor="#336699">

<tr>

<td class="navigationPlain" align="center">Communication Services</td>

</tr>

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/addressed/lmmailing" class="navigationLink">

Lettermail

</a>

</td>

</tr>

 

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/addressed/aamailing" class="navigationLink">

Addressed Admail

</a>

</td>

</tr>

 

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/addressed/pubmailing" class="navigationLink">

Publications Mail

</a>

</td>

</tr>

 

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/uaff" class="navigationLink">

Unaddressed Admail - Fully Featured

</a>

</td>

</tr>

 

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/uaeoe" class="navigationLink">

Unadressed Admail - Express Order Entry

</a>

</td>

</tr>

 

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/uasom" class="navigationLink">

Unaddressed Admail - SOM Only

</a>

</td>

</tr>

 

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/addressed/iilpmailing" class="navigationLink">Int'l Incentive Letter-post</a>

</td>

</tr>

 

<tr>

<td class="navigationPlain" align="center">Distribution Services</td>

</tr>

 

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/shipment/domestic" class="navigationLink">

Ship Canada

</a>

</td>

</tr>

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/shipment/us" class="navigationLink">

Ship USA

</a>

</td>

</tr>

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/shipment/international" class="navigationLink">

Ship International

</a>

</td>

</tr>

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/ShippingEOE" class="navigationLink">

Ship Canada - Express Order Shipping

</a>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

<td width="375" align="center" valign="top">

<table>

<tr>

<td class="blueHeading" align="center">Bienvenue</td>

</tr>

<tr>

<td class="blueHeading" align="center">Outils électroniques d'expédition</td>

</tr>

<tr>

<td align="center">

<table cellpadding="0" cellspacing="0" border="0" bgcolor="#336699">

<tr>

<td align="center" width="200">

 

<table width="240" border="0" cellpadding="4" cellspacing="1" bgcolor="#336699">

<tr>

<td class="navigationPlain" align="center">Services de communication</td>

</tr>

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/addressed/lmmailing?locale=fr_CA" class="navigationLink">

Lettre poste

</a>

</td>

</tr>

 

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/addressed/aamailing?locale=fr_CA" class="navigationLink">

Médiaposte avec adresse

</a>

</td>

</tr>

 

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/addressed/pubmailing?locale=fr_CA" class="navigationLink">

Poste publications

</a>

</td>

</tr>

 

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/uaff?locale=fr_CA" class="navigationLink">

Médiaposte sans adresse - Haut de gamme

</a>

</td>

</tr>

 

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/uaeoe?locale=fr_CA" class="navigationLink">

Médiaposte sans adresse - Saisie d'une commande express

</a>

</td>

</tr>

 

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/uasom?locale=fr_CA" class="navigationLink">

Médiaposte sans adresse - DD seulement

</a>

</td>

</tr>

 

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/addressed/iilpmailing?locale=fr_CA" class="navigationLink">

Tarif préférentiel Int'l/É.U.

</a>

</td>

</tr>

 

<tr>

<td class="navigationPlain" align="center">Services de distribution</td>

</tr>

 

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/shipment/domestic?locale=fr_CA" class="navigationLink">

Expédition (Canada)

</a>

</td>

</tr>

 

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/ShippingEOE?locale=fr_CA" class="navigationLink">

Saisie d'une commande express pour Expédier au Canada

</a>

</td>

</tr>

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/shipment/us?locale=fr_CA" class="navigationLink">

Expédition (États-Unis)

</a>

</td>

</tr>

<tr>

<td class="navigationLink" nowrap="nowrap"><a href="/esto/app/shipment/international?locale=fr_CA" class="navigationLink">

Expédition (international)

</a>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

<table width="750" cellspacing="0" align="center">

<tr>

<td width="375" class="footNote">1301.10.109</td>

<td width="375" class="footNote">08-Jan-2013 18:33</td>

</tr>

</table></body>

 

Step 3. Error: Start Shipping Failed check in /usr/www/users/flip/catalog/sl1mbox2/ship_canadapost.php at line 424. This most likely means that Canada Post has changed their user interface. You need to update your Canada Post Automatic Shipping Labels module.

 

What the system is waiting for is one of the following entries:

 

https://est.canadapost.ca/esto/app/shipment/domestic

 

https://est.canadapost.ca/esto/app/shipment/us

 

https://est.canadapost.ca/esto/app/shipment/international

 

So that needs to be fitted into the code (I think).

Link to comment
Share on other sites

Weird, my log looks different...

 

https%3A%2F%2Fwww.canadapost.ca%2Fcpid%2Fapps%2Fprocesstoken%3Ftarget_url%3Dhttps%3A%2F%2Fest.canadapost.ca%2Festo%2Fssoprocesstoken X-powered-by: Web Server 10_1 Via: 1.1 https-canadapost Transfer-encoding: chunked HTTP/1.1 200 OK Server: Web Server X-powered-by: Web Server 10_1 Content-Type: text/html; charset=UTF-8 Proxy-agent: Proxy 10_1 Date: Fri, 11 Jan 2013 13:16:54 GMT Content-Length: 916 Connection: keep-alive Set-Cookie: CPO_SSID_PRD10_UI_CPO=R1406373914; path=/

 

Sending data to

 

 

 

 

 

 

 

 

 

 

Sending data to

 

 

 

 

Step 3. Error: Failed check in /home/flournet/public_html/osc_admin/ship_canadapost.php at line 387. This most likely means that Canada Post has changed their user interface. You need to update your Canada Post Automatic Shipping Labels module.

Link to comment
Share on other sites

Hey Pinball, no nothing yet... I worked on it yesterday for about an hour and decided it is beyond my very limited experience...

 

The entire interface has changed... And although the page looks builds there are several problems which I just do not understand...

 

I called Can Post again to get an update on my support ticket, however, still have not received any info.

 

As a backup I have one of the sponsor members (not sure if I should be using names...) working on a new 2.3 site - I have asked him if there is interest in building a new webserivces platform module... If he agree's to build the new platform however, it would be up to him to release it publicly...

 

If he (the sponsor memeber) says no to building a new module, and Can Post does not reply... I will have to look elsewhere (probably an open bid on freelancer or something) to have the module built...

 

Our business does signigicant volume via Can Post... and doing labels manually just takes too much time and is mistake prone....

Link to comment
Share on other sites

  • 4 weeks later...

I spoke to Fabien Clermont at CanadaPost. He is the one addressing this issue. It sounds like they will want everyone to go over to the web services system eventually but I am trying to work out a solution so we can get our current code working and then move on to an update for the web services for a future upgrade.

 

They are going to send over the new URL's and formats. I will try to apply to the existing code to get it working. I'll post any results and findings.

 

Jeff,

 

Did you ever get the new URLs and formats?

 

Thanks,

 

John :-#)#

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

It looks like the old API system will have to be updated to the new Web Services connection method. We have sent the project outline to a development company we use for cost and time frame. I will post any detail on progress as we get them.

 

Anything to report Jeff? It's been months...we are still manually doing our CP labels...

Link to comment
Share on other sites

  • 1 month later...

I haven't read all the posts in this forum but I thought I would mention that I have just implemented a rewrite of the CP Automated Labels addon (5445) using the Canada Post XML API for non-contract accounts guideline to replace the previous get-page/post-page API.

 

I haven't formally packaged the changes at this point but this is what I have done:

 

catalog/includes/modules/shipping/canadapost.php

--> addon 5842

--> most constants for labels can be set in Admin now including Test mode for labels

--> contains Lettermail and Letterpost functions but these can be turned off in Admin

catalog/admin/ship_canadapost.php

--> XML API has 3 steps: Create Shipment, Acquire Artifact (shipping label) and Acquire Tracking PIN (tracking no.)

--> the look and feel is basically the same, labels are still in PDF form and stored in the same subfolder

catalog/admin/includes/classes/shipping_form.php

--> all redundant code removed

catalog/admin/third-party/cert/cacert.pem

--> third party cert required and provided by CP

catalog/admin/shipping_label.php

--> remove, not required

catalog/admin/includes/functions/ship_canadapost.php

--> remove, not required

 

I have implemented these changes in this 2.2 website, thesoapfarm.com

 

Please advise if this has value.

Link to comment
Share on other sites

  • 2 weeks later...

Does anyone have anything to share/download

 

I would love to start from a good base and begin building a new 2.3.3 Canada Post shipping module and integrate some of the great features seen on modules like UPSXML with dimensional shipping support, per item exclusions etc.

 

I am on no position to build something from scratch though. . . As an open source user, it would also be offered as open source.

 

Anything would be of value. you can email me echo "chad".'@'."noboyfamous".".ca";

Edited by nobodyfamous
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...