Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -70,20 +70,17 @@ |
71 | 71 | * Define transactions |
72 | 72 | * |
73 | 73 | * Please do not add more transactions to this array. |
| 74 | + * |
74 | 75 | * This method should define: |
75 | 76 | * - INSERT_ORDERWITHPAYMENT: used for payments |
76 | 77 | * - TEST_CONNECTION: testing connections - is this still valid? |
77 | 78 | * - GET_ORDERSTATUS |
78 | | - * |
79 | | - * @todo |
80 | | - * - Remove BANK_TRANSFER |
81 | | - * |
82 | 79 | */ |
83 | 80 | public function defineTransactions() { |
84 | 81 | |
85 | 82 | // Define the transaction types and groups |
86 | | - $this->defineTransactionGroups(); |
87 | | - $this->defineTransactionTypes(); |
| 83 | + $this->definePaymentMethods(); |
| 84 | + $this->definePaymentSubmethods(); |
88 | 85 | |
89 | 86 | $this->transactions = array( ); |
90 | 87 | |
— | — | @@ -186,24 +183,18 @@ |
187 | 184 | } |
188 | 185 | |
189 | 186 | /** |
190 | | - * Define transaction groups |
191 | | - * |
192 | | - * At some point, we are going to need methods to get this information to display available forms |
193 | | - * |
194 | | - * @todo |
195 | | - * - This is not in use. This is a map to @see GlobalCollectAdapter::defineTransactionTypes() |
196 | | - * |
| 187 | + * Define payment methods |
197 | 188 | */ |
198 | | - private function defineTransactionGroups() { |
| 189 | + protected function definePaymentMethods() { |
199 | 190 | |
200 | | - $this->transaction_groups = array(); |
| 191 | + $this->payment_methods = array(); |
201 | 192 | |
202 | | - $this->transaction_groups['rtbt'] = array( |
| 193 | + $this->payment_methods['rtbt'] = array( |
203 | 194 | 'label' => 'Real time bank transfer', |
204 | 195 | 'types' => array( 'rtbt_ideal', 'rtbt_eps', 'rtbt_sofortuberweisung', 'rtbt_nordea_sweeden', 'rtbt_enets', ), |
205 | 196 | ); |
206 | 197 | |
207 | | - $this->transaction_groups['bt'] = array( |
| 198 | + $this->payment_methods['bt'] = array( |
208 | 199 | 'label' => 'Bank transfer', |
209 | 200 | 'types' => array( 'bt', ), |
210 | 201 | 'validation' => array( 'creditCard' => false, ) |
— | — | @@ -212,19 +203,19 @@ |
213 | 204 | } |
214 | 205 | |
215 | 206 | /** |
216 | | - * Define transaction types |
| 207 | + * Define payment submethods |
217 | 208 | * |
218 | 209 | */ |
219 | | - private function defineTransactionTypes() { |
| 210 | + protected function definePaymentSubmethods() { |
220 | 211 | |
221 | | - $this->transaction_types = array(); |
| 212 | + $this->payment_submethods = array(); |
222 | 213 | |
223 | 214 | /* |
224 | 215 | * Bank transfers |
225 | 216 | */ |
226 | 217 | |
227 | 218 | // Bank Transfer |
228 | | - $this->transaction_types['bt'] = array( |
| 219 | + $this->payment_submethods['bt'] = array( |
229 | 220 | 'paymentproductid' => 11, |
230 | 221 | 'label' => 'Bank Transfer', |
231 | 222 | 'group' => 'bt', |
— | — | @@ -236,7 +227,7 @@ |
237 | 228 | */ |
238 | 229 | |
239 | 230 | // Nordea (Sweeden) |
240 | | - $this->transaction_types['rtbt_nordea_sweeden'] = array( |
| 231 | + $this->payment_submethods['rtbt_nordea_sweeden'] = array( |
241 | 232 | 'paymentproductid' => 805, |
242 | 233 | 'label' => 'Nordea (Sweeden)', |
243 | 234 | 'group' => 'rtbt', |
— | — | @@ -244,7 +235,7 @@ |
245 | 236 | ); |
246 | 237 | |
247 | 238 | // Ideal |
248 | | - $this->transaction_types['rtbt_ideal'] = array( |
| 239 | + $this->payment_submethods['rtbt_ideal'] = array( |
249 | 240 | 'paymentproductid' => 809, |
250 | 241 | 'label' => 'Ideal', |
251 | 242 | 'group' => 'rtbt', |
— | — | @@ -252,7 +243,7 @@ |
253 | 244 | ); |
254 | 245 | |
255 | 246 | // eNETS |
256 | | - $this->transaction_types['rtbt_enets'] = array( |
| 247 | + $this->payment_submethods['rtbt_enets'] = array( |
257 | 248 | 'paymentproductid' => 810, |
258 | 249 | 'label' => 'eNETS', |
259 | 250 | 'group' => 'rtbt', |
— | — | @@ -260,7 +251,7 @@ |
261 | 252 | ); |
262 | 253 | |
263 | 254 | // Sofortuberweisung/DIRECTebanking |
264 | | - $this->transaction_types['rtbt_sofortuberweisung'] = array( |
| 255 | + $this->payment_submethods['rtbt_sofortuberweisung'] = array( |
265 | 256 | 'paymentproductid' => 836, |
266 | 257 | 'label' => 'Sofortuberweisung/DIRECTebanking', |
267 | 258 | 'group' => 'rtbt', |
— | — | @@ -268,7 +259,7 @@ |
269 | 260 | ); |
270 | 261 | |
271 | 262 | // eps Online-Überweisung |
272 | | - $this->transaction_types['rtbt_eps'] = array( |
| 263 | + $this->payment_submethods['rtbt_eps'] = array( |
273 | 264 | 'paymentproductid' => 856, |
274 | 265 | 'label' => 'eps Online-Überweisung', |
275 | 266 | 'group' => 'rtbt', |
— | — | @@ -290,48 +281,48 @@ |
291 | 282 | } |
292 | 283 | |
293 | 284 | /** |
294 | | - * Get a transaction group meta |
| 285 | + * Get payment method meta |
295 | 286 | * |
296 | | - * @param string $group Groups contain transaction types |
| 287 | + * @param string $payment_method Payment methods contain payment submethods |
297 | 288 | */ |
298 | | - public function getTransactionGroupMeta( $group ) { |
| 289 | + public function getPaymentMethodMeta( $payment_method ) { |
299 | 290 | |
300 | | - if ( isset( $this->transaction_groups[ $group ] ) ) { |
| 291 | + if ( isset( $this->payment_methods[ $payment_method ] ) ) { |
301 | 292 | |
302 | | - return $this->transaction_groups[ $group ]; |
| 293 | + return $this->payment_methods[ $payment_method ]; |
303 | 294 | } |
304 | 295 | else { |
305 | | - $message = 'The transaction group [ ' . $group . ' ] was not found.'; |
| 296 | + $message = 'The payment method [ ' . $payment_method . ' ] was not found.'; |
306 | 297 | throw new Exception( $message ); |
307 | 298 | } |
308 | 299 | } |
309 | 300 | |
310 | 301 | /** |
311 | | - * Get a transaction type meta |
| 302 | + * Get payment submethod meta |
312 | 303 | * |
313 | | - * @param string $transactionType Transaction types are mapped to paymentproductid |
| 304 | + * @param string $payment_submethod Payment submethods are mapped to paymentproductid |
314 | 305 | */ |
315 | | - public function getTransactionTypeMeta( $transactionType, $options = array() ) { |
| 306 | + public function getPaymentSubmethodMeta( $payment_submethod, $options = array() ) { |
316 | 307 | |
317 | 308 | extract( $options ); |
318 | 309 | |
319 | 310 | $log = isset( $log ) ? (boolean) $log : false ; |
320 | 311 | |
321 | | - if ( isset( $this->transaction_types[ $transactionType ] ) ) { |
| 312 | + if ( isset( $this->payment_submethods[ $payment_submethod ] ) ) { |
322 | 313 | |
323 | 314 | if ( $log ) { |
324 | | - $this->log( 'Getting transaction type: ' . ( string ) $transactionType ); |
| 315 | + $this->log( 'Getting payment submethod: ' . ( string ) $payment_submethod ); |
325 | 316 | } |
326 | 317 | |
327 | 318 | // Ensure that the validation index is set. |
328 | | - if ( !isset( $this->transaction_types[ $transactionType ]['validation'] ) ) { |
329 | | - $this->transaction_types[ $transactionType ]['validation'] = array(); |
| 319 | + if ( !isset( $this->payment_submethods[ $payment_submethod ]['validation'] ) ) { |
| 320 | + $this->payment_submethods[ $payment_submethod ]['validation'] = array(); |
330 | 321 | } |
331 | 322 | |
332 | | - return $this->transaction_types[ $transactionType ]; |
| 323 | + return $this->payment_submethods[ $payment_submethod ]; |
333 | 324 | } |
334 | 325 | else { |
335 | | - $message = 'The transaction type [ ' . $transactionType . ' ] was not found.'; |
| 326 | + $message = 'The payment submethod [ ' . $payment_submethod . ' ] was not found.'; |
336 | 327 | throw new Exception( $message ); |
337 | 328 | } |
338 | 329 | } |
— | — | @@ -406,11 +397,6 @@ |
407 | 398 | $transaction = $this->currentTransaction(); |
408 | 399 | |
409 | 400 | switch ( $transaction ) { |
410 | | - case 'BANK_TRANSFER': |
411 | | - $data = $this->xmlChildrenToArray( $response, 'ROW' ); |
412 | | - $data['ORDER'] = $this->xmlChildrenToArray( $response, 'ORDER' ); |
413 | | - $data['PAYMENT'] = $this->xmlChildrenToArray( $response, 'PAYMENT' ); |
414 | | - break; |
415 | 401 | case 'INSERT_ORDERWITHPAYMENT': |
416 | 402 | $data = $this->xmlChildrenToArray( $response, 'ROW' ); |
417 | 403 | $data['ORDER'] = $this->xmlChildrenToArray( $response, 'ORDER' ); |
— | — | @@ -458,7 +444,7 @@ |
459 | 445 | 'card_type', |
460 | 446 | //'card_num', |
461 | 447 | 'returnto', |
462 | | - 'transaction_type', |
| 448 | + 'payment_method', |
463 | 449 | 'order_id', //This may or may not oughta-be-here... |
464 | 450 | ); |
465 | 451 | } |
— | — | @@ -518,19 +504,21 @@ |
519 | 505 | } |
520 | 506 | |
521 | 507 | /** |
522 | | - * Stage: transaction_type |
| 508 | + * Stage: payment_method |
523 | 509 | * |
524 | 510 | * @param string $type request|response |
525 | 511 | * |
526 | 512 | * @todo |
527 | | - * - ISSUERID will need to provide a dropdown for rtbt_ideal and rtbt_ideal. |
| 513 | + * - Need to implement this for credit card if necessary |
| 514 | + * - ISSUERID will need to provide a dropdown for rtbt_eps and rtbt_ideal. |
528 | 515 | */ |
529 | | - protected function stage_transaction_type( $type = 'request' ) { |
| 516 | + protected function stage_payment_method( $type = 'request' ) { |
530 | 517 | |
531 | | - $transaction_type = array_key_exists( 'transaction_type', $this->postdata ) ? $this->postdata['transaction_type']: false; |
| 518 | + $payment_method = array_key_exists( 'payment_method', $this->postdata ) ? $this->postdata['payment_method']: false; |
| 519 | + $payment_submethod = array_key_exists( 'payment_submethod', $this->postdata ) ? $this->postdata['payment_submethod']: false; |
532 | 520 | |
533 | 521 | // These will be grouped and ordred by payment product id |
534 | | - switch ( $transaction_type ) { |
| 522 | + switch ( $payment_submethod ) { |
535 | 523 | |
536 | 524 | /* Bank transfer */ |
537 | 525 | case 'bt': |
— | — | @@ -567,7 +555,7 @@ |
568 | 556 | break; |
569 | 557 | } |
570 | 558 | } |
571 | | - |
| 559 | + |
572 | 560 | /** |
573 | 561 | * Stage: returnto |
574 | 562 | * |