r102829 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102828‎ | r102829 | r102830 >
Date:00:31, 12 November 2011
Author:jpostlethwaite
Status:ok (Comments)
Tags:fundraising 
Comment:
Reordered methods defineErrorMap() and defineDataConstraints() for code cleanliness.
Modified paths:
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -50,47 +50,20 @@
5151 }
5252
5353 /**
54 - * Define error_map
 54+ * Define dataConstraints
5555 *
5656 * @todo
57 - * - Add: Error messages
58 - */
59 - public function defineErrorMap() {
60 -
61 - $this->error_map = array(
62 - 0 => 'globalcollect_gateway-response-default',
63 - 430452 => 'globalcollect_gateway-response-default', // Not authorised :: This message was generated when trying to attempt a direct debit transaction from Belgium.
64 - 430900 => 'globalcollect_gateway-response-default', // NO VALID PROVIDERS FOUND FOR COMBINATION MERCHANTID: NNNN, PAYMENTPRODUCT: NNN, COUNTRYCODE: XX, CURRENCYCODE: XXX
65 -
66 - // Internal messages
67 - 'internal-0000' => 'donate_interface-processing-error', // Failed failed pre-process checks.
68 - 'internal-0001' => 'donate_interface-processing-error', // Transaction could not be processed due to an internal error.
69 - 'internal-0002' => 'donate_interface-processing-error', // Communication failure
70 -
71 - // Do bank validation messages
72 - //'dbv-50' => 'globalcollect_gateway-response-dbv-50', // Account number format incorrect
73 - //'dbv-80' => 'globalcollect_gateway-response-dbv-80', // Account details missing
74 - //'dbv-330' => 'globalcollect_gateway-response-dbv-330', // Check digit format is incorrect
75 - //'dbv-340' => 'globalcollect_gateway-response-dbv-340', // Branch code not submitted
76 -
77 - );
78 - }
79 -
80 - /**
81 - * Define data_constraints
82 - *
83 - * @todo
8457 * - card_type: what do we do about this one? It is also payment_product.
8558 *
8659 */
8760 public function defineDataConstraints() {
8861
89 - $this->data_constraints = array(
 62+ $this->dataConstraints = array(
9063
9164 // General fields
9265
9366 //'ACCOUNTHOLDER' => 'account_holder', AN50
94 - 'account_holder' => array('type' => 'alphanumeric', 'length' => 50, ),
 67+ 'account_holder' => array( 'type' => 'alphanumeric', 'length' => 50, ),
9568
9669 //'ACCOUNTNAME' => 'account_name' AN35
9770 'account_name' => array( 'type' => 'alphanumeric', 'length' => 35, ),
@@ -141,8 +114,8 @@
142115 //'BRANCHCODE' => 'branch_code' N5
143116 'branch_code' => array( 'type' => 'numeric', 'length' => 5, ),
144117
145 - //'CITY' => 'city' AN50
146 - 'city' => array( 'type' => 'alphanumeric', 'length' => 50, ),
 118+ //'CITY' => 'city' AN40
 119+ 'city' => array( 'type' => 'alphanumeric', 'length' => 40, ),
147120
148121 //'COUNTRYCODE' => 'country' AN2
149122 'country' => array( 'type' => 'alphanumeric', 'length' => 2, ),
@@ -251,6 +224,33 @@
252225 'zip' => array( 'type' => 'alphanumeric', 'length' => 10, ),
253226 );
254227 }
 228+
 229+ /**
 230+ * Define error_map
 231+ *
 232+ * @todo
 233+ * - Add: Error messages
 234+ */
 235+ public function defineErrorMap() {
 236+
 237+ $this->error_map = array(
 238+ 0 => 'globalcollect_gateway-response-default',
 239+ 430452 => 'globalcollect_gateway-response-default', // Not authorised :: This message was generated when trying to attempt a direct debit transaction from Belgium.
 240+ 430900 => 'globalcollect_gateway-response-default', // NO VALID PROVIDERS FOUND FOR COMBINATION MERCHANTID: NNNN, PAYMENTPRODUCT: NNN, COUNTRYCODE: XX, CURRENCYCODE: XXX
 241+
 242+ // Internal messages
 243+ 'internal-0000' => 'donate_interface-processing-error', // Failed failed pre-process checks.
 244+ 'internal-0001' => 'donate_interface-processing-error', // Transaction could not be processed due to an internal error.
 245+ 'internal-0002' => 'donate_interface-processing-error', // Communication failure
 246+
 247+ // Do bank validation messages
 248+ //'dbv-50' => 'globalcollect_gateway-response-dbv-50', // Account number format incorrect
 249+ //'dbv-80' => 'globalcollect_gateway-response-dbv-80', // Account details missing
 250+ //'dbv-330' => 'globalcollect_gateway-response-dbv-330', // Check digit format is incorrect
 251+ //'dbv-340' => 'globalcollect_gateway-response-dbv-340', // Branch code not submitted
 252+
 253+ );
 254+ }
255255
256256 /**
257257 * Define var_map
@@ -1538,12 +1538,6 @@
15391539 public function defineStagedVars() {
15401540 //OUR field names.
15411541 $this->staged_vars = array(
1542 - 'fname',
1543 - 'lname',
1544 - 'street',
1545 - 'city',
1546 - 'state',
1547 - 'email',
15481542 'amount',
15491543 'card_type',
15501544 //'card_num',
@@ -1556,36 +1550,6 @@
15571551 );
15581552 }
15591553
1560 - protected function stage_fname( $type = 'request' ) {
1561 - // Truncate to 15 characters due to GlobalCollect's field length limit
1562 - $this->staged_data['fname'] = substr( $this->staged_data['fname'], 0, 15 );
1563 - }
1564 -
1565 - protected function stage_lname( $type = 'request' ) {
1566 - // Truncate to 35 characters due to GlobalCollect's field length limit
1567 - $this->staged_data['lname'] = substr( $this->staged_data['lname'], 0, 35 );
1568 - }
1569 -
1570 - protected function stage_street( $type = 'request' ) {
1571 - // Truncate to 50 characters due to GlobalCollect's field length limit
1572 - $this->staged_data['street'] = substr( $this->staged_data['street'], 0, 50 );
1573 - }
1574 -
1575 - protected function stage_city( $type = 'request' ) {
1576 - // Truncate to 40 characters due to GlobalCollect's field length limit
1577 - $this->staged_data['city'] = substr( $this->staged_data['city'], 0, 40 );
1578 - }
1579 -
1580 - protected function stage_state( $type = 'request' ) {
1581 - // Truncate to 35 characters due to GlobalCollect's field length limit
1582 - $this->staged_data['state'] = substr( $this->staged_data['state'], 0, 35 );
1583 - }
1584 -
1585 - protected function stage_email( $type = 'request' ) {
1586 - // Truncate to 70 characters due to GlobalCollect's field length limit
1587 - $this->staged_data['email'] = substr( $this->staged_data['email'], 0, 70 );
1588 - }
1589 -
15901554 protected function stage_language( $type = 'request' ) {
15911555 $language = strtolower( $this->staged_data['language'] );
15921556
@@ -1727,7 +1691,7 @@
17281692 $this->var_map['PAYMENTPRODUCTID'] = 'payment_product';
17291693 $this->var_map['COUNTRYCODEBANK'] = 'country';
17301694
1731 - $this->data_constraints['iban']['length'] = 21;
 1695+ $this->dataConstraints['iban']['length'] = 21;
17321696
17331697 // Direct debit has different required fields for each paymentproductid.
17341698 $this->addKeysToTransactionForSubmethod( $payment_submethod );
@@ -1755,13 +1719,23 @@
17561720
17571721 /* Bank transfer */
17581722 case 'bt':
 1723+
 1724+ // Brazil
 1725+ if ( $this->staged_data['country'] == 'BR' ) {
 1726+ $this->dataConstraints['direct_debit_text']['city'] = 50;
 1727+ }
 1728+
 1729+ // Korea - Manual does not specify North or South
 1730+ if ( $this->staged_data['country'] == 'KR' ) {
 1731+ $this->dataConstraints['direct_debit_text']['city'] = 50;
 1732+ }
17591733 $this->staged_data['payment_product'] = $this->payment_submethods[ $payment_submethod ]['paymentproductid'];
17601734 $this->var_map['PAYMENTPRODUCTID'] = 'payment_product';
17611735 break;
17621736
17631737 /* Direct Debit */
17641738 case 'dd_nl':
1765 - $this->data_constraints['direct_debit_text']['length'] = 32;
 1739+ $this->dataConstraints['direct_debit_text']['length'] = 32;
17661740
17671741 $this->setupStagePaymentMethodForDirectDebit( $payment_submethod, $type);
17681742 break;
@@ -1771,7 +1745,7 @@
17721746 $this->setupStagePaymentMethodForDirectDebit( $payment_submethod, $type);
17731747 break;
17741748 case 'dd_at':
1775 - $this->data_constraints['direct_debit_text']['length'] = 28;
 1749+ $this->dataConstraints['direct_debit_text']['length'] = 28;
17761750
17771751 $this->setupStagePaymentMethodForDirectDebit( $payment_submethod, $type);
17781752 break;
@@ -1788,18 +1762,18 @@
17891763 $this->setupStagePaymentMethodForDirectDebit( $payment_submethod, $type);
17901764 break;
17911765 case 'dd_es':
1792 - $this->data_constraints['direct_debit_text']['length'] = 40;
 1766+ $this->dataConstraints['direct_debit_text']['length'] = 40;
17931767
17941768 $this->setupStagePaymentMethodForDirectDebit( $payment_submethod, $type);
17951769 break;
17961770 case 'dd_fr':
1797 - $this->data_constraints['direct_debit_text']['length'] = 18;
 1771+ $this->dataConstraints['direct_debit_text']['length'] = 18;
17981772
17991773 $this->setupStagePaymentMethodForDirectDebit( $payment_submethod, $type);
18001774 break;
18011775 case 'dd_it':
1802 - $this->data_constraints['bank_check_digit']['length'] = 1;
1803 - $this->data_constraints['direct_debit_text']['length'] = 32;
 1776+ $this->dataConstraints['bank_check_digit']['length'] = 1;
 1777+ $this->dataConstraints['direct_debit_text']['length'] = 32;
18041778
18051779 $this->setupStagePaymentMethodForDirectDebit( $payment_submethod, $type);
18061780 break;

Follow-up revisions

RevisionCommit summaryAuthorDate
r102832Added variable $this->dataConstraints. Added method $this->formatStagedData()...jpostlethwaite00:43, 12 November 2011
r103847MFT r102338, r102681, r102685, r102810, r102828, r102829, r102832, r102836, r...khorn22:30, 21 November 2011
r103848MFT r102338, r102681, r102685, r102810, r102828, r102829, r102832, r102836, r...khorn22:31, 21 November 2011

Comments

#Comment by Jpostlethwaite (talk | contribs)   00:37, 12 November 2011

Removed stage methods:

- stage_fname() - stage_lname() - stage_street() - stage_city() - stage_state() - stage_email()

Changed case of data_constraints() to dataConstraints()

Added custom data constraints for Bank Transfer Brazil and Korea.

Status & tagging log