Extension:DonationGateway

What Can This Extension Do?
The donation gateway process is an expandable group of extensions for accepting donations while offering a choice of currency and payment gateway. The process begins with a donation interface form. The form is tag extension which asks for the donation amount, currency and payment method (i.e., Paypal or credit card). The payment methods are each extensions process the donation. Each gateway supplies the donation extension with necessary information (through hooks); the form name value, the form display name, and the URL for redirection to the gateway. Amount and currency are passed to that URL so that the gateway extension can process the donation.

How You Can Help
Suggestions for improving security and better wiki-specific integration are welcome and encouraged. Also, other gateway extensions for other payment options are being developed, the more the merrier.

Current Status
A special page extension gateway for Payflow Pro is being tested and reviewed, as is a simple redirection to Paypal. The next version will include matching gateways with the currency they accept. There is no data saved locally.

Current Extensions:


 * donate_interface: tag extension to display form on Wiki Page
 * payflowpro_gateway: special page extension to accept credit cards through Payflow Pro
 * paypal_gateway: redirects donation to Paypal (in progress)

Usage
Add this tag to your Donate wiki page:

The hooks are set up on the extension_name.php page within the extension's directory. Two hooks are required, gwValue to pass the form's drop down menu values, and gwPage to pass the redirection URL. The form value must match the array key, the donation interface uses this key to decide which gateway the user has requested and send them to the right place.

Note: these hooks do not yet pass the currencies accepted by the gateway. This will be added in the next version.

For example, the PayflowPro Gateway is set up like this:

//Hooks required to interface with the donation extension (include on page)

//gwValue supplies the value of the form option and the name that appears on the dropdown menu

// $displayName os the name shown to the user

// $formValue is the value returned by the form 

// NOTE: the array keys must all match $formValue

$wgHooks['gwValue'][] = 'pfpGatewayValue';

$wgHooks['gwPage'][] = 'pfpGatewayPage';

// Hook to register value and name of this gateway, displayed in the form's drop down menu

function pfpGatewayValue(&$displayName, &$formValue) { $displayName['payflow'] = "Credit Card"; $formValue['payflow'] = "payflow"; //this value must match the array key

return true; }

// Hook to supply the page address of the payment gateway

// The user will redirected here with supplied data with input data appended (GET).

// For example, if $url[$key] = index.php?title=Special:PayflowPro

// the result will look like this: http://www.yourdomain.com/index.php?title=Special:PayflowPro&amount=75.00&currency_code=USD&payment_method=payflow

function pfpGatewayPage(&$url) { $url['payflow'] = "/index.php?title=Special:PayflowProGateway"; return true; }

The Paypal gateway (and all subsequent extensions) are set up the same way:

$wgHooks['gwValue'][] = 'uniqueIDGatewayValue';

$wgHooks['gwPage'][] = 'uniqueIDGatewayPage';

function uniqueIDGatewayValue(&$displayName, &$formValue) { $displayName['formValue'] = "Name User Sees in Drop Down Menu"; $formValue['formValue'] = "formValue"; //this value must match the array key, it represents the "name=formValue" on the form

return true; }

function uniqueIDGatewayPage(&$url) { $url['formValue'] = "URL to page processing the donation";

return true; }

PayflowPro Gateway Special Page Settings and Options
There are two form markups included in the code for displaying the form - one is a table and one is using fieldsets. Both include classnames for easier CSSing. The fieldsets version is commented out by default but can be switched manually.

The message displayed at the top of the form can be edited in the payflowpro_gateway.i18.php file. It is the 'from_message' option.

Payflow account settings should be edited in the included .inc file.

Paypal Gateway Settings
In the paypalGatewayPage function in paypal_gateway.php, replace shout%40fourkitchens%2ecom with your business email address, the one connected to your Paypal account. myname%40mybusinessurl%2ecome function paypalGatewayPage(&$url) { $url['paypal'] = "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=shout%40fourkitchens%2ecom&lc=US&no_note=1&no_shipping=1&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted";

Download instructions
COMING SOON

Installation
To install this extension, add the following to LocalSettings.php:

To Do

 * Donation Interface needs to check for currencies accepted by gateways


 * All gateways need to pass currencies accepted as set by extension user (currently allows all currencies that are accepted by Paypal (and Payflow Pro)


 * Paypal Gateway needs generic URL with generic Paypal username values that can be changed by extension user


 * PayflowPro Gateway needs to handle address verification logic


 * Better methods for securing Payflow Pro gateway are welcome and encouraged.