r102087 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102086‎ | r102087 | r102088 >
Date:05:15, 5 November 2011
Author:jpostlethwaite
Status:ok (Comments)
Tags:fundraising 
Comment:
Added new information to payment_submethods. Required keys are now designated in for each direct debit product. These are now added with the method: addKeysToTransactionForSubmethod(). Although the fields are required, if they did not exist in staging or in the form as elements, they will not be attached to the XML request sent to GlobalCollect - this is not a bug, it is a feature! Several more fields for direct debit were added to $this->var_map.
Modified paths:
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -37,7 +37,6 @@
3838 *
3939 * @todo
4040 * - RETURNURL: Find out where the returnto URL is supposed to be coming from.
41 - * - IPADDRESS: Is the server IPA or the user/client IPA?
4241 */
4342 public function defineVarMap() {
4443
@@ -45,23 +44,34 @@
4645 'ACCOUNTHOLDER' => 'account_holder',
4746 'ACCOUNTNAME' => 'account_name',
4847 'ACCOUNTNUMBER' => 'account_number',
 48+ 'ADDRESSLINE1E' => 'address_line_1e', //dd:CH
 49+ 'ADDRESSLINE2' => 'address_line_2', //dd:CH
 50+ 'ADDRESSLINE3' => 'address_line_3', //dd:CH
 51+ 'ADDRESSLINE4' => 'address_line_4', //dd:CH
4952 'ATTEMPTID' => 'attempt_id',
5053 'AUTHORIZATIONID' => 'authorization_id',
5154 'AMOUNT' => 'amount',
5255 'BANKACCOUNTNUMBER' => 'bank_account_number',
 56+ 'BANKAGENZIA' => 'bank_agenzia', // dd:IT
5357 'BANKCHECKDIGIT' => 'bank_check_digit',
5458 'BANKCODE' => 'bank_code',
 59+ 'BANKFILIALE' => 'bank_filiale', // dd:IT
5560 'BANKNAME' => 'bank_name',
5661 'BRANCHCODE' => 'branch_code',
5762 'CITY' => 'city',
5863 'COUNTRYCODE' => 'country',
5964 'COUNTRYCODEBANK' => 'country_code_bank',
6065 'COUNTRYDESCRIPTION'=> 'country_description',
 66+ 'CUSTOMERBANKCITY' => 'customer_bank_city', // dd
 67+ 'CUSTOMERBANKSTREET'=> 'customer_bank_street', // dd
 68+ 'CUSTOMERBANKNUMBER'=> 'customer_bank_number', // dd
 69+ 'CUSTOMERBANKZIP' => 'customer_bank_zip', // dd
6170 'CREDITCARDNUMBER' => 'card_num',
6271 'CURRENCYCODE' => 'currency',
6372 'CVV' => 'cvv',
6473 'DATECOLLECT' => 'date_collect',
6574 'DIRECTDEBITTEXT' => 'direct_debit_text',
 75+ 'DOMICILIO' => 'domicilio', // dd:ES
6676 'EFFORTID' => 'effort_id',
6777 'EMAIL' => 'email',
6878 'EXPIRYDATE' => 'expiration',
@@ -74,13 +84,14 @@
7585 'ORDERID' => 'order_id',
7686 'PAYMENTPRODUCTID' => 'card_type',
7787 'PAYMENTREFERENCE' => 'payment_reference',
 88+ 'PROVINCIA' => 'provincia', // dd:ES
7889 'RETURNURL' => 'returnto',
7990 'SPECIALID' => 'special_id',
8091 'STATE' => 'state',
8192 'STREET' => 'street',
8293 'SURNAME' => 'lname',
8394 'SWIFTCODE' => 'swift_code',
84 - 'TRANSACTIONTYPE' => 'transaction_type',
 95+ 'TRANSACTIONTYPE' => 'transaction_type', // dd:GB,NL
8596 'ZIP' => 'zip',
8697 );
8798 }
@@ -496,6 +507,10 @@
497508
498509 /*
499510 * Direct debit
 511+ *
 512+ * See: WebCollect 7.1 Technical guide: Appendix H Country-specific direct debit keys
 513+ *
 514+ * - keys: These values, which can be found in $this->var_map, will only be put in the request, if they are populated from the form or staging.
500515 */
501516
502517 // Direct debit: AT
@@ -504,6 +519,7 @@
505520 'label' => 'Direct debit: AT',
506521 'group' => 'dd',
507522 'validation' => array(),
 523+ 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'BANKCODE', 'BANKNAME', 'DIRECTDEBITTEXT', ),
508524 );
509525
510526 // Direct debit: BE
@@ -512,6 +528,7 @@
513529 'label' => 'Direct debit: BE',
514530 'group' => 'dd',
515531 'validation' => array(),
 532+ 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'AUTHORIZATIONID', 'BANKNAME', 'DIRECTDEBITTEXT', ),
516533 );
517534
518535 // Direct debit: CH
@@ -520,6 +537,7 @@
521538 'label' => 'Direct debit: CH',
522539 'group' => 'dd',
523540 'validation' => array(),
 541+ 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'ADDRESSLINE1E', 'ADDRESSLINE2', 'ADDRESSLINE3', 'ADDRESSLINE4', 'BANKCODE', 'BANKNAME', 'CUSTOMERBANKCITY', 'CUSTOMERBANKNUMBER', 'CUSTOMERBANKSTREET', 'CUSTOMERBANKZIP', 'DIRECTDEBITTEXT', 'IBAN', ),
524542 );
525543
526544 // Direct debit: DE
@@ -528,6 +546,7 @@
529547 'label' => 'Direct debit: DE',
530548 'group' => 'dd',
531549 'validation' => array(),
 550+ 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'BANKCODE', 'BANKNAME', 'DIRECTDEBITTEXT', ),
532551 );
533552
534553 // Direct debit: ES
@@ -536,6 +555,7 @@
537556 'label' => 'Direct debit: ES',
538557 'group' => 'dd',
539558 'validation' => array(),
 559+ 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'BANKCODE', 'BANKNAME', 'BRANCHCODE', 'BANKCHECKDIGIT', 'CUSTOMERBANKCITY', 'CUSTOMERBANKSTREET', 'CUSTOMERBANKZIP', 'DIRECTDEBITTEXT', 'DOMICILIO', 'PROVINCIA', ),
540560 );
541561
542562 // Direct debit: FR
@@ -544,6 +564,7 @@
545565 'label' => 'Direct debit: FR',
546566 'group' => 'dd',
547567 'validation' => array(),
 568+ 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'BANKCODE', 'BANKNAME', 'BRANCHCODE', 'BANKCHECKDIGIT', 'DIRECTDEBITTEXT', ),
548569 );
549570
550571 // Direct debit: GB
@@ -552,6 +573,7 @@
553574 'label' => 'Direct debit: GB',
554575 'group' => 'dd',
555576 'validation' => array(),
 577+ 'keys' => array( 'ACCOUNTNUMBER', 'AUTHORIZATIONID', 'BANKCODE', 'BANKNAME', 'DIRECTDEBITTEXT', 'TRANSACTIONTYPE', ),
556578 );
557579
558580 // Direct debit: IT
@@ -560,6 +582,7 @@
561583 'label' => 'Direct debit: IT',
562584 'group' => 'dd',
563585 'validation' => array(),
 586+ 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'BANKCODE', 'BANKNAME', 'BRANCHCODE', 'BANKAGENZIA', 'BANKCHECKDIGIT', 'BANKFILIALE', 'CUSTOMERBANKCITY', 'CUSTOMERBANKNUMBER', 'CUSTOMERBANKSTREET', 'CUSTOMERBANKZIP', 'DIRECTDEBITTEXT', ),
564587 );
565588
566589 // Direct debit: NL
@@ -568,6 +591,7 @@
569592 'label' => 'Direct debit: NL',
570593 'group' => 'dd',
571594 'validation' => array(),
 595+ 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'BANKNAME', 'DIRECTDEBITTEXT', 'TRANSACTIONTYPE', ),
572596 );
573597
574598 /*
@@ -1140,6 +1164,8 @@
11411165 * - Need to implement this for credit card if necessary
11421166 * - ISSUERID will need to provide a dropdown for rtbt_eps and rtbt_ideal.
11431167 * - COUNTRYCODEBANK will need it's own dropdown for country. Do not map to 'country'
 1168+ * - DATECOLLECT is using gmdate('Ymd')
 1169+ * - DIRECTDEBITTEXT will need to be translated. This is what appears on the bank statement for donations for a client. This is hardcoded to: Wikimedia Foundation
11441170 */
11451171 protected function stage_payment_method( $type = 'request' ) {
11461172
@@ -1157,34 +1183,29 @@
11581184
11591185 /* Direct Debit */
11601186 case 'dd_nl':
1161 - case 'dd_de':
 1187+ case 'dd_gb':
 1188+ $this->staged_data['transaction_type'] = '01';
11621189 case 'dd_at':
1163 - case 'dd_fr':
1164 - case 'dd_gb':
11651190 case 'dd_be':
11661191 case 'dd_ch':
 1192+ case 'dd_de':
 1193+ case 'dd_es':
 1194+ case 'dd_fr':
11671195 case 'dd_it':
1168 - case 'dd_es':
 1196+
 1197+ // DATECOLLECT is required on all Direct Debit
 1198+ $this->addKeyToTransaction('DATECOLLECT');
 1199+
 1200+ $this->staged_data['date_collect'] = gmdate('Ymd');
 1201+ $this->staged_data['direct_debit_text'] = 'Wikimedia Foundation';
 1202+
11691203 $this->staged_data['payment_product'] = $this->payment_submethods[ $payment_submethod ]['paymentproductid'];
11701204 $this->var_map['PAYMENTPRODUCTID'] = 'payment_product';
11711205 $this->var_map['COUNTRYCODEBANK'] = 'country';
11721206
1173 - // Currently, this is needed by the Netherlands
1174 - $this->staged_data['transaction_type'] = '01';
 1207+ // Direct debit has different required fields for each paymentproductid.
 1208+ $this->addKeysToTransactionForSubmethod( $payment_submethod );
11751209
1176 - $this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS']['PAYMENT'][] = 'ACCOUNTNAME';
1177 - $this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS']['PAYMENT'][] = 'ACCOUNTNUMBER';
1178 - $this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS']['PAYMENT'][] = 'AUTHORIZATIONID';
1179 - $this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS']['PAYMENT'][] = 'BANKCHECKDIGIT';
1180 - $this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS']['PAYMENT'][] = 'BANKCODE';
1181 - $this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS']['PAYMENT'][] = 'BANKNAME';
1182 - $this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS']['PAYMENT'][] = 'BRANCHCODE';
1183 - $this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS']['PAYMENT'][] = 'COUNTRYCODEBANK';
1184 - $this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS']['PAYMENT'][] = 'DATECOLLECT';
1185 - $this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS']['PAYMENT'][] = 'DIRECTDEBITTEXT';
1186 - //$this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS']['PAYMENT'][] = 'IBAN';
1187 - $this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS']['PAYMENT'][] = 'TRANSACTIONTYPE';
1188 -
11891210 break;
11901211
11911212 /* Real time bank transfer */
@@ -1200,21 +1221,29 @@
12011222 $this->staged_data['payment_product'] = $this->payment_submethods[ $payment_submethod ]['paymentproductid'];
12021223 $this->var_map['PAYMENTPRODUCTID'] = 'payment_product';
12031224
1204 - // Add the ISSUERID field if it does not exist
1205 - if ( !in_array( 'ISSUERID', $this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS']['PAYMENT'] ) ) {
1206 - $this->transactions['INSERT_ORDERWITHPAYMENT']['request']['REQUEST']['PARAMS']['PAYMENT'][] = 'ISSUERID';
1207 - }
 1225+ $this->addKeyToTransaction('ISSUERID');
12081226 break;
12091227
12101228 /* Default Case */
12111229 default:
1212 - //$this->staged_data['payment_product'] = $this->payment_submethods[ $payment_submethod ]['paymentproductid'];
1213 - //$this->var_map['PAYMENTPRODUCTID'] = 'payment_product';
 1230+
 1231+ // Nothing is done in the default case.
12141232 break;
12151233 }
12161234 }
12171235
12181236 /**
 1237+ * Add keys to transaction for submethod
 1238+ *
 1239+ */
 1240+ protected function addKeysToTransactionForSubmethod( $payment_submethod ) {
 1241+
 1242+ foreach ( $this->payment_submethods[ $payment_submethod ]['keys'] as $key ) {
 1243+ $this->addKeyToTransaction( $key );
 1244+ }
 1245+ }
 1246+
 1247+ /**
12191248 * Stage: returnto
12201249 *
12211250 * @param string $type request|response

Follow-up revisions

RevisionCommit summaryAuthorDate
r102110Sync'ing i18n files to trunk @ r102087awjrichards19:42, 5 November 2011
r102114Sync'ing i18n files for DonationInterface to trunk @ r102087awjrichards20:17, 5 November 2011
r102236MFT r90286, r100671, r100837, r100950, r101060, r101063, r101064, r101073, r1......khorn03:06, 7 November 2011
r102237MFT r90286, r100671, r100837, r100950, r101060, r101063, r101064, r101073, r1......khorn03:07, 7 November 2011

Comments

#Comment by Jpostlethwaite (talk | contribs)   05:35, 5 November 2011

As you can see the some of the lines of code are really long.

I am hesitant to make changes in this right now. We should see how the arrays take shape as any more data as added. I have some ideas about this, but now is not the time for testing.

Status & tagging log