Index: trunk/extensions/DonationInterface/donationinterface.php |
— | — | @@ -297,6 +297,39 @@ |
298 | 298 | //this really should be redefined in LocalSettings. |
299 | 299 | $wgGlobalCollectGatewayAllowedHtmlForms = $wgDonationInterfaceAllowedHtmlForms; |
300 | 300 | $wgGlobalCollectGatewayAllowedHtmlForms['lightbox1'] = $wgGlobalCollectGatewayHtmlFormDir .'/lightbox1.html'; |
| 301 | + |
| 302 | + $wgGlobalCollectGatewayCvvMap = array( |
| 303 | + 'M' => true, //CVV check performed and valid value. |
| 304 | + 'N' => false, //CVV checked and no match. |
| 305 | + 'P' => true, //CVV check not performed, not requested |
| 306 | + 'S' => false, //Card holder claims no CVV-code on card, issuer states CVV-code should be on card. |
| 307 | + 'U' => true, //? //Issuer not certified for CVV2. |
| 308 | + 'Y' => false, //Server provider did not respond. |
| 309 | + '0' => true, //No service available. |
| 310 | + ); |
| 311 | + |
| 312 | + $wgGlobalCollectGatewayAvsMap = array( |
| 313 | + 'A' => 50, //Address (Street) matches, Zip does not. |
| 314 | + 'B' => 50, //Street address match for international transactions. Postal code not verified due to incompatible formats. |
| 315 | + 'C' => 50, //Street address and postal code not verified for international transaction due to incompatible formats. |
| 316 | + 'D' => 0, //Street address and postal codes match for international transaction. |
| 317 | + 'E' => 100, //AVS Error. |
| 318 | + 'F' => 0, //Address does match and five digit ZIP code does match (UK only). |
| 319 | + 'G' => 50, //Address information is unavailable; international transaction; non-AVS participant. |
| 320 | + 'I' => 50, //Address information not verified for international transaction. |
| 321 | + 'M' => 0, //Street address and postal codes match for international transaction. |
| 322 | + 'N' => 100, //No Match on Address (Street) or Zip. |
| 323 | + 'P' => 50, //Postal codes match for international transaction. Street address not verified due to incompatible formats. |
| 324 | + 'R' => 100, //Retry, System unavailable or Timed out. |
| 325 | + 'S' => 50, //Service not supported by issuer. |
| 326 | + 'U' => 50, //Address information is unavailable. |
| 327 | + 'W' => 50, //9 digit Zip matches, Address (Street) does not. |
| 328 | + 'X' => 0, //Exact AVS Match. |
| 329 | + 'Y' => 0, //Address (Street) and 5 digit Zip match. |
| 330 | + 'Z' => 50, //5 digit Zip matches, Address (Street) does not. |
| 331 | + '0' => 50, //No service available. |
| 332 | + ); |
| 333 | + |
301 | 334 | } |
302 | 335 | |
303 | 336 | //PayflowPro gateway globals |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro.adapter.php |
— | — | @@ -265,6 +265,7 @@ |
266 | 266 | } |
267 | 267 | |
268 | 268 | protected function pre_process_card(){ |
| 269 | + $this->incrementNumAttempt(); |
269 | 270 | $this->runPreProcessHooks(); |
270 | 271 | } |
271 | 272 | |
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( 'K4sVoodoo' ); |
| 70 | + $_SESSION['order_status'][$oid] = $this->adapter->do_transaction( 'Confirm_CreditCard' ); |
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 |
— | — | @@ -287,13 +287,13 @@ |
288 | 288 | 'ACTION' => 'GET_ORDERSTATUS', |
289 | 289 | 'VERSION' => '2.0' |
290 | 290 | ), |
291 | | - 'loop_for_status' => array( |
292 | | - //'pending', |
293 | | - 'pending-poke', |
294 | | - 'complete', |
295 | | - 'failed', |
296 | | - 'revised', |
297 | | - ) |
| 291 | +// 'loop_for_status' => array( |
| 292 | +// //'pending', |
| 293 | +// 'pending-poke', |
| 294 | +// 'complete', |
| 295 | +// 'failed', |
| 296 | +// 'revised', |
| 297 | +// ) |
298 | 298 | ); |
299 | 299 | |
300 | 300 | $this->transactions['CANCEL_PAYMENT'] = array( |
— | — | @@ -714,16 +714,16 @@ |
715 | 715 | */ |
716 | 716 | public function do_transaction( $transaction ){ |
717 | 717 | switch ( $transaction ){ |
718 | | - case 'K4sVoodoo' : |
719 | | - return $this->doK4svoodoo(); |
| 718 | + case 'Confirm_CreditCard' : |
| 719 | + return $this->transactionConfirm_CreditCard(); |
720 | 720 | break; |
721 | 721 | default: |
722 | 722 | return parent::do_transaction( $transaction ); |
723 | 723 | } |
724 | 724 | } |
725 | 725 | |
726 | | - //TODO: rename, yo. |
727 | | - private function doK4svoodoo(){ |
| 726 | + |
| 727 | + private function transactionConfirm_CreditCard(){ |
728 | 728 | global $wgRequest; //this is for pulling vars straight from the querystring |
729 | 729 | $pull_vars = array( |
730 | 730 | 'CVVRESULT' => 'cvv_result', |
— | — | @@ -739,42 +739,101 @@ |
740 | 740 | if ( count( $addme ) ){ |
741 | 741 | $this->addData( $addme ); |
742 | 742 | } |
| 743 | + $logmsg = $this->getData_Raw( 'contribution_tracking_id' ) . ': '; |
| 744 | + $logmsg .= 'CVV Result: ' . $this->getData_Raw( 'cvv_result' ); |
| 745 | + $logmsg .= ', AVS Result: ' . $this->getData_Raw( 'avs_result' ); |
| 746 | + self::log( $logmsg ); |
743 | 747 | |
744 | 748 | $status_result = $this->do_transaction( 'GET_ORDERSTATUS' ); |
745 | 749 | |
746 | | -// $status_result['data']; |
747 | | -// |
748 | | - //TODO: If we've already failed, flame out here instead of later. |
| 750 | + //error_log( "GET_ORDERSTATUS result: " . $status_result ); |
| 751 | + |
| 752 | + $cancelflag = false; //this will denote the thing we're trying to do with the donation attempt |
| 753 | + $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. |
| 754 | + $problemmessage = ''; //to be used in conjunction with the flag. |
| 755 | + |
| 756 | + //we filtered |
| 757 | + if ( array_key_exists( 'action', $status_result ) && $status_result['action'] != 'process' ){ |
| 758 | + $cancelflag = true; |
| 759 | + } elseif ( array_key_exists( 'status', $status_result ) && $status_result['status'] === false ) { |
| 760 | + //can't communicate or internal error |
| 761 | + $problemflag = true; |
| 762 | + } |
749 | 763 | |
750 | | - if ( isset( $status_result['data'] ) && is_array( $status_result['data'] ) ){ |
751 | | - //if they're set, get CVVRESULT && AVSRESULT |
752 | | - $pull_vars['EFFORTID'] = 'effort_id'; |
753 | | - $pull_vars['ATTEMPTID'] = 'attempt_id'; |
754 | | - $addme = array(); |
755 | | - foreach ( $pull_vars as $theirkey => $ourkey) { |
756 | | - if ( array_key_exists( $theirkey, $status_result['data'] ) ){ |
757 | | - $addme[$ourkey] = $status_result['data'][$theirkey]; |
758 | | - } |
| 764 | + if ( !$cancelflag && !$problemflag ) { |
| 765 | + $order_status_results = $this->getTransactionWMFStatus(); |
| 766 | + if (!$order_status_results){ |
| 767 | + $problemflag = true; |
| 768 | + $problemmessage = "We don't have a Transaction WMF Status after doing a GET_ORDERSTATUS."; |
759 | 769 | } |
| 770 | + switch ( $order_status_results ){ |
| 771 | + //status says no - probably no need to cancel, but why not be explicit? |
| 772 | + case 'failed' : |
| 773 | + case 'revised' : |
| 774 | + $cancelflag = true; |
| 775 | + break; |
| 776 | + } |
| 777 | + } |
760 | 778 | |
761 | | - if ( count( $addme ) ){ |
762 | | - $this->addData( $addme ); |
| 779 | + //if we got here with no problemflag, |
| 780 | + //confirm or cancel the payment based on $cancelflag |
| 781 | + if ( !$problemflag ){ |
| 782 | + if ( isset( $status_result['data'] ) && is_array( $status_result['data'] ) ){ |
| 783 | + //if they're set, get CVVRESULT && AVSRESULT |
| 784 | + $pull_vars['EFFORTID'] = 'effort_id'; |
| 785 | + $pull_vars['ATTEMPTID'] = 'attempt_id'; |
| 786 | + $addme = array(); |
| 787 | + foreach ( $pull_vars as $theirkey => $ourkey) { |
| 788 | + if ( array_key_exists( $theirkey, $status_result['data'] ) ){ |
| 789 | + $addme[$ourkey] = $status_result['data'][$theirkey]; |
| 790 | + } |
| 791 | + } |
| 792 | + |
| 793 | + if ( count( $addme ) ){ |
| 794 | + $this->addData( $addme ); |
| 795 | + } |
763 | 796 | } |
764 | 797 | |
765 | | - //now, either do a cancel or a process, depending on what the filters |
766 | | - //said we should do. |
767 | | - switch ( $status_result['action'] ){ |
768 | | - case 'process' : |
769 | | - $final = $this->do_transaction( 'SET_PAYMENT' ); |
770 | | - break; |
771 | | - case 'reject' : |
772 | | - $final = $this->do_transaction( 'CANCEL_PAYMENT' ); |
773 | | - break; |
| 798 | + if ( !$cancelflag ){ |
| 799 | + $final = $this->do_transaction( 'SET_PAYMENT' ); |
| 800 | + if ( isset( $final['status'] ) && $final['status'] === true ) { |
| 801 | + $this->setTransactionWMFStatus( $order_status_results ); //this had damn well better exist if we got this far. |
| 802 | + $this->runPostProcessHooks(); //stomp is in here |
| 803 | + $this->unsetAllSessionData(); |
| 804 | + } else { |
| 805 | + $problemflag = true; |
| 806 | + $problemmessage = "SET_PAYMENT couldn't communicate properly!"; |
| 807 | + } |
| 808 | + } else { |
| 809 | + $final = $this->do_transaction( 'CANCEL_PAYMENT' ); |
| 810 | + if ( isset( $final['status'] ) && $final['status'] === true ) { |
| 811 | + $this->setTransactionWMFStatus( 'failed' ); |
| 812 | + $this->unsetAllSessionData(); |
| 813 | + } else { |
| 814 | + $problemflag = true; |
| 815 | + $problemmessage = "CANCEL_PAYMENT couldn't communicate properly!"; |
| 816 | + } |
774 | 817 | } |
775 | | - return $final; |
776 | 818 | } |
777 | | -// error_log("Got nothing good back from the first call..."); |
778 | | - return $status_result; |
| 819 | + |
| 820 | + if ( $problemflag ){ |
| 821 | + //we have probably had a communication problem that could mean stranded payments. |
| 822 | + $problemmessage = $this->getData_Raw( 'contribution_tracking_id' ) . ':' . $this->getData_Raw( 'order_id' ) . ' ' . $problemmessage; |
| 823 | + self::log( $problemmessage ); |
| 824 | + //hurm. It would be swell if we had a message that told the user we had some kind of internal error. |
| 825 | + return array( |
| 826 | + 'status' => false, |
| 827 | + //TODO: appropriate messages. |
| 828 | + 'message' => $problemmessage, |
| 829 | + 'errors' => array( |
| 830 | + '1000000' => 'Transaction could not be processed due to an internal error.' |
| 831 | + ), |
| 832 | + 'action' => $this->getValidationAction(), |
| 833 | + ); |
| 834 | + } |
| 835 | + |
| 836 | +// return something better... if we need to! |
| 837 | + return $status_result; |
779 | 838 | } |
780 | 839 | |
781 | 840 | /** |
— | — | @@ -1175,6 +1234,7 @@ |
1176 | 1235 | } |
1177 | 1236 | |
1178 | 1237 | protected function pre_process_insert_orderwithpayment(){ |
| 1238 | + $this->incrementNumAttempt(); |
1179 | 1239 | if ( $this->getData_Raw( 'payment_method' ) === 'cc' ){ |
1180 | 1240 | $this->addDonorDataToSession(); |
1181 | 1241 | } |
— | — | @@ -1186,8 +1246,10 @@ |
1187 | 1247 | } |
1188 | 1248 | } |
1189 | 1249 | |
1190 | | - protected function post_process_get_orderstatus(){ |
1191 | | - $this->runPostProcessHooks(); |
| 1250 | + protected function post_process_insert_orderwithpayment(){ |
| 1251 | + if ( $this->getData_Raw( 'payment_method' ) != 'cc' ){ |
| 1252 | + $this->runPostProcessHooks(); |
| 1253 | + } |
1192 | 1254 | } |
1193 | 1255 | |
1194 | 1256 | /** |
— | — | @@ -1199,17 +1261,9 @@ |
1200 | 1262 | return null; |
1201 | 1263 | } |
1202 | 1264 | |
1203 | | - $result_map = array( |
1204 | | - 'M' => true, //CVV check performed and valid value. |
1205 | | - 'N' => false, //CVV checked and no match. |
1206 | | - 'P' => true, //CVV check not performed, not requested |
1207 | | - 'S' => false, //Card holder claims no CVV-code on card, issuer states CVV-code should be on card. |
1208 | | - 'U' => true, //? //Issuer not certified for CVV2. |
1209 | | - 'Y' => false, //Server provider did not respond. |
1210 | | - '0' => true, //No service available. |
1211 | | - ); |
| 1265 | + $cvv_map = $this->getGlobal( 'CvvMap' ); |
1212 | 1266 | |
1213 | | - $result = $result_map[$this->getData_Raw( 'cvv_result' )]; |
| 1267 | + $result = $cvv_map[$this->getData_Raw( 'cvv_result' )]; |
1214 | 1268 | return $result; |
1215 | 1269 | |
1216 | 1270 | } |
— | — | @@ -1225,29 +1279,9 @@ |
1226 | 1280 | //Best guess here: |
1227 | 1281 | //Scale of 0 - 100, of Problem we think this result is likely to cause. |
1228 | 1282 | |
1229 | | - $result_map = array( |
1230 | | - 'A' => 50, //Address (Street) matches, Zip does not. |
1231 | | - 'B' => 50, //Street address match for international transactions. Postal code not verified due to incompatible formats. |
1232 | | - 'C' => 50, //Street address and postal code not verified for international transaction due to incompatible formats. |
1233 | | - 'D' => 0, //Street address and postal codes match for international transaction. |
1234 | | - 'E' => 100, //AVS Error. |
1235 | | - 'F' => 0, //Address does match and five digit ZIP code does match (UK only). |
1236 | | - 'G' => 50, //Address information is unavailable; international transaction; non-AVS participant. |
1237 | | - 'I' => 50, //Address information not verified for international transaction. |
1238 | | - 'M' => 0, //Street address and postal codes match for international transaction. |
1239 | | - 'N' => 100, //No Match on Address (Street) or Zip. |
1240 | | - 'P' => 50, //Postal codes match for international transaction. Street address not verified due to incompatible formats. |
1241 | | - 'R' => 100, //Retry, System unavailable or Timed out. |
1242 | | - 'S' => 50, //Service not supported by issuer. |
1243 | | - 'U' => 50, //Address information is unavailable. |
1244 | | - 'W' => 50, //9 digit Zip matches, Address (Street) does not. |
1245 | | - 'X' => 0, //Exact AVS Match. |
1246 | | - 'Y' => 0, //Address (Street) and 5 digit Zip match. |
1247 | | - 'Z' => 50, //5 digit Zip matches, Address (Street) does not. |
1248 | | - '0' => 50, //No service available. |
1249 | | - ); |
| 1283 | + $avs_map = $this->getGlobal( 'AvsMap' ); |
1250 | 1284 | |
1251 | | - $result = $result_map[$this->getData_Raw( 'avs_result' )]; |
| 1285 | + $result = $avs_map[$this->getData_Raw( 'avs_result' )]; |
1252 | 1286 | return $result; |
1253 | 1287 | } |
1254 | 1288 | |
Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -742,8 +742,8 @@ |
743 | 743 | * numeric codes (even if we have to make them up ourselves) and |
744 | 744 | * human-readable assessments of what happened, probably straight from |
745 | 745 | * the gateway. |
746 | | - * 'action' = (sometimes there) What the pre-commit hooks said we should go |
747 | | - * do with ourselves, if they were fired off. |
| 746 | + * 'action' = What the pre-commit hooks said we should go do with ourselves. |
| 747 | + * If none were fired, this will be set to 'process' |
748 | 748 | * 'data' = The data passed back to us from the transaction, in a nice |
749 | 749 | * key-value array. |
750 | 750 | */ |
— | — | @@ -754,9 +754,6 @@ |
755 | 755 | |
756 | 756 | try { |
757 | 757 | $this->setCurrentTransaction( $transaction ); |
758 | | - |
759 | | - //TODO: This is a problem here. Needs to be moved to pre_process or something. |
760 | | - $this->incrementNumAttempt(); |
761 | 758 | |
762 | 759 | //If we have any special pre-process instructions for this |
763 | 760 | //transaction, do 'em. |
— | — | @@ -868,6 +865,7 @@ |
869 | 866 | 'errors' => array( |
870 | 867 | '1000000' => 'communication failure' //...stupid code. |
871 | 868 | ), |
| 869 | + 'action' => $this->getValidationAction(), |
872 | 870 | ); |
873 | 871 | } |
874 | 872 | |
— | — | @@ -892,30 +890,10 @@ |
893 | 891 | // log that the transaction is essentially complete |
894 | 892 | self::log( $this->getData_Raw( 'contribution_tracking_id' ) . " Transaction complete." ); |
895 | 893 | |
896 | | - //getTransactionStatus works here like this, because it only returns |
897 | | - //something other than false if it's the sort of a transaction that can |
898 | | - //denote a successful donation. |
899 | | -// $wmfStatus = $this->getTransactionWMFStatus(); |
900 | | -// switch ( $wmfStatus ){ |
901 | | -// case 'failed' : //only kill their session if they've tried three (or somehow more) times. |
902 | | -// if ( (int)$this->getData_Staged('numAttempt') < 3 ) { |
903 | | -// break; |
904 | | -// } |
905 | | -// case 'complete' : |
906 | | -// case 'pending' : |
907 | | -// case 'pending-poke' : |
908 | | -// $this->unsetAllSessionData(); |
909 | | -// } |
910 | | - |
911 | 894 | $this->debugarray[] = 'numAttempt = ' . $this->getData_Staged('numAttempt'); |
912 | 895 | |
913 | 896 | return $this->getTransactionAllResults(); |
914 | | - |
915 | | - //speaking of universal form: |
916 | | - //$result['status'] = something I wish could be boiled down to a bool, but that's way too optimistic, I think. |
917 | | - //$result['message'] = whatever we want to display back? |
918 | | - //$result['errors']['code']['message'] = |
919 | | - //$result['data'][$whatever] = values they pass back to us for whatever reason. We might... log it, or pieces of it, or something? |
| 897 | + |
920 | 898 | } |
921 | 899 | |
922 | 900 | function getCurlBaseOpts() { |