Tidbits @ Kassemi

A collection of opinions, thoughts, tricks and misc. information.

Thursday, September 22, 2005


Programming for Paypal

Yep. I'm back. Again after a little while. I just don't have all that much to give anybody yet, and don't like coming up here and writing when I have nothing interesting to say.

Before I begin bitching, let me first start on a lighter note. I've switched from PHPEclipse to Quanta for my PHP/HTML/Javascript work. And (being on a KDE desktop) I no longer have to put up with the memory hog that Eclipse really is. Quanta is more responsive and does just about everything that Eclipse did. I will definitely switch back to Eclipse when I get back into other languages (Java/C), as I really do like it, but just don't have the memory (512MB) or the money (0$) to get more. If you're doing work with PHP and are running KDE - you can run it elsewhere, but it will take more memory - you should consider taking a look at Quanta, which is probably already installed. Done with that, for now...

So I downloaded the documentation for Paypal's API yesterday, hoping to easily get some good Paypal programming into my project. I need something very simple:

  1. Person wants something, person selects it.

  2. Person wants to pay for that thing, and clicks button to do so.

  3. Person gets the options to pay via their paypal account, or through a credit card

  4. Information entered

  5. Information confirmed

  6. Confirmation Sent

Simple enough, right? I took a look at the documentation, and was overwhelmed, for the first time in a while. There were thousands of pages of information, and sorting through it all was just not an option. For something as simple as the above, it shouldn't take a thousand pages. So I searched around the paypal developer's section. I found the paypal SDK (available for several different languages, my language this year is PHP), and I downloaded it. I imported it into my project manager, and voila, 5.8 Megs of a wonderfully organized PEAR installation. Oh. I haven't yet written about my thoughts of PEAR. I'll do that soon... But for the meantime, I just don't like it. If I'm going to be using code, I'd much rather it be available to me like my other code is, not through some installable module...

So the PEAR stuff is disabled on my PHP installation, and I didn't feel like recompiling. So I continue my search, and enter the PayPal developer's forum. May I say how much useless, incomplete information lies within those walls? I did find a few posts that got me started, and finally realized that there was no way I would be getting through this without learning how to use SOAP. My first stop was the PHP manual, which told me that I needed to enable SOAP on my PHP install... I quickly opened up vi:


Saved the file on my server, and opened it up....

'./configure' '--prefix=/usr/local/php'
'--with-apxs2=/usr/local/apache2/bin/apxs' '--with-libxml'
'--with-zlib' '--with-bz2' '--enable-calendar' '--with-jpeg-dir'
'--with-tiff-dir' '--with-gd' '--with-png-dir' '--with-zlib-dir'
'--with-freetype-dir=/usr/include/freetype2/' '--with-t1-lib'
'--with-mysql=/usr/local/mysql' '--with-mysql-sock=/tmp/mysql_sock/mysql.sock'
'--enable-sockets' '--with-tidy' '--with-gmp' '--with-openssl'

DAMN! I need to recompile for that native PHP5 SOAP support, don't I!? ARGH!

$ su -c removepkg PHP
password: X
$ cd /source/php5
$ make clean
$ ./configure --prefix=/package --EVERYTHING + --enable-soap
$ make
$ su -c make install
$ cd /package
$ su
# makepkg PHPwithSOAP.tgz
# installpkg PHPwithSOAP.tgz

Okay. After restarting Apache, I had PHP with SOAP. I read the documentation at php.net more thoroughly, and got a pretty good idea of what I was doing. Now I may not yet be an expert with SOAP, but the following just seemed a little long:

$params = array(
'ItemTotal'=>array('_'=>'100.00', 'currencyID'=>'USD'),
'TaxTotal'=>array('_'=>'0', 'currencyID'=>'USD')

$params = array('DoExpressCheckoutPaymentRequest'=>$params);

Now why the heck would they make me waste the bandwidth and send them a string as long as "DoExpressCheckoutPaymentRequestDetails?" Can't they make that (and quite a few others) a little smaller? ARGH! Well, a few hours messing with my SOAP requests to Paypal, I finally got something working. I can now click a Pay now with Paypal button, and have a test account charge 100 dollars to a fake user. And the amount goes through! The only problem is the assloads of configuration I'm going to have to do to make this a good script that I can actually use for my sites!

End Rant.

Comments: Post a Comment

<< Home


August 2005   September 2005   October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006  

This page is powered by Blogger. Isn't yours?