Tech Journal Back to Tech Journal

Testing PayPal actions using the PayPal Sandbox

There's a "Sandbox" for playing around. It's like a duplicate of paypal.com, except that none of the transaction affect anything outside the sandbox. No real money is moved (however fake-money can move between sandbox accounts), and no e-mails are sent (they can be send within the sandbox, and viewed in the "Test Emails" section of your DeveloperCenteral sandbox settings.)

1. Create a login for PayPal Developer Central [https://developer.paypal.com/]. The email for this login must be a different e-mail from your business account. This is also a "real" account - but on inasmuch as e-mail is concerned. It doesn't hold money. This is a "manager" account for creating accounts in the sandbox and interacting with the developer community (such as posting in the forums.)

2. Login to https://developer.paypal.com/

3. In your Sandbox settings, click on "Test Accounts"

4. Create a Seller account - this will simulate the store's user.
Country determines language, so use U.S.
Login Email seems to get ignored, and it just generates its own, but type something. It's a completely fake email address, and doesn't need to exist!
Password: this will be the password you will need to login using the account's login-email when you want to login to the Sandbox.

5. Click "Create Account", which will bring you back to the list of Test Accounts (now, no longer empty), and you'll see the Login Email (this is the actual login e-mail you should use to login to https://www.sandbox.paypal.com/)

6. Test the seller account by going to https://www.sandbox.paypal.com/ and typing in the Login Email the login email you saw in the account list, and for Password use the password you supplied when creating the account. You can modify all the settings here - change password, move fake-money, etc.

7. Let's create a buyer with some money. Go back to the PayPal Developer Central, and under Sandbox go to Test Accounts again. Click on "Create Test Account" again (this time it might be hidden in the "title bar" of the accounts list)

8. Choose "Buyer", and supply a login-email and password like when you created the Seller. Before clicking "Create Account", click on "Advanced Options", and give him some money. (The limit is $9999). Click on "Create Account" to create it.

9. Again, you may go to https://www.sandbox.paypal.com/ and log in to the account using the Login Email you see in the list of accounts. This one will be marked as "Personal" (as opposed to the "Business" that the Seller is.)

10. Read from https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=p/pdn/howto_checkout to see what you need to do a checkout. Make special note that the URL to the ACTION of the FORM starts with "www.sandbox.paypal.com" and not simply "www.paypal.com".

11. You may notice that you have an added $1 to orders, due to "handling". You can modify this by going to your Seller's account in the Sandbox, and clicking on "Profile". Go to your "Shipping Calculations"

12. Regarding PDT [https://www.paypal.com/IntegrationCenter/ic_pdt.html]: Also see in the Seller's Profile the "Website Payment Preferences":
- turn "Auto Return" to "On"
- set the Return URL to be the URL to the file that gets the transation ID
- turn "Payment Data Transfer" to "On"
Click on "Save" -- you'll be given an identity token... something like "la9ugCiOk0R86ScDY1fLFowVu1oATq30qjJhKx-RrqF15gcIAkbJlQIikau"

Same with IPN.

Problems and possible solutions

Q: even after setting "Auto Return", it doesn't return to the "return" URL!
A1: Make sure that your Seller (the "Business" user) to have a "Test Mode" (right-most column) to "Enabled" (just click on the "Disabled" link in the "Test Mode" column of the list of users in your Sandbox of Developer Central)
A2: you must URL-encode the URLs! (If you are sending them "raw")

Q: Even after turning on IPN, my server doesn't register any hits from paypal!
A1: Make sure the URL you have given to the server is of a valid hostname. Perhaps paypal.com's DNS server hasn't been updated with it yet.
A2: you must URL-encode the URLs! (If you are sending them "raw")

Q: my custom image in "image_url" is ignored!
A: you must URL-encode the URLs! (If you are sending them "raw")

Q: Even after turning on PDT and clicking on "Return to Metchant" - I don't get any POST params to my return-URL!
A1: You should proved a "notify_url" (no, I don't know why this works.)
A2: you sould also give pass a parameter of "rm" (return method) which should be set to "2" (for POST, and return all transaction variables)

 

See Also:
http://www.pdncommunity.com/pdn/board/message?board.id=basicpayments&message.id=368

Last updated on 2008-01-06 16:15:41 -0700, by Shalom Craimer

Back to Tech Journal