MediaWiki fundraising/REL1_35
IngenicoMethodCodec.php
Go to the documentation of this file.
1<?php
2
13 public function stage( GatewayType $adapter, $normalized, &$stagedData ) {
14 $logger = DonationLoggerFactory::getLogger( $adapter );
15
16 // FIXME: too much variable management
17 if ( empty( $normalized['payment_method'] ) ) {
18 $stagedData['payment_method'] = '';
19 $stagedData['payment_submethod'] = '';
20 return;
21 }
22 $payment_method = $normalized['payment_method'];
23 $payment_submethod = $normalized['payment_submethod'];
24
25 // We might support a variation of the submethod for this country.
26 // TODO: Having to front-load the country in the payment submethod is pretty lame.
27 // If we don't have one deliberately set...
28 if ( !$payment_submethod ) {
29 $trythis = $payment_method . '_' . strtolower( $normalized['country'] );
30 if ( array_key_exists( $trythis, $adapter->getPaymentSubmethods() ) ) {
31 $payment_submethod = $trythis;
32 $stagedData['payment_submethod'] = $payment_submethod;
33 }
34 }
35
36 // Lookup the payment product ID.
37 if ( $payment_submethod ) {
38 try {
39 $submethod_data = $adapter->getPaymentSubmethodMeta( $payment_submethod );
40 if ( isset( $submethod_data['paymentproductid'] ) ) {
41 $stagedData['payment_product'] = $submethod_data['paymentproductid'];
42 }
43 }
44 catch ( OutOfBoundsException $ex ) {
45 // Already logged. We don't have the heart to abort here.
46 }
47 } else {
48 $logger->debug( "payment_submethod found to be empty. Probably okay though." );
49 }
50
51 switch ( $payment_method ) {
52 case 'dd':
53 $stagedData['date_collect'] = gmdate( 'Ymd' );
54 $stagedData['direct_debit_text'] = 'Wikimedia Foundation';
55 break;
56 case 'ew':
57 $stagedData['descriptor'] = 'Wikimedia Foundation/Wikipedia';
58 break;
59 }
60
61 // Tweak transaction type
62 switch ( $payment_submethod ) {
63 case 'dd_nl':
64 $stagedData['transaction_type'] = '01';
65 break;
66 case 'dd_gb':
67 $stagedData['transaction_type'] = '01';
68 break;
69 }
70 }
71}
static getLogger(GatewayType $adapter, $suffix='', LogPrefixProvider $prefixer=null)
Convert our payment methods into Ingenico codes.
stage(GatewayType $adapter, $normalized, &$stagedData)
Stage: payment_product and a few minor tweaks Stages the payment product ID for GC.
GatewayType Interface.
getPaymentSubmethods()
Get the entire list of payment submethod definitions.
getPaymentSubmethodMeta( $payment_submethod=null)
Get metadata for the specified payment submethod.
Used to mark any class which implements an staging method, for transforming data into the form expect...