Jump to content
Latest News: (loading..)
insaini

Canada Post Automated Labels 2.0 AND Canada Post Shipping Module 4.0

Recommended Posts

Well after 6 hours of working on this I managed to fix the xml parsing error ... shop postal code wasn't entered correctly in the backend configuration shipping/packaging. Such a relief to get it working and so frustrating that it ate up so much time for something so simple.

 

Now only problem is in the automated labels I get an error

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /hsphere/local/home/mysite.com/catalog/admin/includes/languages/english/ship_canadapost.php on line 38

 

Can anyone help me?

Share this post


Link to post
Share on other sites

After I installed Canada Post Automated Labels 2.0, I couldn't pass step2. I read some of the messages here, I thought I missed libssh2 too. I contacted with my host, they said I have it. After that I read all

the messages there. I changed the 'case 2' of ship_canadapost_ajax.php according to the message from

Alexei Karpenko http://forums.oscommerce.com/index.php?sho...78107&st=20.

 

Now I still can not pass step 2. I put the debug mode, I can see I got the response, but it didn't contain

<input type=hidden name="SSO_VERSION_MAJOR" value="3">, that's why it failed on the following line of ship_canadapost_ajax.php

 

// Sanity Check and Progress Report

if (strstr($response, '<input type=hidden name="SSO_VERSION_MAJOR" value="3">') === FALSE) {

cp_error(2, 'Failed check in ' . __FILE__ . ' at line ' . __LINE__ . '. This most likely means that Canada Post has changed their user interface. You need to update your Canada Post Automatic Shipping Labels module.');

curl_close($ch); die(); /////////////////////

} else {

cp_progress(2, 'Logged in.');

}

 

I noticed that there is similar check on the other steps, but I don't think I got those in the response(I commoned out those line to see what is the response). By the way, the response is not error, it was html

file, and if I commoned out those check lines, I could get pdf file(yesterday I can see the content, but not today), but it still failed on step 8 today.

 

Does anybody please help me? I appreciate it.

Share this post


Link to post
Share on other sites
For those having problem with the new log in procedure :

 

http://forums.oscommerce.com/index.php?sho...78107&st=20

 

I'm really missing something here... that code doesn't exist in my files to replace???

 

and I'm still getting this error Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /hsphere/local/home/site-removed/admin/includes/languages/english/ship_canadapost.php on line 38

Share this post


Link to post
Share on other sites
I'm really missing something here... that code doesn't exist in my files to replace???

 

and I'm still getting this error Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /hsphere/local/home/site-removed/admin/includes/languages/english/ship_canadapost.php on line 38

fixed the warning error I now just have the Failed check error This most likely means that Canada Post has changed their user interface. You need to update your Canada Post Automatic Shipping Labels module. HELP PLEASE

Share this post


Link to post
Share on other sites

I recently installed this contribution, and I think that I've got everything working now (except for the newest change to Canada Posts Interface).

 

Step 2. Error: Failed check in /home/********/public_html/admin/includes/languages/english/ship_canadapost.php at line 9. This most likely means that Canada Post has changed their user interface. You need to update your Canada Post Automatic Shipping Labels module.

 

What I had before:

 

$curl -V
curl 7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 lib
Protocols: tftp ftp telnet dict ldap http file https ftps
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz

 

What I have now:

 

$curl -V
curl 7.19.5 (i686-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 libssh2/0.18
Protocols: tftp ftp telnet dict http file https ftps scp sftp
Features: IDN IPv6 Largefile NTLM SSL libz

 

What I had before:

 

// configuration definitions
define (ORIGINAL_REFERRER, 'https://est-oee.canadapost-postescanada.ca');
define (SSO, 'https://sso-cal.canadapost-postescanada.ca');
define (PAGE, 'shipping/estShipping.jsp?locale=en_CA&formId=');
define (PDF, '/waitingForPDF.jsp?servletName=ParcelMailViewLabelServlet&label=forward&locale=en_CA&language=en_CA');
// step definitions
define (START, ORIGINAL_REFERRER.'/'.PAGE.$form_prefix.'0');
define (LOGIN, SSO.'/sso/login/redirect');
define (APPLICATION, ORIGINAL_REFERRER.'/ShippingServlet');
define (TRANSMIT, ORIGINAL_REFERRER.'/ParcelMailTransmitServlet');
define (RESET, ORIGINAL_REFERRER.'/ResetSessionServlet');

 

What I have now:

 

// configuration definitions
define (ORIGINAL_REFERRER, 'https://est-oee.canadapost-postescanada.ca');
define (SSO, 'https://sso-cal.canadapost-postescanada.ca');
define (PAGE, 'shipping/estShipping.jsp?locale=en_CA&formId=');
define (PDF, '/waitingForPDF.jsp?servletName=ParcelMailViewLabelServlet&label=forward&locale=en_CA&language=en_CA');
// step definitions
define (START, ORIGINAL_REFERRER.'/'.PAGE.$form_prefix.'0');
define (LOGIN, SSO.'/cpid/login/redirect');
define (APPLICATION, ORIGINAL_REFERRER.'/ShippingServlet');
define (TRANSMIT, ORIGINAL_REFERRER.'/ParcelMailTransmitServlet');
define (RESET, ORIGINAL_REFERRER.'/ResetSessionServlet');

 

What I had before:

 

				// login post vars
			$query_string = 'SHOP=CPFRCOMM&SSO_ITS_URL=%2Fsso%2Flogin.jsp&SSO_ACTION=0&P_SHOP=CPFRCOMM'
									. '&login_type=2&password_length=0&%7Elanguage=EN&APP_ID=B2B'
									. '&SSO_USERID=' . urlencode(MODULE_SHIPPING_CANADAPOST_USERID)
									. '&SSO_PASSWORD=' . urlencode(MODULE_SHIPPING_CANADAPOST_PASSWORD);
			// curl init
			$ch = cp_setup(false);
			$response = cp_post_page($ch, LOGIN, $query_string);
			curl_close($ch);
			// Canada Post customer number
			$regexp = "SSO_CUSTOMER_NUMBER\" value=\"([0123456789]*)(,|\")";
			$matches = '';
			preg_match("/$regexp/siU", $response, $matches);
			if (!tep_session_is_registered('cp_customer')) {
					tep_session_register('cp_customer');
			}
			$cp_customer = $matches[1];
			// progress update
			if (strstr($response, '<input type=hidden name="SSO_VERSION_MAJOR" value="3">') === FALSE) {
					do_cp_error($step, SC_GENERAL_ERROR);
			} else {
					cp_progress($step, LOGGEDIN);
			}
			break;

 

What I have now:

 

				case 2:
			// login post vars
			$query_string = 'SHOP=CPFRCOMM&SSO_ITS_URL=%2Fcpid%2login%2FsignIn%3F&SSO_ACTION=0&P_SHOP=CPFRCOMM'
									. '&login_type=2&password_length=0&language=EN&APP_ID=B2B'
									. '&SSO_USERID=' . urlencode(MODULE_SHIPPING_CANADAPOST_USERID)
									. '&SSO_PASSWORD=' . urlencode(MODULE_SHIPPING_CANADAPOST_PASSWORD);
			// curl init
			$ch = cp_setup(false);
			$response = cp_post_page($ch, LOGIN, $query_string);
			curl_close($ch);
			// Canada Post customer number
			$regexp = "SSO_CUSTOMER_NUMBER\" value=\"([0123456789]*)(,|\")";
			$matches = '';
			preg_match("/$regexp/siU", $response, $matches);
			if (!tep_session_is_registered('cp_customer')) {
					tep_session_register('cp_customer');
			}
			$cp_customer = $matches[1];
			// progress update
			if (strstr($response, '<input type=hidden name="SSO_VERSION_MAJOR" value="3">') === FALSE) {
					do_cp_error($step, SC_GENERAL_ERROR);
			} else {
					cp_progress($step, LOGGEDIN);
			}
			break;

 

If you see what it is that needs to be changed, certainly help me out as well as everyone else who is in need of this solution.

 

The one other issue I have, is that it doesn't seem to calculate the weight of the package and I'm not 100% sure if it adjusts the box dimensions if I have a bigger box would be required to ship, etc. Any feedback would be great.

 

Thank you in advance.

 

Sincerely,

 

Kevin

Share this post


Link to post
Share on other sites

Kevin, looks like you forgot the new requests to "https://sso-cal.canadapost-postescanada.ca/cpid/apps/signIn?execution=e1s". Perhaps this would work:

				case 2:
			// curl init
			$ch = cp_setup(false);
			// new login
			$response = cp_get_page($ch, SSO.'/cpid/apps/signIn?LOCALE=en&~language=EN&APP_ID=B2B&SSO_REFERRER_URL=https://obc.canadapost.ca/zcpb2b/b2b/init.do?language=EN&shop=CPENCOMM');
			// new login form
			$query_string = 'frmCPIDSignIn:signIn.x=46&frmCPIDSignIn:signIn.y=11&frmCPIDSignIn_SUBMIT=1'
									. '&frmCPIDSignIn:j_username=' . urlencode(MODULE_SHIPPING_CANADAPOST_USERID)
									. '&frmCPIDSignIn:j_password=' . urlencode(MODULE_SHIPPING_CANADAPOST_PASSWORD);

			$response = cp_post_page($ch, SSO.'/cpid/apps/signIn?execution=e1s1', $query_string);
			// login post vars
			$query_string = 'SHOP=CPFRCOMM&SSO_ITS_URL=%2Fcpid%2login%2FsignIn%3F&SSO_ACTION=0&P_SHOP=CPFRCOMM'
									. '&login_type=2&password_length=0&language=EN&APP_ID=B2B'
									. '&SSO_USERID=' . urlencode(MODULE_SHIPPING_CANADAPOST_USERID)
									. '&SSO_PASSWORD=' . urlencode(MODULE_SHIPPING_CANADAPOST_PASSWORD);
			$response = cp_post_page($ch, LOGIN, $query_string);
			curl_close($ch);
			// Canada Post customer number
			$regexp = "SSO_CUSTOMER_NUMBER\" value=\"([0123456789]*)(,|\")";
			$matches = '';
			preg_match("/$regexp/siU", $response, $matches);
			if (!tep_session_is_registered('cp_customer')) {
					tep_session_register('cp_customer');
			}
			$cp_customer = $matches[1];
			// progress update
			if (strstr($response, '<input type=hidden name="SSO_VERSION_MAJOR" value="3">') === FALSE) {
					do_cp_error($step, SC_GENERAL_ERROR);
			} else {
					cp_progress($step, LOGGEDIN);
			}
			break;

Share this post


Link to post
Share on other sites

Hmm, ok... I don't really run this version of the mod, so I can't test the code. You could try enable debugging by setting $debug = 1 and see at the responses from the Canada Post website. You can compare it to the POST/GET requests that you get if you use the Canada Post site directly using Firebug in Firefox. The way this mod works is it just uses the Canada Post website as you would manually -- Canada Post has no way to see that it's actually a script.

Share this post


Link to post
Share on other sites

This is where I am at with my ~/public_html/admin/ship_canadapost_ajax.php file.

 

Step 2. Error: Failed check in /home/********/public_html/admin/includes/languages/english/ship_canadapost.php at line 9. This most likely means that Canada Post has changed their user interface. You need to update your Canada Post Automatic Shipping Labels module.

 

// configuration definitions
define (ORIGINAL_REFERRER, 'https://est-oee.canadapost-postescanada.ca');
define (SSO, 'https://sso-cal.canadapost-postescanada.ca');
define (PAGE, 'shipping/estShipping.jsp?locale=en_CA&formId=');
define (PDF, '/waitingForPDF.jsp?servletName=ParcelMailViewLabelServlet&label=forward&locale=en_CA&language=en_CA');
// step definitions
define (START, ORIGINAL_REFERRER.'/'.PAGE.$form_prefix.'0');
define (LOGIN, SSO.'/cpid/login/redirect');
define (APPLICATION, ORIGINAL_REFERRER.'/ShippingServlet');
define (TRANSMIT, ORIGINAL_REFERRER.'/ParcelMailTransmitServlet');
define (RESET, ORIGINAL_REFERRER.'/ResetSessionServlet');

 

My code for Step 2

 

				case 2:
			// curl init
			$ch = cp_setup(false);
			// new login
			$response = cp_get_page($ch, SSO.'/cpid/apps/signIn?APP_ID=B2B&SSO_REFERRER_URL=https://obc.canadapost.ca/zcpb2b/b2b/init.do?LOCAL=en_CA&language=EN&shop=CPENCOMM');
			// new login form
			$query_string = 'frmCPIDSignIn:signIn.x=46&frmCPIDSignIn:signIn.y=11&frmCPIDSignIn_SUBMIT=1'
									. '&frmCPIDSignIn:j_username=' . urlencode(MODULE_SHIPPING_CANADAPOST_USERID)
									. '&frmCPIDSignIn:j_password=' . urlencode(MODULE_SHIPPING_CANADAPOST_PASSWORD);

			$response = cp_post_page($ch, SSO.'/cpid/apps/signIn?execution=e3s1', $query_string);
			// login post vars
			$query_string = 'SHOP=CPENCOMM&SSO_ITS_URL=%2Fcpid%2apps%2FsignIn&SSO_ACTION=0&P_SHOP=CPENCOMM'
									. '&login_type=2&password_length=0&language=EN&APP_ID=B2B'
									. '&SSO_USERID=' . urlencode(MODULE_SHIPPING_CANADAPOST_USERID)
									. '&SSO_PASSWORD=' . urlencode(MODULE_SHIPPING_CANADAPOST_PASSWORD);

			$response = cp_post_page($ch, LOGIN, $query_string);
			curl_close($ch);
			// Canada Post customer number
			$regexp = "SSO_CUSTOMER_NUMBER\" value=\"([0123456789]*)(,|\")";
			$matches = '';
			preg_match("/$regexp/siU", $response, $matches);
			if (!tep_session_is_registered('cp_customer')) {
					tep_session_register('cp_customer');
			}
			$cp_customer = $matches[1];
			// progress update
			if (strstr($response, '<input type=hidden name="SSO_VERSION_MAJOR" value="3">') === FALSE) {
					do_cp_error($step, SC_GENERAL_ERROR);
			} else {
					cp_progress($step, LOGGEDIN);
			}
			break;

 

Sometimes it times out and gives me a SQL time out error, is this normal?

 

Step 2 2006 - MySQL server has gone away

select count(*) as total from sessions where sesskey = '4b26f607a76ab414a36dd3488590bc3e'

[TEP STOP]

. Error: Failed check in /home/********/public_html/admin/includes/languages/english/ship_canadapost.php at line 9. This most likely means that Canada Post has changed their user interface. You need to update your Canada Post Automatic Shipping Labels module.

 

Can anyone suggest a handy CentOS utility (like a proxy server) so that I can see the request and the responses that happen during the curl process from within a shell account?

 

Thank you in advance for all of your help and for any of your suggestions.

 

Sincerely,

 

Kevin

Edited by kevin@canadacoaster.com

Share this post


Link to post
Share on other sites

Well I'm almost there... but the expedited and regular shipping are the same price - Canada Post says the problem is with our shopping cart. Does anyone know what I need to change?

 

Canada Post [1 box(es) to be shipped] small - 0.6(kg)

 

Priority Courier, EDD: June 05, 2009 $16.58CA

Expedited, EDD: June 05, 2009 $7.03CA

Regular, EDD: June 09, 2009 $7.03CA

 

PLEASE HELP ASAP! The site was suppose to go live yesterday!

Share this post


Link to post
Share on other sites
This is where I am at with my ~/public_html/admin/ship_canadapost_ajax.php file.

 

Step 2. Error: Failed check in /home/********/public_html/admin/includes/languages/english/ship_canadapost.php at line 9. This most likely means that Canada Post has changed their user interface. You need to update your Canada Post Automatic Shipping Labels module.

 

// configuration definitions
define (ORIGINAL_REFERRER, 'https://est-oee.canadapost-postescanada.ca');
define (SSO, 'https://sso-cal.canadapost-postescanada.ca');
define (PAGE, 'shipping/estShipping.jsp?locale=en_CA&formId=');
define (PDF, '/waitingForPDF.jsp?servletName=ParcelMailViewLabelServlet&label=forward&locale=en_CA&language=en_CA');
// step definitions
define (START, ORIGINAL_REFERRER.'/'.PAGE.$form_prefix.'0');
define (LOGIN, SSO.'/cpid/login/redirect');
define (APPLICATION, ORIGINAL_REFERRER.'/ShippingServlet');
define (TRANSMIT, ORIGINAL_REFERRER.'/ParcelMailTransmitServlet');
define (RESET, ORIGINAL_REFERRER.'/ResetSessionServlet');

...

Kevin

 

Sorry I'm probably wrong as I am in over my head but are your defines missing the first two ' ? Like this...

 

define ('ORIGINAL_REFERRER', 'https://est-oee.canadapost-postescanada.ca');

define ('SSO', 'https://sso-cal.canadapost-postescanada.ca');

define ('PAGE', 'shipping/estShipping.jsp?locale=en_CA&formId=');

define ('PDF', '/waitingForPDF.jsp?servletName=ParcelMailViewLabelServlet&label=forward&locale=en_CA&language=en_CA');

Edited by dandelion

Share this post


Link to post
Share on other sites

can someone please upload a full package here http://addons.oscommerce.com/info/5842 with the changes? Then I will be able to compare files and see what I'm missing to get the automated labels fixed. Thanks

 

Also does anyone know what is wrong that would cause the expedited and regular prices to be the same and to be too much?

Share this post


Link to post
Share on other sites
Also does anyone know what is wrong that would cause the expedited and regular prices to be the same and to be too much?

As far as I know, the prices for Regular and Expedited are exactly the same for VentureOne customers. I would just disable Regular to Canada entirely.

Share this post


Link to post
Share on other sites
Sorry I'm probably wrong as I am in over my head but are your defines missing the first two ' ? Like this...

 

define ('ORIGINAL_REFERRER', 'https://est-oee.canadapost-postescanada.ca');

define ('SSO', 'https://sso-cal.canadapost-postescanada.ca');

define ('PAGE', 'shipping/estShipping.jsp?locale=en_CA&formId=');

define ('PDF', '/waitingForPDF.jsp?servletName=ParcelMailViewLabelServlet&label=forward&locale=en_CA&language=en_CA');

 

Dandelion:

 

Sorry for the lateness of my reply. I really appreciate your effort in trying to resolve my issue. (That's not the solution, but good try.)

 

I'm not sure if you've noticed... but your latest issue is my issue. :)

 

Hopefully we'll get it resolved soon... I've been trying to work with someone from Canada Post to try and resolve it sooner rather than later.

 

Sincerely,

 

Kevin

Share this post


Link to post
Share on other sites
Dandelion:

 

Sorry for the lateness of my reply. I really appreciate your effort in trying to resolve my issue. (That's not the solution, but good try.)

 

I'm not sure if you've noticed... but your latest issue is my issue. :)

 

Hopefully we'll get it resolved soon... I've been trying to work with someone from Canada Post to try and resolve it sooner rather than later.

 

Sincerely,

 

Kevin

 

any update on this problem ? I cant find what to do to fix the login process

 

but I got this error in debug mode :

https://sso-cal.canadapost-postescanada.ca/.../login/redirect

 

HTTP/1.1 502 Bad Gateway

Server: Sun-Java-System-Web-Server/7.0

Date: Mon, 15 Jun 2009 20:08:42 GMT

Transfer-encoding: chunked

 

<HTML><HEAD><TITLE>Bad Gateway</TITLE></HEAD>

<BODY><H1>Bad Gateway</H1>

Processing of this request was delegated to a server that is not functioning properly.

</BODY></HTML>

Edited by syn0ptic

Share this post


Link to post
Share on other sites
I've been waiting for over a week for our Canada Post Representative to get back to me with the fix.

I doubt that Canada Post would support what is basically a hack. They do not provide any API for programmers to ship online.

Share this post


Link to post
Share on other sites

Hi all,

 

I am running this module, I am running into an issue. This morning I had a sale, the module returned the sale's shipping costs at $11.80. Each item sold was

L 26 cm x W 26 cm x H 2 cm @ .2 kg. I have the option ship in its original packaging checked, but the invoice stated that two boxes would be shipped. I am shipping them wrapped together, and not in a box. So I am wondering if there is a way to accomplish that via this module?

 

BTW the Canada Post website calculated the shipping at $6.31 total.

 

Mucho gracias

Share this post


Link to post
Share on other sites

I have the same issue with the labels and Step 2. I have verified that everything with my webhost is setup correctly. Would this have anything to do with my CC not being entered in the module setup within administration?

 

I am running out of ideas on how to trouble shoot this.

Share this post


Link to post
Share on other sites
I have the same issue with the labels and Step 2. I have verified that everything with my webhost is setup correctly. Would this have anything to do with my CC not being entered in the module setup within administration?

 

I am running out of ideas on how to trouble shoot this.

 

 

There seems to have been a modification with the Canada posts website log in as of june 29th. I'm running in to the same problem. Most likely someone will post a fix in a little bit.

Share this post


Link to post
Share on other sites

I think the canadapost.com logins fields got updated last few days so that has messed it up for all of us. Yes, let's hope there is a lovely "someone" out there who can rescue us asap.

Edited by csaxvik

Share this post


Link to post
Share on other sites
Look in the Canada Post forum by Natrium. He has posted a fix as CP changed the login field names slightly

Hey christian,

 

What forum are you talking about? Maybe you can post the link to the fix?

 

Thanks,

Jonathon

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×