[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.