r99830 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99829‎ | r99830 | r99831 >
Date:23:29, 14 October 2011
Author:kaldari
Status:ok
Tags:fundraising 
Comment:
follow-up to r99825, improving test functions
Modified paths:
  • /branches/fundraising/extensions/DonationInterface/gateway_common/donation.api.php (modified) (history)

Diff [purge]

Index: branches/fundraising/extensions/DonationInterface/gateway_common/donation.api.php
@@ -10,24 +10,27 @@
1111
1212 $params = $this->extractRequestParams();
1313
 14+ $gateway = $params['gateway'];
 15+
1416 // If you want to test with fake data, pass a 'test' param set to true.
1517 // You still have to set the gateway you are testing though.
1618 if ( array_key_exists( 'test', $params ) && $params['test'] ) {
17 - $params = $this->getTestData();
 19+ $params = $this->getTestData( $gateway );
1820 }
1921
20 - $gateway = $params['gateway'];
2122 $method = $params['payment_method'];
2223
2324 if ( $gateway == 'payflowpro' ) {
2425 $gatewayObj = new PayflowProAdapter();
2526 switch ( $method ) {
 27+ // TODO: add other payment methods
2628 default:
2729 $result = $gatewayObj->do_transaction( 'Card' );
2830 }
2931 } else if ( $gateway == 'globalcollect' ) {
3032 $gatewayObj = new GlobalCollectAdapter();
3133 switch ( $method ) {
 34+ // TODO: add other payment methods
3235 default:
3336 $result = $gatewayObj->do_transaction( 'TEST_CONNECTION' );
3437 }
@@ -35,16 +38,18 @@
3639 $this->dieUsage( "Invalid gateway <<<$gateway>>> passed to Donation API.", 'unknown_gateway' );
3740 }
3841
39 - $normalizedData = $gatewayObj->getData();
 42+ //$normalizedData = $gatewayObj->getData();
4043
4144 // Some output
4245 $this->getResult()->setIndexedTagName( $result, 'response' );
 46+ $this->getResult()->addValue( 'data', 'request', $params );
4347 $this->getResult()->addValue( 'data', 'result', $result );
4448 }
4549
4650 public function getAllowedParams() {
4751 return array(
4852 'gateway' => $this->defineParam( 'gateway', true ),
 53+ 'test' => $this->defineParam( 'test', false ),
4954 'amount' => $this->defineParam( 'amount', false ),
5055 'currency' => $this->defineParam( 'currency', false ),
5156 'fname' => $this->defineParam( 'fname', false ),
@@ -74,8 +79,9 @@
7580 return $param;
7681 }
7782
78 - private function getTestData() {
 83+ private function getTestData( $gateway ) {
7984 $params = array(
 85+ 'gateway' => $gateway,
8086 'amount' => "35",
8187 'currency' => 'USD',
8288 'fname' => 'Tester',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99825making api testable with bogus datakaldari22:44, 14 October 2011

Status & tagging log