Index: branches/fundraising/extensions/DonationInterface/donationinterface.php |
— | — | @@ -135,6 +135,6 @@ |
136 | 136 | $wgDonationInterfaceRetrySeconds = 5; |
137 | 137 | |
138 | 138 | function efDonationInterfaceUnitTests( &$files ) { |
139 | | - //$files[] = dirname( __FILE__ ) . '/tests/AllTests.php'; |
| 139 | + $files[] = dirname( __FILE__ ) . '/tests/AllTests.php'; |
140 | 140 | return true; |
141 | 141 | } |
Index: branches/fundraising/extensions/DonationInterface/tests/Adapter/GatewayAdapterTestCase.php |
— | — | @@ -24,13 +24,17 @@ |
25 | 25 | require_once dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'DonationInterfaceTestCase.php'; |
26 | 26 | |
27 | 27 | /** |
28 | | - * TODO: Something. |
29 | | - * Something roughly test-shaped. Here. |
30 | | - * ...to be more precise: Test that ALL the gateway adapters (Yes: All two of them) |
31 | | - * are building the XML we think they are, and that they can process sample |
32 | | - * return XML the way we think they should. |
| 28 | + * TODO: Test everything. |
| 29 | + * Make sure all the basic functions in the gateway_adapter are tested here. |
| 30 | + * Also, the extras and their hooks firing properly and... that the fail score |
| 31 | + * they give back is acted upon in the way we think it does. |
| 32 | + * Hint: For that mess, use GatewayAdapter's $debugarray |
33 | 33 | * |
34 | | - * TODO: Then, write all the other tests as well. :| |
| 34 | + * Also, note that it barely makes sense to test the functions that need to be |
| 35 | + * defined in each gateway as per the abstract class. If we did that here, we'd |
| 36 | + * basically be just testing the test code. So, don't do it. |
| 37 | + * Those should definitely be tested in the various gateway-specific test |
| 38 | + * classes. |
35 | 39 | * |
36 | 40 | * @group Fundraising |
37 | 41 | * @group Splunge |
— | — | @@ -51,7 +55,7 @@ |
52 | 56 | $gateway->publicCurrentTransaction( 'Test1' ); |
53 | 57 | $built = $gateway->buildRequestXML(); |
54 | 58 | $expected = '<?xml version="1.0"?>' . "\n"; |
55 | | - $expected .= '<XML><REQUEST><ACTION>Donate</ACTION><ACCOUNT><MERCHANTID>128</MERCHANTID><PASSWORD>k4ftw</PASSWORD><VERSION>3.2</VERSION><RETURNURL>http://' . TESTS_HOSTNAME . '/index.php/Donate-thanks/en</RETURNURL></ACCOUNT><DONATION><DONOR>Tester Testington</DONOR><AMOUNT>35000</AMOUNT><CURRENCYCODE>USD</CURRENCYCODE><LANGUAGECODE>en</LANGUAGECODE><COUNTRYCODE>US</COUNTRYCODE></DONATION></REQUEST></XML>' . "\n"; |
| 59 | + $expected .= '<XML><REQUEST><ACTION>Donate</ACTION><ACCOUNT><MERCHANTID>128</MERCHANTID><PASSWORD>k4ftw</PASSWORD><VERSION>3.2</VERSION><RETURNURL>http://' . TESTS_HOSTNAME . '/index.php/Special:GlobalCollectGatewayResult</RETURNURL></ACCOUNT><DONATION><DONOR>Tester Testington</DONOR><AMOUNT>35000</AMOUNT><CURRENCYCODE>USD</CURRENCYCODE><LANGUAGECODE>en</LANGUAGECODE><COUNTRYCODE>US</COUNTRYCODE></DONATION></REQUEST></XML>' . "\n"; |
56 | 60 | $this->assertEquals($built, $expected, "The constructed XML for transaction type Test1 does not match our expected."); |
57 | 61 | |
58 | 62 | } |
— | — | @@ -320,7 +324,8 @@ |
321 | 325 | public function curl_transaction($data) { |
322 | 326 | $data = ""; |
323 | 327 | $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>'; |
324 | | - return $data; |
| 328 | + $this->setTransactionResult( $data ); |
| 329 | + return true; |
325 | 330 | } |
326 | 331 | } |
327 | 332 | |
Index: branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -142,7 +142,6 @@ |
143 | 143 | $this->errors['retryMsg'] = $responseMsg; |
144 | 144 | $this->displayForm( $data, $this->errors ); |
145 | 145 | } |
146 | | - $this->displayResultsForDebug( $result ); |
147 | 146 | } |
148 | 147 | |
149 | 148 | /** |
Index: branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro.adapter.php |
— | — | @@ -124,10 +124,11 @@ |
125 | 125 | |
126 | 126 | /** |
127 | 127 | * Interpret response code, return |
128 | | - * 1 if approved |
129 | | - * 2 if declined |
| 128 | + * 1 if approved - 'complete' |
| 129 | + * 2 if declined - 'failed' |
130 | 130 | * 3 if invalid data was submitted by user |
131 | 131 | * 4 all other errors |
| 132 | + * 5 if pending - 'pending' |
132 | 133 | */ |
133 | 134 | function getResponseErrors( $response ) { |
134 | 135 | |
— | — | @@ -142,36 +143,47 @@ |
143 | 144 | switch ( $resultCode ) { |
144 | 145 | case '0': |
145 | 146 | $errors['1'] = wfMsg( 'payflowpro_gateway-response-0' ); |
| 147 | + $this->setTransactionWMFStatus( 'complete' ); |
146 | 148 | break; |
147 | 149 | case '126': |
148 | 150 | $errors['5'] = wfMsg( 'payflowpro_gateway-response-126-2' ); |
| 151 | + $this->setTransactionWMFStatus( 'pending' ); |
149 | 152 | break; |
150 | 153 | case '12': |
151 | 154 | $errors['2'] = wfMsg( 'payflowpro_gateway-response-12' ); |
| 155 | + $this->setTransactionWMFStatus( 'failed' ); |
152 | 156 | break; |
153 | 157 | case '13': |
154 | 158 | $errors['2'] = wfMsg( 'payflowpro_gateway-response-13' ); |
| 159 | + $this->setTransactionWMFStatus( 'failed' ); |
155 | 160 | break; |
156 | 161 | case '114': |
157 | 162 | $errors['2'] = wfMsg( 'payflowpro_gateway-response-114' ); |
| 163 | + $this->setTransactionWMFStatus( 'failed' ); |
158 | 164 | break; |
159 | 165 | case '4': |
160 | 166 | $errors['3'] = wfMsg( 'payflowpro_gateway-response-4' ); |
| 167 | + $this->setTransactionWMFStatus( 'failed' ); |
161 | 168 | break; |
162 | 169 | case '23': |
163 | 170 | $errors['3'] = wfMsg( 'payflowpro_gateway-response-23' ); |
| 171 | + $this->setTransactionWMFStatus( 'failed' ); |
164 | 172 | break; |
165 | 173 | case '24': |
166 | 174 | $errors['3'] = wfMsg( 'payflowpro_gateway-response-24' ); |
| 175 | + $this->setTransactionWMFStatus( 'failed' ); |
167 | 176 | break; |
168 | 177 | case '112': |
169 | 178 | $errors['3'] = wfMsg( 'payflowpro_gateway-response-112' ); |
| 179 | + $this->setTransactionWMFStatus( 'failed' ); |
170 | 180 | break; |
171 | 181 | case '125': |
172 | 182 | $errors['3'] = wfMsg( 'payflowpro_gateway-response-125-2' ); |
| 183 | + $this->setTransactionWMFStatus( 'failed' ); |
173 | 184 | break; |
174 | 185 | default: |
175 | 186 | $errors['4'] = wfMsg( 'payflowpro_gateway-response-default' ); |
| 187 | + $this->setTransactionWMFStatus( 'failed' ); |
176 | 188 | } |
177 | 189 | |
178 | 190 | return $errors; |
— | — | @@ -182,6 +194,7 @@ |
183 | 195 | * return a key/value array |
184 | 196 | */ |
185 | 197 | function getResponseData( $response ) { |
| 198 | + |
186 | 199 | if ( is_array( $response ) && !empty( $response ) ) { |
187 | 200 | return $response; |
188 | 201 | } |
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php |
— | — | @@ -76,7 +76,7 @@ |
77 | 77 | $this->displayResultsForDebug( $result ); |
78 | 78 | //do the switching between the... stuff. |
79 | 79 | |
80 | | - switch ( $result['data']['WMF_STATUS'] ) { |
| 80 | + switch ( $this->adapter->getTransactionWMFStatus() ) { |
81 | 81 | case 'complete': |
82 | 82 | case 'pending': |
83 | 83 | case 'pending-poke': |
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -281,7 +281,7 @@ |
282 | 282 | break; |
283 | 283 | case 'GET_ORDERSTATUS': |
284 | 284 | $data = $this->xmlChildrenToArray( $response, 'STATUS' ); |
285 | | - $data['WMF_STATUS'] = $this->findCodeAction( 'GET_ORDERSTATUS', 'STATUSID', $data['STATUSID'] ); |
| 285 | + $this->setTransactionWMFStatus( $this->findCodeAction( 'GET_ORDERSTATUS', 'STATUSID', $data['STATUSID'] ) ); |
286 | 286 | $data['ORDER'] = $this->xmlChildrenToArray( $response, 'ORDER' ); |
287 | 287 | break; |
288 | 288 | } |
Index: branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -461,6 +461,11 @@ |
462 | 462 | |
463 | 463 | // log that the transaction is essentially complete |
464 | 464 | self::log( $this->getData( 'order_id' ) . " Transaction complete." ); |
| 465 | + |
| 466 | + //if we're not actively adding the donor data to the session, kill it. |
| 467 | + if ( !$this->transaction_option( 'addDonorDataToSession' ) ) { |
| 468 | + $this->unsetAllGatewaySessionData(); |
| 469 | + } |
465 | 470 | |
466 | 471 | return $this->getTransactionAllResults(); |
467 | 472 | |
— | — | @@ -974,9 +979,8 @@ |
975 | 980 | * @return mixed WMF Transaction results status, or false if not set. |
976 | 981 | */ |
977 | 982 | public function getTransactionWMFStatus() { |
978 | | - if ( array_key_exists( 'data', $this->transaction_results ) && |
979 | | - array_key_exists( 'WMF_STATUS', $this->transaction_results['data'] ) ) { |
980 | | - return $this->transaction_results['data']['WMF_STATUS']; |
| 983 | + if ( array_key_exists( 'WMF_STATUS', $this->transaction_results ) ) { |
| 984 | + return $this->transaction_results['WMF_STATUS']; |
981 | 985 | } else { |
982 | 986 | return false; |
983 | 987 | } |
— | — | @@ -987,7 +991,7 @@ |
988 | 992 | * switching on behavior. |
989 | 993 | */ |
990 | 994 | public function setTransactionWMFStatus( $status ) { |
991 | | - $this->transaction_results['data']['WMF_STATUS'] = $status; |
| 995 | + $this->transaction_results['WMF_STATUS'] = $status; |
992 | 996 | } |
993 | 997 | |
994 | 998 | public function getTransactionMessage() { |
Index: branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -401,7 +401,9 @@ |
402 | 402 | } else { |
403 | 403 | $gateway_ident = "DonationData"; |
404 | 404 | } |
405 | | - unset( $_SESSION[$gateway_ident . 'EditToken'] ); |
| 405 | + if ( isset( $_SESSION ) && isset( $_SESSION[$gateway_ident . 'EditToken'] ) ){ |
| 406 | + unset( $_SESSION[$gateway_ident . 'EditToken'] ); |
| 407 | + } |
406 | 408 | } |
407 | 409 | |
408 | 410 | /** |