Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php |
— | — | @@ -92,26 +92,19 @@ |
93 | 93 | // The form was submitted and the payment method has been set |
94 | 94 | $this->adapter->log( "Form posted and payment method set." ); |
95 | 95 | |
96 | | - /* Commenting out because this is completely breaking Credit Card in GC. |
97 | | - * Under usual circumstances, that would be an automatic revert, but |
98 | | - * there were no small number of clean places to do that. |
99 | | - **/ |
| 96 | + /* |
| 97 | + * The $payment_method should default to false. |
| 98 | + * |
| 99 | + * An invalid $payment_method will cause an error. |
| 100 | + */ |
| 101 | + $payment_method = ( isset( $data['payment_method'] ) && !empty( $data['payment_method'] ) ) ? $data['payment_method'] : 'cc'; |
| 102 | + $payment_submethod = ( isset( $data['payment_submethod'] ) && !empty( $data['payment_submethod'] ) ) ? $data['payment_submethod'] : ''; |
| 103 | + |
| 104 | + $payment_submethodMeta = $this->adapter->getPaymentSubmethodMeta( $payment_submethod, array( 'log' => true, ) ); |
100 | 105 | |
101 | | -// /* |
102 | | -// * The $payment_method should default to false. |
103 | | -// * |
104 | | -// * An invalid $payment_method will cause an error. |
105 | | -// */ |
106 | | -// $payment_method = ( isset( $data['payment_method'] ) && !empty( $data['payment_method'] ) ) ? $data['payment_method'] : false; |
107 | | -// $payment_submethod = ( isset( $data['payment_submethod'] ) && !empty( $data['payment_submethod'] ) ) ? $data['payment_submethod'] : false; |
108 | | -// |
109 | | -// $payment_submethodMeta = $this->adapter->getPaymentSubmethodMeta( $payment_submethod, array( 'log' => true, ) ); |
110 | | -// |
111 | | -// // Check form for errors |
112 | | -// $form_errors = $this->validateForm( $data, $this->errors, $payment_submethodMeta['validation'] ); |
| 106 | + // Check form for errors |
| 107 | + $form_errors = $this->validateForm( $data, $this->errors, $payment_submethodMeta['validation'] ); |
113 | 108 | |
114 | | - $form_errors = $this->validateForm( $data, $this->errors, array( 'address', 'amount', 'creditCard', 'email', 'name' ) ); |
115 | | - |
116 | 109 | // If there were errors, redisplay form, otherwise proceed to next step |
117 | 110 | if ( $form_errors ) { |
118 | 111 | |
— | — | @@ -124,10 +117,10 @@ |
125 | 118 | |
126 | 119 | $this->displayResultsForDebug( $result ); |
127 | 120 | |
128 | | - //if ( $payment_method == 'credit' ) { |
| 121 | + if ( $payment_method == 'cc' ) { |
129 | 122 | |
130 | | - $this->executeIframeForCreditCard( $result ); |
131 | | - //} |
| 123 | + $this->executeIframeForCreditCard( $result ); |
| 124 | + } |
132 | 125 | |
133 | 126 | |
134 | 127 | //TODO: add all the hooks back in. |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -184,16 +184,26 @@ |
185 | 185 | |
186 | 186 | /** |
187 | 187 | * Define payment methods |
| 188 | + * |
| 189 | + * The credit card group has a catchall for unspecified payment types. |
188 | 190 | */ |
189 | 191 | protected function definePaymentMethods() { |
190 | 192 | |
191 | 193 | $this->payment_methods = array(); |
192 | 194 | |
| 195 | + // Credit Cards |
| 196 | + $this->payment_methods['cc'] = array( |
| 197 | + 'label' => 'Credit Cards', |
| 198 | + 'types' => array( '', 'visa', 'mc', 'amex', 'discover', 'maestro', 'solo', 'laser', 'jcb,', 'cb', ), |
| 199 | + ); |
| 200 | + |
| 201 | + // Real Time Bank Transfers |
193 | 202 | $this->payment_methods['rtbt'] = array( |
194 | 203 | 'label' => 'Real time bank transfer', |
195 | | - 'types' => array( 'rtbt_ideal', 'rtbt_eps', 'rtbt_sofortuberweisung', 'rtbt_nordea_sweeden', 'rtbt_enets', ), |
| 204 | + 'types' => array( 'rtbt_ideal', 'rtbt_eps', 'rtbt_sofortuberweisung', 'rtbt_nordea_sweeden', 'rtbt_enets', ), |
196 | 205 | ); |
197 | 206 | |
| 207 | + // Bank Transfers |
198 | 208 | $this->payment_methods['bt'] = array( |
199 | 209 | 'label' => 'Bank transfer', |
200 | 210 | 'types' => array( 'bt', ), |
— | — | @@ -211,6 +221,94 @@ |
212 | 222 | $this->payment_submethods = array(); |
213 | 223 | |
214 | 224 | /* |
| 225 | + * Credit Card |
| 226 | + */ |
| 227 | + |
| 228 | + // None specified - This is a catchall to validate all options for credit cards. |
| 229 | + $this->payment_submethods[''] = array( |
| 230 | + 'paymentproductid' => 0, |
| 231 | + 'label' => 'Any', |
| 232 | + 'group' => 'cc', |
| 233 | + 'validation' => array( 'address' => true, 'amount' => true, 'creditCard' => true, 'email' => true, 'name' => true, ), |
| 234 | + ); |
| 235 | + |
| 236 | + /* |
| 237 | + * Credit Card |
| 238 | + */ |
| 239 | + |
| 240 | + // Visa |
| 241 | + $this->payment_submethods['visa'] = array( |
| 242 | + 'paymentproductid' => 1, |
| 243 | + 'label' => 'Visa', |
| 244 | + 'group' => 'cc', |
| 245 | + 'validation' => array( 'address' => true, 'amount' => true, 'creditCard' => true, 'email' => true, 'name' => true, ), |
| 246 | + ); |
| 247 | + |
| 248 | + // MasterCard |
| 249 | + $this->payment_submethods['mc'] = array( |
| 250 | + 'paymentproductid' => 3, |
| 251 | + 'label' => 'MasterCard', |
| 252 | + 'group' => 'cc', |
| 253 | + 'validation' => array( 'address' => true, 'amount' => true, 'creditCard' => true, 'email' => true, 'name' => true, ), |
| 254 | + ); |
| 255 | + |
| 256 | + // American Express |
| 257 | + $this->payment_submethods['amex'] = array( |
| 258 | + 'paymentproductid' => 2, |
| 259 | + 'label' => 'American Express', |
| 260 | + 'group' => 'cc', |
| 261 | + 'validation' => array( 'address' => true, 'amount' => true, 'creditCard' => true, 'email' => true, 'name' => true, ), |
| 262 | + ); |
| 263 | + |
| 264 | + // Maestro |
| 265 | + $this->payment_submethods['maestro'] = array( |
| 266 | + 'paymentproductid' => 117, |
| 267 | + 'label' => 'Maestro', |
| 268 | + 'group' => 'cc', |
| 269 | + 'validation' => array( 'address' => true, 'amount' => true, 'creditCard' => true, 'email' => true, 'name' => true, ), |
| 270 | + ); |
| 271 | + |
| 272 | + // Solo |
| 273 | + $this->payment_submethods['solo'] = array( |
| 274 | + 'paymentproductid' => 118, |
| 275 | + 'label' => 'Solo', |
| 276 | + 'group' => 'cc', |
| 277 | + 'validation' => array( 'address' => true, 'amount' => true, 'creditCard' => true, 'email' => true, 'name' => true, ), |
| 278 | + ); |
| 279 | + |
| 280 | + // Laser |
| 281 | + $this->payment_submethods['laser'] = array( |
| 282 | + 'paymentproductid' => 124, |
| 283 | + 'label' => 'Laser', |
| 284 | + 'group' => 'cc', |
| 285 | + 'validation' => array( 'address' => true, 'amount' => true, 'creditCard' => true, 'email' => true, 'name' => true, ), |
| 286 | + ); |
| 287 | + |
| 288 | + // JCB |
| 289 | + $this->payment_submethods['jcb'] = array( |
| 290 | + 'paymentproductid' => 125, |
| 291 | + 'label' => 'JCB', |
| 292 | + 'group' => 'cc', |
| 293 | + 'validation' => array( 'address' => true, 'amount' => true, 'creditCard' => true, 'email' => true, 'name' => true, ), |
| 294 | + ); |
| 295 | + |
| 296 | + // Discover |
| 297 | + $this->payment_submethods['discover'] = array( |
| 298 | + 'paymentproductid' => 128, |
| 299 | + 'label' => 'Discover', |
| 300 | + 'group' => 'cc', |
| 301 | + 'validation' => array( 'address' => true, 'amount' => true, 'creditCard' => true, 'email' => true, 'name' => true, ), |
| 302 | + ); |
| 303 | + |
| 304 | + // CB |
| 305 | + $this->payment_submethods['cb'] = array( |
| 306 | + 'paymentproductid' => 130, |
| 307 | + 'label' => 'CB', // Carte Bancaire OR Carte Bleue |
| 308 | + 'group' => 'cc', |
| 309 | + 'validation' => array( 'address' => true, 'amount' => true, 'creditCard' => true, 'email' => true, 'name' => true, ), |
| 310 | + ); |
| 311 | + |
| 312 | + /* |
215 | 313 | * Bank transfers |
216 | 314 | */ |
217 | 315 | |
— | — | @@ -325,32 +423,27 @@ |
326 | 424 | */ |
327 | 425 | public function getPaymentSubmethodMeta( $payment_submethod, $options = array() ) { |
328 | 426 | |
329 | | - /* Commenting out because this is completely breaking Credit Card in GC. |
330 | | - * Under usual circumstances, that would be an automatic revert, but |
331 | | - * there were no small number of clean places to do that. |
332 | | - **/ |
| 427 | + extract( $options ); |
333 | 428 | |
334 | | -// extract( $options ); |
335 | | -// |
336 | | -// $log = isset( $log ) ? (boolean) $log : false ; |
337 | | -// |
338 | | -// if ( isset( $this->payment_submethods[ $payment_submethod ] ) ) { |
339 | | -// |
340 | | -// if ( $log ) { |
341 | | -// $this->log( 'Getting payment submethod: ' . ( string ) $payment_submethod ); |
342 | | -// } |
343 | | -// |
344 | | -// // Ensure that the validation index is set. |
345 | | -// if ( !isset( $this->payment_submethods[ $payment_submethod ]['validation'] ) ) { |
346 | | -// $this->payment_submethods[ $payment_submethod ]['validation'] = array(); |
347 | | -// } |
348 | | -// |
349 | | -// return $this->payment_submethods[ $payment_submethod ]; |
350 | | -// } |
351 | | -// else { |
352 | | -// $message = 'The payment submethod [ ' . $payment_submethod . ' ] was not found.'; |
353 | | -// throw new Exception( $message ); |
354 | | -// } |
| 429 | + $log = isset( $log ) ? (boolean) $log : false ; |
| 430 | + |
| 431 | + if ( isset( $this->payment_submethods[ $payment_submethod ] ) ) { |
| 432 | + |
| 433 | + if ( $log ) { |
| 434 | + $this->log( 'Getting payment submethod: ' . ( string ) $payment_submethod ); |
| 435 | + } |
| 436 | + |
| 437 | + // Ensure that the validation index is set. |
| 438 | + if ( !isset( $this->payment_submethods[ $payment_submethod ]['validation'] ) ) { |
| 439 | + $this->payment_submethods[ $payment_submethod ]['validation'] = array(); |
| 440 | + } |
| 441 | + |
| 442 | + return $this->payment_submethods[ $payment_submethod ]; |
| 443 | + } |
| 444 | + else { |
| 445 | + $message = 'The payment submethod [ ' . $payment_submethod . ' ] was not found.'; |
| 446 | + throw new Exception( $message ); |
| 447 | + } |
355 | 448 | } |
356 | 449 | |
357 | 450 | /** |