//// // 2. LOG IN $response = cp_get_page($ch, 'https://sso-cal.canadapost-postescanada.ca/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'); $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);Also make sure to go to the EST site manually and update the account when requested.
Canada Post Automatic Labels
#41
Posted 01 July 2009 - 04:44 PM
#42
Posted 14 July 2009 - 01:19 PM
natrium42, on Jun 18 2009, 12:05 AM, said:
Sorry about the delay in my response. The shipping addresses that I've tried are to the USA. I've tried every shipping method available and it still fails at Step 5.
Thanks,
Alex
#43
Posted 14 August 2009 - 01:59 AM
#44
Posted 17 November 2009 - 06:06 AM
==================================
Version 1.2.2 (2009-11-17)
- Fix changed login process
- Remove Purolator and add the new FedEx shipping methods
Please see http://addons.oscommerce.com/info/5445 to download
#45
Posted 18 November 2009 - 07:41 PM
natrium42, on 17 November 2009 - 06:06 AM, said:
==================================
Version 1.2.2 (2009-11-17)
- Fix changed login process
- Remove Purolator and add the new FedEx shipping methods
Please see http://addons.oscommerce.com/info/5445 to download
Doesn't seem to work! All I am getting now is
Fatal error: Call to undefined function cp_post_var() in ship_canadapost.php on line 273
#46
Posted 18 November 2009 - 11:21 PM
You need to add this function at the end of that file:
function cp_post_var($var) {
if(get_magic_quotes_gpc()) {
return stripslashes($_POST[$var]);
} else {
return $HTTP_POST_VARS[$var];
}
}I fixed this in the package with version 1.2.3.
Edited by natrium42, 18 November 2009 - 11:30 PM.
#47
Posted 02 March 2010 - 12:42 AM
Step 7. Error: Failed check in .../public_html/shop/admin/ship_canadapost.php at line 740. This most likely means that Canada Post has changed their user interface. You need to update your Canada Post Automatic Shipping Labels module.
Any idea what's going on? I just reinstalled this contrib to see if it would fix it but no.
#48
Posted 18 March 2010 - 06:06 PM
natrium42, on 06 February 2008 - 06:40 PM, said:
You can run the SQL statements through a screen in myPhpAdmin by copying and pasting the code out of the new_install.sql. Of course, backup your database or better yet use a test server.
Thanks,
Now one more problem - in the Manufacturers section of Admin, if I try to change the country code it is not successful UNLESS I also define a Manufacturer's Image at the same time! I tried just doing the Manufacturer's URL instead of Image but while it did record the URL that did not change the countries_id from '0', only if I added an image or changed the image would it update the manufacturer's country of origin...
Is this a bug or did I miss a step during install?
John :-#)#
#49
Posted 21 March 2010 - 02:33 AM
<form name="theForm" action="../ShippingServlet" method="post">
<input type="Hidden" name="translatorName" value="cpc.ui.online.shipping.ShippingInfoTranslator">
<input type="Hidden" name="pageName" value="shipping/estShipping.jsp?locale=en_CA&formId=130">
<input type="Hidden" name="errorMessage" value="">
<input type="Hidden" name="errorField" value="">
<input type="Hidden" name="nextPageFormId" value="121">
<input type="hidden" name="clientId" value=""> <!--this field is used in retrieving an address from address book-->
<input type="hidden" name="formId" value="130">
<input type="hidden" name="maxAddrBookEntry" value="250">
<input type="hidden" name="numAddrBookEntry" value="0">
<input type="hidden" name="irsNo" value="">
Note that "formId" value (130 - International) appears to be set by these lines:
<tr><td class="nav" height="25" width="200"><a href="javascript: submitNavigationForm('shipping/estShipping.jsp?locale=en_CA&formId=110')" class="nav" target="_top" >Ship Canada</a></td></tr>
<tr><td class="nav" height="25" width="200"><a href="javascript: submitNavigationForm('ShippingEOE?useraction=start&locale=en_CA')" class="nav" target="_top" >Ship Canada - Express Order Entry</a></td></tr>
<tr><td class="nav" height="25" width="200"><a href="javascript: submitNavigationForm('shipping/estShipping.jsp?locale=en_CA&formId=120')" class="nav" target="_top">Ship USA</a></td></tr>
<tr><td class="nav" height="25" width="200"><a href="javascript: submitNavigationForm('shipping/estShipping.jsp?locale=en_CA&formId=130')" class="nav" target="_top">Ship International</a></td></tr>
so somewhere the "US" destination (formId=120) is not getting passed through - leading to the program defaulting to International (formId=130). This explains why it fails in Step five with the error message:
Step 5. Error: Failed check in /xxx/.../catalog/admin/ship_canadapost.php at line 545
with line 545 showing the result of the country code (if wrong) I assume.
Trying to figure out where the "US" destination is passed through to CP so I can fix the problem, however my PHP error log only shows when I send the label request to CP (press "Submit" button http://www....com/catalog/admin/ship_canadapost.php?oID=4&action=new&status=3:)
[20-Mar-2010 21:57:15] PHP Notice: Constant AFFILIATE_NOTIFY_AFTER_BILLING already defined in /usr/..../catalog/admin/includes/application_top.php on line 69
[20-Mar-2010 21:57:16] PHP Notice: Undefined index: cID in /usr/..../catalog/admin/ship_canadapost.php on line 261
[20-Mar-2010 21:57:34] PHP Notice: Constant AFFILIATE_NOTIFY_AFTER_BILLING already defined in /usr/.../catalog/admin/includes/application_top.php on line 69
[20-Mar-2010 21:57:34] PHP Notice: Undefined variable: HTTP_POST_VARS in /usr/..../catalog/admin/includes/functions/ship_canadapost.php on line 123
[20-Mar-2010 21:57:34] PHP Notice: Undefined variable: HTTP_POST_VARS in /usr/..../catalog/admin/includes/functions/ship_canadapost.php on line 123
(repeats same error another 15 times then ends with)
[20-Mar-2010 21:57:39] PHP Notice: Undefined offset: 1 in /usr/..../catalog/admin/includes/functions/ship_canadapost.php on line 108
Ideas?
John :-#)#
#50
Posted 23 March 2010 - 06:22 AM
Pinball, on 21 March 2010 - 02:33 AM, said:
<form name="theForm" action="../ShippingServlet" method="post">
<input type="Hidden" name="translatorName" value="cpc.ui.online.shipping.ShippingInfoTranslator">
<input type="Hidden" name="pageName" value="shipping/estShipping.jsp?locale=en_CA&formId=130">
<input type="Hidden" name="errorMessage" value="">
<input type="Hidden" name="errorField" value="">
<input type="Hidden" name="nextPageFormId" value="121">
<input type="hidden" name="clientId" value=""> <!--this field is used in retrieving an address from address book-->
<input type="hidden" name="formId" value="130">
<input type="hidden" name="maxAddrBookEntry" value="250">
<input type="hidden" name="numAddrBookEntry" value="0">
<input type="hidden" name="irsNo" value="">
Note that "formId" value (130 - International) appears to be set by these lines:
<tr><td class="nav" height="25" width="200"><a href="javascript: submitNavigationForm('shipping/estShipping.jsp?locale=en_CA&formId=110')" class="nav" target="_top" >Ship Canada</a></td></tr>
<tr><td class="nav" height="25" width="200"><a href="javascript: submitNavigationForm('ShippingEOE?useraction=start&locale=en_CA')" class="nav" target="_top" >Ship Canada - Express Order Entry</a></td></tr>
<tr><td class="nav" height="25" width="200"><a href="javascript: submitNavigationForm('shipping/estShipping.jsp?locale=en_CA&formId=120')" class="nav" target="_top">Ship USA</a></td></tr>
<tr><td class="nav" height="25" width="200"><a href="javascript: submitNavigationForm('shipping/estShipping.jsp?locale=en_CA&formId=130')" class="nav" target="_top">Ship International</a></td></tr>
so somewhere the "US" destination (formId=120) is not getting passed through - leading to the program defaulting to International (formId=130). This explains why it fails in Step five with the error message:
Step 5. Error: Failed check in /xxx/.../catalog/admin/ship_canadapost.php at line 545
with line 545 showing the result of the country code (if wrong) I assume.
Trying to figure out where the "US" destination is passed through to CP so I can fix the problem, however my PHP error log only shows when I send the label request to CP (press "Submit" button http://www....com/catalog/admin/ship_canadapost.php?oID=4&action=new&status=3:)
[20-Mar-2010 21:57:15] PHP Notice: Constant AFFILIATE_NOTIFY_AFTER_BILLING already defined in /usr/..../catalog/admin/includes/application_top.php on line 69
[20-Mar-2010 21:57:16] PHP Notice: Undefined index: cID in /usr/..../catalog/admin/ship_canadapost.php on line 261
[20-Mar-2010 21:57:34] PHP Notice: Constant AFFILIATE_NOTIFY_AFTER_BILLING already defined in /usr/.../catalog/admin/includes/application_top.php on line 69
[20-Mar-2010 21:57:34] PHP Notice: Undefined variable: HTTP_POST_VARS in /usr/..../catalog/admin/includes/functions/ship_canadapost.php on line 123
[20-Mar-2010 21:57:34] PHP Notice: Undefined variable: HTTP_POST_VARS in /usr/..../catalog/admin/includes/functions/ship_canadapost.php on line 123
(repeats same error another 15 times then ends with)
[20-Mar-2010 21:57:39] PHP Notice: Undefined offset: 1 in /usr/..../catalog/admin/includes/functions/ship_canadapost.php on line 108
Ideas?
John :-#)#
OK, chatting with Alexei it turns out that OSCommerce/OSCMax are using something called long arrays, which are being phased out of php - they are not going to be available once php 6.0 is released (this needs to be addressed!).
So the cure for the undefined variable HTTP_POST_VARS (and HTP_GET_VARS) is to simply replace $HTTP_POST_VARS with $_POST and to replace $HTTP_GET_VARS with $_GET in his contribution which is Canada Post Automatic Labels 1.2.3.
BUT NOT for the rest of your OSCMax/Commerce site...for now...
I used a good text editor (TextWrangler - MAC) to do the required search & replace and now I get past this problem as shown above, and down to the Payment section, where I have inserted the php code "die();" which terminates the PHP code before making a payment to Canada Post (section 6 as I recall).
I'll try to write this up a bit clearer once I have verified that this works for me, and have checked with Alexei - he is very busy right now with exams I believe.
John :-#)#
#51
Posted 29 March 2010 - 06:45 AM
Pinball, on 23 March 2010 - 06:22 AM, said:
So the cure for the undefined variable HTTP_POST_VARS (and HTP_GET_VARS) is to simply replace $HTTP_POST_VARS with $_POST and to replace $HTTP_GET_VARS with $_GET in his contribution which is Canada Post Automatic Labels 1.2.3.
BUT NOT for the rest of your OSCMax/Commerce site...for now...
I used a good text editor (TextWrangler - MAC) to do the required search & replace and now I get past this problem as shown above, and down to the Payment section, where I have inserted the php code "die();" which terminates the PHP code before making a payment to Canada Post (section 6 as I recall).
I'll try to write this up a bit clearer once I have verified that this works for me, and have checked with Alexei - he is very busy right now with exams I believe.
John :-#)#
Further to this program (1.2.3 version) I have found there is one obsolete section in admin/catagories.php which is this line of code - the link to launch a search page for Harmonized Shipping Codes/Tariffs in catalog/admin/categories.php while in the Add/Edit :
-----------------------
***REPLACE this added (1.2.3) code:
<td class="main"><a href="http://www.cbsa-asfc.gc.ca/trade-commerce/tariff-tarif/tariff2007/01-99/table-e.html" target="_blank">HS Tariff</a>:</td>
******With this code:
<td class="main"><a href="http://www.statcan.gc.ca/trade-commerce/cec/trade-commerce-eng.htm" target="_blank">HS Tariff</a>:</td>
-----------------------
This (when you click on HS Tariffs:) opens a new tab/window for Statistics Canada search "Canadian Export Classification" and you can search for your code using key words (start with a single word) or part of a tariff code - say the first 4 numbers, no "." in the search window.
John :-#)#
#52
Posted 26 May 2010 - 04:46 AM
Is there an easy modification to the code so that is one of the returned parameters?
Thanks!
John :-#)#
#53
Posted 29 May 2010 - 01:55 AM
#54 ONLINE
Posted 06 August 2010 - 10:08 PM
I've installed this mod on my test site and cannot get past Step 2.
Step 1. Initialized. Step 2. Error: Failed check in /mnt/w0113/d12/s07/b02a2859/www/osc_admin_dev/ship_canadapost.php at line 346. This most likely means that Canada Post has changed their user interface. You need to update your Canada Post Automatic Shipping Labels module.
I've tried multiple versions of admin/ship_canadapost.php // 2. LOG IN code... below is what I currently have
////
// 2. LOG IN
$response = cp_get_page($ch, 'https://sso-cal.canadapost-postescanada.ca/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');
$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);
$response = cp_post_page($ch, 'https://sso-cal.canadapost-postescanada.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://sso-cal.canadapost-postescanada.ca/cpid/login/redirect', $query_string);
// get Canada Post customer number
$regexp = "SSO_CUSTOMER_NUMBER\" value=\"([0123456789]*)(,|\")";
$matches = '';
preg_match("/$regexp/siU", $response, $matches);
$cp_customer = $matches[1];
$response = cp_submit_page($ch, $response, 'https://sso-cal.canadapost-postescanada.ca');
// 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.');
}
Any help would be appreciated....
#55 ONLINE
Posted 07 August 2010 - 12:30 AM
////
// 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);
// get Canada Post customer number
$regexp = "SSO_CUSTOMER_NUMBER\" value=\"([0123456789]*)(,|\")";
$matches = '';
preg_match("/$regexp/siU", $response, $matches);
$cp_customer = $matches[1];
$response = cp_submit_page($ch, $response, 'https://www.canadapost.ca');
// 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.');
}
#56 ONLINE
Posted 07 August 2010 - 06:51 PM
Apparently not passing Step 2 is almost always to do with the cURL missing OpenSSL AND! libssh2...
Right now my cURL is
cURL support enabled cURL Information libcurl/7.19.0 OpenSSL/0.9.8k zlib/1.1.3
Just waiting for my host to reconfigure the cURL (it didn't seem like it would be an issue... other than the system admin has to do it and they don't work on the weekend).
#57 ONLINE
Posted 29 January 2011 - 10:15 PM
Quote
cURL support enabled
cURL Information libcurl/7.21.3 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 libssh2/1.2.7
However, I still cannot pass step 2.
Quote
I sure port 30000 is open... as Canada Post Quotes (I belive) come through port 30000.
Quote
30000
So... I'm not sure what this issue is...
The only thing I'm not 100% clear on is; what login info do I use?
Or the login to EST I presume??? Or the login to sellonline?
Right now I'm testing with the EST login info;
$cp_user = '<********>'; $cp_password = '<******>'; $cp_contract = '<00********>'; // if you have a CP contract, put it here to pay via // account instead of credit card $cp_use_account = 1; // set to 1 to pay via account instead of credit card
Any suggestions would be a great help...
Currently the the code at step 2 looks like;
// 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'
#58 ONLINE
Posted 30 January 2011 - 04:32 PM
It is creating the lable on the Can Post site... However NOT able to open it.
Warning: fopen(http://www.mysite.ca/shop/images/canadapost/611.pdf) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/*******/public_html/osc_admin/ship_canadapost.php on line 755 Warning: fwrite(): supplied argument is not a valid stream resource in /home/*******/public_html/osc_admin/ship_canadapost.php on line 756 Warning: fclose(): supplied argument is not a valid stream resource in /home/*******/public_html/osc_admin/ship_canadapost.php on line 757
I have double checked... and I have uploaded and changed the file permission to 777 here; /public_html/osc_admin/images/canadapost/
What is funny is the above error is pointing to my "catalog";
fopen(http://www.mysite.ca/shop/images/canadapost/611.pdf)Shouldn't it be pointing to;
osc_admin/images/canadapost/????????
#59 ONLINE
Posted 31 January 2011 - 01:57 AM
Below are my edits... just in case it helps someone else (I take no responsibily for these edits... all I can say is they worked for me).
In admin/ship_canadapost.php
change (on or about line 72);
$label_file = DIR_WS_IMAGES . 'canadapost/' . $order_id . '.pdf';to;
$label_file = '/home/******/public_html/admin/images/canadapost/' . $order_id . '.pdf';
Change (on or about line 755-757);
$fh = fopen($label_file, 'wb'); fwrite($fh, $response); fclose($fh);to;
$fh = fopen('/home/*****/public_html/admin/images/canadapost/' . $order_id . '.pdf', 'wb');
fwrite($fh, $response);
fclose($fh);
Change (on or about 795);
echo '<a href="' . $label_file . '">Open PDF</a></b><br><br>';to;
echo '<b>PDF Label: <a href="' . sprintf(LABEL_FILE,$order_id) . '" target="_blank">Open</a></b><br><br>';This also opens the label in a new window.
In admin/includes/languages/english/ship_canadapost.php
add (just below <?php);
define('LABEL_FILE', 'http://www.mysite.com/admin/images/canadapost/%s.pdf');
#60
Posted 21 February 2011 - 06:35 PM
"
Error: Failed check in ship_canadapost.php at line 347. This most likely means that Canada Post has changed their user interface. You need to update your Canada Post Automatic Shipping Labels module.
"
I was having trouble accessing the CP website this morning, but it seems to be available again.
Johan









