http://www.mediawiki.org/wiki/Special:Code/MediaWiki/100096
Revision: 100096
Author: kaldari
Date: 2011-10-17 22:56:44 +0000 (Mon, 17 Oct 2011)
Log Message:
-----------
some minor improvements to the donate API
Modified Paths:
--------------
branches/fundraising/extensions/DonationInterface/gateway_common/donation.api.php
Modified:
branches/fundraising/extensions/DonationInterface/gateway_common/donation.api.php
===================================================================
---
branches/fundraising/extensions/DonationInterface/gateway_common/donation.api.php
2011-10-17 22:56:08 UTC (rev 100095)
+++
branches/fundraising/extensions/DonationInterface/gateway_common/donation.api.php
2011-10-17 22:56:44 UTC (rev 100096)
@@ -9,28 +9,34 @@
global $wgRequest, $wgParser;
$params = $this->extractRequestParams();
+ $options = array();
$gateway = $params['gateway'];
// If you want to test with fake data, pass a 'test' param set
to true.
// You still have to set the gateway you are testing though.
+ // It looks like this only works if the Test global variable
for that gateway is true.
if ( array_key_exists( 'test', $params ) && $params['test'] ) {
$params = $this->getTestData( $gateway );
+ $options['testData'] = $params;
}
$method = $params['payment_method'];
if ( $gateway == 'payflowpro' ) {
- $gatewayObj = new PayflowProAdapter();
+ $gatewayObj = new PayflowProAdapter( $options );
switch ( $method ) {
// TODO: add other payment methods
default:
$result = $gatewayObj->do_transaction(
'Card' );
}
} else if ( $gateway == 'globalcollect' ) {
- $gatewayObj = new GlobalCollectAdapter();
+ $gatewayObj = new GlobalCollectAdapter( $options );
switch ( $method ) {
// TODO: add other payment methods
+ case 'card':
+ $result = $gatewayObj->do_transaction(
'INSERT_ORDERWITHPAYMENT' );
+ break;
default:
$result = $gatewayObj->do_transaction(
'TEST_CONNECTION' );
}
@@ -39,38 +45,46 @@
}
//$normalizedData = $gatewayObj->getData();
+ $outputResult = array();
+ $outputResult['message'] = $result['message'];
+ $outputResult['status'] = $result['status'];
+ $outputResult['returnurl'] =
$result['data']['PAYMENT']['RETURNURL'];
+ $outputResult['errors'] = implode( '; ', $result['errors'] );
- // Some output
+ $this->getResult()->addValue( 'data', 'request', $params );
+ $this->getResult()->addValue( 'data', 'result', $outputResult );
+
+ /*
$this->getResult()->setIndexedTagName( $result, 'response' );
- $this->getResult()->addValue( 'data', 'request', $params );
$this->getResult()->addValue( 'data', 'result', $result );
+ */
}
public function getAllowedParams() {
return array(
- 'gateway' => $this->defineParam( 'gateway', true ),
- 'test' => $this->defineParam( 'test', false ),
- 'amount' => $this->defineParam( 'amount', false ),
- 'currency' => $this->defineParam( 'currency', false ),
- 'fname' => $this->defineParam( 'fname', false ),
- 'mname' => $this->defineParam( 'mname', false ),
- 'lname' => $this->defineParam( 'lname', false ),
- 'street' => $this->defineParam( 'street', false ),
- 'city' => $this->defineParam( 'city', false ),
- 'state' => $this->defineParam( 'state', false ),
- 'zip' => $this->defineParam( 'zip', false ),
- 'email' => $this->defineParam( 'email', false ),
- 'country' => $this->defineParam( 'country', false ),
- 'card_num' => $this->defineParam( 'card_num', false ),
- 'card_type' => $this->defineParam( 'card_type', false
),
- 'expiration' => $this->defineParam( 'expiration', false
),
- 'cvv' => $this->defineParam( 'cvv', false ),
- 'payment_method' => $this->defineParam(
'payment_method', false ),
- 'language' => $this->defineParam( 'language', false ),
+ 'gateway' => $this->defineParam( true ),
+ 'test' => $this->defineParam( false ),
+ 'amount' => $this->defineParam( false ),
+ 'currency' => $this->defineParam( false ),
+ 'fname' => $this->defineParam( false ),
+ 'mname' => $this->defineParam( false ),
+ 'lname' => $this->defineParam( false ),
+ 'street' => $this->defineParam( false ),
+ 'city' => $this->defineParam( false ),
+ 'state' => $this->defineParam( false ),
+ 'zip' => $this->defineParam( false ),
+ 'emailAdd' => $this->defineParam( false ),
+ 'country' => $this->defineParam( false ),
+ 'card_num' => $this->defineParam( false ),
+ 'card_type' => $this->defineParam( false ),
+ 'expiration' => $this->defineParam( false ),
+ 'cvv' => $this->defineParam( false ),
+ 'payment_method' => $this->defineParam( false ),
+ 'language' => $this->defineParam( false ),
);
}
- private function defineParam( $paramName, $required = false, $type =
'string' ) {
+ private function defineParam( $required = false, $type = 'string' ) {
if ( $required ) {
$param = array( ApiBase::PARAM_TYPE => $type,
ApiBase::PARAM_REQUIRED => true );
} else {
@@ -91,15 +105,19 @@
'city' => 'San Francisco',
'state' => 'CA',
'zip' => '94104',
- 'email' => '[email protected]',
+ 'emailAdd' => '[email protected]',
'country' => 'US',
- 'card_num' => '378282246310005',
- 'card_type' => 'american',
- 'expiration' => date( 'my', strtotime( '+1 year 1
month' ) ),
- 'cvv' => '001',
'payment_method' => 'card',
'language' => 'en',
+ 'card_type' => '1', // Is this valid for PayflowPro?
);
+ if ( $gateway != 'globalcollect' ) {
+ $params += array(
+ 'card_num' => '378282246310005',
+ 'expiration' => date( 'my', strtotime( '+1 year
1 month' ) ),
+ 'cvv' => '001',
+ );
+ }
return $params;
}
@@ -116,7 +134,7 @@
'city' => 'City',
'state' => 'State abbreviation',
'zip' => 'Postal code',
- 'email' => 'Email address',
+ 'emailAdd' => 'Email address',
'country' => 'Country code',
'card_num' => 'Credit card number',
'card_type' => 'Credit card type',
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs