http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96595
Revision: 96595
Author: khorn
Date: 2011-09-08 18:57:50 +0000 (Thu, 08 Sep 2011)
Log Message:
-----------
More DonationInterface refactoring. Added a couple rudimentary tests and put
everything back to a working state.
Modified Paths:
--------------
branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
branches/fundraising/extensions/DonationInterface/tests/DonationInterfaceTest.php
Modified:
branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php
===================================================================
---
branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php
2011-09-08 18:54:08 UTC (rev 96594)
+++
branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php
2011-09-08 18:57:50 UTC (rev 96595)
@@ -28,9 +28,49 @@
function getResponseData( $response );
/**
+ * Actually do... stuff. Here.
+ * TODO: Better comment.
+ * Process the entire response gott'd by the last four functions.
+ */
+ function processResponse( $response );
+
+ /**
* Anything we need to do to the data coming in, before we send it off.
*/
function stageData();
+
+ /**
+ * defineTransactions will define the $transactions array.
+ * The array will contain everything we need to know about the request
structure for all the transactions we care about,
+ * for the current gateway.
+ * First array key: Some way for us to id the transaction. Doesn't
actually have to be the gateway's name for it, but I'm going with that until I
have a reason not to.
+ * Second array key:
+ * 'request' contains the structure of that request.
Leaves in the array tree will eventually be mapped to actual values of ours,
+ * according to the precidence established in the getValue
function.
+ * 'values' contains default values for the transaction.
Things that are typically not overridden should go here.
+ */
+ function defineTransactions();
+
+ /**
+ * defineVarMap needs to set up the $var_map array.
+ * Keys = the name (or node name) value in the gateway transaction
+ * Values = the mediawiki field name for the corresponding piece of
data.
+ */
+ function defineVarMap();
+
+ /**
+ * defineAccountInfo needs to set up the $accountInfo array.
+ * Keys = the name (or node name) value in the gateway transaction
+ * Values = The actual values for those keys. Probably have to access a
global or two. (use getGlobal()!)
+ */
+ function defineAccountInfo();
+
+ /**
+ * defineReturnValueMap sets up the $return_value_map array.
+ * Keys = The different constants that may be contained as values in
the gateway's response.
+ * Values = what that string constant means to mediawiki.
+ */
+ function defineReturnValueMap();
}
abstract class GatewayAdapter implements GatewayType {
@@ -41,28 +81,66 @@
protected $accountInfo;
protected $url;
protected $transactions;
+ protected $return_value_map;
protected $postdata;
protected $postdatadefaults;
protected $xmlDoc;
protected $dataObj;
+ //ALL OF THESE need to be redefined in the children. Much voodoo
depends on the accuracy of these constants.
const gatewayname = 'Donation Gateway';
const identifier = 'donation';
const communicationtype = 'xml'; //this needs to be either 'xml' or
'namevalue'
const globalprefix = 'wgDonationGateway'; //...for example.
function __construct(){
+
$dir = dirname( __FILE__ ) . '/';
require_once( $dir . '../gateway_common/DonationData.php' );
$this->dataObj = new DonationData(get_called_class());
$this->postdata = $this->dataObj->getData();
- self::log("Back in the Gateway Adapter: " .
print_r($this->postdata, true));
//TODO: Fix this a bit.
$this->posted = $this->dataObj->wasPosted();
+
+ global $wgDonationInterfaceTest; //this is so the forms can see
it.
+ //TODO: Alter the forms so they don't need the global?
+ if ( !self::getGlobal('Test') ) {
+ $this->url = self::getGlobal('URL');
+ $wgDonationInterfaceTest = false;
+ } else {
+ $this->url = self::getGlobal('TestingURL');
+ $wgDonationInterfaceTest = true;
+ }
+
+ $this->setPostDefaults();
+ $this->defineTransactions();
+ $this->defineVarMap();
+ $this->defineAccountInfo();
+ $this->defineReturnValueMap();
+
+
$this->stageData();
}
+ /**
+ * Override this in children if you want different defaults.
+ */
+ function setPostDefaults(){
+ $returnTitle = Title::newFromText( 'Donate-thanks/en' );
+ $returnto = $returnTitle->getFullURL();
+
+ $this->postdatadefaults = array(
+ 'order_id' => '112358' . rand(),
+ 'amount' => '11.38',
+ 'currency' => 'USD',
+ 'language' => 'en',
+ 'country' => 'US',
+ 'returnto' => $returnto,
+ 'user_ip' => ( self::getGlobal('Test') ) ?
'12.12.12.12' : wfGetIP(), // current user's IP address
+ );
+ }
+
function checkTokens(){
return $this->dataObj->checkTokens();
}
@@ -196,6 +274,8 @@
//if we're still okay (hey, even if we're not), get relevent
dataz.
$returned['data'] = $this->getResponseData($formatted);
+
+ $this->processResponse($returned);
//TODO: Actually pull these from somewhere legit.
if ( $returned['status'] === true ) {
@@ -306,6 +386,7 @@
if ( $return['headers']['http_code'] != 200 ) {
$return['result'] = false;
//TODO: i18n here!
+ //TODO: But also, fire off some kind of "No response
from the gateway" thing to somebody so we know right away.
$return['message'] = 'No response from ' .
self::getGatewayName() . '. Please try again later!';
$when = time();
self::log( $this->postdatadefaults['order_id'] . ' No
response from ' . self::getGatewayName() . ': ' . curl_error( $ch ) );
Modified:
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
===================================================================
---
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
2011-09-08 18:54:08 UTC (rev 96594)
+++
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
2011-09-08 18:57:50 UTC (rev 96595)
@@ -4,44 +4,34 @@
require_once( $dir . '../gateway_common/gateway.adapter.php' );
class GlobalCollectAdapter extends GatewayAdapter {
- //Contains the map of THEIR var names, to OURS.
- //I'd have gone the other way, but we'd run into 1:many pretty quick.
-
const gatewayname = 'Global Collect';
const identifier = 'globalcollect';
const communicationtype = 'xml';
const globalprefix = 'wgGlobalCollectGateway';
/**
- * Anything we need to do to the data coming in, before we send it off.
+ * stageData should alter the postdata array in all ways necessary in
preparation for
+ * communication with the gateway.
*/
function stageData(){
- //TODO: Make a Thing in which we do things like this.
$this->postdata['amount'] = $this->postdata['amount'] * 100;
}
+
function __construct( ) {
$this->classlocation = __FILE__;
-
parent::__construct();
-
- $returnTitle = Title::newFromText( 'Donate-thanks/en' );
- $returnto = $returnTitle->getFullURL();
-
- //this DEFINITELY needs to be defined in the parent class, and
contain everything anybody might want to know.
- $this->postdatadefaults = array(
- 'order_id' => '112358' . rand(),
- 'amount' => '11.38',
- 'currency' => 'USD',
- 'language' => 'en',
- 'country' => 'US',
- 'returnto' => $returnto,
- 'user_ip' => ( self::getGlobal('Test') ) ?
'12.12.12.12' : wfGetIP(), // current user's IP address
+ }
+
+ function defineAccountInfo(){
+ $this->accountInfo = array(
+ 'MERCHANTID' => self::getGlobal('MerchantID'),
+ //'IPADDRESS' => '', //TODO: Not sure if this should be
OUR ip, or the user's ip. Hurm.
+ 'VERSION' => "1.0",
);
-
-
- ///ehh. Most of this should be broken up into functions for the
sake of readibility.
-
+ }
+
+ function defineVarMap(){
$this->var_map = array(
'ORDERID' => 'order_id',
'AMOUNT' => 'amount',
@@ -49,124 +39,73 @@
'LANGUAGECODE' => 'language',
'COUNTRYCODE' => 'country',
'MERCHANTREFERENCE' => 'order_id',
- 'RETURNURL' => 'returnto', //I think. It might not even
BE here yet. Boo-urns.
+ 'RETURNURL' => 'returnto', //TODO: Fund out where the
returnto URL is supposed to be coming from.
'IPADDRESS' => 'user_ip', //TODO: Not sure if this
should be OUR ip, or the user's ip. Hurm.
);
-
+ }
+
+ function defineReturnValueMap(){
$this->return_value_map = array(
'OK' => true,
'NOK' => false,
);
-
- global $wgDonationInterfaceTest; //this is so the forms can see
it.
- if ( !self::getGlobal('Test') ) {
- $this->url = self::getGlobal('URL');
- $wgDonationInterfaceTest = false;
- } else {
- $this->url = self::getGlobal('TestingURL');
- $wgDonationInterfaceTest = true;
- }
-
- $this->accountInfo = array(
- 'MERCHANTID' => self::getGlobal('MerchantID'),
- //'IPADDRESS' => '', //TODO: Not sure if this should be
OUR ip, or the user's ip. Hurm.
- 'VERSION' => "1.0",
- );
-
- //oof. This is getting a little long and unwieldy. Maybe we
should build it. Or maybe that sucks. I can't tell yet.
- /* General idea here:
- * This bad boy will (probably) contain the structure of all
possible transactions as defined by the gateway.
- * First array key: Some way for us to id the transaction.
Doesn't actually have to be the gateway's name for it, but
- * I'm starting with that.
- * Second array key:
- * 'structure' contains the layout of that
transaction.
- * 'defaults' contains default values for the leaf
'values'
- * I could put a 'type' in here, but I think we
can assume that if 'structure' is multi-layer, we're XML.
- * Array "leaves" in 'structure' will be assigned a value
according to the var_map, and the posted data.
- * There should also be a mechanism for assigning
defaults, but I'm not entirely sure what that would look like quite yet...
- *
- */
- $this->transactions = array(
- 'INSERT_ORDERWITHPAYMENT' => array(
- 'request' => array(
- 'REQUEST' => array(
- 'ACTION',
- 'META' => array(
- 'MERCHANTID',
-// 'IPADDRESS',
- 'VERSION'
+ }
+
+ function defineTransactions(){
+ $this->transactions = array();
+
+ $this->transactions['INSERT_ORDERWITHPAYMENT'] = array(
+ 'request' => array(
+ 'REQUEST' => array(
+ 'ACTION',
+ 'META' => array(
+ 'MERCHANTID',
+ // 'IPADDRESS',
+ 'VERSION'
+ ),
+ 'PARAMS' => array(
+ 'ORDER' => array(
+ 'ORDERID',
+ 'AMOUNT',
+ 'CURRENCYCODE',
+ 'LANGUAGECODE',
+ 'COUNTRYCODE',
+ 'MERCHANTREFERENCE'
),
- 'PARAMS' => array(
- 'ORDER' => array(
- 'ORDERID',
- 'AMOUNT',
- 'CURRENCYCODE',
- 'LANGUAGECODE',
- 'COUNTRYCODE',
-
'MERCHANTREFERENCE'
- ),
- 'PAYMENT' => array(
-
'PAYMENTPRODUCTID',
- 'AMOUNT',
- 'CURRENCYCODE',
- 'LANGUAGECODE',
- 'COUNTRYCODE',
-
'HOSTEDINDICATOR',
- 'RETURNURL',
- )
+ 'PAYMENT' => array(
+ 'PAYMENTPRODUCTID',
+ 'AMOUNT',
+ 'CURRENCYCODE',
+ 'LANGUAGECODE',
+ 'COUNTRYCODE',
+ 'HOSTEDINDICATOR',
+ 'RETURNURL',
)
)
- ),
- 'values' => array(
- 'ACTION' => 'INSERT_ORDERWITHPAYMENT',
- 'HOSTEDINDICATOR' => '1',
- 'PAYMENTPRODUCTID' => '3',
- ),
- 'result' => array( //just like the rest: This
is still in flux. But the idea here is that this is the sctucture you'd scan
for.
- 'RESULT' => 'value'
- ),
- 'result_errors' => array(
- 'ERROR' => array(
- 'CODE' => 'value', //as opposed
to "attribute", which would imply that it belongs to the parent...
- 'MESSAGE' => 'value',
- )
- ),
- 'result_data' => array(
- 'ROW' => array(
- //uhh... presumably we'd look for some
Stuff in here.
- )
)
),
- 'TEST_CONNECTION' => array(
- 'request' => array(
- 'REQUEST' => array(
- 'ACTION',
- 'META' => array(
- 'MERCHANTID',
+ 'values' => array(
+ 'ACTION' => 'INSERT_ORDERWITHPAYMENT',
+ 'HOSTEDINDICATOR' => '1',
+ 'PAYMENTPRODUCTID' => '3',
+ ),
+ );
+
+ $this->transactions['TEST_CONNECTION'] = array(
+ 'request' => array(
+ 'REQUEST' => array(
+ 'ACTION',
+ 'META' => array(
+ 'MERCHANTID',
// 'IPADDRESS',
- 'VERSION'
- ),
- 'PARAMS' => array( )
- )
- ),
- 'values' => array(
- 'ACTION' => 'TEST_CONNECTION'
- ),
- 'result' => array( //just like the rest: This
is still in flux. But the idea here is that this is the sctucture you'd scan
for.
- 'RESULT' => 'value'
- ),
- 'result_errors' => array(
- 'ERROR' => array(
- 'CODE' => 'value', //as opposed
to "attribute", which would imply that it belongs to the parent...
- 'MESSAGE' => 'value',
- )
- ),
- 'result_data' => array(
- 'ROW' => array(
- //uhh... presumably we'd look for some
Stuff in here.
- )
+ 'VERSION'
+ ),
+ 'PARAMS' => array( )
)
),
+ 'values' => array(
+ 'ACTION' => 'TEST_CONNECTION'
+ )
);
}
@@ -239,5 +178,9 @@
self::log( "Returned Data: " . print_r($data, true));
return $data;
}
+
+ function processResponse( $response ) {
+ //TODO: Stuff.
+ }
}
Modified:
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php
===================================================================
---
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php
2011-09-08 18:54:08 UTC (rev 96594)
+++
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php
2011-09-08 18:57:50 UTC (rev 96595)
@@ -175,11 +175,11 @@
}
} else {
// Display form for the first time
- $adapter::log("Not posted, or not processed.
Showing the form for the first time.");
+ $this->adapter->log("Not posted, or not
processed. Showing the form for the first time.");
$this->fnPayflowDisplayForm( $data,
$this->errors );
}
} else {
- if ( !$adapter->isCache() ) {
+ if ( !$this->adapter->isCache() ) {
// if we're not caching, there's a token
mismatch
$this->errors['general']['token-mismatch'] =
wfMsg( 'globalcollect_gateway-token-mismatch' );
}
@@ -200,13 +200,13 @@
global $wgOut, $wgRequest;
// save contrib tracking id early to track abondonment
- if ( !empty($data) && ( $data[ 'numAttempt' ] == '0' && (
!$wgRequest->getText( 'utm_source_id', false ) || $wgRequest->getText(
'_nocache_' ) == 'true' ) ) ) {
- $tracked = $this->fnPayflowSaveContributionTracking(
$data );
- if ( !$tracked ) {
- $when = time();
- self::log( $data[ 'order_id' ] . ' Unable to
save data to the contribution_tracking table ' . $when );
- }
- }
+// if ( !empty($data) && ( $data[ 'numAttempt' ] == '0' && (
!$wgRequest->getText( 'utm_source_id', false ) || $wgRequest->getText(
'_nocache_' ) == 'true' ) ) ) {
+// $tracked = $this->fnPayflowSaveContributionTracking(
$data );
+// if ( !$tracked ) {
+// $when = time();
+// self::log( $data[ 'order_id' ] . ' Unable to
save data to the contribution_tracking table ' . $when );
+// }
+// }
$form_class = $this->getFormClass();
$form_obj = new $form_class( $data, $error );
Modified:
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
===================================================================
---
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
2011-09-08 18:54:08 UTC (rev 96594)
+++
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
2011-09-08 18:57:50 UTC (rev 96595)
@@ -100,7 +100,12 @@
} else {
$amount = '0.00';
}
+
+ // Get array of default account values necessary for Payflow
+ require_once( 'includes/payflowUser.inc' );
+ $payflow_data = payflowUser();
+
// track the number of attempts the user has made
$numAttempt = $wgRequest->getVal( 'numAttempt', 0 );
Modified:
branches/fundraising/extensions/DonationInterface/tests/DonationInterfaceTest.php
===================================================================
---
branches/fundraising/extensions/DonationInterface/tests/DonationInterfaceTest.php
2011-09-08 18:54:08 UTC (rev 96594)
+++
branches/fundraising/extensions/DonationInterface/tests/DonationInterfaceTest.php
2011-09-08 18:57:50 UTC (rev 96595)
@@ -11,17 +11,223 @@
*
* @group Fundraising
* @group Splunge
+ * @group Gateways
* @author Katie Horn <[email protected]>
*/
class DonationInterfaceTest extends MediaWikiTestCase {
+ function testbuildRequestXML() {
+ $gateway = new TestAdapter();
+ $gateway->publicCurrentTransaction( 'Test1' );
+ $built = $gateway->buildRequestXML();
+ $expected = '<?xml version="1.0"?>' . "\n";
+ $expected .=
'<XML><REQUEST><ACTION>Donate</ACTION><ACCOUNT><MERCHANTID>128</MERCHANTID><PASSWORD>k4ftw</PASSWORD><VERSION>3.2</VERSION><RETURNURL>http://localhost/index.php/Donate-thanks/en</RETURNURL></ACCOUNT><DONATION><DONOR>
</DONOR><AMOUNT>0</AMOUNT><CURRENCYCODE>USD</CURRENCYCODE><LANGUAGECODE>en</LANGUAGECODE><COUNTRYCODE>US</COUNTRYCODE></DONATION></REQUEST></XML>'
. "\n";
+ $this->assertEquals($built, $expected, "The constructed XML for
transaction type Test1 does not match our expected.");
+
+ }
+
+ function testParseResponseXML() {
+ $gateway = new TestAdapter();
+ $returned = $gateway->do_transaction( 'Test2' );
+
+ $expected_errors = array(
+ 128 => "Your shoe's untied...",
+ 45 => "Low clearance!"
+ );
+
+ $expected_data = array(
+ 'thing' => 'stuff',
+ 'otherthing' => 12,
+ );
+
+ $this->assertEquals($returned['status'], true, "Status should
be true at this point.");
+
+ $this->assertEquals($returned['errors'], $expected_errors,
"Expected errors were not found.");
+
+ $this->assertEquals($returned['data'], $expected_data,
"Expected data was not found.");
+
+ $this->assertEquals($returned['message'], "Test2 Transaction
Successful!", "Expected message was not returned.");
+
+ }
+
+}
+
+$dir = dirname( __FILE__ ) . '/';
+require_once( $dir . '../gateway_common/gateway.adapter.php' );
+
+class TestAdapter extends GatewayAdapter {
+
+ const gatewayname = 'Test Gateway';
+ const identifier = 'testgateway';
+ const communicationtype = 'xml';
+ const globalprefix = 'wgTestAdapterGateway';
+
+ function stageData(){
+ $this->postdata['amount'] = $this->postdata['amount'] * 1000;
+ $this->postdata['name'] = $this->postdata['fname'] . " " .
$this->postdata['lname'];
+ }
+
+ function __construct( ) {
+ global $wgTestAdapterGatewayTestVar,
$wgTestAdapterGatewayUseSyslog;
+ $wgTestAdapterGatewayTestVar = "Hi there!";
+ $wgTestAdapterGatewayUseSyslog = true;
+ $this->classlocation = __FILE__;
+ parent::__construct();
+
+ }
+
+ function defineAccountInfo(){
+ $this->accountInfo = array(
+ 'MERCHANTID' => '128',
+ 'PASSWORD' => 'k4ftw',
+ //'IPADDRESS' => '', //TODO: Not sure if this should be
OUR ip, or the user's ip. Hurm.
+ 'VERSION' => "3.2",
+ );
+ }
+
+ function defineVarMap(){
+ $this->var_map = array(
+ 'DONOR' => 'name',
+ 'AMOUNT' => 'amount',
+ 'CURRENCYCODE' => 'currency',
+ 'LANGUAGECODE' => 'language',
+ 'COUNTRYCODE' => 'country',
+ 'OID' => 'order_id',
+ 'RETURNURL' => 'returnto', //TODO: Fund out where the
returnto URL is supposed to be coming from.
+ );
+ }
+
+ function defineReturnValueMap(){
+ $this->return_value_map = array(
+ 'AOK' => true,
+ 'WRONG' => false,
+ );
+ }
+
+ function defineTransactions(){
+ $this->transactions = array();
+
+ $this->transactions['Test1'] = array(
+ 'request' => array(
+ 'REQUEST' => array(
+ 'ACTION',
+ 'ACCOUNT' => array(
+ 'MERCHANTID',
+ 'PASSWORD',
+ 'VERSION',
+ 'RETURNURL',
+ ),
+ 'DONATION' => array(
+ 'DONOR',
+ 'AMOUNT',
+ 'CURRENCYCODE',
+ 'LANGUAGECODE',
+ 'COUNTRYCODE',
+ //'OID', //move this to another
test. It's different every time, dorkus.
+ )
+ )
+ ),
+ 'values' => array(
+ 'ACTION' => 'Donate',
+ ),
+ );
+
+ $this->transactions['Test2'] = array(
+ 'request' => array(
+ 'REQUEST' => array(
+ 'ACTION',
+ )
+ ),
+ 'values' => array(
+ 'ACTION' => 'Donate2',
+ ),
+ );
+ self::log(print_r($this->transactions, true));
+ }
+
/**
- * This test is deeply stupid, btw.
+ * Take the entire response string, and strip everything we don't care
about.
+ * For instance: If it's XML, we only want correctly-formatted XML.
Headers must be killed off.
+ * return a string.
*/
- function assertTestClassExists() {
- $this->assertTrue( true, "WeeeooooOOOHOO!!1one1" );
+ function getFormattedResponse( $rawResponse ){
+ $xmlString = $this->stripXMLResponseHeaders($rawResponse);
+ $displayXML = $this->formatXmlString( $xmlString );
+ $realXML = new DomDocument( '1.0' );
+ self::log( "Here is the Raw XML: " . $displayXML ); //I am
apparently a huge fibber.
+ $realXML->loadXML( trim( $xmlString ) );
+ return $realXML;
}
+
+ /**
+ * Parse the response to get the status. Not sure if this should return
a bool, or something more... telling.
+ */
+ function getResponseStatus( $response ){
+ $aok = true;
+
+ foreach ( $response->getElementsByTagName( 'RESULT' ) as $node
) {
+ if ( array_key_exists( $node->nodeValue,
$this->return_value_map ) && $this->return_value_map[$node->nodeValue] !== true
) {
+ $aok = false;
+ }
+ }
+
+ return $aok;
+ }
+
+ /**
+ * Parse the response to get the errors in a format we can log and
otherwise deal with.
+ * return a key/value array of codes (if they exist) and messages.
+ */
+ function getResponseErrors( $response ){
+ $errors = array();
+ foreach ( $response->getElementsByTagName( 'warning' ) as $node
) {
+ $code = '';
+ $message = '';
+ foreach ( $node->childNodes as $childnode ) {
+ if ($childnode->nodeName === "code"){
+ $code = $childnode->nodeValue;
+ }
+ if ($childnode->nodeName === "message"){
+ $message = $childnode->nodeValue;
+ }
+ }
+ $errors[$code] = $message;
+ self::log( "ON NOES! ERRORS: " . print_r($errors, true)
);
+ }
+ return $errors;
+ }
+
+ /**
+ * Harvest the data we need back from the gateway.
+ * return a key/value array
+ */
+ function getResponseData( $response ){
+ $data = array();
+ foreach ( $response->getElementsByTagName( 'ImportantData' ) as
$node ) {
+ foreach ( $node->childNodes as $childnode ) {
+ if (trim($childnode->nodeValue) != ''){
+ $data[$childnode->nodeName] =
$childnode->nodeValue;
+ }
+ }
+ }
+ self::log( "Returned Data: " . print_r($data, true));
+ return $data;
+ }
+
+ function processResponse( $response ) {
+ //TODO: Stuff.
+ }
+
+ function publicCurrentTransaction( $transaction = '' ){
+ $this->currentTransaction( $transaction );
+ }
+
+ function curl_transaction($data) {
+ $data = "";
+ $data['result'] = 'BLAH BLAH BLAH BLAH whatever something blah
blah<?xml version="1.0"?>' . "\n" .
'<XML><Response><Status>AOK</Status><ImportantData><thing>stuff</thing><otherthing>12</otherthing></ImportantData><errorswarnings><warning><code>128</code><message>Your
shoe\'s untied...</message></warning><warning><code>45</code><message>Low
clearance!</message></warning></errorswarnings></Response></XML>';
+ return $data;
+ }
}
?>
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs