• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Test your Account Upgrades using the PayPal Sandbox

Shadab

Well-known member
#1
PayPal has an excellent sandbox environment where you can simulate transactions for your web application. And XenForo supports it out of the box. So you can quite easily test your user account upgrades, without actually transferring any real money. I've outlined the procedure here. Hope you'll find it useful. :)

Preparation

Open /library/XenForo/ControllerPublic/Account.php (line 1154-1155):
Find:
PHP:
			//'payPalUrl' => 'https://www.sandbox.paypal.com/cgi-bin/websrc',
			'payPalUrl' => 'https://www.paypal.com/cgi-bin/websrc',
Replace with:
PHP:
			'payPalUrl' => 'https://www.sandbox.paypal.com/cgi-bin/websrc',
			//'payPalUrl' => 'https://www.paypal.com/cgi-bin/websrc',
Basically, uncomment the sandbox URL and comment out the real paypal URL. If you are not comfortable with performing a file edit, please say so. I'll provide an addon which would swap these urls for you without any edits.

Oh, and once you're done with the testing. Revert this change!

Setup the Sandbox

1. Go to: https://developer.paypal.com/ and sign up for a sandbox account. You'll have to use an email address different from the one you used to sign up for your PayPal account. Sign up and confirm the email address.

Signup:
01.png

Confirm:
02.png

2. Login to the PayPal Sandbox environment and create a "Preconfigured" test account.

03.png

3. You'll have to setup two preconfigured test accounts. One as a buyer, and one as a seller. Make sure you are creating verified accounts and with some fake-funding, enough to perform your transactions. The configuration forms are shown in the screenshots below:

Seller Account:
04.png

Buyer Account:
05.png

Test Accounts Overview:
06.png

Setup your Account Upgrades

4. Go to: Admin Panel » Users » User Upgrades. Setup your real upgrades (which the registered users will purchase later on) and point your payment gateway to the fake "seller" account you just created. In my case the test1 account is the Seller/Business account.

07.png

Make the Purchase

5. Open up another browser and login as some other user. I'll be using "Test User 1" for purchasing the account upgrades. Go to the Account Upgrades page and proceed to purchase any of your upgrades.

08.png

6. When you are presented with the PayPal login page, use the fake "buyer" account you had created in the sandbox. In my case "test2" is the Buyer/Personal account.

Login with Fake Buyer Account:
09.png

Once you login, confirm the payment and return to the merchant website.
You'll be presented with the usual "Thank you for the Purchase" page.

10.png

...continued.
 

Shadab

Well-known member
#2
Confirmation?

7. Wait for a short while, then head over to your Admin Panel.
Goto: Users » Active User Upgrades. The test user should now be listed on this page.

11.png

8. Any permission and/or styling preferences will now be applicable to that user. In my case, the "Test Upgrade 1" added a secondary usergroup for which a different user title and username CSS was specified.

12.png

9. You can now safely delete the buyer and seller test accounts from the sandbox.

13.png

:)
 

Brogan

XenForo moderator
Staff member
#3
Great stuff Shadab, I wasn't aware this was possible so I'll be doing this to go through the upgrade process to check how it all works.
 

Grover

Well-known member
#5
Manuals like this one are invaluable for the community... thank you very much indeed for your clear instructions, Shadab!