Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php |
— | — | @@ -66,7 +66,7 @@ |
67 | 67 | $adapter_oid = $adapter_oid['order_id']; |
68 | 68 | if ( $oid && !empty( $oid ) && $oid === $adapter_oid ) { |
69 | 69 | if ( !array_key_exists( 'order_status', $_SESSION ) || !array_key_exists( $oid, $_SESSION['order_status'] ) ) { |
70 | | - $_SESSION['order_status'][$oid] = $this->adapter->do_transaction( 'GET_ORDERSTATUS' ); |
| 70 | + $_SESSION['order_status'][$oid] = $this->adapter->do_transaction( 'K4sVoodoo' ); |
71 | 71 | $_SESSION['order_status'][$oid]['data']['count'] = 0; |
72 | 72 | } else { |
73 | 73 | $_SESSION['order_status'][$oid]['data']['count'] = $_SESSION['order_status'][$oid]['data']['count'] + 1; |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -29,6 +29,7 @@ |
30 | 30 | $this->var_map = array( |
31 | 31 | 'ACCOUNTNAME' => 'account_name', |
32 | 32 | 'ACCOUNTNUMBER' => 'account_number', |
| 33 | + 'ATTEMPTID' => 'attempt_id', |
33 | 34 | 'AUTHORIZATIONID' => 'authorization_id', |
34 | 35 | 'AMOUNT' => 'amount', |
35 | 36 | 'BANKCHECKDIGIT' => 'bank_check_digit', |
— | — | @@ -43,6 +44,7 @@ |
44 | 45 | 'CVV' => 'cvv', |
45 | 46 | 'DATECOLLECT' => 'date_collect', |
46 | 47 | 'DIRECTDEBITTEXT' => 'direct_debit_text', |
| 48 | + 'EFFORTID' => 'effort_id', |
47 | 49 | 'EMAIL' => 'email', |
48 | 50 | 'EXPIRYDATE' => 'expiration', |
49 | 51 | 'FIRSTNAME' => 'fname', |
— | — | @@ -61,6 +63,16 @@ |
62 | 64 | 'ZIP' => 'zip', |
63 | 65 | ); |
64 | 66 | } |
| 67 | + |
| 68 | + /** |
| 69 | + * Setting some GC-specific defaults. |
| 70 | + * @param array $options These get extracted in the parent. |
| 71 | + */ |
| 72 | + function setPostDefaults( $options = array() ) { |
| 73 | + parent::setPostDefaults( $options ); |
| 74 | + $this->postdatadefaults['attempt_id'] = '1'; |
| 75 | + $this->postdatadefaults['effort_id'] = '1'; |
| 76 | + } |
65 | 77 | |
66 | 78 | /** |
67 | 79 | * Define return_value_map |
— | — | @@ -231,6 +243,54 @@ |
232 | 244 | 'revised', |
233 | 245 | ) |
234 | 246 | ); |
| 247 | + |
| 248 | + $this->transactions['CANCEL_PAYMENT'] = array( |
| 249 | + 'request' => array( |
| 250 | + 'REQUEST' => array( |
| 251 | + 'ACTION', |
| 252 | + 'META' => array( |
| 253 | + 'MERCHANTID', |
| 254 | + 'IPADDRESS', |
| 255 | + 'VERSION' |
| 256 | + ), |
| 257 | + 'PARAMS' => array( |
| 258 | + 'PAYMENT' => array( |
| 259 | + 'ORDERID', |
| 260 | + 'EFFORTID', |
| 261 | + 'ATTEMPTID', |
| 262 | + ), |
| 263 | + ) |
| 264 | + ) |
| 265 | + ), |
| 266 | + 'values' => array( |
| 267 | + 'ACTION' => 'CANCEL_PAYMENT', |
| 268 | + 'VERSION' => '1.0' |
| 269 | + ), |
| 270 | + ); |
| 271 | + |
| 272 | + $this->transactions['SET_PAYMENT'] = array( |
| 273 | + 'request' => array( |
| 274 | + 'REQUEST' => array( |
| 275 | + 'ACTION', |
| 276 | + 'META' => array( |
| 277 | + 'MERCHANTID', |
| 278 | + 'IPADDRESS', |
| 279 | + 'VERSION' |
| 280 | + ), |
| 281 | + 'PARAMS' => array( |
| 282 | + 'PAYMENT' => array( |
| 283 | + 'ORDERID', |
| 284 | + 'EFFORTID', |
| 285 | + 'PAYMENTPRODUCTID', |
| 286 | + ), |
| 287 | + ) |
| 288 | + ) |
| 289 | + ), |
| 290 | + 'values' => array( |
| 291 | + 'ACTION' => 'SET_PAYMENT', |
| 292 | + 'VERSION' => '1.0' |
| 293 | + ), |
| 294 | + ); |
235 | 295 | } |
236 | 296 | |
237 | 297 | /** |
— | — | @@ -525,6 +585,76 @@ |
526 | 586 | } |
527 | 587 | |
528 | 588 | /** |
| 589 | + * Because GC has some processes that involve more than one do_transaction |
| 590 | + * chained together, we're catching those special ones in an overload and |
| 591 | + * letting the rest behave normally. |
| 592 | + */ |
| 593 | + public function do_transaction( $transaction ){ |
| 594 | + switch ( $transaction ){ |
| 595 | + case 'K4sVoodoo' : |
| 596 | + return $this->doK4svoodoo(); |
| 597 | + break; |
| 598 | + default: |
| 599 | + return parent::do_transaction( $transaction ); |
| 600 | + } |
| 601 | + } |
| 602 | + |
| 603 | + //TODO: rename, yo. |
| 604 | + private function doK4svoodoo(){ |
| 605 | + global $wgRequest; //this is for pulling vars straight from the querystring |
| 606 | + $pull_vars = array( |
| 607 | + 'CVVRESULT' => 'cvv_result', |
| 608 | + 'AVSRESULT' => 'avs_result', |
| 609 | + ); |
| 610 | + $addme = array(); |
| 611 | + foreach ( $pull_vars as $theirkey => $ourkey) { |
| 612 | + $tmp = $wgRequest->getVal( $theirkey, null ); |
| 613 | + if ( !is_null( $tmp ) ) { |
| 614 | + $addme[$ourkey] = $tmp; |
| 615 | + } |
| 616 | + } |
| 617 | + if ( count( $addme ) ){ |
| 618 | + $this->addData( $addme ); |
| 619 | + } |
| 620 | + |
| 621 | + $status_result = $this->do_transaction( 'GET_ORDERSTATUS' ); |
| 622 | + |
| 623 | +// $status_result['data']; |
| 624 | +// |
| 625 | + //TODO: If we've already failed, flame out here instead of later. |
| 626 | + |
| 627 | + if ( isset( $status_result['data'] ) && is_array( $status_result['data'] ) ){ |
| 628 | + //if they're set, get CVVRESULT && AVSRESULT |
| 629 | + $pull_vars['EFFORTID'] = 'effort_id'; |
| 630 | + $pull_vars['ATTEMPTID'] = 'attempt_id'; |
| 631 | + $addme = array(); |
| 632 | + foreach ( $pull_vars as $theirkey => $ourkey) { |
| 633 | + if ( array_key_exists( $theirkey, $status_result['data'] ) ){ |
| 634 | + $addme[$ourkey] = $status_result['data'][$theirkey]; |
| 635 | + } |
| 636 | + } |
| 637 | + |
| 638 | + if ( count( $addme ) ){ |
| 639 | + $this->addData( $addme ); |
| 640 | + } |
| 641 | + |
| 642 | + //now, either do a cancel or a process, depending on what the filters |
| 643 | + //said we should do. |
| 644 | + switch ( $status_result['action'] ){ |
| 645 | + case 'process' : |
| 646 | + $final = $this->do_transaction( 'SET_PAYMENT' ); |
| 647 | + break; |
| 648 | + case 'reject' : |
| 649 | + $final = $this->do_transaction( 'CANCEL_PAYMENT' ); |
| 650 | + break; |
| 651 | + } |
| 652 | + return $final; |
| 653 | + } |
| 654 | +// error_log("Got nothing good back from the first call..."); |
| 655 | + return $status_result; |
| 656 | + } |
| 657 | + |
| 658 | + /** |
529 | 659 | * Take the entire response string, and strip everything we don't care about. |
530 | 660 | * For instance: If it's XML, we only want correctly-formatted XML. Headers must be killed off. |
531 | 661 | * return a string. |
— | — | @@ -904,28 +1034,79 @@ |
905 | 1035 | |
906 | 1036 | protected function pre_process_insert_orderwithpayment(){ |
907 | 1037 | if ( $this->getData( 'payment_method' ) === 'cc' ){ |
908 | | - $this->runPreProcessHooks(); //this is shortly to move elsewhere. |
909 | 1038 | $this->addDonorDataToSession(); |
910 | 1039 | } |
911 | 1040 | } |
912 | 1041 | |
913 | 1042 | protected function pre_process_get_orderstatus(){ |
914 | 1043 | if ( $this->getData( 'payment_method' ) === 'cc' ){ |
915 | | - //if they're set, get CVVRESULT && AVSRESULT |
916 | | - global $wgRequest; |
917 | | - $cvv_result = $wgRequest->getVal( 'CVVRESULT', null ); |
918 | | - $avs_result = $wgRequest->getVal( 'AVSRESULT', null ); |
919 | | - if ( !is_null($cvv_result) ){ |
920 | | - $this->debugarray[] = "CVV result: $cvv_result"; |
921 | | - } |
922 | | - if ( !is_null($avs_result) ){ |
923 | | - $this->debugarray[] = "AVS result: $avs_result"; |
924 | | - } |
| 1044 | + $this->runPreProcessHooks(); |
925 | 1045 | } |
926 | 1046 | } |
927 | 1047 | |
928 | 1048 | protected function post_process_get_orderstatus(){ |
929 | 1049 | $this->runPostProcessHooks(); |
930 | 1050 | } |
| 1051 | + |
| 1052 | + /** |
| 1053 | + * getCVVResult is intended to be used by the functions filter, to |
| 1054 | + * determine if we want to fail the transaction ourselves or not. |
| 1055 | + */ |
| 1056 | + public function getCVVResult(){ |
| 1057 | + if ( is_null( $this->getData( 'cvv_result' ) ) ){ |
| 1058 | + return null; |
| 1059 | + } |
| 1060 | + |
| 1061 | + $result_map = array( |
| 1062 | + 'M' => true, //CVV check performed and valid value. |
| 1063 | + 'N' => false, //CVV checked and no match. |
| 1064 | + 'P' => true, //CVV check not performed, not requested |
| 1065 | + 'S' => false, //Card holder claims no CVV-code on card, issuer states CVV-code should be on card. |
| 1066 | + 'U' => true, //? //Issuer not certified for CVV2. |
| 1067 | + 'Y' => false, //Server provider did not respond. |
| 1068 | + '0' => true, //No service available. |
| 1069 | + ); |
| 1070 | + |
| 1071 | + $result = $result_map[$this->getData( 'cvv_result' )]; |
| 1072 | + return $result; |
931 | 1073 | |
| 1074 | + } |
| 1075 | + |
| 1076 | + /** |
| 1077 | + * getAVSResult is intended to be used by the functions filter, to |
| 1078 | + * determine if we want to fail the transaction ourselves or not. |
| 1079 | + */ |
| 1080 | + public function getAVSResult(){ |
| 1081 | + if ( is_null( $this->getData( 'avs_result' ) ) ){ |
| 1082 | + return null; |
| 1083 | + } |
| 1084 | + //Best guess here: |
| 1085 | + //Scale of 0 - 100, of Problem we think this result is likely to cause. |
| 1086 | + |
| 1087 | + $result_map = array( |
| 1088 | + 'A' => 50, //Address (Street) matches, Zip does not. |
| 1089 | + 'B' => 50, //Street address match for international transactions. Postal code not verified due to incompatible formats. |
| 1090 | + 'C' => 50, //Street address and postal code not verified for international transaction due to incompatible formats. |
| 1091 | + 'D' => 0, //Street address and postal codes match for international transaction. |
| 1092 | + 'E' => 100, //AVS Error. |
| 1093 | + 'F' => 0, //Address does match and five digit ZIP code does match (UK only). |
| 1094 | + 'G' => 50, //Address information is unavailable; international transaction; non-AVS participant. |
| 1095 | + 'I' => 50, //Address information not verified for international transaction. |
| 1096 | + 'M' => 0, //Street address and postal codes match for international transaction. |
| 1097 | + 'N' => 100, //No Match on Address (Street) or Zip. |
| 1098 | + 'P' => 50, //Postal codes match for international transaction. Street address not verified due to incompatible formats. |
| 1099 | + 'R' => 100, //Retry, System unavailable or Timed out. |
| 1100 | + 'S' => 50, //Service not supported by issuer. |
| 1101 | + 'U' => 50, //Address information is unavailable. |
| 1102 | + 'W' => 50, //9 digit Zip matches, Address (Street) does not. |
| 1103 | + 'X' => 0, //Exact AVS Match. |
| 1104 | + 'Y' => 0, //Address (Street) and 5 digit Zip match. |
| 1105 | + 'Z' => 50, //5 digit Zip matches, Address (Street) does not. |
| 1106 | + '0' => 50, //No service available. |
| 1107 | + ); |
| 1108 | + |
| 1109 | + $result = $result_map[$this->getData( 'avs_result' )]; |
| 1110 | + return $result; |
| 1111 | + } |
| 1112 | + |
932 | 1113 | } |
\ No newline at end of file |
Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -642,16 +642,19 @@ |
643 | 643 | * human-readable assessments of what happened, probably straight from |
644 | 644 | * the gateway. |
645 | 645 | * 'action' = (sometimes there) What the pre-commit hooks said we should go |
646 | | - * do with ourselves. Mostly in there for debugging purposes at this |
647 | | - * point, as nothing on the outside should care at all, how we do things |
648 | | - * internally. |
| 646 | + * do with ourselves, if they were fired off. |
649 | 647 | * 'data' = The data passed back to us from the transaction, in a nice |
650 | 648 | * key-value array. |
651 | 649 | */ |
652 | 650 | public function do_transaction( $transaction ) { |
| 651 | + //reset, in case this isn't our first time. |
| 652 | + $this->transaction_results = array(); |
| 653 | + $this->setValidationAction('process', true); |
| 654 | + |
653 | 655 | try { |
654 | 656 | $this->setCurrentTransaction( $transaction ); |
655 | | - //update the contribution tracking data |
| 657 | + |
| 658 | + //TODO: This is a problem here. Needs to be moved to pre_process or something. |
656 | 659 | $this->incrementNumAttempt(); |
657 | 660 | |
658 | 661 | //If we have any special pre-process instructions for this |
— | — | @@ -675,6 +678,7 @@ |
676 | 679 | ); |
677 | 680 | } |
678 | 681 | |
| 682 | + //TODO: Maybe move this to the pre_process functions? |
679 | 683 | $this->dataObj->updateContributionTracking( defined( 'OWA' ) ); |
680 | 684 | |
681 | 685 | // If the payment processor requires XML, package our data into XML. |
— | — | @@ -732,6 +736,10 @@ |
733 | 737 | |
734 | 738 | //TODO: Death to the pulled_data parameter! |
735 | 739 | $this->processResponse( $pulled_data ); //now we've set all the transaction results... |
| 740 | + |
| 741 | + //well, almost all. |
| 742 | + $this->setTransactionResult( $this->getValidationAction(), 'action' ); |
| 743 | + |
736 | 744 | } else { |
737 | 745 | self::log( "Transaction Communication failed" . print_r( $this->getTransactionAllResults(), true ) ); |
738 | 746 | } |
— | — | @@ -783,21 +791,20 @@ |
784 | 792 | // log that the transaction is essentially complete |
785 | 793 | self::log( $this->getData( 'contribution_tracking_id' ) . " Transaction complete." ); |
786 | 794 | |
787 | | - //Session Handling |
788 | 795 | //getTransactionStatus works here like this, because it only returns |
789 | 796 | //something other than false if it's the sort of a transaction that can |
790 | 797 | //denote a successful donation. |
791 | | - $wmfStatus = $this->getTransactionWMFStatus(); |
792 | | - switch ( $wmfStatus ){ |
793 | | - case 'failed' : //only kill their session if they've tried three (or somehow more) times. |
794 | | - if ( (int)$this->postdata['numAttempt'] < 3 ) { |
795 | | - break; |
796 | | - } |
797 | | - case 'complete' : |
798 | | - case 'pending' : |
799 | | - case 'pending-poke' : |
800 | | - $this->unsetAllSessionData(); |
801 | | - } |
| 798 | +// $wmfStatus = $this->getTransactionWMFStatus(); |
| 799 | +// switch ( $wmfStatus ){ |
| 800 | +// case 'failed' : //only kill their session if they've tried three (or somehow more) times. |
| 801 | +// if ( (int)$this->postdata['numAttempt'] < 3 ) { |
| 802 | +// break; |
| 803 | +// } |
| 804 | +// case 'complete' : |
| 805 | +// case 'pending' : |
| 806 | +// case 'pending-poke' : |
| 807 | +// $this->unsetAllSessionData(); |
| 808 | +// } |
802 | 809 | |
803 | 810 | $this->debugarray[] = 'numAttempt = ' . $this->postdata['numAttempt']; |
804 | 811 | |