Category: PHP

Paypal encrypted button pitfalls

[repost because the original post was lost due to an error from my hosting provider]

I recently had to implement a small online payment system using an encrypted paypal button (‘after hours’). All of this in an existing modx cms installation. Modx is an absolutely handy, powerfull and totally undervalued cms system that doesn’t seem to get the attention it deserves. So there – my free mention.

I used this article and script from a company called Stellar Web Solutions as a starting point for encrypting the button data. (no need to reinvent the wheel)

Now, to keep others from falling into the same pitfalls as I did…

Bad OpenSSL Version

If you get the error:

The email address for the business is not present in the encrypted blob. Please contact your merchant.

Then you probably have OpenSSL version 0.9.8b which has a known issue with pipes, resulting in a cut-off output. This version unfortunately seems to be quite common on shared hosting solutions, who ofcourse are very reluctant to update their ‘working’ installations.

You could either upgrade your OpenSSL version, or refrain from using pipes. When using the Stellar Web script, you can try the fix posted here, which worked for me.

If you are not using the bad OpenSSL version, I’d suggest that at least something is wrong with the encrypted data.

Use the correct certificate

Don’t mix the sandbox with the live certificate, they are different!

Only use 2 decimals for values

I got the following error:

The link you have used to enter the PayPal system contains an incorrectly formatted item amount.

Turned out my calculated price contained too much decimal places for the value. It should have been only 2. When googling this I also found that it might mean you used a comma instead of a point or vice versa.

For such a widespread system, too bad paypal doesn’t give any clearer error messages, or provide more info on what the above errors could mean. I found lots of posts asking about the above, but had to really dig to find some answers.

Dew-NewPHPplinks category insert made easier

A while ago a friend of mine wanted to run an ‘internet directory’ using a php/mysql based script called Dew-NewPHPLinks.

He wanted to add a whole bunch of categories but the online standard way to do this really is a bit cumbersome to add more than a handfull at a time. I helped him out by writing a little php script that adds categories from a txt file with a fairly straightforward layout.

You can find the script here.

I really can’t remember the exact purpose of formatting/parameters, but the script itself contains a little example commented in which I remember was straightforward at the time.

Remember to change the path to your categories-textfile and your mysql connection parameters as needed.