Friday, January 29, 2010

Sending Encrypted Data via URL?

Another lesson learned.

I am working on my PayPal Adaptive Payments application and I want buyers to be able to report when books are received or not received. Being the clever type of guy I am, I decided I should encrypt the data being sent in the email like the pay key that PayPal sends when first creating a sale through the AP. It is only good for a few hours after it is created for finishing the transaction but it is a great number for tracking payments. But I don't want it getting out to just anybody.

I tried doing a straight encryption but that ends up with all sorts of garbage that is not URL compatible. Being the genius guru I am, I figured I would just urlencode it to fix that problem.

Didn't work.

Turns out that it is pretty much impossible to reverse this process. Ends up with some garbage coming out. Oh well.

Just for everyones' enjoyment, the site I'm working on is at http://www.donomall.com. You can get to the book section from there. Anybody wanting to comment on the sites can do so. I have thick skin. Usually. I am NOT a designer. Keep that in mind. :)

Labels: , , ,

Wednesday, January 20, 2010

Bring in the APIs!

I am finally opening up my big project. Not pretty yet but it is functional so far. It has passed through months of testing and sobbing and pounding of head on monitor. But here it is. I'd love to see if you can break it.

What does it do? It combines shopping APIs from all over the place. eBay, Amazon, LinkShare, Commission Junction, Valore and many others to give the biggest internet comparison shopping site around. Is it slow? Not really. That took the most work but I did it with ColdFusion 8 and cfthread.

First thing I did was to build the API search functions into a CFC. Make the cfc an application object since it is used by everybody all the time. 1 function for each API. When run in sequence it was taking up to 1 minute to get any results. What was I to do?

Okay, I did threads. Each api call is a thread. This also helped if there was an error along the way in any of them it wouldn't jam up the whole thing. So this got results in around 15 seconds. What I did to take up the time was put an intermediate page in. You enter your search and you go to this "doing search" page where you see advertisements for other products. The searches themselves are actually happening in an iFrame that is 1px by 1px. When it is done loading it redirects the parent page to the results page.

BUT where are the results? To keep from jamming up my server memory I decided to jam up my database instead. Everybody who comes on the site gets their own temp table that holds the results of their searches. This way subsequent searches to narrow down the results are faster and easier. Of course this leaves the problem much like abandoned shopping carts. No biggy tho. Same solution. On session end the table is dropped. If that doesn't get it I have a scheduled task that runs every hour that clears out any tables that are over 2 hours old, which just happens to be the same as the session time out.  I seriously doubt anybody is going to be searching on my site for over 2 hours. But if they are they will get a new table because that is the first check I do in the onRequest function.

Anyway, it is still a work in progress but it is doing great so far. It is also the foundation for my entry into the PayPal new Advanced Payment API contest. Wish me luck on that. I have my application submitted for approval.

The site of my most awesome project? http://www.donomall.com/

Labels: , , , ,