CODEgrunt blog

Commentary and insight on web development and the Internet at large written with a wry smile and a hungry look.

MonerisHPP payment module for Prestashop (Canada only) - Fri Sep 03, 2010

For those looking for a potential shopping cart Prestashop is a cleanly written and actively supported codebase which is a compelling alternative to the other FOSS cart options. From this programmer's point of view it is the nicest internally and generally much easier to modify than other aging systems like osCommerce or Zen-Cart. However, being newer and originating from Europe means that Canadian merchant processors like Moneris are not supported out of the box either as a free or paid module.

To help with this situation I am making available the Moneris HPP (Hosted PayPage) module that I have written. This module allows shops to accept of payments using Merchant Processor Moneris' "Hosted PayPage" service. This module has been confirmed to work with Moneris Canada. The module is available free of charge but donations are also welcome if you feel like the module has helped you out.

Please note that this module DOES NOT WORK WITH THE US MONERIS service. For whatever silly reason, the US Moneris uses a different API which is similar functionally but requires different variables and only supports a single return URL. If you would like me to write a payment module for the US service, drop me a note for a quote.

The module also will work with Prestashop 1.4 if you add an include for "init.php" to the top of "order-confirmation.php". Remove the two existing include lines and replace them with:

require(dirname(__FILE__).'/../../config/config.inc.php');
require (_PS_ROOT_DIR_.'/init.php');
require(dirname(__FILE__).'/monerishpp.php');

If you require support or want assistance with integration then my normal consultation rates apply (contact me for a quote).

Download Moneris HPP Payment Module For Prestashop (tested with Prestashop 1.3.1)

As an aside, this module has also been submitted to the Prestastore site but as the approval process is taking inordinately long, I am posting locally here in case anyone needs to get a Moneris site rolling and cannot wait.

the joys of disabling Javascript - Mon May 31, 2010

I suppose that I am paranoid by nature, at least with respects to web technologies. Javascript for example is obviously a powerful, feature friendly way of creating dynamic content but the idea of client side scripting that is not under the user's control has always made me a little nervous (the vast majority of browser exploits rely on it for example). So my default browsing environment is with ads blocked and Javascript disabled.

More and more these days I am seeing artifacts of new school web designers either confusing or forgetting that client side is not under their control and that not everyone (or every thing such as the plethora of bots out there) sees the world through rosy Javascript coloured glasses. Take the NHL's web designers for a Javascript-less ride and we get this:

nhl.com with Javascript disabled

What's in the red circle? Let us take a look:

nhl.com with Javascript disabled says "values were inserted here in example"
//values were inserted here in example

It is hard to tell whether someone was taking "copy and paste" too literally or whether a 3rd party is injecting content they should not be but none the less, it makes for an amusing and informative Google search.

The obvious lesson is do not forget to test your code with Javascript disabled because at the very least Google will.

ISO country list, where art thou? - Wed Dec 30, 2009

While rewriting an old codebase of mine I decided that I should re-think how I was storing country data and switch to using country codes directly since those are standardized, immediately obvious when looking at the data and just as indexable by MySQL as numerical Indices. My old HTML piped through Awk generated MySQL table does not contain country codes so off to Google I went. Well somewhat surprisingly there are a lot of bad answers out there as to where to find an official list of country codes.

To hopefully safe time for those on the hunt, the official list of country codes can be found here:

The data is available in a number of formats including XML, plain text and viewable HTML.

topics: programming

carriage returns are false metal - Mon Nov 16, 2009

Ahh, carriage returns how I love thee. Today I managed to waste around 20 minutes banging my head against some very simple Javascript used to open a new window when the user clicks a link:

<a href="http://codegrunt.com" onclick="window.open(this.href); return false;">this is a link</a>

Trivial code, user clicks link and new window opens up. If life was only that simple - instead of the desired behaviour, the original URL was also firing and causing the originating window to load the URL as well. Arrrgh.

Can you see the bug? It is a trick question really as you would have probably have to view the source to notice it. The problem was a stray carriage return after "return" which causes Javascript to skip the return value of "false" and happily follow the link in both the current page and a new window. Now normally this would have been immediately obvious to me but my IDE is set up to nicely linewrap long lines which normally is pure awesome but unfortunately tricked me today when high LCD contrast (and perhaps not enough coffee) made the grey line wrap less obvious.

I hate these situations, something so simple going inexplicably astray. It becomes so easy to spiral off on dangerous tangents, "Oh no, maybe NoScript is doing something funny. . ." or "Crap, I bet something buried in an external library is messing with events!" Time consuming goose chases which could easily create their own mess as you wade frantically through trying to solve an issue that seems both impossible and ridiculous.

It has been a while but I again know how it feels to get punked by carriage returns.

simple MySQL handler class - Mon Aug 31, 2009

MySQL has come a long way since its early days what with stored query support and such. That said, the usage you will find in the average web application is still going to be limited to basic INSERT, UPDATE and SELECT queries. While there are no shortage of MySQL abstraction classes, all of the ones I have come across tend to either add too much overhead or do not really make the process of retrieving data from the backend any quicker or easier. Thus the creation of this MySQL handler class.

The intent with this class is not to be pretty or completist. It's goal is to provide the core functions needed for the average web application while keeping it simple. Query results are returned as multidimensional array using associative column names. It offers a few "magic" values by default ("insert_id" and "numrows") and has some utility functions thrown in for dealing with the result set.

I do not claim this is the most beautiful MySQL class out there. I can say however that it makes life a lot easier in many situations compared to either dealing with the database directly or using a full scale database abstraction layer.

A simple MySQL handler class.

blog

CODEgrunt consulting

Experienced PHP web developer.

$35 an hour, no job too small.

There is no replacement for integrity and experience.

Contact me for more information.

calendar

May 2012

Sun
Mon
Tue
Wed
Thu
Fri
Sat
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2