r103076 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103075‎ | r103076 | r103077 >
Date:23:35, 14 November 2011
Author:khorn
Status:ok
Tags:
Comment:
More (but still preliminary) work toward a command-line solution for finding donations which were completed on GlobalCollect's hosted credit card form, but that never came back to us to finish up the final processing.
Had to do some juggling on the inside of GC's "Confirm_CreditCard" - we still want to fire off the process hooks, but because the orphan data doesn't have CVV and AVS until after the GET_ORDERSTATUS goes through, we have to wait and fire off the pre-process hooks after that call (but they will still fire before we either set or cancel the payment).
A couple minor notice-killing edits in minfraud as well.
Modified paths:
  • /trunk/extensions/DonationInterface/extras/minfraud/minfraud.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/extras/minfraud/minfraud.body.php
@@ -112,7 +112,7 @@
113113 public function can_bypass_minfraud() {
114114 // if the data bits data_hash and action are not set, we need to hit minFraud
115115 $localdata = $this->gateway_adapter->getData_Raw();
116 - if ( !strlen( $localdata['data_hash'] ) || !strlen( $localdata['action'] ) ) {
 116+ if ( !isset($localdata['data_hash']) || !strlen( $localdata['data_hash'] ) || !isset($localdata['action']) || !strlen( $localdata['action'] ) ) {
117117 return FALSE;
118118 }
119119
Index: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php
@@ -9,8 +9,13 @@
1010
1111 class GlobalCollectOrphanRectifier extends Maintenance {
1212 function execute(){
 13+
 14+ $max_per_execute = 50;
 15+
 16+
1317
1418 //load in and chunk the list of XML. Phase 1: From a file
 19+ //MUST include contribution_tracking id!
1520
1621 //for each chunk, load it into a GC adapter, and have it parse as if it were a response.
1722
@@ -19,11 +24,21 @@
2025 //(Note: This should only work if we're sitting at one of the designated statuses)
2126
2227 $data = array(
23 - 'test' => 'something',
24 - 'othertest' => 'otherthing'
 28+ 'order_id' => '1052864192',
 29+ 'i_order_id' => '1052864192',
 30+ 'city' => '',
 31+ 'state' => '',
 32+ 'zip' => '',
 33+ 'country' => 'US',
 34+ 'email' => '',
 35+ 'card_num' => '',
 36+
2537 );
2638
 39+ //we may need to unset some hooks out here. Like... recaptcha. Makes no sense.
2740 $adapter = new GlobalCollectAdapter(array('external_data' => $data));
 41+ error_log("\n\n\n");
 42+ $results = $adapter->do_transaction('Confirm_CreditCard');
2843 }
2944 }
3045
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -1017,22 +1017,49 @@
10181018 $addme[$ourkey] = $tmp;
10191019 }
10201020 }
1021 - if ( count( $addme ) ){
 1021+
 1022+ $post_status_check = false;
 1023+ if ( count( $addme ) ){ //nothing unusual here.
10221024 $this->addData( $addme );
 1025+ $logmsg = $this->getData_Raw( 'contribution_tracking_id' ) . ': ';
 1026+ $logmsg .= 'CVV Result: ' . $this->getData_Raw( 'cvv_result' );
 1027+ $logmsg .= ', AVS Result: ' . $this->getData_Raw( 'avs_result' );
 1028+ self::log( $logmsg );
 1029+ } else { //this is an orphan transaction.
 1030+ $this->staged_data['order_id'] = $this->staged_data['i_order_id'];
 1031+ $post_status_check = true;
10231032 }
1024 - $logmsg = $this->getData_Raw( 'contribution_tracking_id' ) . ': ';
1025 - $logmsg .= 'CVV Result: ' . $this->getData_Raw( 'cvv_result' );
1026 - $logmsg .= ', AVS Result: ' . $this->getData_Raw( 'avs_result' );
1027 - self::log( $logmsg );
10281033
10291034 $status_result = $this->do_transaction( 'GET_ORDERSTATUS' );
10301035
1031 - //error_log( "GET_ORDERSTATUS result: " . $status_result );
1032 -
10331036 $cancelflag = false; //this will denote the thing we're trying to do with the donation attempt
10341037 $problemflag = false; //this will get set to true, if we can't continue and need to give up and just log the hell out of it.
10351038 $problemmessage = ''; //to be used in conjunction with the flag.
 1039+
10361040
 1041+ if ( $post_status_check ){
 1042+ if ( array_key_exists('data', $status_result) ) {
 1043+ foreach ( $pull_vars as $theirkey => $ourkey) {
 1044+ if ( array_key_exists($theirkey, $status_result['data']) ) {
 1045+ $addme[$ourkey] = $status_result['data'][$theirkey];
 1046+ }
 1047+ }
 1048+ }
 1049+
 1050+ if ( count( $addme ) ){
 1051+ $this->addData( $addme );
 1052+ $logmsg = $this->getData_Raw( 'contribution_tracking_id' ) . ': ';
 1053+ $logmsg .= 'CVV Result: ' . $this->getData_Raw( 'cvv_result' );
 1054+ $logmsg .= ', AVS Result: ' . $this->getData_Raw( 'avs_result' );
 1055+ self::log( $logmsg );
 1056+ $this->runPreProcessHooks();
 1057+ $status_result['action'] = $this->getValidationAction();
 1058+ } else {
 1059+ $problemflag = true; //nothing to be done.
 1060+ $problemmessage = "Unable to retrieve orphan cvv/avs results (Communication problem?).";
 1061+ }
 1062+ }
 1063+
10371064 //we filtered
10381065 if ( array_key_exists( 'action', $status_result ) && $status_result['action'] != 'process' ){
10391066 $cancelflag = true;
@@ -1055,7 +1082,11 @@
10561083 case 'revised' :
10571084 $cancelflag = true; //makes sure we don't try to confirm.
10581085 break;
1059 - }
 1086+ case 'complete' :
 1087+ $problemflag = true; //nothing to be done.
 1088+ $problemmessage = "GET_ORDERSTATUS reports that the payment is already complete.";
 1089+ break;
 1090+ }
10601091 }
10611092
10621093 //if we got here with no problemflag,

Follow-up revisions

RevisionCommit summaryAuthorDate
r103512MFT r103506, r103501, r103499, r103491, r103416, r103385, r103288, r103246, r...khorn21:54, 17 November 2011
r103513MFT r103506, r103501, r103499, r103491, r103416, r103385, r103288, r103246, r...khorn21:57, 17 November 2011

Status & tagging log