https://www.mediawiki.org/wiki/Special:Code/MediaWiki/102047
Revision: 102047
Author: khorn
Date: 2011-11-04 21:09:46 +0000 (Fri, 04 Nov 2011)
Log Message:
-----------
Establishes constraints on settable fields that should contain the over-arching
result for one discrete donation attempt (which can involve multiple
transactions, posts, errors, whatever).
This is the quick and dirty version.
Also noticed upon implementation that we (and by "we" I mean "mostly me":
r97341, r99036, r101959 ) had already screwed this up, so this is a Very Good
Thing.
Modified Paths:
--------------
trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
Modified: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
===================================================================
--- trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
2011-11-04 21:06:06 UTC (rev 102046)
+++ trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
2011-11-04 21:09:46 UTC (rev 102047)
@@ -1276,15 +1276,26 @@
* @param string $transaction The transaction these codes map to.
* @param string $key The (incoming) field name containing the numeric
codes
* we're defining here.
- * @param string $action Should be limited to the values 'complete',
- * 'pending', 'pending-poke', 'failed' and 'revised'... but for now
you're
- * on the honor system, kids. TODO: Limit these values in this
function,
- * once we are slightly more certain we don't need more values.
+ * @param string $action Limited to the values 'complete', 'pending',
+ * 'pending-poke', 'failed' and 'revised'.
* @param int $lower The integer value of the lower-bound in this code
range.
* @param int $upper Optional: The integer value of the upper-bound in
the
* code range. If omitted, it will make a range of one value: The lower
bound.
*/
protected function addCodeRange( $transaction, $key, $action, $lower,
$upper = null ) {
+ //our choices here are:
+ //TODO: Move this somewhere both this function and
+ //setTransactionWMFStatus can get to it.
+ $statuses = array(
+ 'complete',
+ 'pending',
+ 'pending-poke',
+ 'failed',
+ 'revised'
+ );
+ if ( !in_array( $action, $statuses ) ) {
+ throw new MWException( "Transaction WMF Status $action
is invalid." );
+ }
if ( $upper === null ) {
$this->return_value_map[$transaction][$key][$lower] =
$action;
} else {
@@ -1573,11 +1584,23 @@
* process to completion: This status being set at all, denotes the
very end
* of the donation process on our end. Further attempts by the same
user
* will be seen as starting over.
- * @param string $status Only five strings will do anything good in the
rest
- * of the code so far:
- * 'complete', 'pending', 'pending-poke', 'failed', 'revised'
+ * @param string $status The final status of one discrete donation
attempt,
+ * can be one of five values: 'complete', 'pending', 'pending-poke',
+ * 'failed', 'revised'
*/
public function setTransactionWMFStatus( $status ) {
+ //our choices here are:
+ $statuses = array(
+ 'complete',
+ 'pending',
+ 'pending-poke',
+ 'failed',
+ 'revised'
+ );
+ if ( !in_array( $status, $statuses ) ) {
+ throw new MWException( "Transaction WMF Status $status
is invalid." );
+ }
+
$this->transaction_results['WMF_STATUS'] = $status;
}
Modified:
trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
===================================================================
---
trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
2011-11-04 21:06:06 UTC (rev 102046)
+++
trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
2011-11-04 21:09:46 UTC (rev 102047)
@@ -110,7 +110,7 @@
$this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'pending',
300 );
$this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'failed',
310, 350 );
$this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'revised',
400 );
- $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID',
'pending_poke', 525 );
+ $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID',
'pending-poke', 525 );
$this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'pending',
550, 650 );
$this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'complete',
800, 975 ); //these are all post-authorized, but technically pre-settled...
$this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'complete',
1000, 1050 );
@@ -130,7 +130,7 @@
* Allowed:
* - complete
* - pending
- * - pending_poke
+ * - pending-poke
* - revised
*
* Denied:
@@ -143,7 +143,7 @@
$this->goToThankYouOn = array(
'complete',
'pending',
- 'pending_poke',
+ 'pending-poke',
'revised',
);
}
@@ -289,7 +289,7 @@
),
'loop_for_status' => array(
//'pending',
- 'pending_poke',
+ 'pending-poke',
'complete',
'failed',
'revised',
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs