r100279 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100278‎ | r100279 | r100280 >
Date:21:10, 19 October 2011
Author:khorn
Status:ok
Tags:fundraising 
Comment:
Merging the fundraising branch of DonationInterface back into trunk.
Re-upping the changes made to donation.api.php since this lengthy merge started.
As this is a mid-merge commit, the extension will be broken until the merge is completed.
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_common/donation.api.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/gateway_common/donation.api.php
@@ -5,33 +5,34 @@
66 * Call with api.php?action=donate
77 */
88 class DonationApi extends ApiBase {
 9+ var $donationData, $gateway;
910 public function execute() {
1011 global $wgRequest, $wgParser;
1112
12 - $params = $this->extractRequestParams();
13 - $options = array();
 13+ $this->donationData = $this->extractRequestParams();
1414
15 - $gateway = $params['gateway'];
 15+ $this->gateway = $this->donationData['gateway'];
1616
1717 // If you want to test with fake data, pass a 'test' param set to true.
1818 // You still have to set the gateway you are testing though.
1919 // It looks like this only works if the Test global variable for that gateway is true.
20 - if ( array_key_exists( 'test', $params ) && $params['test'] ) {
21 - $params = $this->getTestData( $gateway );
22 - $options['testData'] = $params;
 20+ if ( array_key_exists( 'test', $this->donationData ) && $this->donationData['test'] ) {
 21+ $this->populateTestData();
 22+ } else {
 23+ // If we need to do any local data munging do it here.
2324 }
2425
25 - $method = $params['payment_method'];
 26+ $method = $this->donationData['payment_method'];
2627
27 - if ( $gateway == 'payflowpro' ) {
28 - $gatewayObj = new PayflowProAdapter( $options );
 28+ if ( $this->gateway == 'payflowpro' ) {
 29+ $gatewayObj = new PayflowProAdapter();
2930 switch ( $method ) {
3031 // TODO: add other payment methods
3132 default:
3233 $result = $gatewayObj->do_transaction( 'Card' );
3334 }
34 - } else if ( $gateway == 'globalcollect' ) {
35 - $gatewayObj = new GlobalCollectAdapter( $options );
 35+ } else if ( $this->gateway == 'globalcollect' ) {
 36+ $gatewayObj = new GlobalCollectAdapter();
3637 switch ( $method ) {
3738 // TODO: add other payment methods
3839 case 'card':
@@ -48,11 +49,20 @@
4950 $outputResult = array();
5051 $outputResult['message'] = $result['message'];
5152 $outputResult['status'] = $result['status'];
52 - $outputResult['returnurl'] = $result['data']['PAYMENT']['RETURNURL'];
53 - $outputResult['errors'] = implode( '; ', $result['errors'] );
 53+ if ( array_key_exists( 'RETURNURL', $result['data']['PAYMENT'] ) ) {
 54+ $outputResult['returnurl'] = $result['data']['PAYMENT']['RETURNURL'];
 55+ }
 56+ if ( array_key_exists( 'FORMACTION', $result['data'] ) ) {
 57+ $outputResult['formaction'] = $result['data']['FORMACTION'];
 58+ }
 59+ if ( $result['errors'] ) {
 60+ $outputResult['errors'] = $result['errors'];
 61+ }
5462
55 - $this->getResult()->addValue( 'data', 'request', $params );
56 - $this->getResult()->addValue( 'data', 'result', $outputResult );
 63+ if ( $this->donationData ) {
 64+ $this->getResult()->addValue( null, 'request', $this->donationData );
 65+ }
 66+ $this->getResult()->addValue( null, 'result', $outputResult );
5767
5868 /*
5969 $this->getResult()->setIndexedTagName( $result, 'response' );
@@ -93,9 +103,9 @@
94104 return $param;
95105 }
96106
97 - private function getTestData( $gateway ) {
98 - $params = array(
99 - 'gateway' => $gateway,
 107+ private function populateTestData() {
 108+ $this->donationData = array(
 109+ 'gateway' => $this->gateway,
100110 'amount' => "35",
101111 'currency' => 'USD',
102112 'fname' => 'Tester',
@@ -109,7 +119,7 @@
110120 'country' => 'US',
111121 'payment_method' => 'card',
112122 'language' => 'en',
113 - 'card_type' => '1', // Is this valid for PayflowPro?
 123+ 'card_type' => 'american',
114124 );
115125 if ( $gateway != 'globalcollect' ) {
116126 $params += array(
@@ -118,7 +128,7 @@
119129 'cvv' => '001',
120130 );
121131 }
122 - return $params;
 132+ return true;
123133 }
124134
125135 public function getParamDescription() {

Status & tagging log