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 | | - function setUtmSource() { |
| 321 | + public static function getUtmSource( $utm_source = null, $utm_source_id = null ) { |
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 | Reverse-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: Move this somewhere that looks more gateway-agnostic. |
| 6 | + * TODO: Determine if this is being used by anything anymore, and if so, what. |
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,12 +48,6 @@ |
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 | | - ), |
58 | 52 | ); |
59 | 53 | } |
60 | 54 | |
— | — | @@ -61,8 +55,6 @@ |
62 | 56 | return array( |
63 | 57 | 'dispatch' => 'the API method from which to return data', |
64 | 58 | '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' |
67 | 59 | ); |
68 | 60 | } |
69 | 61 | |
— | — | @@ -81,7 +73,7 @@ |
82 | 74 | if ( isset( $params[ 'dispatch' ] ) && strlen( $params[ 'dispatch' ] ) ) { |
83 | 75 | $method = $this->getDispatchMethod( $params[ 'dispatch' ] ); |
84 | 76 | if ( !in_array( $method, $this->validDispatchMethods ) || !method_exists( $this, $method ) ) { |
85 | | - $this->dieUsage( "Invalid dispatch method <<<$method>>> passed to the Donation Interface Gateway API.", 'unknown_method' ); |
| 77 | + $this->dieUsage( "Invalid dispatch method <<<$method>>> passed to the PayflowPro Gatweay API.", 'unknown_method' ); |
86 | 78 | } |
87 | 79 | |
88 | 80 | // make sure we have tracking data for get_required_dynamic_form_elements |
— | — | @@ -130,21 +122,18 @@ |
131 | 123 | * elements. |
132 | 124 | */ |
133 | 125 | protected function dispatch_get_required_dynamic_form_elements( $params ) { |
| 126 | + global $wgPayflowProGatewaySalt; |
134 | 127 | |
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 | | - |
| 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 | + |
149 | 138 | /** |
150 | 139 | * retrieve and unpack the json encoded string of tracking data |
151 | 140 | * |
— | — | @@ -153,17 +142,12 @@ |
154 | 143 | * pageref => the url-encoded referrer to the full user-requested URL |
155 | 144 | */ |
156 | 145 | $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' ); |
161 | 146 | |
162 | | - // fetch the CSRF prevention token and set it if it's not already set |
163 | | - $token = $donationDataObj->token_getSaltedSessionToken(); |
| 147 | + // clean up tracking data to make sure everything is set correctly |
| 148 | + $tracking_data = PayflowProGateway::cleanTrackingData( $tracking_data, true ); |
164 | 149 | |
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 ); |
| 150 | + // fetch the contribution_tracking_id by inserting tracking data to contrib tracking table |
| 151 | + $contribution_tracking_id = PayflowProGateway::insertContributionTracking( $tracking_data ); |
168 | 152 | |
169 | 153 | // this try/catch design pattern stolen from ClickTracking/ApiSpecialClickTracking.php |
170 | 154 | try { |
— | — | @@ -191,7 +175,11 @@ |
192 | 176 | // add the referrer to the tracked_data array |
193 | 177 | $tracking_data[ 'referrer' ] = urldecode( $unparsed_tracking_data[ 'pageref' ] ); |
194 | 178 | |
195 | | - //DonationData handles the utm normalization now. |
| 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 | + |
196 | 184 | return $tracking_data; |
197 | 185 | } |
198 | 186 | |
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': 'cc', |
| 151 | + 'payment_method': 'card', |
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 | Reverse-merged /trunk/extensions/DonationInterface/payflowpro_gateway/forms:r101441 |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/payflowpro_gateway/pfp_api_controller.js |
— | — | @@ -17,11 +17,7 @@ |
18 | 18 | 'action' : 'pfp', |
19 | 19 | 'dispatch' : 'get_required_dynamic_form_elements', |
20 | 20 | 'format' : 'json', |
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 | | - '"}' |
| 21 | + 'tracking_data' : '{"url": "'+escape(window.location)+'", "pageref": "'+escape(document.referrer)+'"}' |
26 | 22 | }, processFormElements, 'json' ); |
27 | 23 | }; |
28 | 24 | |
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/payflowpro_gateway |
___________________________________________________________________ |
Modified: svn:mergeinfo |
29 | 25 | Reverse-merged /trunk/extensions/DonationInterface/payflowpro_gateway:r101441,101502 |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_forms/Form.php |
— | — | @@ -423,7 +423,6 @@ |
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'], |
428 | 427 | ); |
429 | 428 | } |
430 | 429 | |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_forms/includes/payflowUser.inc |
— | — | @@ -0,0 +1,80 @@ |
| 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/includes/payflowUser.inc |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 82 | + native |
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_forms |
___________________________________________________________________ |
Modified: svn:mergeinfo |
2 | 83 | Reverse-merged /trunk/extensions/DonationInterface/gateway_forms:r101441,101502 |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -64,8 +64,7 @@ |
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' => $wgRequest->getText( 'utm_source' ), |
69 | | - 'utm_source_id' => $wgRequest->getVal( 'utm_source_id', null ), |
| 68 | + 'utm_source' => self::getUtmSource(), //TODO: yes. That. |
70 | 69 | 'utm_medium' => $wgRequest->getText( 'utm_medium' ), |
71 | 70 | 'utm_campaign' => $wgRequest->getText( 'utm_campaign' ), |
72 | 71 | // try to honor the user-set language (uselang), otherwise the language set in the URL (language) |
— | — | @@ -155,58 +154,59 @@ |
156 | 155 | // randomly select a credit card # |
157 | 156 | $card_num_index = array_rand( $card_nums[$cards[$card_index]] ); |
158 | 157 | |
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 | | - ); |
| 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 | + } |
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
— | — | @@ -280,17 +280,7 @@ |
281 | 281 | $this->saveContributionTracking(); |
282 | 282 | } |
283 | 283 | } |
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 | | - |
| 284 | + |
295 | 285 | /** |
296 | 286 | * normalizeAndSanitize helper function. |
297 | 287 | * Takes all possible sources for the intended donation amount, and |
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface |
___________________________________________________________________ |
Modified: svn:mergeinfo |
298 | 288 | Reverse-merged /trunk/extensions/DonationInterface:r101441,101502,101631 |