Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/tests/DonationDataTestCase.php |
— | — | @@ -317,7 +317,7 @@ |
318 | 318 | public static function ensureSession() { |
319 | 319 | public function checkTokens() { |
320 | 320 | function wasPosted(){ |
321 | | - public static function getUtmSource( $utm_source = null, $utm_source_id = null ) { |
| 321 | + function setUtmSource() { |
322 | 322 | public function getOptOuts() { |
323 | 323 | public function getCleanTrackingData( $clean_optouts = false ) { |
324 | 324 | function saveContributionTracking() { |
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/tests |
___________________________________________________________________ |
Modified: svn:mergeinfo |
325 | 325 | Merged /trunk/extensions/DonationInterface/tests:r101441 |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/payflowpro_gateway/api_payflowpro_gateway.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | /** |
4 | 4 | * PayflowPro Gateway API extension |
5 | 5 | * Call with api.php?action=pfp |
6 | | - * TODO: Determine if this is being used by anything anymore, and if so, what. |
| 6 | + * TODO: Move this somewhere that looks more gateway-agnostic. |
7 | 7 | */ |
8 | 8 | |
9 | 9 | class ApiPayflowProGateway extends ApiBase { |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | * An array of valid dispatch methods |
13 | 13 | */ |
14 | 14 | public $validDispatchMethods = array( 'dispatch_get_required_dynamic_form_elements' ); |
15 | | - |
| 15 | + |
16 | 16 | /** |
17 | 17 | * API for PayflowProGateway extension |
18 | 18 | * |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | // extract and validate the parameters |
28 | 28 | $params = $this->extractRequestParams(); |
29 | 29 | $this->validateParams( $params ); |
30 | | - |
| 30 | + |
31 | 31 | // route 'dispatch' requests to the appropriate method |
32 | 32 | if ( strlen( $params[ 'dispatch' ] ) ) { |
33 | 33 | $method = $this->getDispatchMethod( $params[ 'dispatch' ] ); |
— | — | @@ -48,6 +48,12 @@ |
49 | 49 | 'tracking_data' => array( |
50 | 50 | ApiBase::PARAM_TYPE => 'string', |
51 | 51 | ), |
| 52 | + 'gateway' => array( |
| 53 | + ApiBase::PARAM_TYPE => 'string', |
| 54 | + ), |
| 55 | + 'payment_method' => array( |
| 56 | + ApiBase::PARAM_TYPE => 'string', |
| 57 | + ), |
52 | 58 | ); |
53 | 59 | } |
54 | 60 | |
— | — | @@ -55,6 +61,8 @@ |
56 | 62 | return array( |
57 | 63 | 'dispatch' => 'the API method from which to return data', |
58 | 64 | 'tracking_data' => 'A JSON formatted string of data to insert into contribution_tracking', |
| 65 | + 'gateway' => 'The current gateway', |
| 66 | + 'payment_method' => 'The current payment method' |
59 | 67 | ); |
60 | 68 | } |
61 | 69 | |
— | — | @@ -73,7 +81,7 @@ |
74 | 82 | if ( isset( $params[ 'dispatch' ] ) && strlen( $params[ 'dispatch' ] ) ) { |
75 | 83 | $method = $this->getDispatchMethod( $params[ 'dispatch' ] ); |
76 | 84 | if ( !in_array( $method, $this->validDispatchMethods ) || !method_exists( $this, $method ) ) { |
77 | | - $this->dieUsage( "Invalid dispatch method <<<$method>>> passed to the PayflowPro Gatweay API.", 'unknown_method' ); |
| 85 | + $this->dieUsage( "Invalid dispatch method <<<$method>>> passed to the Donation Interface Gateway API.", 'unknown_method' ); |
78 | 86 | } |
79 | 87 | |
80 | 88 | // make sure we have tracking data for get_required_dynamic_form_elements |
— | — | @@ -122,18 +130,21 @@ |
123 | 131 | * elements. |
124 | 132 | */ |
125 | 133 | protected function dispatch_get_required_dynamic_form_elements( $params ) { |
126 | | - global $wgPayflowProGatewaySalt; |
127 | 134 | |
128 | | - // fetch the order_id |
129 | | - //TODO: This include should be *very* deprecated. All the functionality there has been |
130 | | - //recently eaten by gateway.adapter.php and DontationData.php. |
131 | | - require_once( 'includes/payflowUser.inc' ); |
132 | | - $payflow_data = payflowUser(); |
133 | | - $order_id = $payflow_data[ 'order_id' ]; |
134 | | - |
135 | | - // fetch the CSRF prevention token and set it if it's not already set |
136 | | - $token = PayflowProGateway::fnPayflowEditToken( $wgPayflowProGatewaySalt ); |
137 | | - |
| 135 | + //Get the gateway class name. We don't need to instantiate: Just get the name |
| 136 | + //so we can get a new DonationData that *thinks* it's being instantiated by |
| 137 | + //the relevent gateway class. |
| 138 | + $gateway_class = ''; |
| 139 | + switch ( $params['gateway'] ){ |
| 140 | + case 'globalcollect' : |
| 141 | + $gateway_class = 'GlobalCollectAdapter'; |
| 142 | + break; |
| 143 | + case 'payflowpro' : |
| 144 | + default: |
| 145 | + $gateway_class = 'PayflowProAdapter'; |
| 146 | + break; |
| 147 | + } |
| 148 | + |
138 | 149 | /** |
139 | 150 | * retrieve and unpack the json encoded string of tracking data |
140 | 151 | * |
— | — | @@ -142,12 +153,17 @@ |
143 | 154 | * pageref => the url-encoded referrer to the full user-requested URL |
144 | 155 | */ |
145 | 156 | $tracking_data = $this->parseTrackingData( json_decode( $params[ 'tracking_data' ], true ) ); |
| 157 | + //instantiate a new DonationData that behaves like it's owned by the correct gateway. |
| 158 | + $donationDataObj = new DonationData( $gateway_class, false, $tracking_data ); |
| 159 | + // fetch the order_id |
| 160 | + $order_id = $donationDataObj->getVal( 'order_id' ); |
146 | 161 | |
147 | | - // clean up tracking data to make sure everything is set correctly |
148 | | - $tracking_data = PayflowProGateway::cleanTrackingData( $tracking_data, true ); |
| 162 | + // fetch the CSRF prevention token and set it if it's not already set |
| 163 | + $token = $donationDataObj->token_getSaltedSessionToken(); |
149 | 164 | |
150 | | - // fetch the contribution_tracking_id by inserting tracking data to contrib tracking table |
151 | | - $contribution_tracking_id = PayflowProGateway::insertContributionTracking( $tracking_data ); |
| 165 | + //I'd just call DD's saveContributionTracking, but we need all the parts out here. |
| 166 | + $tracking_data = $donationDataObj->getCleanTrackingData(); |
| 167 | + $contribution_tracking_id = $donationDataObj::insertContributionTracking( $tracking_data ); |
152 | 168 | |
153 | 169 | // this try/catch design pattern stolen from ClickTracking/ApiSpecialClickTracking.php |
154 | 170 | try { |
— | — | @@ -175,11 +191,7 @@ |
176 | 192 | // add the referrer to the tracked_data array |
177 | 193 | $tracking_data[ 'referrer' ] = urldecode( $unparsed_tracking_data[ 'pageref' ] ); |
178 | 194 | |
179 | | - // ensure the utm_source is formatted correctly |
180 | | - $utm_source_str = ( isset( $tracking_data[ 'utm_source' ] ) ) ? $tracking_data[ 'utm_source' ] : null; |
181 | | - $utm_source_id = ( isset( $tracking_data[ 'utm_source_id' ] ) ) ? $tracking_data[ 'utm_source_id' ] : null; |
182 | | - $tracking_data[ 'utm_source' ] = PayflowProGateway::getUtmSource( $utm_source_str, $utm_source_id ); |
183 | | - |
| 195 | + //DonationData handles the utm normalization now. |
184 | 196 | return $tracking_data; |
185 | 197 | } |
186 | 198 | |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | |
42 | 42 | // dispatch forms/handling |
43 | 43 | if ( $this->adapter->checkTokens() ) { |
44 | | - if ( $this->adapter->posted) { |
| 44 | + if ( $this->adapter->posted ) { |
45 | 45 | // The form was submitted and the payment method has been set |
46 | 46 | // Check form for errors |
47 | 47 | $form_errors = $this->validateForm( $this->errors ); |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/payflowpro_gateway/forms/js/lightbox1.js |
— | — | @@ -147,7 +147,7 @@ |
148 | 148 | 'zip': $( "input[name='zip']" ).val(), |
149 | 149 | 'emailAdd': $( "input[name='emailAdd']" ).val(), |
150 | 150 | 'country': $( "input[name='country']" ).val(), |
151 | | - 'payment_method': 'card', |
| 151 | + 'payment_method': 'cc', |
152 | 152 | 'language': 'en', |
153 | 153 | |
154 | 154 | 'expiration': $( "input[name='expiration']" ).val(), |
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/payflowpro_gateway/forms |
___________________________________________________________________ |
Modified: svn:mergeinfo |
155 | 155 | Merged /trunk/extensions/DonationInterface/payflowpro_gateway/forms:r101441 |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/payflowpro_gateway/pfp_api_controller.js |
— | — | @@ -17,7 +17,11 @@ |
18 | 18 | 'action' : 'pfp', |
19 | 19 | 'dispatch' : 'get_required_dynamic_form_elements', |
20 | 20 | 'format' : 'json', |
21 | | - 'tracking_data' : '{"url": "'+escape(window.location)+'", "pageref": "'+escape(document.referrer)+'"}' |
| 21 | + 'tracking_data' : '{"url": "'+escape(window.location)+ |
| 22 | + '", "pageref": "'+escape(document.referrer)+ |
| 23 | + '", "gateway": "'+escape(document.gateway)+ |
| 24 | + '", "payment_method": "'+escape(document.payment_method)+ |
| 25 | + '"}' |
22 | 26 | }, processFormElements, 'json' ); |
23 | 27 | }; |
24 | 28 | |
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/payflowpro_gateway |
___________________________________________________________________ |
Modified: svn:mergeinfo |
25 | 29 | Merged /trunk/extensions/DonationInterface/payflowpro_gateway:r101441,101502 |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_forms/Form.php |
— | — | @@ -423,6 +423,7 @@ |
424 | 424 | 'action' => $this->form_data['action'], |
425 | 425 | 'owa_session' => $this->form_data['owa_session'], |
426 | 426 | 'owa_ref' => $this->form_data['owa_ref'], |
| 427 | + 'gateway' => $this->form_data['gateway'], |
427 | 428 | ); |
428 | 429 | } |
429 | 430 | |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_forms/includes/payflowUser.inc |
— | — | @@ -1,80 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Payflow Pro account information |
6 | | - * Payflow individual account information must be defined in the LocalSettings.php file |
7 | | - */ |
8 | | -function payflowUser() { |
9 | | - // User account information from LocalSettings.php |
10 | | - global $wgPayflowProPartnerID, |
11 | | - $wgPayflowProVendorID, |
12 | | - $wgPayflowProUserID, |
13 | | - $wgPayflowProPassword, |
14 | | - $wgPayflowProURL, |
15 | | - $wgPayflowProTestingURL, |
16 | | - $wgPayflowGatewayTest; |
17 | | - |
18 | | - $payflow_data = array( |
19 | | - 'partner' => $wgPayflowProPartnerID, // PayPal or original authorized reseller |
20 | | - 'vendor' => $wgPayflowProVendorID, // paypal merchant login ID |
21 | | - 'user' => $wgPayflowProUserID, // if one or more users are set up, authorized user ID, else same as VENDOR |
22 | | - 'password' => $wgPayflowProPassword, // merchant login password |
23 | | - 'paypalurl' => $wgPayflowProURL, |
24 | | - 'testingurl' => $wgPayflowProTestingURL, // Payflow testing URL |
25 | | - 'trxtype' => 'S', // transaction type - all donations are a sale |
26 | | - 'tender' => 'C', // credit card - all transactions in this case are credit cards |
27 | | - 'verbosity' => 'MEDIUM', // level of detail in Payflow response |
28 | | - 'user_ip' => ( $wgPayflowGatewayTest ) ? '12.12.12.12' : wfGetIP(), // current user's IP address |
29 | | - 'order_id' => payflowGetOrderId(), |
30 | | - 'i_order_id' => payflowGetInternalOrderId(), |
31 | | - ); |
32 | | - |
33 | | - return $payflow_data; |
34 | | -} |
35 | | - |
36 | | -/** |
37 | | - * Fetch and return the 'order_id' for a transaction |
38 | | - * |
39 | | - * Since transactions to PayPal are initially matched internally on their end |
40 | | - * with the 'order_id' field, but we don't actually care what the order id is, |
41 | | - * we generate a sufficiently random number to avoid duplication. |
42 | | - * |
43 | | - * We go ahead and always generate a random order id becuse if PayPal detects |
44 | | - * the same order_id more than once, it considers the request a duplicate, even |
45 | | - * if the data is completely different. |
46 | | - * |
47 | | - * @return int |
48 | | - */ |
49 | | -function payflowGetOrderId() { |
50 | | - return generateOrderId(); |
51 | | -} |
52 | | - |
53 | | -/** |
54 | | - * Generate an internal order id |
55 | | - * |
56 | | - * This is only used internally for tracking a user's 'session' with the credit |
57 | | - * card form. I mean 'session' in the sense of the moment a credit card page |
58 | | - * is loaded for the first time (nothing posted to it - a discrete donation |
59 | | - * session) as opposed to the $_SESSION - as the $_SESSION id could potentially |
60 | | - * not change between contribution attempts. |
61 | | - */ |
62 | | -function payflowGetInternalOrderId() { |
63 | | - global $wgRequest; |
64 | | - |
65 | | - // is an order_id already set? |
66 | | - $i_order_id = $wgRequest->getText( 'i_order_id', 0 ); |
67 | | - |
68 | | - // if the form was not just posted OR there's no order_id set, generate one. |
69 | | - if ( !$wgRequest->wasPosted() || !$i_order_id ) { |
70 | | - $i_order_id = generateOrderId(); |
71 | | - } |
72 | | - |
73 | | - return $i_order_id; |
74 | | -} |
75 | | - |
76 | | -/** |
77 | | - * Generate an order id |
78 | | - */ |
79 | | -function generateOrderId() { |
80 | | - return (double) microtime() * 1000000 . mt_rand(); |
81 | | -} |
\ No newline at end of file |
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_forms |
___________________________________________________________________ |
Modified: svn:mergeinfo |
82 | 1 | Merged /trunk/extensions/DonationInterface/gateway_forms:r101441,101502 |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -64,7 +64,8 @@ |
65 | 65 | 'i_order_id' => $wgRequest->getText( 'i_order_id', null ), //internal id for each contribution attempt |
66 | 66 | 'numAttempt' => $wgRequest->getVal( 'numAttempt', '0' ), |
67 | 67 | 'referrer' => ( $wgRequest->getVal( 'referrer' ) ) ? $wgRequest->getVal( 'referrer' ) : $wgRequest->getHeader( 'referer' ), |
68 | | - 'utm_source' => self::getUtmSource(), //TODO: yes. That. |
| 68 | + 'utm_source' => $wgRequest->getText( 'utm_source' ), |
| 69 | + 'utm_source_id' => $wgRequest->getVal( 'utm_source_id', null ), |
69 | 70 | 'utm_medium' => $wgRequest->getText( 'utm_medium' ), |
70 | 71 | 'utm_campaign' => $wgRequest->getText( 'utm_campaign' ), |
71 | 72 | // try to honor the user-set language (uselang), otherwise the language set in the URL (language) |
— | — | @@ -154,59 +155,58 @@ |
155 | 156 | // randomly select a credit card # |
156 | 157 | $card_num_index = array_rand( $card_nums[$cards[$card_index]] ); |
157 | 158 | |
158 | | - global $wgRequest; //TODO: ARRRGHARGHARGH. That is all. |
159 | | - |
160 | | - $this->normalized = array( |
161 | | - 'amount' => "35", |
162 | | - 'amountOther' => '', |
163 | | - 'email' => 'test@example.com', |
164 | | - 'fname' => 'Tester', |
165 | | - 'mname' => 'T.', |
166 | | - 'lname' => 'Testington', |
167 | | - 'street' => '548 Market St.', |
168 | | - 'city' => 'San Francisco', |
169 | | - 'state' => 'CA', |
170 | | - 'zip' => '94104', |
171 | | - 'country' => 'US', |
172 | | - 'fname2' => 'Testy', |
173 | | - 'lname2' => 'Testerson', |
174 | | - 'street2' => '123 Telegraph Ave.', |
175 | | - 'city2' => 'Berkeley', |
176 | | - 'state2' => 'CA', |
177 | | - 'zip2' => '94703', |
178 | | - 'country2' => 'US', |
179 | | - 'size' => 'small', |
180 | | - 'premium_language' => 'es', |
181 | | - 'card_num' => $card_nums[$cards[$card_index]][$card_num_index], |
182 | | - 'card_type' => $cards[$card_index], |
183 | | - 'expiration' => date( 'my', strtotime( '+1 year 1 month' ) ), |
184 | | - 'cvv' => '001', |
185 | | - 'currency' => 'USD', |
186 | | - 'payment_method' => $wgRequest->getText( 'payment_method' ), |
187 | | - 'payment_submethod' => $wgRequest->getText( 'payment_submethod' ), |
188 | | - 'issuer_id' => $wgRequest->getText( 'issuer_id' ), |
189 | | - 'order_id' => '1234567890', |
190 | | - 'i_order_id' => '1234567890', |
191 | | - 'numAttempt' => 0, |
192 | | - 'referrer' => 'http://www.baz.test.com/index.php?action=foo&action=bar', |
193 | | - 'utm_source' => self::getUtmSource(), |
194 | | - 'utm_medium' => $wgRequest->getText( 'utm_medium' ), |
195 | | - 'utm_campaign' => $wgRequest->getText( 'utm_campaign' ), |
196 | | - 'language' => 'en', |
197 | | - 'comment-option' => $wgRequest->getText( 'comment-option' ), |
198 | | - 'comment' => $wgRequest->getText( 'comment' ), |
199 | | - 'email-opt' => $wgRequest->getText( 'email-opt' ), |
200 | | - // test_string has been disabled - may no longer be needed. |
201 | | - //'test_string' => $wgRequest->getText( 'process' ), |
202 | | - 'token' => '', |
203 | | - 'contribution_tracking_id' => $wgRequest->getText( 'contribution_tracking_id' ), |
204 | | - 'data_hash' => $wgRequest->getText( 'data_hash' ), |
205 | | - 'action' => $wgRequest->getText( 'action' ), |
206 | | - 'gateway' => 'payflowpro', |
207 | | - 'owa_session' => $wgRequest->getText( 'owa_session', null ), |
208 | | - 'owa_ref' => 'http://localhost/defaultTestData', |
209 | | - ); |
210 | | - } |
| 159 | + //This array should be populated with general test defaults, or |
| 160 | + //(preferably) mappings to random stuff... if we keep this around at all. |
| 161 | + //Certainly nothing pulled from a form post or get. |
| 162 | + $this->normalized = array( |
| 163 | + 'amount' => "35", |
| 164 | + 'amountOther' => '', |
| 165 | + 'email' => 'test@example.com', |
| 166 | + 'fname' => 'Tester', |
| 167 | + 'mname' => 'T.', |
| 168 | + 'lname' => 'Testington', |
| 169 | + 'street' => '548 Market St.', |
| 170 | + 'city' => 'San Francisco', |
| 171 | + 'state' => 'CA', |
| 172 | + 'zip' => '94104', |
| 173 | + 'country' => 'US', |
| 174 | + 'fname2' => 'Testy', |
| 175 | + 'lname2' => 'Testerson', |
| 176 | + 'street2' => '123 Telegraph Ave.', |
| 177 | + 'city2' => 'Berkeley', |
| 178 | + 'state2' => 'CA', |
| 179 | + 'zip2' => '94703', |
| 180 | + 'country2' => 'US', |
| 181 | + 'size' => 'small', |
| 182 | + 'premium_language' => 'es', |
| 183 | + 'card_num' => $card_nums[$cards[$card_index]][$card_num_index], |
| 184 | + 'card_type' => $cards[$card_index], |
| 185 | + 'expiration' => date( 'my', strtotime( '+1 year 1 month' ) ), |
| 186 | + 'cvv' => '001', |
| 187 | + 'currency' => 'USD', |
| 188 | + 'payment_method' => 'cc', |
| 189 | + 'payment_submethod' => '', //cards have no payment submethods. |
| 190 | + 'issuer_id' => '', |
| 191 | + 'order_id' => '1234567890', |
| 192 | + 'i_order_id' => '1234567890', |
| 193 | + 'numAttempt' => 0, |
| 194 | + 'referrer' => 'http://www.baz.test.com/index.php?action=foo&action=bar', |
| 195 | + 'utm_source' => 'test_src', |
| 196 | + 'utm_source_id' => null, |
| 197 | + 'utm_medium' => 'test_medium', |
| 198 | + 'utm_campaign' => 'test_campaign', |
| 199 | + 'language' => 'en', |
| 200 | + 'comment-option' => 0, |
| 201 | + 'comment' => 0, |
| 202 | + 'email-opt' => 0, |
| 203 | + 'token' => '', |
| 204 | + 'contribution_tracking_id' => '', |
| 205 | + 'data_hash' => '', |
| 206 | + 'action' => '', |
| 207 | + 'gateway' => 'payflowpro', |
| 208 | + 'owa_session' => '', |
| 209 | + 'owa_ref' => 'http://localhost/defaultTestData', |
| 210 | + ); |
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
— | — | @@ -280,7 +280,17 @@ |
281 | 281 | $this->saveContributionTracking(); |
282 | 282 | } |
283 | 283 | } |
284 | | - |
| 284 | + |
| 285 | + |
| 286 | + function canCache(){ |
| 287 | + if ( $this->getVal( '_cache_' ) === 'true' ){ //::head. hit. keyboard.:: |
| 288 | + if ( $this->isSomething( 'utm_source_id' ) && !is_null( 'utm_source_id' ) ){ |
| 289 | + return true; |
| 290 | + } |
| 291 | + } |
| 292 | + return false; |
| 293 | + } |
| 294 | + |
285 | 295 | /** |
286 | 296 | * normalizeAndSanitize helper function. |
287 | 297 | * Takes all possible sources for the intended donation amount, and |
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface |
___________________________________________________________________ |
Modified: svn:mergeinfo |
288 | 298 | Merged /trunk/extensions/DonationInterface:r101441,101502,101631 |