This long Easter weekend gave me some time to create a new theme for this blog. So after a day of work this is the result. I was a bit tired of the dark unreadable format. At the moment i am still tweaking here and there but it looks fine!
Archive for the ‘wordpress’ tag
A new look for lenss.nl
- On April 4th, 2010
- without comments
Fixing wp-e-commerce for iDEAL payments
- On January 30th, 2010
- without comments
Last Friday a friend approached me with a problem he was having. He was trying to setup a small webshop in a existing WordPress site. For the webshop he was using a plug-in called wp-e-commerce. He chose this plug-in because it is one of few that supports iDEAL payments. Because this shop only serves Holland the only payment option they need is iDEAL.
The iDEAL plug-in seemed to function properly. But the bank portal didn’t respond as expected. The first error i spotted was the mis configured referrer. The error code for this was.
unknown order/0/r
This didn’t solve the problem though. The message change from the previous to
unknown order/1/s
So i spend the next hours reading the manual he got from his bank. And came to the conclusion they do it just a bit different then for what this plug-in was written. The bank expects a hash to be send along each order made. This hash is build up from parts of the order and a secret string. This combined is hashed with the SHA-1 algorithm And added to the form as a hidden field. I wrote a small function to create hash and changed a few other small things in the order form.
The original form looks like this:
<script type="text/javascript">
var Amount = ;
var PSPID = "";
var AM;
if (isNaN(Amount)) {
alert("Amount not a number: " + Amount + " !");
AM = "";
} else {
AM = Math.round(parseFloat(Amount)*100);
}
</script>
<form method='post' action='' id='ideal_form' name='ideal_form'>
<script type="text/javascript">
document.write("
");
document.write("
");
</script>
<INPUT TYPE="hidden" NAME="SHASign" VALUE="4FF8C2FB03B0AA45EA5DE9503AEACB6B603DCFCC">
<input type="hidden" NAME="orderID" value="" />
<input type="hidden" name="currency" value="" />
<input type="hidden" name="language" value="" />
<input type="hidden" name="accepturl" value="">
<input type="hidden" name="cancelurl" value="">
<!--customer information starts-->
<input type="hidden" name="CN" value="=$name;?>">
<input type="hidden" name="EMAIL" value="=$email;?>">
<input type="hidden" name="ownerZIP" value="=$postcode;?>">
<input type="hidden" name="owneraddress" value="=$address;?>">
<input type="hidden" name="ownercty" value="=$country;?>">
<input type="hidden" name="ownertown" value="=$city;?>">
<input type="hidden" name="ownertelno" value="=$phone;?>">
<!--customer information ends-->
<input type="hidden" name="PM" value="iDEAL" />
I didn’t really understand why some values were written by JavaScript. So i removed the JavaScript lines and added the fields to the form. And after adding the hash function statement it looks like this.
<form method='post' action='' id='ideal_form' name='ideal_form'> <input type="hidden" NAME="PSPID" value="" /> <input type="hidden" NAME="orderID" value="" /> <input type="hidden" NAME="amount" value="" /> <input type="hidden" name="currency" value="" /> <input type="hidden" name="language" value="" /> <input type="hidden" name="accepturl" value=""> <input type="hidden" name="cancelurl" value=""> <!--customer information starts--> <input type="hidden" name="CN" value="=$name;?>"> <input type="hidden" name="EMAIL" value="=$email;?>"> <input type="hidden" name="ownerZIP" value="=$postcode;?>"> <input type="hidden" name="owneraddress" value="=$address;?>"> <input type="hidden" name="ownercty" value="=$country;?>"> <input type="hidden" name="ownertown" value="=$city;?>"> <input type="hidden" name="ownertelno" value="=$phone;?>"> <!--customer information ends--> <input type="hidden" name="PM" value="iDEAL" />
echo createSHA1Hash(array(
$purchase_log[0]['id'],
($amount*100),
get_option('ideal_currency'),
get_option('ideal_id'),
'[SHA1-IN-HASH]'
));
</form>
The function i can be placed anywhere in the page. Or a include file. Here’s the code. The only thing that has to be done is replace [SHA1-IN-HASH] with the Hash configured in the bank’s ideal admin.
function createSHA1Hash($hashOptions) {
$str = implode('', $hashOptions);
return '
';
}
While doing some searches i noticed there are more people having issues with this plug-in. So maybe this will save somebody a bit of time.
WordPress and NO-WWW rewrite
- On March 31st, 2009
- with 2 comments
On almost all of my domains i rewrite the WWW sub domain to the no-WWW version. This however went wrong on my own site. And i didn’t even notice it. My friend Alex pointed out that he couldn’t post any comment to the site anymore. So what went wrong?
Normally i use the following lines to do the rewrite.
RewriteCond %{HTTP_HOST} ^www\.lenss\.nl$ [NC]
RewriteRule ^(.*)$ http://lenss.nl/$1 [R=301,L]
My own site however still runs WordPress and this package comes with it’s own set of rewrite rules. And i just dropped my new lines under the WordPress rewrite rules.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteRule . index.php [L]
The result was that the WWW sub domain got rewritten to the no-www version. But everything after the trailing slash got dismissed. So rewrites for blog posts didn’t work. And all request would land on the main index. So i did some testing and combined the two sets of rewrite rules. This seems to function properly
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.lenss\.nl$ [NC]
RewriteRule ^(.*)$ http://lenss.nl/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteRule . index.php [L]
Next time i just need to check my changes more thoroughly. And thank you Alex for point that out to me.
Recent entries
Archives
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
Recent comments
- Mohammad Azhar wrote Hey Thijs, can you please tell me how are we go
- Christian Wania wrote Maybe there is one left for me to adopt? I´m one
- Sylvain wrote Damn it is so hard to find them !! If you still ha
- Thijs Lensselink wrote I didn't find an attribute yet for the file extens
- Sarath D R wrote How do i get the extension of the file ?
Stuff i read
- Adam Maschek
- Ajaxian
- Anton Shevchuk
- Bradley Holt
- Bruce Schneier
- Codinghorror
- Derek Illchuk
- Derick Rethans
- Easily Embarrassed
- ha.ckers
- Ivo Jansch
- Jon Lebensold
- Jon Udell
- Juozas Kaziukėnas
- Max Horvath
- nettuts.com
- phpdeveloper.org
- PHPFreakz
- PHPGG
- PHPGuru
- planet-php
- Planet-websecurity
- Quirksmode
- Rob Allen
- the daily WTF
- The Invisible Things
- The Spanner
- thinkphp.de
- uberChicGeekChick
- Vincent Bruijn
- Vladimir Vukićević
- World of Code








Thijs Lensselink is a 30 year old Web developer from The Netherlands.
With more then 10 years experience in the field of building and maintaining PHP
based web applications. Currently he works as a Freelance Web Developer under ...