PayPal Sandbox Tutorial - Wully616/PUDS GitHub Wiki

In order to test PayPal applications properly the best thing to use is PayPals sandbox website. This tutorial will explain how to configure PUDS to use the sandbox as well as some basic usage of the sandbox so you may test your configurations before launching a live system.

Please make sure you have followed the Installation tutorial first!

https://github.com/Wully616/PUDS/wiki/Installation-Tutorial

First things first, log onto the PayPal developer website by clicking login on the top right, you use your normal PayPal E-mail and password to log in here. https://developer.paypal.com/

paypal_dev

Click the application button on the top left side of the website.

paypal_login

Click the sandbox accounts on the left side of the website under Applications.

sandbox_accounts

You should now see this page, this holds all the sandbox accounts you use for testing. They are fake paypal accounts that work only with the sandbox website (www.sandbox.paypal.com)

sandbox_accounts2

To test PUDS you require two sandbox accounts, one to donate, one to receive so go ahead and click create account in the top right. Fill in the details for the test account, the email does not need to be a real one! Just so that it is unique on the sandbox site. Type in a password, which you need to remember! Give the account some money and a first and last name if you wish and click create account.

account1

Here are my two test accounts: [email protected] & [email protected]

accounts

That is the PayPal side of things configured, now for PUDS.

You should have already configured and installed PUDS as per the installation instructions. We need to change some things so it works with the sandbox though.

First, TAKE A BACKUP OF YOUR CONFIG.PHP!

Next, open up config.php on your webserver.

Under MySQL Database Configuration, change $DBTABLE to a different name such as test (just so you don't fill up your real table with test information which may be incomplete.

$DBTABLE = "test";

Under PayPal Info, comment out the first $payPalURL and uncomment the second one.

//$payPalURL = "https://www.paypal.com/cgi-bin/webscr";

$payPalURL = "https://www.sandbox.paypal.com/cgi-bin/webscr";

Change the $payPalEmail to one of your test accounts, eg [email protected] in my case.

$payPalEmail = "[email protected]";

PUDS is now configured to use the PayPal sandbox, remember to revert your settings after testing.

Now go onto your donation page on your website. I highly recommend you put in your own SteamID for testing purposes.

donatetest

When you click donate you should see Test Site in the bottom left corner of the PayPal page and it should say the test account e-mail you put into config.php in the top left. If you do not see this go back and check your config.php

Log into pay for the donation with your other test account, in my case [email protected].

paypal_testpage

Pay for the donation with the account, to check if the donation was successful, on your webserver check the error_log file for php errors, log.txt for details about the ipn.php script and the ipn_log.txt shows the responses from PayPal for the actual donation.

A successful ipn_log.txt will show the following:

[08/19/2013 1:40 PM] - SUCCESS! IPN POST Vars from Paypal: mc_gross=3.00, protection_eligibility=Ineligible, payer_id=XD8APB3UD2HTG, tax=0.00, payment_date=04:40:23 Aug 19, 2013 PDT, payment_status=Pending, charset=windows-1252, first_name=William, option_selection1=wully, option_selection2=STEAM_0:0:14806053, notify_version=3.7, custom=, payer_status=verified, business=[email protected], quantity=1, verify_sign=Asyr9EozU8RNocAf.wAwpYKtscZ4AlbSGMirDDupA-BuD2sgRCi7zM3l, payer_email=[email protected], option_name1=In-Game Name, option_name2=SteamID, txn_id=6HU45817NW790402J, payment_type=instant, last_name=Robb, receiver_email=[email protected], receiver_id=RW4T3J3T5TTZW, pending_reason=multi_currency, txn_type=web_accept, item_name=PUDS - Game Server Donation, mc_currency=GBP, item_number=, residence_country=US, test_ipn=1, handling_amount=0.00, transaction_subject=, payment_gross=, shipping=0.00, ipn_track_id=7b926b27e06dc, IPN Response from Paypal Server: HTTP/1.1 200 OK

As you can see on the first line, if it says SUCCESS the IPN was successful, the variables in the log show the information submitted to paypal, such as the persons name, steamID, e-mail, the mc_gross shows the price.

In log.txt a successful donation should look as follows:

Connected to database

Table does not exist, creating table.

IPN Validated.

[email protected] wully 3.00 STEAM_0:0:14806053 gold

Added to database.

IP: 149.210.141.26 Port: 27065 Password: password removed Command: ulx adduserid STEAM_0:0:14806053 gold

(Console) added [WB] Wully to group gold

ServerLog: [ULX] (Console) added [WB] Wully to group gold

If there is any errors, they will be displayed here or within the ipn_log.txt.

Any issues please post on github or the ULX release thread.http://forums.ulyssesmod.net/index.php/topic,6524.0.html