r100461 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100460‎ | r100461 | r100462 >
Date:21:59, 21 October 2011
Author:jpostlethwaite
Status:resolved (Comments)
Tags:fundraising 
Comment:
Changed $transaction_groups to $payment_methods. Changed $transaction_types to $payment_submethods. Added get methods for access to payment_methods and payment_submethods.
Modified paths:
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -70,20 +70,17 @@
7171 * Define transactions
7272 *
7373 * Please do not add more transactions to this array.
 74+ *
7475 * This method should define:
7576 * - INSERT_ORDERWITHPAYMENT: used for payments
7677 * - TEST_CONNECTION: testing connections - is this still valid?
7778 * - GET_ORDERSTATUS
78 - *
79 - * @todo
80 - * - Remove BANK_TRANSFER
81 - *
8279 */
8380 public function defineTransactions() {
8481
8582 // Define the transaction types and groups
86 - $this->defineTransactionGroups();
87 - $this->defineTransactionTypes();
 83+ $this->definePaymentMethods();
 84+ $this->definePaymentSubmethods();
8885
8986 $this->transactions = array( );
9087
@@ -186,24 +183,18 @@
187184 }
188185
189186 /**
190 - * Define transaction groups
191 - *
192 - * At some point, we are going to need methods to get this information to display available forms
193 - *
194 - * @todo
195 - * - This is not in use. This is a map to @see GlobalCollectAdapter::defineTransactionTypes()
196 - *
 187+ * Define payment methods
197188 */
198 - private function defineTransactionGroups() {
 189+ protected function definePaymentMethods() {
199190
200 - $this->transaction_groups = array();
 191+ $this->payment_methods = array();
201192
202 - $this->transaction_groups['rtbt'] = array(
 193+ $this->payment_methods['rtbt'] = array(
203194 'label' => 'Real time bank transfer',
204195 'types' => array( 'rtbt_ideal', 'rtbt_eps', 'rtbt_sofortuberweisung', 'rtbt_nordea_sweeden', 'rtbt_enets', ),
205196 );
206197
207 - $this->transaction_groups['bt'] = array(
 198+ $this->payment_methods['bt'] = array(
208199 'label' => 'Bank transfer',
209200 'types' => array( 'bt', ),
210201 'validation' => array( 'creditCard' => false, )
@@ -212,19 +203,19 @@
213204 }
214205
215206 /**
216 - * Define transaction types
 207+ * Define payment submethods
217208 *
218209 */
219 - private function defineTransactionTypes() {
 210+ protected function definePaymentSubmethods() {
220211
221 - $this->transaction_types = array();
 212+ $this->payment_submethods = array();
222213
223214 /*
224215 * Bank transfers
225216 */
226217
227218 // Bank Transfer
228 - $this->transaction_types['bt'] = array(
 219+ $this->payment_submethods['bt'] = array(
229220 'paymentproductid' => 11,
230221 'label' => 'Bank Transfer',
231222 'group' => 'bt',
@@ -236,7 +227,7 @@
237228 */
238229
239230 // Nordea (Sweeden)
240 - $this->transaction_types['rtbt_nordea_sweeden'] = array(
 231+ $this->payment_submethods['rtbt_nordea_sweeden'] = array(
241232 'paymentproductid' => 805,
242233 'label' => 'Nordea (Sweeden)',
243234 'group' => 'rtbt',
@@ -244,7 +235,7 @@
245236 );
246237
247238 // Ideal
248 - $this->transaction_types['rtbt_ideal'] = array(
 239+ $this->payment_submethods['rtbt_ideal'] = array(
249240 'paymentproductid' => 809,
250241 'label' => 'Ideal',
251242 'group' => 'rtbt',
@@ -252,7 +243,7 @@
253244 );
254245
255246 // eNETS
256 - $this->transaction_types['rtbt_enets'] = array(
 247+ $this->payment_submethods['rtbt_enets'] = array(
257248 'paymentproductid' => 810,
258249 'label' => 'eNETS',
259250 'group' => 'rtbt',
@@ -260,7 +251,7 @@
261252 );
262253
263254 // Sofortuberweisung/DIRECTebanking
264 - $this->transaction_types['rtbt_sofortuberweisung'] = array(
 255+ $this->payment_submethods['rtbt_sofortuberweisung'] = array(
265256 'paymentproductid' => 836,
266257 'label' => 'Sofortuberweisung/DIRECTebanking',
267258 'group' => 'rtbt',
@@ -268,7 +259,7 @@
269260 );
270261
271262 // eps Online-Überweisung
272 - $this->transaction_types['rtbt_eps'] = array(
 263+ $this->payment_submethods['rtbt_eps'] = array(
273264 'paymentproductid' => 856,
274265 'label' => 'eps Online-Überweisung',
275266 'group' => 'rtbt',
@@ -290,48 +281,48 @@
291282 }
292283
293284 /**
294 - * Get a transaction group meta
 285+ * Get payment method meta
295286 *
296 - * @param string $group Groups contain transaction types
 287+ * @param string $payment_method Payment methods contain payment submethods
297288 */
298 - public function getTransactionGroupMeta( $group ) {
 289+ public function getPaymentMethodMeta( $payment_method ) {
299290
300 - if ( isset( $this->transaction_groups[ $group ] ) ) {
 291+ if ( isset( $this->payment_methods[ $payment_method ] ) ) {
301292
302 - return $this->transaction_groups[ $group ];
 293+ return $this->payment_methods[ $payment_method ];
303294 }
304295 else {
305 - $message = 'The transaction group [ ' . $group . ' ] was not found.';
 296+ $message = 'The payment method [ ' . $payment_method . ' ] was not found.';
306297 throw new Exception( $message );
307298 }
308299 }
309300
310301 /**
311 - * Get a transaction type meta
 302+ * Get payment submethod meta
312303 *
313 - * @param string $transactionType Transaction types are mapped to paymentproductid
 304+ * @param string $payment_submethod Payment submethods are mapped to paymentproductid
314305 */
315 - public function getTransactionTypeMeta( $transactionType, $options = array() ) {
 306+ public function getPaymentSubmethodMeta( $payment_submethod, $options = array() ) {
316307
317308 extract( $options );
318309
319310 $log = isset( $log ) ? (boolean) $log : false ;
320311
321 - if ( isset( $this->transaction_types[ $transactionType ] ) ) {
 312+ if ( isset( $this->payment_submethods[ $payment_submethod ] ) ) {
322313
323314 if ( $log ) {
324 - $this->log( 'Getting transaction type: ' . ( string ) $transactionType );
 315+ $this->log( 'Getting payment submethod: ' . ( string ) $payment_submethod );
325316 }
326317
327318 // Ensure that the validation index is set.
328 - if ( !isset( $this->transaction_types[ $transactionType ]['validation'] ) ) {
329 - $this->transaction_types[ $transactionType ]['validation'] = array();
 319+ if ( !isset( $this->payment_submethods[ $payment_submethod ]['validation'] ) ) {
 320+ $this->payment_submethods[ $payment_submethod ]['validation'] = array();
330321 }
331322
332 - return $this->transaction_types[ $transactionType ];
 323+ return $this->payment_submethods[ $payment_submethod ];
333324 }
334325 else {
335 - $message = 'The transaction type [ ' . $transactionType . ' ] was not found.';
 326+ $message = 'The payment submethod [ ' . $payment_submethod . ' ] was not found.';
336327 throw new Exception( $message );
337328 }
338329 }
@@ -406,11 +397,6 @@
407398 $transaction = $this->currentTransaction();
408399
409400 switch ( $transaction ) {
410 - case 'BANK_TRANSFER':
411 - $data = $this->xmlChildrenToArray( $response, 'ROW' );
412 - $data['ORDER'] = $this->xmlChildrenToArray( $response, 'ORDER' );
413 - $data['PAYMENT'] = $this->xmlChildrenToArray( $response, 'PAYMENT' );
414 - break;
415401 case 'INSERT_ORDERWITHPAYMENT':
416402 $data = $this->xmlChildrenToArray( $response, 'ROW' );
417403 $data['ORDER'] = $this->xmlChildrenToArray( $response, 'ORDER' );
@@ -458,7 +444,7 @@
459445 'card_type',
460446 //'card_num',
461447 'returnto',
462 - 'transaction_type',
 448+ 'payment_method',
463449 'order_id', //This may or may not oughta-be-here...
464450 );
465451 }
@@ -518,19 +504,21 @@
519505 }
520506
521507 /**
522 - * Stage: transaction_type
 508+ * Stage: payment_method
523509 *
524510 * @param string $type request|response
525511 *
526512 * @todo
527 - * - ISSUERID will need to provide a dropdown for rtbt_ideal and rtbt_ideal.
 513+ * - Need to implement this for credit card if necessary
 514+ * - ISSUERID will need to provide a dropdown for rtbt_eps and rtbt_ideal.
528515 */
529 - protected function stage_transaction_type( $type = 'request' ) {
 516+ protected function stage_payment_method( $type = 'request' ) {
530517
531 - $transaction_type = array_key_exists( 'transaction_type', $this->postdata ) ? $this->postdata['transaction_type']: false;
 518+ $payment_method = array_key_exists( 'payment_method', $this->postdata ) ? $this->postdata['payment_method']: false;
 519+ $payment_submethod = array_key_exists( 'payment_submethod', $this->postdata ) ? $this->postdata['payment_submethod']: false;
532520
533521 // These will be grouped and ordred by payment product id
534 - switch ( $transaction_type ) {
 522+ switch ( $payment_submethod ) {
535523
536524 /* Bank transfer */
537525 case 'bt':
@@ -567,7 +555,7 @@
568556 break;
569557 }
570558 }
571 -
 559+
572560 /**
573561 * Stage: returnto
574562 *

Follow-up revisions

RevisionCommit summaryAuthorDate
r100643Commenting out parts of r100462, r100461, r100411, in order to get CC in Glob...khorn20:07, 24 October 2011
r100648Fixed the issues with credit cards for r100643.jpostlethwaite21:32, 24 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100456Reallocating fields in forms: payment_method. Adding fields: payment_submetho...jpostlethwaite21:42, 21 October 2011

Comments

#Comment by Khorn (WMF) (talk | contribs)   20:09, 24 October 2011

Parts of this broke CC in GlobalCollect. Those parts were commented out in r100643. Please fix asap.

#Comment by Jpostlethwaite (talk | contribs)   21:34, 24 October 2011

Fixed in r100648.

Status & tagging log