While trying to figure out of PayPal Payment Data Transfers I came over an issue that caused my cURL requests to fail.
Category Archives: Software Development
AppleScript: Get name of files in a folder without extension
Have been dipping my toes into some AppleScript today. Boy do I prefer languages that are not so wordy and English… And boy is some things not the easiest to do… Anyways, I wanted to get the names of all files in a certain folder. This is quite easy, but the twist is that I didn’t want the file extension. This was not so easy…
So, in case anyone else needs to do this, or if anyone would happen to have a better, or faster, or more robust way to do this, I share it here. Please comment if you do know of anything which can improve it.
MySQL: Filtering with Regular Expressions
Today I wanted to list all all users in a database who had been too lazy to uppercase the first letter in their name. But how can you do that in MySQL? With regular expressions such a check would be easy to write, but this was in MySQL, not in for example PHP… but wait a minute… MySQL actually supports Regular Expressions? Yes, it does! I honestly had no clue.
PHP: Output a number of bytes in a human readable way
Would you be able to say how much 167892598784 bytes are without spending quite some time thinking about it first? Large amounts of bytes are rarely very readable to people. Not for me anyways.
Just stumbled over a handy function to make that number of bytes a bit more readable for us humans. I found it in a comment in the PHP manual and figured I could note it down here so I don’t lose it and in case someone else could need it. A function like that is just bound to come in handy some day…
PHP Tutorial: PayPal Payment Data Transfers (PDT)
Say you have a PayPal “Buy Now”-button on your website and you have assigned return URLs like http://example.com/order?done and http://example.com/order?canceled. You can then welcome the user back after a successful payment. But what if you wanted to say something more interesting than just “hey, welcome back” when they click on that “Return to Merchant”-button? And can you know if the order was actually done or canceled? Maybe you’d like to log the transaction in your database and mark a payment as complete or something like that too? In that case you sure can’t trust a simple flag in the address bar…
Payment Data Transfer (PDT) is a secure method to retrieve the details about a PayPal transaction so that you can display them to your customer. It is used in combination with Website Payments Standard, so that after a customer returns to your website after paying on the PayPal site, they can instantly view a confirmation message with the details of the transaction. — PayPal
I’ve tried to figure out how to use PDT and found that most samples and classes to build from are usually quite ugly, old or outdated. I didn’t find them too useful anyways… So, therefore, I’ve tried to do my own thing based on the documentation found on the PayPal Developer websites. (Seriously, how many versions of documents and developer websites do they have anyways? It’s like a complete jungle…)
Since the documentation was a bit of a mess, I thought I make a small tutorial on the steps needed to get started. That way I can learn it better myself and hopefully help some other poor souls that need to figure this stuff out as well. Please provide feedback if you have any! Would love to make this page nicer and clearer if possible
Getting started with PayPal Sandbox
I need to figure out how to use the PayPal IPN thing. And for experimentation with PayPal things, you should of course not use live accounts. You could, but it’s probably not the best idea. Luckily, PayPal has something they call a Sandbox where you can create and manage fake PayPal accounts that you can experiment with.
It’s not very difficult to get started, but there was a couple of points that wasn’t totally clear to me at first. Therefore I thought I could document it here.
jQuery: Nice and smooth hover effect
Needed to add a hover effect on some table rows and wanted to make it look nice. Think I managed to get it quite smooth in the end and thought I could share it.