Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -77,6 +77,182 @@ |
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
| 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 | + /** |
81 | 257 | * Define var_map |
82 | 258 | * |
83 | 259 | * @todo |
— | — | @@ -93,7 +269,7 @@ |
94 | 270 | 'ADDRESSLINE3' => 'address_line_3', //dd:CH |
95 | 271 | 'ADDRESSLINE4' => 'address_line_4', //dd:CH |
96 | 272 | 'ATTEMPTID' => 'attempt_id', |
97 | | - 'AUTHORIZATIONID' => 'authorization_id', |
| 273 | + 'AUTHORISATIONID' => 'authorization_id', |
98 | 274 | 'AMOUNT' => 'amount', |
99 | 275 | 'BANKACCOUNTNUMBER' => 'bank_account_number', |
100 | 276 | 'BANKAGENZIA' => 'bank_agenzia', // dd:IT |
— | — | @@ -239,7 +415,7 @@ |
240 | 416 | 'GENERAL' => array( |
241 | 417 | 'ACCOUNTNAME', |
242 | 418 | 'ACCOUNTNUMBER', |
243 | | - 'AUTHORIZATIONID', |
| 419 | + 'AUTHORISATIONID', |
244 | 420 | 'BANKCHECKDIGIT', |
245 | 421 | 'BANKCODE', |
246 | 422 | 'BANKNAME', |
— | — | @@ -591,7 +767,7 @@ |
592 | 768 | 'label' => 'Direct debit: BE', |
593 | 769 | 'group' => 'dd', |
594 | 770 | 'validation' => array(), |
595 | | - 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'AUTHORIZATIONID', 'BANKCHECKDIGIT', 'BANKCODE', 'BANKNAME', 'DIRECTDEBITTEXT', ), |
| 771 | + 'keys' => array( 'ACCOUNTNAME', 'ACCOUNTNUMBER', 'AUTHORISATIONID', 'BANKCHECKDIGIT', 'BANKCODE', 'BANKNAME', 'DIRECTDEBITTEXT', ), |
596 | 772 | ); |
597 | 773 | |
598 | 774 | // Direct debit: CH |
— | — | @@ -636,7 +812,7 @@ |
637 | 813 | 'label' => 'Direct debit: GB', |
638 | 814 | 'group' => 'dd', |
639 | 815 | 'validation' => array(), |
640 | | - 'keys' => array( 'ACCOUNTNUMBER', 'AUTHORIZATIONID', 'BANKCODE', 'BANKNAME', 'DIRECTDEBITTEXT', 'TRANSACTIONTYPE', ), |
| 816 | + 'keys' => array( 'ACCOUNTNUMBER', 'AUTHORISATIONID', 'BANKCODE', 'BANKNAME', 'DIRECTDEBITTEXT', 'TRANSACTIONTYPE', ), |
641 | 817 | ); |
642 | 818 | |
643 | 819 | // Direct debit: IT |
— | — | @@ -1534,6 +1710,29 @@ |
1535 | 1711 | } |
1536 | 1712 | |
1537 | 1713 | /** |
| 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 | + /** |
1538 | 1737 | * Stage: payment_method |
1539 | 1738 | * |
1540 | 1739 | * @param string $type request|response |
— | — | @@ -1561,29 +1760,47 @@ |
1562 | 1761 | |
1563 | 1762 | /* Direct Debit */ |
1564 | 1763 | 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; |
1565 | 1768 | case 'dd_gb': |
1566 | 1769 | $this->staged_data['transaction_type'] = '01'; |
| 1770 | + |
| 1771 | + $this->setup_stage_payment_method_for_direct_debit( $payment_submethod, $type); |
| 1772 | + break; |
1567 | 1773 | 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; |
1568 | 1778 | case 'dd_be': |
| 1779 | + |
| 1780 | + $this->setup_stage_payment_method_for_direct_debit( $payment_submethod, $type); |
| 1781 | + break; |
1569 | 1782 | case 'dd_ch': |
| 1783 | + |
| 1784 | + $this->setup_stage_payment_method_for_direct_debit( $payment_submethod, $type); |
| 1785 | + break; |
1570 | 1786 | case 'dd_de': |
| 1787 | + |
| 1788 | + $this->setup_stage_payment_method_for_direct_debit( $payment_submethod, $type); |
| 1789 | + break; |
1571 | 1790 | 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; |
1572 | 1795 | 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; |
1573 | 1800 | 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; |
1580 | 1803 | |
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); |
1588 | 1805 | break; |
1589 | 1806 | |
1590 | 1807 | /* Online bank transfer */ |