r78095 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78094‎ | r78095 | r78096 >
Date:21:04, 8 December 2010
Author:awjrichards
Status:deferred
Tags:
Comment:
Added support for recurring payments
Modified paths:
  • /trunk/extensions/ContributionTracking/ContributionTracking_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContributionTracking/ContributionTracking_body.php
@@ -90,6 +90,7 @@
9191 // Set the action and tracking ID fields
9292 $repost = array();
9393 $action = 'http://wikimediafoundation.org/';
 94+ $amount_field_name = 'amount'; // the amount fieldname may be different depending on the service
9495 if ( $gateway == 'paypal' ) {
9596 $action = 'https://www.paypal.com/cgi-bin/webscr';
9697
@@ -104,17 +105,28 @@
105106 $repost['business'] = 'donations@wikimedia.org';
106107 $repost['item_name'] = 'One-time donation';
107108 $repost['item_number'] = 'DONATE';
108 - $repost['cmd'] = '_xclick';
109109 $repost['no_note'] = '0';
110 - $repost['notify_url'] = 'https://civicrm.wikimedia.org/fundcore_gateway/paypal';
111110 $repost['return'] = $returnto;
112 -
113111 $repost['currency_code'] = $wgRequest->getText( 'currency_code', 'USD' );
114112
115113 // additional fields to pass to PayPal from single-step credit card form
116114 $repost[ 'first_name' ] = $wgRequest->getText( 'fname', null );
117115 $repost[ 'last_name' ] = $wgRequest->getText( 'lname', null );
118116 $repost[ 'email' ] = $wgRequest->getText( 'email', null );
 117+
 118+ // if this is a recurring donation, we have add'l fields to send to paypal
 119+ if ( $wgRequest->getText( 'recurring_paypal' ) == 'true' ) {
 120+ $repost[ 't3' ] = "M"; // The unit of measurement for for p3 (M = month)
 121+ $repost[ 'p3' ] = '1'; // Billing cycle duration
 122+ $repost[ 'srt' ] = '12'; // # of billing cycles
 123+ $repost[ 'src' ] = '1'; // Make this 'recurring'
 124+ $repost[ 'sra' ] = '1'; // Turn on re-attempt on failure
 125+ $repost[ 'cmd' ] = '_xclick-subscriptions';
 126+ $amount_field_name = 'a3';
 127+ } else {
 128+ $repost['cmd'] = '_xclick';
 129+ $repost['notify_url'] = 'https://civicrm.wikimedia.org/fundcore_gateway/paypal';
 130+ }
119131 }
120132 else if ( $gateway == 'moneybookers' ) {
121133 $action = 'https://www.moneybookers.com/app/payment.pl';
@@ -134,9 +146,9 @@
135147 }
136148
137149 // Normalized amount
138 - $repost['amount'] = $wgRequest->getVal( 'amount' );
 150+ $repost[ $amount_field_name ] = $wgRequest->getVal( 'amount' );
139151 if ( $wgRequest->getVal( 'amountGiven' ) ) {
140 - $repost['amount'] = $wgRequest->getVal( 'amountGiven' );
 152+ $repost[ $amount_field_name ] = $wgRequest->getVal( 'amountGiven' );
141153 }
142154
143155 // Tracking

Status & tagging log