• 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
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.webp

Confirm:
02.webp

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

03.webp

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.webp

Buyer Account:
05.webp

Test Accounts Overview:
06.webp

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.webp

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.webp

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.webp

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.webp

...continued.
 
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.webp

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.webp

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

13.webp

:)
 
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.
 
Manuals like this one are invaluable for the community... thank you very much indeed for your clear instructions, Shadab!
 
Whoa! I didn't know you could do this! Real testing? What will they come up with next? Thanks, man!
 
Top Bottom