r102809 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102808‎ | r102809 | r102810 >
Date:19:24, 11 November 2011
Author:jpostlethwaite
Status:resolved (Comments)
Tags:fundraising 
Comment:
Checking in $this->data_constraints. Fixed spelling error for AUTHORISATIONID. Added new method setup_stage_payment_method_for_direct_debit() to help stage payments for direct debit.
Modified paths:
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -77,6 +77,182 @@
7878 }
7979
8080 /**
 81+ * Define data_constraints
 82+ *
 83+ * @todo
 84+ * - card_type: what do we do about this one? It is also payment_product.
 85+ *
 86+ */
 87+ public function defineDataConstraints() {
 88+
 89+ $this->data_constraints = array(
 90+
 91+ // General fields
 92+
 93+ //'ACCOUNTHOLDER' => 'account_holder', AN50
 94+ 'account_holder' => array('type' => 'alphanumeric', 'length' => 50, ),
 95+
 96+ //'ACCOUNTNAME' => 'account_name' AN35
 97+ 'account_name' => array( 'type' => 'alphanumeric', 'length' => 35, ),
 98+
 99+ //'ACCOUNTNUMBER' => 'account_number' AN30
 100+ 'account_number' => array( 'type' => 'alphanumeric', 'length' => 30, ),
 101+
 102+ //'ADDRESSLINE1E' => 'address_line_1e' AN35
 103+ 'address_line_1e' => array( 'type' => 'alphanumeric', 'length' => 35, ),
 104+
 105+ //'ADDRESSLINE2' => 'address_line_2' AN35
 106+ 'address_line_2' => array( 'type' => 'alphanumeric', 'length' => 35, ),
 107+
 108+ //'ADDRESSLINE3' => 'address_line_3' AN35
 109+ 'address_line_3' => array( 'type' => 'alphanumeric', 'length' => 35, ),
 110+
 111+ //'ADDRESSLINE4' => 'address_line_4' AN35
 112+ 'address_line_4' => array( 'type' => 'alphanumeric', 'length' => 35, ),
 113+
 114+ //'ATTEMPTID' => 'attempt_id' N5
 115+ 'attempt_id' => array( 'type' => 'numeric', 'length' => 5, ),
 116+
 117+ // Did not find this one
 118+ //'AUTHORISATIONID' => 'authorization_id' AN18
 119+ 'authorization_id' => array( 'type' => 'alphanumeric', 'length' => 18, ),
 120+
 121+ //'AMOUNT' => 'amount' N12
 122+ 'amount' => array( 'type' => 'numeric', 'length' => 12, ),
 123+
 124+ //'BANKACCOUNTNUMBER' => 'bank_account_number' AN50
 125+ 'bank_account_number' => array( 'type' => 'alphanumeric', 'length' => 50, ),
 126+
 127+ //'BANKAGENZIA' => 'bank_agenzia' AN30
 128+ 'bank_agenzia' => array( 'type' => 'alphanumeric', 'length' => 30, ),
 129+
 130+ //'BANKCHECKDIGIT' => 'bank_check_digit' AN2
 131+ 'bank_check_digit' => array( 'type' => 'alphanumeric', 'length' => 2, ),
 132+
 133+ //'BANKCODE' => 'bank_code' N5
 134+ 'bank_code' => array( 'type' => 'numeric', 'length' => 5, ),
 135+
 136+ //'BANKFILIALE' => 'bank_filiale' AN30
 137+ 'bank_filiale' => array( 'type' => 'alphanumeric', 'length' => 30, ),
 138+
 139+ //'BANKNAME' => 'bank_name' AN40
 140+ 'bank_name' => array( 'type' => 'alphanumeric', 'length' => 40, ),
 141+
 142+ //'BRANCHCODE' => 'branch_code' N5
 143+ 'branch_code' => array( 'type' => 'numeric', 'length' => 5, ),
 144+
 145+ //'CITY' => 'city' AN50
 146+ 'city' => array( 'type' => 'alphanumeric', 'length' => 50, ),
 147+
 148+ //'COUNTRYCODE' => 'country' AN2
 149+ 'country' => array( 'type' => 'alphanumeric', 'length' => 2, ),
 150+
 151+ //'COUNTRYCODEBANK' => 'country_code_bank' AN2
 152+ 'country_code_bank' => array( 'type' => 'alphanumeric', 'length' => 2, ),
 153+
 154+ //'COUNTRYDESCRIPTION' => 'country_description' AN50
 155+ 'country_description' => array( 'type' => 'alphanumeric', 'length' => 50, ),
 156+
 157+ //'CUSTOMERBANKCITY' => 'customer_bank_city' AN50
 158+ 'customer_bank_city' => array( 'type' => 'alphanumeric', 'length' => 50, ),
 159+
 160+ //'CUSTOMERBANKSTREET' => 'customer_bank_street' AN30
 161+ 'customer_bank_street' => array( 'type' => 'alphanumeric', 'length' => 30, ),
 162+
 163+ //'CUSTOMERBANKNUMBER' => 'customer_bank_number' N5
 164+ 'customer_bank_number' => array( 'type' => 'numeric', 'length' => 5, ),
 165+
 166+ //'CUSTOMERBANKZIP' => 'customer_bank_zip' AN10
 167+ 'customer_bank_zip' => array( 'type' => 'alphanumeric', 'length' => 10, ),
 168+
 169+ //'CREDITCARDNUMBER' => 'card_num' N19
 170+ 'card_num' => array( 'type' => 'numeric', 'length' => 19, ),
 171+
 172+ //'CURRENCYCODE' => 'currency_code' AN3
 173+ 'currency_code' => array( 'type' => 'alphanumeric', 'length' => 3, ),
 174+
 175+ //'CVV' => 'cvv' N4
 176+ 'cvv' => array( 'type' => 'numeric', 'length' => 4, ),
 177+
 178+ //'DATECOLLECT' => 'date_collect' D8 YYYYMMDD
 179+ 'date_collect' => array( 'type' => 'date', 'length' => 8, ),
 180+
 181+ //'DIRECTDEBITTEXT' => 'direct_debit_text' AN50
 182+ 'direct_debit_text' => array( 'type' => 'alphanumeric', 'length' => 50, ),
 183+
 184+ //'DOMICILIO' => 'domicilio' AN30
 185+ 'domicilio' => array( 'type' => 'alphanumeric', 'length' => 30, ),
 186+
 187+ //'EFFORTID' => 'effort_id' N5
 188+ 'effort_id' => array( 'type' => 'numeric', 'length' => 5, ),
 189+
 190+ //'EMAIL' => 'email' AN70
 191+ 'email' => array( 'type' => 'alphanumeric', 'length' => 70, ),
 192+
 193+ //'EXPIRYDATE' => 'expiration' N4 MMYY
 194+ 'expiration' => array( 'type' => 'numeric', 'length' => 4, ),
 195+
 196+ //'FIRSTNAME' => 'fname' AN15
 197+ 'fname' => array( 'type' => 'alphanumeric', 'length' => 15, ),
 198+
 199+ //'IBAN' => 'iban' AN50
 200+ // IBAN is AN21 on direct debit
 201+ 'iban' => array( 'type' => 'alphanumeric', 'length' => 50, ),
 202+
 203+ //'IPADDRESS' => 'user_ip' AN32
 204+ 'user_ip' => array( 'type' => 'alphanumeric', 'length' => 32, ),
 205+
 206+ //'ISSUERID' => 'issuer_id' N4
 207+ 'issuer_id' => array( 'type' => 'numeric', 'length' => 4, ),
 208+
 209+ //'LANGUAGECODE' => 'language' AN2
 210+ 'language' => array( 'type' => 'alphanumeric', 'length' => 2, ),
 211+
 212+ //'MERCHANTREFERENCE' => 'order_id' AN50
 213+ 'order_id' => array( 'type' => 'alphanumeric', 'length' => 50, ),
 214+
 215+ //'ORDERID' => 'order_id' N10
 216+ 'order_id' => array( 'type' => 'numeric', 'length' => 10, ),
 217+
 218+ // This is mapped to other things
 219+ //'PAYMENTPRODUCTID' => 'card_type' AN50
 220+ 'card_type' => array( 'type' => 'numeric', 'length' => 5, ),
 221+ 'payment_product' => array( 'type' => 'numeric', 'length' => 5, ),
 222+
 223+ //'PAYMENTREFERENCE' => 'payment_reference' AN20
 224+ 'payment_reference' => array( 'type' => 'alphanumeric', 'length' => 20, ),
 225+
 226+ //'PROVINCIA' => 'provincia' AN30
 227+ 'provincia' => array( 'type' => 'alphanumeric', 'length' => 30, ),
 228+
 229+ //'RETURNURL' => 'returnto' AN512
 230+ 'returnto' => array( 'type' => 'alphanumeric', 'length' => 512, ),
 231+
 232+ //'SPECIALID' => 'special_id' AN255
 233+ 'special_id' => array( 'type' => 'alphanumeric', 'length' => 255, ),
 234+
 235+ //'STATE' => 'state' AN35
 236+ 'state' => array( 'type' => 'alphanumeric', 'length' => 35, ),
 237+
 238+ //'STREET' => 'street' AN50
 239+ 'street' => array( 'type' => 'alphanumeric', 'length' => 50, ),
 240+
 241+ //'SURNAME' => 'lname' AN35
 242+ 'lname' => array( 'type' => 'alphanumeric', 'length' => 35, ),
 243+
 244+ //'SWIFTCODE' => 'swift_code' AN255
 245+ // This is AN11 for several payment types we are not dealing with yet.
 246+ 'swift_code' => array( 'type' => 'alphanumeric', 'length' => 255, ),
 247+
 248+ //'TRANSACTIONTYPE' => 'transaction_type' AN2
 249+ 'transaction_type' => array( 'type' => 'alphanumeric', 'length' => 2, ),
 250+
 251+ //'ZIP' => 'zip' AN10
 252+ 'zip' => array( 'type' => 'alphanumeric', 'length' => 10, ),
 253+ );
 254+ }
 255+
 256+ /**
81257 * Define var_map
82258 *
83259 * @todo
@@ -93,7 +269,7 @@
94270 'ADDRESSLINE3' => 'address_line_3', //dd:CH
95271 'ADDRESSLINE4' => 'address_line_4', //dd:CH
96272 'ATTEMPTID' => 'attempt_id',
97 - 'AUTHORIZATIONID' => 'authorization_id',
 273+ 'AUTHORISATIONID' => 'authorization_id',
98274 'AMOUNT' => 'amount',
99275 'BANKACCOUNTNUMBER' => 'bank_account_number',
100276 'BANKAGENZIA' => 'bank_agenzia', // dd:IT
@@ -239,7 +415,7 @@
240416 'GENERAL' => array(
241417 'ACCOUNTNAME',
242418 'ACCOUNTNUMBER',
243 - 'AUTHORIZATIONID',
 419+ 'AUTHORISATIONID',
244420 'BANKCHECKDIGIT',
245421 'BANKCODE',
246422 'BANKNAME',
@@ -591,7 +767,7 @@
592768 'label' => 'Direct debit: BE',
593769 'group' => 'dd',
594770 'validation' => array(),
595 - 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'AUTHORIZATIONID', 'BANKCHECKDIGIT', 'BANKCODE', 'BANKNAME', 'DIRECTDEBITTEXT', ),
 771+ 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'AUTHORISATIONID', 'BANKCHECKDIGIT', 'BANKCODE', 'BANKNAME', 'DIRECTDEBITTEXT', ),
596772 );
597773
598774 // Direct debit: CH
@@ -636,7 +812,7 @@
637813 'label' => 'Direct debit: GB',
638814 'group' => 'dd',
639815 'validation' => array(),
640 - 'keys' => array( 'ACCOUNTNUMBER', 'AUTHORIZATIONID', 'BANKCODE', 'BANKNAME', 'DIRECTDEBITTEXT', 'TRANSACTIONTYPE', ),
 816+ 'keys' => array( 'ACCOUNTNUMBER', 'AUTHORISATIONID', 'BANKCODE', 'BANKNAME', 'DIRECTDEBITTEXT', 'TRANSACTIONTYPE', ),
641817 );
642818
643819 // Direct debit: IT
@@ -1534,6 +1710,29 @@
15351711 }
15361712
15371713 /**
 1714+ * Stage: setup_stage_payment_method_for_direct_debit
 1715+ *
 1716+ * @param string $payment_submethod
 1717+ * @param string $type request|response
 1718+ */
 1719+ protected function setup_stage_payment_method_for_direct_debit( $payment_submethod, $type = 'request' ) {
 1720+
 1721+ // DATECOLLECT is required on all Direct Debit
 1722+ $this->addKeyToTransaction('DATECOLLECT');
 1723+
 1724+ $this->staged_data['date_collect'] = gmdate('Ymd');
 1725+ $this->staged_data['direct_debit_text'] = 'Wikimedia Foundation';
 1726+
 1727+ $this->staged_data['payment_product'] = $this->payment_submethods[ $payment_submethod ]['paymentproductid'];
 1728+ $this->data_constraints['IBAN']['length'] = 21;
 1729+ $this->var_map['PAYMENTPRODUCTID'] = 'payment_product';
 1730+ $this->var_map['COUNTRYCODEBANK'] = 'country';
 1731+
 1732+ // Direct debit has different required fields for each paymentproductid.
 1733+ $this->addKeysToTransactionForSubmethod( $payment_submethod );
 1734+ }
 1735+
 1736+ /**
15381737 * Stage: payment_method
15391738 *
15401739 * @param string $type request|response
@@ -1561,29 +1760,47 @@
15621761
15631762 /* Direct Debit */
15641763 case 'dd_nl':
 1764+ $this->data_constraints['DIRECTDEBITTEXT']['length'] = 32;
 1765+
 1766+ $this->setup_stage_payment_method_for_direct_debit( $payment_submethod, $type);
 1767+ break;
15651768 case 'dd_gb':
15661769 $this->staged_data['transaction_type'] = '01';
 1770+
 1771+ $this->setup_stage_payment_method_for_direct_debit( $payment_submethod, $type);
 1772+ break;
15671773 case 'dd_at':
 1774+ $this->data_constraints['DIRECTDEBITTEXT']['length'] = 28;
 1775+
 1776+ $this->setup_stage_payment_method_for_direct_debit( $payment_submethod, $type);
 1777+ break;
15681778 case 'dd_be':
 1779+
 1780+ $this->setup_stage_payment_method_for_direct_debit( $payment_submethod, $type);
 1781+ break;
15691782 case 'dd_ch':
 1783+
 1784+ $this->setup_stage_payment_method_for_direct_debit( $payment_submethod, $type);
 1785+ break;
15701786 case 'dd_de':
 1787+
 1788+ $this->setup_stage_payment_method_for_direct_debit( $payment_submethod, $type);
 1789+ break;
15711790 case 'dd_es':
 1791+ $this->data_constraints['DIRECTDEBITTEXT']['length'] = 40;
 1792+
 1793+ $this->setup_stage_payment_method_for_direct_debit( $payment_submethod, $type);
 1794+ break;
15721795 case 'dd_fr':
 1796+ $this->data_constraints['DIRECTDEBITTEXT']['length'] = 18;
 1797+
 1798+ $this->setup_stage_payment_method_for_direct_debit( $payment_submethod, $type);
 1799+ break;
15731800 case 'dd_it':
1574 -
1575 - // DATECOLLECT is required on all Direct Debit
1576 - $this->addKeyToTransaction('DATECOLLECT');
1577 -
1578 - $this->staged_data['date_collect'] = gmdate('Ymd');
1579 - $this->staged_data['direct_debit_text'] = 'Wikimedia Foundation';
 1801+ $this->data_constraints['BANKCHECKDIGIT']['length'] = 1;
 1802+ $this->data_constraints['DIRECTDEBITTEXT']['length'] = 32;
15801803
1581 - $this->staged_data['payment_product'] = $this->payment_submethods[ $payment_submethod ]['paymentproductid'];
1582 - $this->var_map['PAYMENTPRODUCTID'] = 'payment_product';
1583 - $this->var_map['COUNTRYCODEBANK'] = 'country';
1584 -
1585 - // Direct debit has different required fields for each paymentproductid.
1586 - $this->addKeysToTransactionForSubmethod( $payment_submethod );
1587 -
 1804+ $this->setup_stage_payment_method_for_direct_debit( $payment_submethod, $type);
15881805 break;
15891806
15901807 /* Online bank transfer */

Follow-up revisions

RevisionCommit summaryAuthorDate
r102810Fixed wrong index on data_constraints. Changed method to camel case for codin...jpostlethwaite19:58, 11 November 2011
r102929Re-attempting MFT r102576, r102577, r102578, r102579, r102581, r102689, r1027...khorn00:50, 14 November 2011

Comments

#Comment by Kaldari (talk | contribs)   19:54, 11 November 2011

Need to fix case on instances of data_constraints['XXXXX'] to data_constraints['xxx_xx'].

#Comment by Jpostlethwaite (talk | contribs)   19:59, 11 November 2011

Using wrong indexes for:

$this->data_constraints['DIRECTDEBITTEXT']['length'] = 32;

Should be:

$this->data_constraints['direct_debit_text']['length'] = 32;
#Comment by Kaldari (talk | contribs)   20:02, 11 November 2011

fixed in r102810.

Status & tagging log