• 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…]

  • Spiroplot – An HTML 5 and Javascript spirograph plotter

    Spirograph plot

    Once upon a time I had a cool toy known as spirograph, I can remember this from when I must have been only 6 or 7 and use to have great fun drawing the shapes that it produced. It was basically a load of plastic circles with gears on the edge and you had fixed peices that and moving peices with holes for pens. The moving peices could be rotated around either the inside or outside of the fixed peices and each had a variety of hole positions for the pen. This produced all kinds of wonderful plots and patterns. So I had 5 minutes free and created an HTML 5 plotter which is included in this post below, it is capable of both the Hypotrochoid inside) and Epitrochoid (outside) types of plot. The controls are as follows, Radius A is the size of the fixed peice, if the radius value is negative then Hypotrochoid plots are produced if it is positive then Epitrochoid plots are produced. The Radius B sets the size of the moving peice. The offset parameter sets the % from the edge to the centre of the moving piece where the pen is. Original Spirograph had fixed holes for pens, but as this is software it does not have the same physical limits. The Gearing factor can be automatic which rotates the B peice at the correct gear ratio based on the A/B radius or you can use manual gearing inputs for plots that cannot be produced with physical Spirograph. The Auto Gear tick box enables/disables manual gear ratio entry. The other tick box shows/hides the tools that form the plots.

    Spiroplot

    A HTML 5 spirograph plotter. If you see nothing or it does not work you need a HTML5 compatable browser and javascript enabled.

  • Debian wordpress multisite woocommerse bug?

    For some unknown reason following the instructions I wrote out in the last post woocommerce broke and it looks like somehow it is getting the PLUGIN_URL wrong and using the PLUGIN_DIR instead/appended to so you end up with some horrible url requests from the woocommerce scripts eg :-

    File does not exist: /var/www/wordpress/www.example.com/plugins/var, referer: http://www.example.com/
    

    The easiest solution to this is to create the symlink :-

    /var/lib/wordpress/wp-content/plugins/var/lib/wordpress/wp-content -> /var/lib/wordpress/wp-content
    

    To fudge the problem. Its only woocommerce doing this out of all the plugins I have installed so far, so not 100% sure if its a general WordPress bug or a woocommerce bug. PITA but trivial to work around

  • WordPress debian multisite

    Before I forget, or kill some one next time I have to do this, I had better write it down.

    WordPress supports multisite out of the box these days, but Debian supported it long ago and to be honest I would rather use a Debian security team version of wordpress to get my automatic updates and security fixes along with the rest of the server security rather than having to manually mess about unpacking multiple tarballs to update multiple wordpress sites

    to install wordpress on a clean system

    apt-get install wordpress mysql-server

    Yep wordpress only recommends mysql-server so you need to add mysql-server too.

    By default the Debian magic scripts will work with data in /srv/www, I did not want this. I wanted my data under /var/www/wordpress/

    The two files

    /usr/share/doc/wordpress/examples/apache.conf
    /usr/share/doc/wordpress/examples/setup-mysql.gz

    are your friends here, the first one are some example apache confs to make the multisite magic work the second is a quick way to setup an empty wordpress site and to create the mysql user, the config and the folder structure needed.

    Before you do that, enable some apache modules to let the magic work, you need vhost_alias and rewrite as a minimum

    a2enmod vhost_alias rewrite

    Next copy the setup-mysql script, unpack it and mod it to the required folder structure :-

    cd ~
    cp /usr/share/doc/wordpress/examples/setup-mysql.gz ~/
    gzip -d setup-mysql.gz
    sed -i 's/\/srv\/www\//\/var\/www\/wordpress\//g' setup-mysql
    chmod +x setup-mysql
    ./setup-mysql -n databaseuser name.of.site.com
    

    where databaseuser is the name you want to use for mysql access (account will be created and all set up) and name.of.site.com will be the the physical name used in the /var/www/wordpress/ folder to keep the sites separate.

    Now the final thing to do is to configure apache

    What you probably want to do is create a new default virtual host that will grab any requests and handle them BUT do this as a lower priority to any static sites you may have. So create a new file in /etc/apache2/sites-available/50-wordpress with the following content :-

    ## Virtual host VirtualDocumentRoot
    
            NameVirtualHost *:80
    
            
            UseCanonicalName Off
            VirtualDocumentRoot /usr/share/wordpress
            Options All
    
            # wp-content in /srv/www/wp-content/$0
            RewriteEngine On
            RewriteRule ^/wp-content/(.*)$ /var/www/wordpress/%{HTTP_HOST}/$1
            
    

    Which is pretty much the first example in /usr/share/doc/wordpress/examples/apache.conf with my folder locations tweaked as I like them.

    then enable the site

    a2ensite 50-wordpress

    You will with this setup also want to remove the default

     a2dissite default 

    Then if you need to add any static sites in the future add them as regular vhosts with site names starting with numbers less that 50- then they will take priority. If no static matches are found it will try to dynamicly match via the wordpress configuration. If this fails you will get a ungraceful message from the debian wp-config.php file but I’m not really bothered about that at this stage.

    and finally don’t forget to restart the web server

    service apache2 restart
  • Sams4s RS232 protocol

    I’ve just launched my new project to be able to talk to and program Sams4s cash registers using open source tools, the code can be found at https://github.com/robincornelius/ECRComms it is not finished but what of it there is currently works with an ER-230 and in theory the backup/download should work with many other models. The actual editing will be model/version dependent and I will need help from others to make it work with more than just the two models I have here (the ER230 and the ER380M).

    I’ve also started a documentation project that can be found here this is the documentation of the protocol and file format as I work it out.

  • Finally have a site again

    It was the 17th Aug 2012 when I realised my new version of this website had vanished from the internet. I guess it serves me right for trying to use a free webhost when I have a perfectly good Virtual server I should have been using.

    I tried to use 000webhost and install a word press site there. And all seemed good, But a week or so later the site was gone, my account blocked and the only thing I could find out was I used too many resources on the server. It was only a fucking wordpress site, what do they expect people to host, one single static html page that says Hello World?. What annoyed me the most though was there were no warnings, no emails nothing. They just yanked the site and then held you ransom to upgrade to premium to get it back.

    Anyway that badness is a long time in the past, but i’ve been so busy I’ve only now found the time to really do anything about it and fix the site. I can’t really believe it was that long ago but thats the date on my twitter posts venting my anger.

    So here back again is another wordpress site. Somewhere to put posts on various little projects that I am working on and hopefully I can start posting a new open source project that I am working on here very soon.

  • September Hours

    Now the “crazyness” is behind i’ve been going back and filling out my time sheets. My september hours looked like this

    SepHours

    So thats only 271.h hours for September worked ;-/