Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js |
— | — | @@ -1,14 +1,14 @@ |
2 | 2 | //<![CDATA[ |
3 | | -function addEvent(obj, evType, fn){ |
4 | | - if (obj.addEventListener){ |
5 | | - obj.addEventListener(evType, fn, false); |
6 | | - return true; |
7 | | - } else if (obj.attachEvent){ |
8 | | - var r = obj.attachEvent("on"+evType, fn); |
9 | | - return r; |
10 | | - } else { |
11 | | - return false; |
12 | | - } |
| 3 | +function addEvent(obj, evType, fn){ |
| 4 | + if (obj.addEventListener){ |
| 5 | + obj.addEventListener(evType, fn, false); |
| 6 | + return true; |
| 7 | + } else if (obj.attachEvent){ |
| 8 | + var r = obj.attachEvent("on"+evType, fn); |
| 9 | + return r; |
| 10 | + } else { |
| 11 | + return false; |
| 12 | + } |
13 | 13 | } |
14 | 14 | |
15 | 15 | function getIfSessionSet() { |
— | — | @@ -21,24 +21,7 @@ |
22 | 22 | field.style.color = 'black'; |
23 | 23 | } |
24 | 24 | } |
25 | | -function clearField2( field, defaultValue ) { |
26 | | - if (field.value != defaultValue) { |
27 | | - field.value = ''; |
28 | | - field.style.color = 'black'; |
29 | | - } |
30 | | -} |
31 | 25 | |
32 | | -function switchToPayPal() { |
33 | | - document.getElementById('payflow-table-cc').style.display = 'none'; |
34 | | - document.getElementById('payflowpro_gateway-form-submit').style.display = 'none'; |
35 | | - document.getElementById('payflowpro_gateway-form-submit-paypal').style.display = 'block'; |
36 | | -} |
37 | | -function switchToCreditCard() { |
38 | | - document.getElementById('payflow-table-cc').style.display = 'table'; |
39 | | - document.getElementById('payflowpro_gateway-form-submit').style.display = 'block'; |
40 | | - document.getElementById('payflowpro_gateway-form-submit-paypal').style.display = 'none'; |
41 | | -} |
42 | | - |
43 | 26 | function validate_form( form ) { |
44 | 27 | var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'State', 'Zip', 'CardNum', 'Cvv' ]; |
45 | 28 | |
— | — | @@ -54,7 +37,7 @@ |
55 | 38 | output += payflowproGatewayErrorMsgJs + ' ' + currField + '.\r\n'; |
56 | 39 | } |
57 | 40 | } |
58 | | - |
| 41 | + |
59 | 42 | //set state to "outside us" |
60 | 43 | if ( document.payment.country.value != '840' ) { |
61 | 44 | document.payment.state.value = 'XX'; |
— | — | @@ -72,8 +55,8 @@ |
73 | 56 | if( output ) { |
74 | 57 | alert( output ); |
75 | 58 | return false; |
76 | | - } |
77 | | - |
| 59 | + } |
| 60 | + |
78 | 61 | return true; |
79 | 62 | } |
80 | 63 | |
— | — | @@ -100,7 +83,7 @@ |
101 | 84 | |
102 | 85 | function PopupCVV() { |
103 | 86 | cvv = window.open("", 'cvvhelp','scrollbars=yes,resizable=yes,width=600,height=400,left=200,top=100'); |
104 | | - cvv.document.write( payflowproGatewayCVVExplain ); |
| 87 | + cvv.document.write( payflowproGatewayCVVExplain ); |
105 | 88 | cvv.focus(); |
106 | 89 | } |
107 | 90 | |
— | — | @@ -111,5 +94,5 @@ |
112 | 95 | } |
113 | 96 | } |
114 | 97 | |
115 | | -window.onfocus = CloseCVV; |
| 98 | +window.onfocus = CloseCVV; |
116 | 99 | //]]> |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -384,7 +384,7 @@ |
385 | 385 | global $wgOut, $wgDonationTestingMode, $wgPayflowGatewayUseHTTPProxy, $wgPayflowGatewayHTTPProxy; |
386 | 386 | |
387 | 387 | // update contribution tracking |
388 | | - $this->updateContributionTracking( $data ); |
| 388 | + $this->updateContributionTracking( $data, defined( 'OWA' ) ); |
389 | 389 | |
390 | 390 | // create payflow query string, include string lengths |
391 | 391 | $queryArray = array( |
— | — | @@ -919,6 +919,36 @@ |
920 | 920 | wfSetupSession(); |
921 | 921 | } |
922 | 922 | |
| 923 | + |
| 924 | +/** |
| 925 | + * Fetches ID for reference URL for OWA tracking |
| 926 | + * |
| 927 | + * In the event that the URL is not already in the database, insert it |
| 928 | + * and return it's id. Otehrewise, just return its id. |
| 929 | + * @param string $ref The reference URL |
| 930 | + * @return int The id for the reference URL - 0 if not found |
| 931 | + */ |
| 932 | + function get_owa_ref_id( $ref ) { |
| 933 | + // Replication lag means sometimes a new event will not exist in the table yet |
| 934 | + $dbw = contributionTrackingConnection(); |
| 935 | + $id_num = $dbw->selectField( |
| 936 | + 'contribution_tracking_owa_ref', |
| 937 | + 'id', |
| 938 | + array( 'url' => $ref ), |
| 939 | + __METHOD__ |
| 940 | + ); |
| 941 | + // Once we're on mysql 5, we can use replace() instead of this selectField --> insert or update hooey |
| 942 | + if ( $id_num === false ) { |
| 943 | + $dbw->insert( |
| 944 | + 'contribution_tracking_owa_ref', |
| 945 | + array( 'url' => (string) $ref ), |
| 946 | + __METHOD__ |
| 947 | + ); |
| 948 | + $id_num = $dbw->insertId(); |
| 949 | + } |
| 950 | + return $id_num === false ? 0 : $id_num; |
| 951 | + } |
| 952 | + |
923 | 953 | /** |
924 | 954 | * Populate the $data array for the credit card form |
925 | 955 | * |
— | — | @@ -928,6 +958,12 @@ |
929 | 959 | public function fnGetFormData( $amount, $numAttempt, $token, $order_id ) { |
930 | 960 | global $wgPayflowGatewayTest, $wgRequest; |
931 | 961 | |
| 962 | + // fetch ID for the url reference for OWA tracking |
| 963 | + $owa_ref = $wgRequest->getText( 'owa_ref', null ); |
| 964 | + if( $owa_ref != null && !is_numeric( $owa_ref )){ |
| 965 | + $owa_ref = $this->get_owa_ref_id( $owa_ref ); |
| 966 | + } |
| 967 | + |
932 | 968 | // if we're in testing mode and an action hasn't yet be specified, prepopulate the form |
933 | 969 | if ( !$wgRequest->getText( 'action', false ) && !$numAttempt && $wgPayflowGatewayTest ) { |
934 | 970 | // define arrays of cc's and cc #s for random selection |
— | — | @@ -978,6 +1014,8 @@ |
979 | 1015 | 'data_hash' => $wgRequest->getText( 'data_hash' ), |
980 | 1016 | 'action' => $wgRequest->getText( 'action' ), |
981 | 1017 | 'gateway' => 'payflowpro', |
| 1018 | + 'owa_session' => $wgRequest->getText( 'owa_session', null ), |
| 1019 | + 'owa_ref' => $owa_ref, |
982 | 1020 | ); |
983 | 1021 | } else { |
984 | 1022 | $data = array( |
— | — | @@ -1015,6 +1053,8 @@ |
1016 | 1054 | 'data_hash' => $wgRequest->getText( 'data_hash' ), |
1017 | 1055 | 'action' => $wgRequest->getText( 'action' ), |
1018 | 1056 | 'gateway' => 'payflowpro', // this may need to become dynamic in the future |
| 1057 | + 'owa_session' => $wgRequest->getText( 'owa_session', null ), |
| 1058 | + 'owa_ref' => $owa_ref, |
1019 | 1059 | ); |
1020 | 1060 | } |
1021 | 1061 | return $data; |
— | — | @@ -1133,6 +1173,8 @@ |
1134 | 1174 | 'utm_source' => $data['utm_source'], |
1135 | 1175 | 'utm_medium' => $data['utm_medium'], |
1136 | 1176 | 'utm_campaign' => $data['utm_campaign'], |
| 1177 | + 'owa_session' => $data['owa_session'], |
| 1178 | + 'owa_ref' => $data['owa_ref'], |
1137 | 1179 | 'optout' => $optout[ 'optout' ], |
1138 | 1180 | 'language' => $data['language'], |
1139 | 1181 | ); |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php |
— | — | @@ -65,6 +65,15 @@ |
66 | 66 | $this->setStylePath(); |
67 | 67 | } |
68 | 68 | $wgOut->addExtensionStyle( $this->getStylePath() ); |
| 69 | + /** |
| 70 | + * if OWA is enabled, load the JS. |
| 71 | + * |
| 72 | + * We do this here (rather than in individual forms) because if OWA is |
| 73 | + * enabled, we ALWAYS want to make sure it gets included. |
| 74 | + */ |
| 75 | + if(defined('OWA')){ |
| 76 | + $this->loadOwaJs(); |
| 77 | + } |
69 | 78 | } |
70 | 79 | |
71 | 80 | /** |
— | — | @@ -351,6 +360,8 @@ |
352 | 361 | 'contribution_tracking_id' => $this->form_data[ 'contribution_tracking_id' ], |
353 | 362 | 'data_hash' => $this->form_data[ 'data_hash' ], |
354 | 363 | 'action' => $this->form_data[ 'action' ], |
| 364 | + 'owa_session' => $this->form_data[ 'owa_session' ], |
| 365 | + 'owa_ref' => $this->form_data[ 'owa_ref' ], |
355 | 366 | ); |
356 | 367 | } |
357 | 368 | |
— | — | @@ -651,6 +662,20 @@ |
652 | 663 | '/extensions/DonationInterface/payflowpro_gateway/pfp_api_controller.js?284"></script>' ); |
653 | 664 | } |
654 | 665 | |
| 666 | + protected function loadOwaJs() { |
| 667 | + global $wgOut, $wgScriptPath; |
| 668 | + $wgOut->addHeadItem('owa_tracker_verts', '<script type="text/javascript" src="http://owa.tesla.usability.wikimedia.org/owa/modules/base/js/owa.tracker-combined-min.js"></script>'); |
| 669 | + |
| 670 | + $wgOut->addHeadItem( 'owa_get_info', '<script type="text/javascript" src="' . |
| 671 | + $wgScriptPath . |
| 672 | + '/extensions/DonationInterface/payflowpro_gateway/owa_get_info.js?284"></script>' ); |
| 673 | + $wgOut->addHeadItem( 'owa_tracker', '<script type="text/javascript" src="' . |
| 674 | + $wgScriptPath . |
| 675 | + '/extensions/DonationInterface/payflowpro_gateway/owa.tracker-combined-min.js?284"></script>' ); |
| 676 | + |
| 677 | + } |
| 678 | + |
| 679 | + |
655 | 680 | /** |
656 | 681 | * Generate HTML for <noscript> tags |
657 | 682 | * |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/owa_get_info.js |
— | — | @@ -1,18 +1,7 @@ |
2 | 2 | var get_owa_information = function() { |
3 | | -if(OWA.util.readCookie){ |
4 | | - var owa_s_val = OWA.util.readCookie("owa_s"); |
5 | | - var owa_s_ident = "sid%3D%3E"; |
6 | | - var owaS_start_index = owa_s_val.indexOf(owa_s_ident); |
7 | | - //NOTE: This only works as long as sid is the last param in the OWA cookie |
8 | | - if(owaS_start_index >= 0){ |
9 | | - var owaSessionID = owa_s_val.substr(owaS_start_index + owa_s_ident.length); |
10 | | - if(document.getElementById("owa_session_id") && |
11 | | - document.getElementById("owa_pageref") ){ ){ |
12 | | - document.getElementById("owa_session_id").value = owaSessionID; |
13 | | - document.getElementById("owa_pageref").value = encode(window.location); |
14 | | - } |
15 | | - } |
| 3 | +if(OWA.util.getState){ |
| 4 | + jQuery("input[name=owa_session]").val( OWA.util.getState('s', 'sid') ); |
| 5 | + jQuery("input[name=owa_ref]").val( escape(window.location) ); |
16 | 6 | } |
17 | 7 | }; |
18 | | - |
19 | 8 | if(jQuery){jQuery(document).ready(get_owa_information);} |