• Sage pay and Sage 50 shopping basket Integration

    Well you would think that this is well understood and well documented as sage are a pretty big payment gateway for credit card transactions. But it appears no, the fine details of the integration seem to be spread across multiple versions of documentation and worse than that across versions that look almost identical but have subtle changes in them. Even going through Sage’s support does not seem to shed light on these issues and all you get sent is yet another version of the documentation. Eventually you get all the pieces and manage to put everything together.

    The latest Sagepay protocol is v3.00 at the time of writing and v3.00 supports two methods to send your items to sagepay, one is a text based format with colon delimiters, the other an XML format.

    Note 1 : Sage 50 at the time of writing absolutely does not in any way imaginable support the basketXML format so don’t even bother using it. Sage 50 in fact only supports protocol v2.33 (which apart from basketXML is identical).

    Note 2: If you want to send items over so that they integrate with your stock system in Sage 50 you might be very tempted to try to use basketXML as it has a productSKU field which seems exactly what you were looking for, but as per note 1 it wont work and the correct way to do it (and it depends on where you got the documentation from if you have this little jem) is in the description field place the product SKU/unique identifier in square brackets eg [PRO001]My Product:1:1.99:0:1.99:199 .

    Note 3: To set the delivery charge you need to add a extra item to the basket text field, but ignore the documentation and do not set any unused fields to — set them to 0 instead, so if you have delivery with no tax it is Delivery:1:5.99:0:5.99:5.99 NOT Delivery:—:—:—:—:5.99 as per the instructions.

    Note 4: Delivery charges, the name of the delivery charges you pass in the basket eg “Delivery” “Carriage” needs to match the name in sage 50 in the accounts set up or the import wizard will not know what to do with it. I believe other extras can be passed across in the same way for other non stock type charges.

    Delivery charges don’t integrate correctly with sage 50, you have to set them up as a line item. Not impressed with the entire set up

  • node.js securing the username/password database

    Following on from my last post, I decided to have a look at a better solution for password hashing as the last example just used SHA1 which is far from optimal, so here are some changes to handle hashing via a pbkdf2 function which is far far better and far more secure.

    [Read More…]

  • node.js, express, mongo, and passport

    Building on the tutorial from http://cwbuecheler.com/web/tutorials/2013/node-express-mongo/ I wanted to add passport support to allow basic authentication to the site and there seemed to be a few too many conflicting and out of date instructions for what should have been a really simple process.

    The objective is local username/password authentication and as we are doing that we might as well be good and store a password hash not the actual password in the db. This could easily be extended to be properly salted etc.

    [Read More…]