Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -37,7 +37,6 @@ |
38 | 38 | * |
39 | 39 | * @todo |
40 | 40 | * - RETURNURL: Find out where the returnto URL is supposed to be coming from. |
41 | | - * - IPADDRESS: Is the server IPA or the user/client IPA? |
42 | 41 | */ |
43 | 42 | public function defineVarMap() { |
44 | 43 | |
— | — | @@ -45,23 +44,34 @@ |
46 | 45 | 'ACCOUNTHOLDER' => 'account_holder', |
47 | 46 | 'ACCOUNTNAME' => 'account_name', |
48 | 47 | '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 |
49 | 52 | 'ATTEMPTID' => 'attempt_id', |
50 | 53 | 'AUTHORIZATIONID' => 'authorization_id', |
51 | 54 | 'AMOUNT' => 'amount', |
52 | 55 | 'BANKACCOUNTNUMBER' => 'bank_account_number', |
| 56 | + 'BANKAGENZIA' => 'bank_agenzia', // dd:IT |
53 | 57 | 'BANKCHECKDIGIT' => 'bank_check_digit', |
54 | 58 | 'BANKCODE' => 'bank_code', |
| 59 | + 'BANKFILIALE' => 'bank_filiale', // dd:IT |
55 | 60 | 'BANKNAME' => 'bank_name', |
56 | 61 | 'BRANCHCODE' => 'branch_code', |
57 | 62 | 'CITY' => 'city', |
58 | 63 | 'COUNTRYCODE' => 'country', |
59 | 64 | 'COUNTRYCODEBANK' => 'country_code_bank', |
60 | 65 | '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 |
61 | 70 | 'CREDITCARDNUMBER' => 'card_num', |
62 | 71 | 'CURRENCYCODE' => 'currency', |
63 | 72 | 'CVV' => 'cvv', |
64 | 73 | 'DATECOLLECT' => 'date_collect', |
65 | 74 | 'DIRECTDEBITTEXT' => 'direct_debit_text', |
| 75 | + 'DOMICILIO' => 'domicilio', // dd:ES |
66 | 76 | 'EFFORTID' => 'effort_id', |
67 | 77 | 'EMAIL' => 'email', |
68 | 78 | 'EXPIRYDATE' => 'expiration', |
— | — | @@ -74,13 +84,14 @@ |
75 | 85 | 'ORDERID' => 'order_id', |
76 | 86 | 'PAYMENTPRODUCTID' => 'card_type', |
77 | 87 | 'PAYMENTREFERENCE' => 'payment_reference', |
| 88 | + 'PROVINCIA' => 'provincia', // dd:ES |
78 | 89 | 'RETURNURL' => 'returnto', |
79 | 90 | 'SPECIALID' => 'special_id', |
80 | 91 | 'STATE' => 'state', |
81 | 92 | 'STREET' => 'street', |
82 | 93 | 'SURNAME' => 'lname', |
83 | 94 | 'SWIFTCODE' => 'swift_code', |
84 | | - 'TRANSACTIONTYPE' => 'transaction_type', |
| 95 | + 'TRANSACTIONTYPE' => 'transaction_type', // dd:GB,NL |
85 | 96 | 'ZIP' => 'zip', |
86 | 97 | ); |
87 | 98 | } |
— | — | @@ -496,6 +507,10 @@ |
497 | 508 | |
498 | 509 | /* |
499 | 510 | * 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. |
500 | 515 | */ |
501 | 516 | |
502 | 517 | // Direct debit: AT |
— | — | @@ -504,6 +519,7 @@ |
505 | 520 | 'label' => 'Direct debit: AT', |
506 | 521 | 'group' => 'dd', |
507 | 522 | 'validation' => array(), |
| 523 | + 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'BANKCODE', 'BANKNAME', 'DIRECTDEBITTEXT', ), |
508 | 524 | ); |
509 | 525 | |
510 | 526 | // Direct debit: BE |
— | — | @@ -512,6 +528,7 @@ |
513 | 529 | 'label' => 'Direct debit: BE', |
514 | 530 | 'group' => 'dd', |
515 | 531 | 'validation' => array(), |
| 532 | + 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'AUTHORIZATIONID', 'BANKNAME', 'DIRECTDEBITTEXT', ), |
516 | 533 | ); |
517 | 534 | |
518 | 535 | // Direct debit: CH |
— | — | @@ -520,6 +537,7 @@ |
521 | 538 | 'label' => 'Direct debit: CH', |
522 | 539 | 'group' => 'dd', |
523 | 540 | 'validation' => array(), |
| 541 | + 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'ADDRESSLINE1E', 'ADDRESSLINE2', 'ADDRESSLINE3', 'ADDRESSLINE4', 'BANKCODE', 'BANKNAME', 'CUSTOMERBANKCITY', 'CUSTOMERBANKNUMBER', 'CUSTOMERBANKSTREET', 'CUSTOMERBANKZIP', 'DIRECTDEBITTEXT', 'IBAN', ), |
524 | 542 | ); |
525 | 543 | |
526 | 544 | // Direct debit: DE |
— | — | @@ -528,6 +546,7 @@ |
529 | 547 | 'label' => 'Direct debit: DE', |
530 | 548 | 'group' => 'dd', |
531 | 549 | 'validation' => array(), |
| 550 | + 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'BANKCODE', 'BANKNAME', 'DIRECTDEBITTEXT', ), |
532 | 551 | ); |
533 | 552 | |
534 | 553 | // Direct debit: ES |
— | — | @@ -536,6 +555,7 @@ |
537 | 556 | 'label' => 'Direct debit: ES', |
538 | 557 | 'group' => 'dd', |
539 | 558 | 'validation' => array(), |
| 559 | + 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'BANKCODE', 'BANKNAME', 'BRANCHCODE', 'BANKCHECKDIGIT', 'CUSTOMERBANKCITY', 'CUSTOMERBANKSTREET', 'CUSTOMERBANKZIP', 'DIRECTDEBITTEXT', 'DOMICILIO', 'PROVINCIA', ), |
540 | 560 | ); |
541 | 561 | |
542 | 562 | // Direct debit: FR |
— | — | @@ -544,6 +564,7 @@ |
545 | 565 | 'label' => 'Direct debit: FR', |
546 | 566 | 'group' => 'dd', |
547 | 567 | 'validation' => array(), |
| 568 | + 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'BANKCODE', 'BANKNAME', 'BRANCHCODE', 'BANKCHECKDIGIT', 'DIRECTDEBITTEXT', ), |
548 | 569 | ); |
549 | 570 | |
550 | 571 | // Direct debit: GB |
— | — | @@ -552,6 +573,7 @@ |
553 | 574 | 'label' => 'Direct debit: GB', |
554 | 575 | 'group' => 'dd', |
555 | 576 | 'validation' => array(), |
| 577 | + 'keys' => array( 'ACCOUNTNUMBER', 'AUTHORIZATIONID', 'BANKCODE', 'BANKNAME', 'DIRECTDEBITTEXT', 'TRANSACTIONTYPE', ), |
556 | 578 | ); |
557 | 579 | |
558 | 580 | // Direct debit: IT |
— | — | @@ -560,6 +582,7 @@ |
561 | 583 | 'label' => 'Direct debit: IT', |
562 | 584 | 'group' => 'dd', |
563 | 585 | 'validation' => array(), |
| 586 | + 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'BANKCODE', 'BANKNAME', 'BRANCHCODE', 'BANKAGENZIA', 'BANKCHECKDIGIT', 'BANKFILIALE', 'CUSTOMERBANKCITY', 'CUSTOMERBANKNUMBER', 'CUSTOMERBANKSTREET', 'CUSTOMERBANKZIP', 'DIRECTDEBITTEXT', ), |
564 | 587 | ); |
565 | 588 | |
566 | 589 | // Direct debit: NL |
— | — | @@ -568,6 +591,7 @@ |
569 | 592 | 'label' => 'Direct debit: NL', |
570 | 593 | 'group' => 'dd', |
571 | 594 | 'validation' => array(), |
| 595 | + 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'BANKNAME', 'DIRECTDEBITTEXT', 'TRANSACTIONTYPE', ), |
572 | 596 | ); |
573 | 597 | |
574 | 598 | /* |
— | — | @@ -1140,6 +1164,8 @@ |
1141 | 1165 | * - Need to implement this for credit card if necessary |
1142 | 1166 | * - ISSUERID will need to provide a dropdown for rtbt_eps and rtbt_ideal. |
1143 | 1167 | * - 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 |
1144 | 1170 | */ |
1145 | 1171 | protected function stage_payment_method( $type = 'request' ) { |
1146 | 1172 | |
— | — | @@ -1157,34 +1183,29 @@ |
1158 | 1184 | |
1159 | 1185 | /* Direct Debit */ |
1160 | 1186 | case 'dd_nl': |
1161 | | - case 'dd_de': |
| 1187 | + case 'dd_gb': |
| 1188 | + $this->staged_data['transaction_type'] = '01'; |
1162 | 1189 | case 'dd_at': |
1163 | | - case 'dd_fr': |
1164 | | - case 'dd_gb': |
1165 | 1190 | case 'dd_be': |
1166 | 1191 | case 'dd_ch': |
| 1192 | + case 'dd_de': |
| 1193 | + case 'dd_es': |
| 1194 | + case 'dd_fr': |
1167 | 1195 | 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 | + |
1169 | 1203 | $this->staged_data['payment_product'] = $this->payment_submethods[ $payment_submethod ]['paymentproductid']; |
1170 | 1204 | $this->var_map['PAYMENTPRODUCTID'] = 'payment_product'; |
1171 | 1205 | $this->var_map['COUNTRYCODEBANK'] = 'country'; |
1172 | 1206 | |
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 ); |
1175 | 1209 | |
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 | | - |
1189 | 1210 | break; |
1190 | 1211 | |
1191 | 1212 | /* Real time bank transfer */ |
— | — | @@ -1200,21 +1221,29 @@ |
1201 | 1222 | $this->staged_data['payment_product'] = $this->payment_submethods[ $payment_submethod ]['paymentproductid']; |
1202 | 1223 | $this->var_map['PAYMENTPRODUCTID'] = 'payment_product'; |
1203 | 1224 | |
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'); |
1208 | 1226 | break; |
1209 | 1227 | |
1210 | 1228 | /* Default Case */ |
1211 | 1229 | 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. |
1214 | 1232 | break; |
1215 | 1233 | } |
1216 | 1234 | } |
1217 | 1235 | |
1218 | 1236 | /** |
| 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 | + /** |
1219 | 1248 | * Stage: returnto |
1220 | 1249 | * |
1221 | 1250 | * @param string $type request|response |