21 May 08

Accepting PayPal Payments

As I prepare to bring my teaching website, Your Online Life, online, I’ve been fiddling with PayPal. I plan to use it to accept credit card payments, and I got lost within their documentation. But I managed to pull together what I need, and here’s what I found.

First, log in to PayPal, then click on the link to your Profile, then click on Website Payment Preferences. Type in a Return URL—this is the page on your site that PayPal will send the user back to after they’ve paid. Turn on Payment Data Transfer and save. The page will refresh with an Identity Token.

Now for some HTML. On the page where the user will pay for the item, enter something like this:

<form action="https://www.paypal.com/cgi-bin/webscr"method="post"><input type="hidden" name="cmd" value="_xclick"><input type="hidden" name="business" value="YOUR_EMAIL_ADDRESS"><input type="hidden" name="item_name" value="ITEM_NAME"><input type="hidden" name="item_number" value="1"><input type="hidden" name="amount" value="5.00"><input type="hidden" name="shipping" value="0.00"><input type="hidden" name="no_shipping" value="0"><input type="hidden" name="no_note" value="1"><input type="hidden" name="currency_code" value="USD"><input type="hidden" name="lc" value="US"><input type="hidden" name="bn" value="PP-BuyNowBF"><input type="image"src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif"border="0" name="submit" alt="PayPal"><img alt="" border="0"src="https://www.paypal.com/en_US/i/scr/pixel.gif"width="1" height="1"></form>

Obviously, change YOUR_EMAIL_ADDRESS and ITEM_NAME to your PayPal email address, and the name of the item your client will be buying. This will display a big “Buy Now!” PayPal button.

Now, go to the return page, the one that PayPal will redirect to. PayPal will send a transaction ID to this page, as an HTTP GET variable, named “tx”. Grab “tx”. Then post the following back to PayPal:

<form method=post
action="https://www.paypal.com/cgi-bin/webscr"><input type="hidden" name="cmd" value="_notify-synch"><input type="hidden" name="tx" value="TRANSACTION_ID"><input type="hidden" name="at" value="IDENTITY_TOKEN"><input type="submit" value="PDT"></form>

Plug in the value for “tx” in TRANSACTION_ID, and hardcode your identity token in the “at” field.

You should get back something like this:

SUCCESSfirst_name=Jane+Doelast_name=Smithpayment_status=Completedpayer_email=janedoesmith%40hotmail.compayment_gross=5.00mc_currency=USDcustom=Purchasing+cool+poster

A bit complicated, but it works.

Leave a Reply

I work for Amazon. The content on this site is my own and doesn’t necessarily represent Amazon’s position.