PayPal
MediaWiki Extension
MW:Extension:PayPal is an extension for creating PayPal donation forms using a <paypal> tag. PokerCoder requested adding IPN support to the extension through this RentACoder job and has accepted User:Nad's bid to complete the work.
Installation
To install the extension, just save the code into your extensions directory as usual and include it from your LocalSettings.php file. You should also create a file of the same name as the extension but with the .log file-extension instead of .php (e.g. PayPal.log) and make it writable by the web server to allow IPN responses or debugging information to be logged there.
Testing IPN
The paypal sandbox allows all operations done within the paypal site to be performed within a test environment. It's useful to have a wildcard email domain so you can use any number of email addresses for different test accounts etc.
To set up a paypal sandbox environment suitable to test the MediaWiki PayPal extension, you must first sign up as a developer at https://developer.paypal.com using the email address that your paypal forms are set to (use a different password, or change the form's to another address completely if you like, but ensure that your forms match the paypal developer login).
Next set up two test accounts at https://www.sandbox.paypal.com (the session will be logged in as the master account, and the test account gets created under that). One of the test accounts will act as merchant and the other as buyer. You'll need an email address for each (they can be imaginary, but I recommend they be real if you have a wild card email domain to create unlimited addresses under). Both accounts need to have their email addresses confirmed and must have a bank account added and confirmed before test transactions can be done, so you need to log in to each and go through those processes. Note that the emails which get sent during this process are not physically sent outside the sandbox environment - you must retrieve them from the developer site's "test emails" section.
Finally you need to tell the PayPal MediaWiki extension to use the test merchant account. To do this, set the $wgPayPalTest global variable to the email address of the merchant test account in your LocalSettings.php file, but don't change anything in your form definitions - these must stay set to the email of the master account which you used to log in to the main paypal developer site (which I personally prefer to keep the same as the real business email so the forms don't need to change when switching from testing to real).
To make a test transaction first go to your form and click the button like usual. If it asks you to log into the developer site first, you need to log in to this with your master email address, then go back to the form and click buy again, this time it should take you to a normal looking paypal buy screen, at the top it should have in a large font the email address of the merchant test account you created. In the login form at the bottom, enter the email address and password of the buyer test account you created. Proceed with the transaction as normal and then click "return to merchant" when done.
If the transaction has worked correctly, you'll see the total update in the forms text (this could take a few seconds depending on the type of transaction and how long it takes paypal to validate it). If it has not worked, then the log file you should have created when following the installation instructions of the MediaWiki PayPal extension will hopefully be of some help.
IPN Developer Resources
Instant Payment Notification, included with Website Payment products, Express Checkout, and Standard Checkout, is available to PayPal Premier and Business members. Instant Payment Notification allows you to integrate your PayPal payments with your website's back-end operations, so that you get immediate notification and authentication of any PayPal payments and disputes you may receive.
When a customer makes a payment to you, PayPal will post a notification to your server at a URL you specify. Included in this notification will be all of your customer's payment information (e.g. customer name, amount) as well as a piece of encrypted code. When your server receives a notification, it will then post the information, including the encrypted code, back to a secure PayPal URL. PayPal will authenticate the transaction by checking the encrypted string. This post-back of the IPN data to PayPal prevents "spoofing," so you can be sure that the IPN came from PayPal. Upon verification, PayPal will send confirmation of its validity back to your server.
- IPN at PayPal Integration Center
- IPN Introduction for Developers
- DesignerTuts Tutorial
- IPN Manual
- IPN Technical Overview
- Instant Code Samples
- IPN Techniques
- Basic Inventory Management Using IPN
- IPN Test Environment
- IPN PHP Script Generator
- Good IPN tech info