r74754 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74753‎ | r74754 | r74755 >
Date:00:19, 14 October 2010
Author:awjrichards
Status:deferred
Tags:
Comment:
Added AJAX js for the API; Explicitly set form actions to include param to prevent form caching; Now prevents caching when _nocache_=true in query string
Modified paths:
  • /trunk/extensions/DonationInterface/payflowpro_gateway/api_payflowpro_gateway.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/OneStepTwoColumn.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnPayPal.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumn.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumnLetter.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/pfp_api_controller.js (added) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/api_payflowpro_gateway.php
@@ -135,19 +135,20 @@
136136 * pageref => the url-encoded referrer to the full user-requested URL
137137 */
138138 $tracking_data = $this->parseTrackingData( json_decode( $params[ 'tracking_data' ], true ));
139 -
 139+
140140 // clean up tracking data to make sure everything is set correctly
141141 $tracking_data = PayflowProGateway::cleanTrackingData( $tracking_data, true );
142 -
 142+
143143 // fetch the contribution_tracking_id by inserting tracking data to contrib tracking table
144144 $contribution_tracking_id = PayflowProGateway::insertContributionTracking( $tracking_data );
145145
146146 // this try/catch design pattern stolen from ClickTracking/ApiSpecialClickTracking.php
147147 try {
148148 // add dynamic elements to result object
149 - $this->getResult()->addValue( array( 'dynamic_form_elements' ), 'order_id', $order_id );
 149+ $this->getResult()->addValue( array( 'dynamic_form_elements' ), 'orderid', $order_id );
150150 $this->getResult()->addValue( array( 'dynamic_form_elements' ), 'token', $token );
151151 $this->getResult()->addValue( array( 'dynamic_form_elements' ), 'contribution_tracking_id', $contribution_tracking_id );
 152+ $this->getResult()->addValue( array( 'dynamic_form_elements' ), 'tracking_data', $tracking_data );
152153 } catch ( Exception $e ) {
153154 /* no result */
154155 }
@@ -161,7 +162,7 @@
162163 */
163164 protected function parseTrackingData( $unparsed_tracking_data ) {
164165 // get the query string from the URL and turn it into an associative array
165 - $url_bits = wfParseUrl( $unparsed_tracking_data[ 'url' ] );
 166+ $url_bits = wfParseUrl( urldecode( $unparsed_tracking_data[ 'url' ] ));
166167 $tracking_data = wfCgiToArray( $url_bits[ 'query' ] );
167168
168169 // add the referrer to the tracked_data array
Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js
@@ -15,14 +15,6 @@
1616 sajax_do_call( 'efPayflowGatewayCheckSession', [], checkSession );
1717 }
1818
19 -addEvent( window, 'load', getIfSessionSet );
20 -
21 -function checkSession( request ) {
22 - if ( request.responseText == "no" ) {
23 - window.location = document.location.href;
24 - }
25 -}
26 -
2719 function clearField( field, defaultValue ) {
2820 if (field.value == defaultValue) {
2921 field.value = '';
@@ -53,8 +45,8 @@
5446
5547
5648 // validate email address
57 - var apos = form.emailAdd.value.indexOf("@");
58 - var dotpos = form.emailAdd.value.lastIndexOf(".");
 49+ var apos = document.payment.emailAdd.value.indexOf("@");
 50+ var dotpos = document.payment.emailAdd.value.lastIndexOf(".");
5951
6052 if( apos < 1 || dotpos-apos < 2 ) {
6153 output += payflowproGatewayErrorMsgEmail;
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -56,7 +56,11 @@
5757 $wgPayFlowProGatewayCSSVersion, $wgPayflowGatewayPaypalURL,
5858 $wgPayflowGatewaySalt;
5959
60 - session_cache_limiter( 'nocache' );
 60+ // disable caching - this will likely be set in the URL to prevent form caching
 61+ if ( $wgRequest->getText( '_nocache_' ) == 'true' ) {
 62+ session_cache_limiter( 'nocache' );
 63+ }
 64+
6165 $this->fnPayflowEnsureSession();
6266 $this->setHeaders();
6367
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumn.php
@@ -2,205 +2,205 @@
33
44 class PayflowProGateway_Form_TwoStepTwoColumn extends PayflowProGateway_Form {
55
6 - public function __construct( &$form_data, &$form_errors ) {
7 - global $wgOut, $wgScriptPath;
8 -
9 - parent::__construct( $form_data, $form_errors );
10 -
11 - // we only want to load this JS if the form is being rendered
12 - $wgOut->addHeadItem( 'validatescript',
13 - '<script type="text/javascript" src="' . $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/validate_input.js?284"></script>'
14 - );
15 - $first = wfMsg( 'payflowpro_gateway-first' );
16 - $last = wfMsg( 'payflowpro_gateway-last' );
17 - $js = <<<EOT
 6+ public function __construct( &$form_data, &$form_errors ) {
 7+ global $wgOut, $wgScriptPath;
 8+
 9+ parent::__construct( $form_data, $form_errors );
 10+
 11+ // we only want to load this JS if the form is being rendered
 12+ $this->loadValidateJs(); // validation JS
 13+ $this->loadApiJs(); // API/Ajax JS
 14+
 15+ $first = wfMsg( 'payflowpro_gateway-first' );
 16+ $last = wfMsg( 'payflowpro_gateway-last' );
 17+ $js = <<<EOT
1818 <script type="text/javascript">
1919 function loadPlaceholders() {
20 - var fname = document.getElementById('fname');
21 - var lname = document.getElementById('lname');
22 - var amountOther = document.getElementById('amountOther');
23 - if (fname.value == '') {
24 - fname.style.color = '#999999';
25 - fname.value = '$first';
26 - }
27 - if (lname.value == '') {
28 - lname.style.color = '#999999';
29 - lname.value = '$last';
30 - }
 20+ var fname = document.getElementById('fname');
 21+ var lname = document.getElementById('lname');
 22+ var amountOther = document.getElementById('amountOther');
 23+ if (fname.value == '') {
 24+ fname.style.color = '#999999';
 25+ fname.value = '$first';
 26+ }
 27+ if (lname.value == '') {
 28+ lname.style.color = '#999999';
 29+ lname.value = '$last';
 30+ }
3131 }
3232 addEvent( window, 'load', loadPlaceholders );
3333 </script>
3434 EOT;
35 - $wgOut->addHeadItem( 'placeholders', $js );
36 - }
37 -
38 - /**
39 - * Required method for constructing the entire form
40 - *
41 - * This can of course be overloaded by a child class.
42 - * @return string The entire form HTML
43 - */
44 - public function getForm() {
45 - $form = $this->generateFormStart();
46 - $form .= $this->getCaptchaHTML();
47 - $form .= $this->generateFormSubmit();
48 - $form .= $this->generateFormEnd();
49 - return $form;
50 - }
51 -
52 - public function generateFormStart() {
53 - global $wgPayflowGatewayHeader, $wgPayflwGatewayTest, $wgOut;
54 - $form = $this->generateBannerHeader();
55 -
56 - $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) );
57 -
58 - // provide a place at the top of the form for displaying general messages
59 - if ( $this->form_errors['general'] ) {
60 - $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' ));
61 - if ( is_array( $this->form_errors['general'] )) {
62 - foreach ( $this->form_errors['general'] as $this->form_errors_msg ) {
63 - $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg );
64 - }
65 - } else {
66 - $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg );
67 - }
68 - $form .= Xml::closeElement( 'div' );
69 - }
 35+ $wgOut->addHeadItem( 'placeholders', $js );
 36+ }
7037
71 - // open form
72 - $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard-form' ) );
73 -
74 - // Xml::element seems to convert html to htmlentities
75 - $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>";
76 - $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => '', 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) );
77 -
78 - $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section'));
79 - $form .= $this->generatePersonalContainer();
80 - $form .= Xml::closeElement( 'div' ); // close div#left-column
81 -
82 - $form .= Xml::openElement( 'div', array( 'id' => 'right-column', 'class' => 'payflow-cc-form-section' ));
83 - $form .= $this->generatePaymentContainer();
84 -
85 - return $form;
86 - }
 38+ /**
 39+ * Required method for constructing the entire form
 40+ *
 41+ * This can of course be overloaded by a child class.
 42+ * @return string The entire form HTML
 43+ */
 44+ public function getForm() {
 45+ $form = $this->generateFormStart();
 46+ $form .= $this->getCaptchaHTML();
 47+ $form .= $this->generateFormSubmit();
 48+ $form .= $this->generateFormEnd();
 49+ return $form;
 50+ }
8751
88 - public function generateFormSubmit() {
89 - // submit button
90 - $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit'));
91 - $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' ));
92 - //$form .= Xml::submitButton( wfMsg( 'payflowpro_gateway-submit-button' ));
93 - $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-cc-button'), 'onclick' => 'submit_form( this )', 'type' => 'submit'));
94 - $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button
95 - $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) .
96 - wfMsg( 'payflowpro_gateway-donate-click' );
97 - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-submessage
98 - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit
99 - return $form;
100 - }
101 -
102 - public function generateFormEnd() {
103 - $form = '';
104 - // add hidden fields
105 - $hidden_fields = $this->getHiddenFields();
106 - foreach ( $hidden_fields as $field => $value ) {
107 - $form .= Xml::hidden( $field, $value );
108 - }
109 - $form .= Xml::closeElement( 'div' ); // close div#right-column
110 - $form .= Xml::closeElement( 'form' );
111 - $form .= Xml::closeElement( 'div' ); // close div#mw-creditcard-form
112 - $form .= $this->generateDonationFooter();
113 - $form .= Xml::closeElement( 'div' ); // div#close mw-creditcard
114 - return $form;
115 - }
 52+ public function generateFormStart() {
 53+ global $wgPayflowGatewayHeader, $wgPayflwGatewayTest, $wgOut;
 54+ $form = $this->generateBannerHeader();
11655
117 - protected function generatePersonalContainer() {
118 - $form = '';
119 - $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-personal-info' )); ;
120 - $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header','id' => 'payflow-cc-form-header-personal' ), wfMsg( 'payflowpro_gateway-cc-form-header-personal' ));
121 - $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-donor' ) );
122 -
123 - $form .= $this->generatePersonalFields();
124 -
125 - $form .= Xml::closeElement( 'table' ); // close table#payflow-table-donor
126 - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-personal-info
 56+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) );
12757
128 - return $form;
129 - }
 58+ // provide a place at the top of the form for displaying general messages
 59+ if ( $this->form_errors['general'] ) {
 60+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' ));
 61+ if ( is_array( $this->form_errors['general'] )) {
 62+ foreach ( $this->form_errors['general'] as $this->form_errors_msg ) {
 63+ $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg );
 64+ }
 65+ } else {
 66+ $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg );
 67+ }
 68+ $form .= Xml::closeElement( 'div' );
 69+ }
13070
131 - protected function generatePersonalFields() {
132 - // first name
133 - $form = $this->getNameField();
134 -
135 - // country
136 - $form .= $this->getCountryField();
 71+ // open form
 72+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard-form' ) );
13773
138 - // street
139 - $form .= $this->getStreetField();
 74+ // Xml::element seems to convert html to htmlentities
 75+ $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>";
 76+ $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) );
14077
 78+ $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section'));
 79+ $form .= $this->generatePersonalContainer();
 80+ $form .= Xml::closeElement( 'div' ); // close div#left-column
14181
142 - // city
143 - $form .= $this->getCityField();
144 -
145 - // state
146 - $form .= $this->getStateField();
147 -
148 - // zip
149 - $form .= $this->getZipField();
150 -
151 - // email
152 - $form .= $this->getEmailField();
 82+ $form .= Xml::openElement( 'div', array( 'id' => 'right-column', 'class' => 'payflow-cc-form-section' ));
 83+ $form .= $this->generatePaymentContainer();
15384
154 - return $form;
155 - }
 85+ return $form;
 86+ }
15687
157 - protected function generatePaymentContainer() {
158 - $form = '';
159 - // credit card info
160 - $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-payment-info' ));
161 - $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header', 'id' => 'payflow-cc-form-header-payment' ), wfMsg( 'payflowpro_gateway-cc-form-header-payment' ));
162 - $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc' ) );
163 -
164 - $form .= $this->generatePaymentFields();
165 -
166 - $form .= Xml::closeElement( 'table' ); // close table#payflow-table-cc
167 - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-payment-info
 88+ public function generateFormSubmit() {
 89+ // submit button
 90+ $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit'));
 91+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' ));
 92+ //$form .= Xml::submitButton( wfMsg( 'payflowpro_gateway-submit-button' ));
 93+ $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-cc-button'), 'onclick' => 'submit_form( this )', 'type' => 'submit'));
 94+ $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button
 95+ $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) .
 96+ wfMsg( 'payflowpro_gateway-donate-click' );
 97+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-submessage
 98+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit
 99+ return $form;
 100+ }
168101
169 - return $form;
170 - }
 102+ public function generateFormEnd() {
 103+ $form = '';
 104+ // add hidden fields
 105+ $hidden_fields = $this->getHiddenFields();
 106+ foreach ( $hidden_fields as $field => $value ) {
 107+ $form .= Xml::hidden( $field, $value );
 108+ }
 109+ $form .= Xml::closeElement( 'div' ); // close div#right-column
 110+ $form .= Xml::closeElement( 'form' );
 111+ $form .= Xml::closeElement( 'div' ); // close div#mw-creditcard-form
 112+ $form .= $this->generateDonationFooter();
 113+ $form .= Xml::closeElement( 'div' ); // div#close mw-creditcard
 114+ return $form;
 115+ }
171116
172 - protected function generatePaymentFields() {
173 - global $wgScriptPath, $wgPayflowGatewayTest;
 117+ protected function generatePersonalContainer() {
 118+ $form = '';
 119+ $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-personal-info' )); ;
 120+ $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header','id' => 'payflow-cc-form-header-personal' ), wfMsg( 'payflowpro_gateway-cc-form-header-personal' ));
 121+ $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-donor' ) );
174122
175 - $form = '';
176 -
177 - // amount
178 - $form = '<tr>';
179 - $form .= '<td colspan="2"><span class="creditcard-error-msg">' . $this->form_errors['invalidamount'] . '</span></td>';
180 - $form .= '</tr>';
181 - $form .= '<tr>';
182 - $form .= '<td class="label">' . Xml::label(wfMsg( 'payflowpro_gateway-donor-amount' ), 'amount') . '</td>';
183 - $form .= '<td>' . Xml::input( 'amount', '7', $this->form_data['amount'], array( 'type' => 'text', 'maxlength' => '10', 'id' => 'amount' ) ) .
184 - ' ' . $this->generateCurrencyDropdown() . '</td>';
185 - $form .= '</tr>';
186 -
187 - // card logos
188 - $form .= '<tr>';
189 - $form .= '<td />';
190 - $form .= '<td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" )) . '</td>';
191 - $form .= '</tr>';
192 -
193 - // credit card type
194 - $form .= $this->getCreditCardTypeField();
195 -
196 - // card number
197 - $form .= $this->getCardnumberField();
198 -
199 - // expiry
200 - $form .= $this->getExpiryField();
201 -
202 - // cvv
203 - $form .= $this->getCvvField();
 123+ $form .= $this->generatePersonalFields();
204124
205 - return $form;
206 - }
207 -}
\ No newline at end of file
 125+ $form .= Xml::closeElement( 'table' ); // close table#payflow-table-donor
 126+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-personal-info
 127+
 128+ return $form;
 129+ }
 130+
 131+ protected function generatePersonalFields() {
 132+ // first name
 133+ $form = $this->getNameField();
 134+
 135+ // country
 136+ $form .= $this->getCountryField();
 137+
 138+ // street
 139+ $form .= $this->getStreetField();
 140+
 141+
 142+ // city
 143+ $form .= $this->getCityField();
 144+
 145+ // state
 146+ $form .= $this->getStateField();
 147+
 148+ // zip
 149+ $form .= $this->getZipField();
 150+
 151+ // email
 152+ $form .= $this->getEmailField();
 153+
 154+ return $form;
 155+ }
 156+
 157+ protected function generatePaymentContainer() {
 158+ $form = '';
 159+ // credit card info
 160+ $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-payment-info' ));
 161+ $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header', 'id' => 'payflow-cc-form-header-payment' ), wfMsg( 'payflowpro_gateway-cc-form-header-payment' ));
 162+ $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc' ) );
 163+
 164+ $form .= $this->generatePaymentFields();
 165+
 166+ $form .= Xml::closeElement( 'table' ); // close table#payflow-table-cc
 167+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-payment-info
 168+
 169+ return $form;
 170+ }
 171+
 172+ protected function generatePaymentFields() {
 173+ global $wgScriptPath, $wgPayflowGatewayTest;
 174+
 175+ $form = '';
 176+
 177+ // amount
 178+ $form = '<tr>';
 179+ $form .= '<td colspan="2"><span class="creditcard-error-msg">' . $this->form_errors['invalidamount'] . '</span></td>';
 180+ $form .= '</tr>';
 181+ $form .= '<tr>';
 182+ $form .= '<td class="label">' . Xml::label(wfMsg( 'payflowpro_gateway-donor-amount' ), 'amount') . '</td>';
 183+ $form .= '<td>' . Xml::input( 'amount', '7', $this->form_data['amount'], array( 'type' => 'text', 'maxlength' => '10', 'id' => 'amount' ) ) .
 184+ ' ' . $this->generateCurrencyDropdown() . '</td>';
 185+ $form .= '</tr>';
 186+
 187+ // card logos
 188+ $form .= '<tr>';
 189+ $form .= '<td />';
 190+ $form .= '<td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" )) . '</td>';
 191+ $form .= '</tr>';
 192+
 193+ // credit card type
 194+ $form .= $this->getCreditCardTypeField();
 195+
 196+ // card number
 197+ $form .= $this->getCardnumberField();
 198+
 199+ // expiry
 200+ $form .= $this->getExpiryField();
 201+
 202+ // cvv
 203+ $form .= $this->getCvvField();
 204+
 205+ return $form;
 206+ }
 207+}
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumnLetter.php
@@ -53,7 +53,7 @@
5454
5555 // Xml::element seems to convert html to htmlentities
5656 $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>";
57 - $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => '', 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) );
 57+ $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) );
5858
5959 $form .= $this->generateBillingContainer();
6060 return $form;
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnPayPal.php
@@ -31,7 +31,7 @@
3232
3333 // Xml::element seems to convert html to htmlentities
3434 $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>";
35 - $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => '', 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) );
 35+ $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) );
3636
3737 $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section'));
3838 $form .= $this->generatePersonalContainer();
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php
@@ -634,4 +634,39 @@
635635 $form .= '</tr>';
636636 return $form;
637637 }
 638+
 639+ protected function loadValidateJs() {
 640+ global $wgOut, $wgScriptPath;
 641+ $wgOut->addHeadItem( 'validatescript', '<script type="text/javascript" src="' .
 642+ $wgScriptPath .
 643+ '/extensions/DonationInterface/payflowpro_gateway/validate_input.js?284"></script>' );
 644+ }
 645+
 646+ protected function loadApiJs() {
 647+ global $wgOut, $wgScriptPath;
 648+ $wgOut->addHeadItem( 'pfp_api_call', '<script type="text/javascript" src="' .
 649+ $wgScriptPath .
 650+ '/extensions/DonationInterface/payflowpro_gateway/pfp_api_controller.js?284"></script>' );
 651+ }
 652+
 653+ /**
 654+ * Determine the 'no cache' form action
 655+ *
 656+ * This mostly exists to ensure that the form does not try to use AJAX to
 657+ * overwrite certain hidden form params that are normally overwitten for
 658+ * cached versions of the form.
 659+ * @return string $url The full URL for the form to post to
 660+ */
 661+ protected function getNoCacheAction() {
 662+ global $wgRequest;
 663+
 664+ $url = $wgRequest->getFullRequestURL();
 665+
 666+ // it the _nocache_ param != true, add it to the URL
 667+ if ( !$wgRequest->getText( '_nocache_' )) {
 668+ $url = wfAppendQuery( $url, array( '_nocache_' => 'true' ));
 669+ }
 670+
 671+ return $url;
 672+ }
638673 }
\ No newline at end of file
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/OneStepTwoColumn.php
@@ -1,244 +1,244 @@
22 <?php
33
44 class PayflowProGateway_Form_OneStepTwoColumn extends PayflowProGateway_Form {
5 - public $paypal = false; // true for paypal only version
 5+ public $paypal = false; // true for paypal only version
66
7 - public function __construct( &$form_data, &$form_errors ) {
8 - global $wgOut, $wgScriptPath;
9 -
10 - parent::__construct( $form_data, $form_errors );
11 -
12 - // update the list of hidden fields we need to use in this form.
13 - $this->updateHiddenFields();
14 -
15 - // we only want to load this JS if the form is being rendered
16 - $wgOut->addHeadItem( 'validatescript', '<script type="text/javascript" src="' .
17 - $wgScriptPath .
18 - '/extensions/DonationInterface/payflowpro_gateway/validate_input.js?284"></script>' );
19 - }
20 -
21 - /**
22 - * Required method for constructing the entire form
23 - *
24 - * This can of course be overloaded by a child class.
25 - * @return string The entire form HTML
26 - */
27 - public function getForm() {
28 - $form = $this->generateFormStart();
29 - $form .= $this->getCaptchaHTML();
30 - $form .= $this->generateFormSubmit();
31 - $form .= $this->generateFormEnd();
32 - return $form;
33 - }
34 -
35 - public function generateFormStart() {
36 - global $wgPayflowGatewayHeader, $wgPayflwGatewayTest, $wgOut, $wgRequest;
37 -
38 - $this->paypal = $wgRequest->getBool( 'paypal', false );
39 -
40 - $form = $this->generateBannerHeader();
41 -
42 - $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) );
43 -
44 - // provide a place at the top of the form for displaying general messages
45 - if ( $this->form_errors['general'] ) {
46 - $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' ));
47 - if ( is_array( $this->form_errors['general'] )) {
48 - foreach ( $this->form_errors['general'] as $this->form_errors_msg ) {
49 - $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg );
50 - }
51 - } else {
52 - $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg );
53 - }
54 - $form .= Xml::closeElement( 'div' );
55 - }
 7+ public function __construct( &$form_data, &$form_errors ) {
 8+ global $wgOut, $wgScriptPath;
569
57 - // open form
58 - $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard-form' ) );
59 -
60 - // Xml::element seems to convert html to htmlentities
61 - $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>";
62 - $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => '', 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) );
63 -
64 - $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section'));
65 - $form .= $this->generatePersonalContainer();
66 -
67 - if ( !$this->paypal ) {
68 - $form .= Xml::closeElement( 'div' ); // close div#left-column
69 -
70 - $form .= Xml::openElement( 'div', array( 'id' => 'right-column', 'class' => 'payflow-cc-form-section' ));
71 - $form .= $this->generatePaymentContainer();
72 - }
73 -
74 - return $form;
75 - }
76 - public function generateFormSubmit() {
77 - // submit button
78 - $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit'));
79 - $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' ));
80 - if ( $this->paypal ) {
81 - $form .= Xml::hidden( 'PaypalRedirect', false );
82 - $form .= Xml::element( 'input', array( 'class' => 'input-button button-navyblue', 'value' => wfMsg( 'payflowpro_gateway-submit-button'), 'onclick' => 'document.payment.PaypalRedirect.value=\'true\';document.payment.submit();', 'type' => 'submit'));
83 - } else {
84 - $form .= Xml::element( 'input', array( 'class' => 'input-button button-navyblue', 'value' => wfMsg( 'payflowpro_gateway-submit-button'), 'onclick' => 'submit_form( this )', 'type' => 'submit'));
85 - $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button
86 - $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) .
87 - wfMsg( 'payflowpro_gateway-donate-click' );
88 - }
89 - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-submessage
90 - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit
91 -
92 - return $form;
93 - }
94 -
95 - public function generateFormEnd() {
96 - $form = '';
97 - // add hidden fields
98 - $hidden_fields = $this->getHiddenFields();
99 - foreach ( $hidden_fields as $field => $value ) {
100 - $form .= Xml::hidden( $field, $value );
101 - }
102 - $form .= Xml::closeElement( 'div' ); // close div#right-column
103 - $form .= Xml::closeElement( 'form' );
104 - $form .= Xml::closeElement( 'div' ); // close div#mw-creditcard-form
105 - $form .= $this->generateDonationFooter();
106 - $form .= Xml::closeElement( 'div' ); // div#close mw-creditcard
107 - return $form;
108 - }
 10+ parent::__construct( $form_data, $form_errors );
10911
110 - protected function generateBannerHeader() {
111 - global $wgPayflowGatewayHeader, $wgOut, $wgRequest;
112 -
113 - $template = '';
114 -
115 - // intro text
116 - if ( $wgRequest->getText('masthead', false)) {
117 - $template = $wgOut->parse( '{{' . $wgRequest->getText( 'masthead' ) . '/' . $this->form_data[ 'language' ] . '}}' );
118 - } elseif ( $wgPayflowGatewayHeader ) {
119 - $header = str_replace( '@language', $this->form_data[ 'language' ], $wgPayflowGatewayHeader );
120 - $template = $wgOut->parse( $header );
121 - }
122 -
123 - // make sure that we actually have a matching template to display so we don't display the 'redlink'
124 - if ( strlen( $template ) && !preg_match( '/redlink\=1/', $template )) {
125 - $wgOut->addHtml( $template );
126 - }
127 - }
 12+ // update the list of hidden fields we need to use in this form.
 13+ $this->updateHiddenFields();
12814
129 - protected function generatePersonalContainer() {
130 - global $wgRequest, $wgScriptPath;
131 - $form = '';
132 - $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-personal-info' )); ;
133 - $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header','id' => 'payflow-cc-form-header-personal' ), wfMsg( 'payflowpro_gateway-make-your-donation' ));
134 - if ( !$this->paypal ) {
135 - $source = $wgRequest->getText( 'utm_source' );
136 - $medium = $wgRequest->getText( 'utm_medium' );
137 - $campaign = $wgRequest->getText( 'utm_campaign' );
138 - $formname = $wgRequest->getText( 'form_name' );
139 - $form .= Xml::Tags( 'p', array( 'id' => 'payflowpro_gateway-cc_otherways' ), wfMsg( 'payflowpro_gateway-paypal', $wgScriptPath, $formname, $source, $medium, $campaign ));
140 - }
141 - $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-donor' ) );
142 -
143 - $form .= $this->generatePersonalFields();
144 -
145 - $form .= Xml::closeElement( 'table' ); // close table#payflow-table-donor
146 - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-personal-info
 15+ // we only want to load this JS if the form is being rendered
 16+ $this->loadValidateJs(); // validation JS
 17+
 18+ $this->loadApiJs(); // API/Ajax JS
 19+ }
14720
148 - return $form;
149 - }
 21+ /**
 22+ * Required method for constructing the entire form
 23+ *
 24+ * This can of course be overloaded by a child class.
 25+ * @return string The entire form HTML
 26+ */
 27+ public function getForm() {
 28+ $form = $this->generateFormStart();
 29+ $form .= $this->getCaptchaHTML();
 30+ $form .= $this->generateFormSubmit();
 31+ $form .= $this->generateFormEnd();
 32+ return $form;
 33+ }
15034
151 - protected function generatePersonalFields() {
152 - $form = '';
153 -
154 - // name
155 - $form .= $this->getNameField();
156 -
157 - // email
158 - $form .= $this->getEmailField();
159 -
160 - //comment message
161 - $form .= $this->getCommentMessageField();
162 -
163 - //comment
164 - $form .= $this->getCommentField();
165 -
166 - // anonymous
167 - $form .= $this->getCommentOptionField();
 35+ public function generateFormStart() {
 36+ global $wgPayflowGatewayHeader, $wgPayflwGatewayTest, $wgOut, $wgRequest;
16837
169 - // email agreement
170 - $form .= $this->getEmailOptField();
171 -
172 - // amount
173 - $form .= $this->getAmountField();
174 -
175 - return $form;
176 - }
 38+ $this->paypal = $wgRequest->getBool( 'paypal', false );
17739
178 - protected function generatePaymentContainer() {
179 - $form = '';
180 - // credit card info
181 - $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-payment-info' ));
182 - $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc' ) );
183 -
184 - $form .= $this->generatePaymentFields();
185 -
186 - $form .= Xml::closeElement( 'table' ); // close table#payflow-table-cc
187 - $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-payment-info
 40+ $form = $this->generateBannerHeader();
18841
189 - return $form;
190 - }
 42+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) );
19143
192 - protected function generatePaymentFields() {
193 - global $wgScriptPath, $wgPayflowGatewayTest;
 44+ // provide a place at the top of the form for displaying general messages
 45+ if ( $this->form_errors['general'] ) {
 46+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' ));
 47+ if ( is_array( $this->form_errors['general'] )) {
 48+ foreach ( $this->form_errors['general'] as $this->form_errors_msg ) {
 49+ $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg );
 50+ }
 51+ } else {
 52+ $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg );
 53+ }
 54+ $form .= Xml::closeElement( 'div' );
 55+ }
19456
195 - $form = '';
196 -
197 - // card logos
198 - $form .= '<tr>';
199 - $form .= '<td />';
200 - $form .= '<td>&nbsp;<br/>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" )) . '</td>';
201 - $form .= '</tr>';
202 -
203 - // card number
204 - $form .= $this->getCardnumberField();
205 -
206 - // cvv
207 - $form .= $this->getCvvField();
208 -
209 - // expiry
210 - $form .= $this->getExpiryField();
211 -
212 - // street
213 - $form .= $this->getStreetField();
 57+ // open form
 58+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard-form' ) );
21459
215 - // city
216 - $form .= $this->getCityField();
 60+ // Xml::element seems to convert html to htmlentities
 61+ $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>";
 62+ $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) );
21763
218 - // state
219 - $form .= $this->getStateField();
220 -
221 - // zip
222 - $form .= $this->getZipField();
223 -
224 - // country
225 - $form .= $this->getCountryField();
 64+ $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section'));
 65+ $form .= $this->generatePersonalContainer();
22666
227 - return $form;
228 - }
229 -
230 - /**
231 - * Update hidden fields to not set any comment-related fields
232 - */
233 - public function updateHiddenFields() {
234 - $hidden_fields = $this->getHiddenFields();
 67+ if ( !$this->paypal ) {
 68+ $form .= Xml::closeElement( 'div' ); // close div#left-column
23569
236 - // make sure that the below elements are not set in the hidden fields
237 - $not_needed = array( 'comment-option', 'email-opt', 'comment' );
 70+ $form .= Xml::openElement( 'div', array( 'id' => 'right-column', 'class' => 'payflow-cc-form-section' ));
 71+ $form .= $this->generatePaymentContainer();
 72+ }
23873
239 - foreach ( $not_needed as $field ) {
240 - unset( $hidden_fields[ $field ] );
241 - }
242 -
243 - $this->setHiddenFields( $hidden_fields );
244 - }
245 -}
\ No newline at end of file
 74+ return $form;
 75+ }
 76+ public function generateFormSubmit() {
 77+ // submit button
 78+ $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit'));
 79+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' ));
 80+ if ( $this->paypal ) {
 81+ $form .= Xml::hidden( 'PaypalRedirect', false );
 82+ $form .= Xml::element( 'input', array( 'class' => 'input-button button-navyblue', 'value' => wfMsg( 'payflowpro_gateway-submit-button'), 'onclick' => 'document.payment.PaypalRedirect.value=\'true\';document.payment.submit();', 'type' => 'submit'));
 83+ } else {
 84+ $form .= Xml::element( 'input', array( 'class' => 'input-button button-navyblue', 'value' => wfMsg( 'payflowpro_gateway-submit-button'), 'onclick' => 'submit_form( this )', 'type' => 'submit'));
 85+ $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button
 86+ $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) .
 87+ wfMsg( 'payflowpro_gateway-donate-click' );
 88+ }
 89+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-submessage
 90+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit
 91+
 92+ return $form;
 93+ }
 94+
 95+ public function generateFormEnd() {
 96+ $form = '';
 97+ // add hidden fields
 98+ $hidden_fields = $this->getHiddenFields();
 99+ foreach ( $hidden_fields as $field => $value ) {
 100+ $form .= Xml::hidden( $field, $value );
 101+ }
 102+ $form .= Xml::closeElement( 'div' ); // close div#right-column
 103+ $form .= Xml::closeElement( 'form' );
 104+ $form .= Xml::closeElement( 'div' ); // close div#mw-creditcard-form
 105+ $form .= $this->generateDonationFooter();
 106+ $form .= Xml::closeElement( 'div' ); // div#close mw-creditcard
 107+ return $form;
 108+ }
 109+
 110+ protected function generateBannerHeader() {
 111+ global $wgPayflowGatewayHeader, $wgOut, $wgRequest;
 112+
 113+ $template = '';
 114+
 115+ // intro text
 116+ if ( $wgRequest->getText('masthead', false)) {
 117+ $template = $wgOut->parse( '{{' . $wgRequest->getText( 'masthead' ) . '/' . $this->form_data[ 'language' ] . '}}' );
 118+ } elseif ( $wgPayflowGatewayHeader ) {
 119+ $header = str_replace( '@language', $this->form_data[ 'language' ], $wgPayflowGatewayHeader );
 120+ $template = $wgOut->parse( $header );
 121+ }
 122+
 123+ // make sure that we actually have a matching template to display so we don't display the 'redlink'
 124+ if ( strlen( $template ) && !preg_match( '/redlink\=1/', $template )) {
 125+ $wgOut->addHtml( $template );
 126+ }
 127+ }
 128+
 129+ protected function generatePersonalContainer() {
 130+ global $wgRequest, $wgScriptPath;
 131+ $form = '';
 132+ $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-personal-info' )); ;
 133+ $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header','id' => 'payflow-cc-form-header-personal' ), wfMsg( 'payflowpro_gateway-make-your-donation' ));
 134+ if ( !$this->paypal ) {
 135+ $source = $wgRequest->getText( 'utm_source' );
 136+ $medium = $wgRequest->getText( 'utm_medium' );
 137+ $campaign = $wgRequest->getText( 'utm_campaign' );
 138+ $formname = $wgRequest->getText( 'form_name' );
 139+ $form .= Xml::Tags( 'p', array( 'id' => 'payflowpro_gateway-cc_otherways' ), wfMsg( 'payflowpro_gateway-paypal', $wgScriptPath, $formname, $source, $medium, $campaign ));
 140+ }
 141+ $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-donor' ) );
 142+
 143+ $form .= $this->generatePersonalFields();
 144+
 145+ $form .= Xml::closeElement( 'table' ); // close table#payflow-table-donor
 146+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-personal-info
 147+
 148+ return $form;
 149+ }
 150+
 151+ protected function generatePersonalFields() {
 152+ $form = '';
 153+
 154+ // name
 155+ $form .= $this->getNameField();
 156+
 157+ // email
 158+ $form .= $this->getEmailField();
 159+
 160+ //comment message
 161+ $form .= $this->getCommentMessageField();
 162+
 163+ //comment
 164+ $form .= $this->getCommentField();
 165+
 166+ // anonymous
 167+ $form .= $this->getCommentOptionField();
 168+
 169+ // email agreement
 170+ $form .= $this->getEmailOptField();
 171+
 172+ // amount
 173+ $form .= $this->getAmountField();
 174+
 175+ return $form;
 176+ }
 177+
 178+ protected function generatePaymentContainer() {
 179+ $form = '';
 180+ // credit card info
 181+ $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-payment-info' ));
 182+ $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc' ) );
 183+
 184+ $form .= $this->generatePaymentFields();
 185+
 186+ $form .= Xml::closeElement( 'table' ); // close table#payflow-table-cc
 187+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-payment-info
 188+
 189+ return $form;
 190+ }
 191+
 192+ protected function generatePaymentFields() {
 193+ global $wgScriptPath, $wgPayflowGatewayTest;
 194+
 195+ $form = '';
 196+
 197+ // card logos
 198+ $form .= '<tr>';
 199+ $form .= '<td />';
 200+ $form .= '<td>&nbsp;<br/>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" )) . '</td>';
 201+ $form .= '</tr>';
 202+
 203+ // card number
 204+ $form .= $this->getCardnumberField();
 205+
 206+ // cvv
 207+ $form .= $this->getCvvField();
 208+
 209+ // expiry
 210+ $form .= $this->getExpiryField();
 211+
 212+ // street
 213+ $form .= $this->getStreetField();
 214+
 215+ // city
 216+ $form .= $this->getCityField();
 217+
 218+ // state
 219+ $form .= $this->getStateField();
 220+
 221+ // zip
 222+ $form .= $this->getZipField();
 223+
 224+ // country
 225+ $form .= $this->getCountryField();
 226+
 227+ return $form;
 228+ }
 229+
 230+ /**
 231+ * Update hidden fields to not set any comment-related fields
 232+ */
 233+ public function updateHiddenFields() {
 234+ $hidden_fields = $this->getHiddenFields();
 235+
 236+ // make sure that the below elements are not set in the hidden fields
 237+ $not_needed = array( 'comment-option', 'email-opt', 'comment' );
 238+
 239+ foreach ( $not_needed as $field ) {
 240+ unset( $hidden_fields[ $field ] );
 241+ }
 242+
 243+ $this->setHiddenFields( $hidden_fields );
 244+ }
 245+}
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php
@@ -45,7 +45,7 @@
4646
4747 // Xml::element seems to convert html to htmlentities
4848 $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>";
49 - $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => '', 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) );
 49+ $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) );
5050
5151 $form .= $this->generateBillingContainer();
5252 return $form;
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php
@@ -2,20 +2,20 @@
33
44 # Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
55 if( !defined( 'MEDIAWIKI' ) ) {
6 - echo <<<EOT
 6+ echo <<<EOT
77 To install PayflowPro Gateway extension, put the following line in LocalSettings.php:
88 require_once( "\$IP/extensions/payflowpro_gateway/payflowpro_gateway.php" );
99 EOT;
10 - exit( 1 );
 10+ exit( 1 );
1111 }
1212
1313 // Extension credits that will show up on Special:Version
1414 $wgExtensionCredits['specialpage'][] = array(
15 - 'name' => 'PayflowPro Gateway',
16 - 'author' => 'Four Kitchens',
17 - 'version' => '1.0.0',
18 - 'descriptionmsg' => 'payflowpro_gateway-desc',
19 - 'url' => 'http://www.mediawiki.org/wiki/Extension:PayflowProGateway',
 15+ 'name' => 'PayflowPro Gateway',
 16+ 'author' => 'Four Kitchens',
 17+ 'version' => '1.0.0',
 18+ 'descriptionmsg' => 'payflowpro_gateway-desc',
 19+ 'url' => 'http://www.mediawiki.org/wiki/Extension:PayflowProGateway',
2020 );
2121
2222 // Set up the new special page
@@ -95,7 +95,7 @@
9696 * The URL to redirect a transaction to PayPal
9797 */
9898 $wgPayflowGatewayPaypalURL = '';
99 -
 99+
100100 /**
101101 * Hooks required to interface with the donation extension (include <donate> on page)
102102 *
@@ -105,64 +105,49 @@
106106 $wgHooks['DonationInterface_Value'][] = 'pfpGatewayValue';
107107 $wgHooks['DonationInterface_Page'][] = 'pfpGatewayPage';
108108
109 -// use sajax
110 -$wgUseAjax = true;
111 -$wgAjaxExportList[] = 'efPayflowGatewayCheckSession';
112 -
113109 // enable the API
114110 $wgAPIModules[ 'pfp' ] = 'ApiPayflowProGateway';
115111 $wgAutoloadClasses[ 'ApiPayflowProGateway' ] = $dir . 'api_payflowpro_gateway.php';
116 -/**
117 - * Return whether or not payflowEditToken is set in the session
118 - */
119 -function efPayflowGatewayCheckSession() {
120 - $token_set = ( isset( $_SESSION[ 'payflowEditToken' ] )) ? 'yes' : 'no';
121 - $ajax = new AjaxResponse( $token_set );
122 - // if we don't explicitly set the content type, things break
123 - $ajax->setContentType( 'text/plain' );
124 - return $ajax;
125 -}
126112
127113 function payflowGatewayConnection() {
128 - global $wgPayflowGatewayDBserver, $wgPayflowGatewayDBname;
129 - global $wgPayflowGatewayDBuser, $wgPayflowGatewayDBpassword;
 114+ global $wgPayflowGatewayDBserver, $wgPayflowGatewayDBname;
 115+ global $wgPayflowGatewayDBuser, $wgPayflowGatewayDBpassword;
130116
131 - static $db;
 117+ static $db;
132118
133 - if ( !$db ) {
134 - $db = new DatabaseMysql(
135 - $wgPayflowGatewayDBserver,
136 - $wgPayflowGatewayDBuser,
137 - $wgPayflowGatewayDBpassword,
138 - $wgPayflowGatewayDBname );
139 - $db->query( "SET names utf8" );
140 - }
 119+ if ( !$db ) {
 120+ $db = new DatabaseMysql(
 121+ $wgPayflowGatewayDBserver,
 122+ $wgPayflowGatewayDBuser,
 123+ $wgPayflowGatewayDBpassword,
 124+ $wgPayflowGatewayDBname );
 125+ $db->query( "SET names utf8" );
 126+ }
141127
142 - return $db;
 128+ return $db;
143129 }
144130
145 -
146131 /**
147132 * Hook to register form value and display name of this gateway
148133 * also supplies currencies supported by this gateway
149134 */
150135 function pfpGatewayValue( &$values ) {
151136
152 - $values['payflow'] = array(
153 - 'gateway' => 'payflow',
154 - 'display_name' => 'Credit Card',
155 - 'form_value' => 'payflow',
156 - 'currencies' => array(
157 - 'GBP' => 'GBP: British Pound',
158 - 'EUR' => 'EUR: Euro',
159 - 'USD' => 'USD: U.S. Dollar',
160 - 'AUD' => 'AUD: Australian Dollar',
161 - 'CAD' => 'CAD: Canadian Dollar',
162 - 'JPY' => 'JPY: Japanese Yen',
163 - ),
164 - );
 137+ $values['payflow'] = array(
 138+ 'gateway' => 'payflow',
 139+ 'display_name' => 'Credit Card',
 140+ 'form_value' => 'payflow',
 141+ 'currencies' => array(
 142+ 'GBP' => 'GBP: British Pound',
 143+ 'EUR' => 'EUR: Euro',
 144+ 'USD' => 'USD: U.S. Dollar',
 145+ 'AUD' => 'AUD: Australian Dollar',
 146+ 'CAD' => 'CAD: Canadian Dollar',
 147+ 'JPY' => 'JPY: Japanese Yen',
 148+ ),
 149+ );
165150
166 - return true;
 151+ return true;
167152 }
168153
169154 /**
@@ -173,8 +158,15 @@
174159 * the result might look like this: http://www.yourdomain.com/index.php?title=Special:PayflowPro&amount=75.00&currency_code=USD&payment_method=payflow
175160 */
176161 function pfpGatewayPage( &$url ) {
177 - global $wgScript;
 162+ global $wgScript;
178163
179 - $url['payflow'] = $wgScript . "?title=Special:PayflowProGateway";
180 - return true;
 164+ $url['payflow'] = $wgScript . "?title=Special:PayflowProGateway";
 165+ return true;
181166 }
 167+
 168+//Add JQuery
 169+$wgHooks['BeforePageDisplay'][] = 'pfpAddJQuery';
 170+function pfpAddJQuery($out, $sk){
 171+ $out->includeJQuery();
 172+ return true;
 173+}
Index: trunk/extensions/DonationInterface/payflowpro_gateway/pfp_api_controller.js
@@ -0,0 +1,30 @@
 2+( function( $ ) {
 3+ $.getDynamicFormElements = function(){
 4+ var tracking_data = {"url": escape(window.location), "pageref": escape(document.referrer)};
 5+
 6+ var processFormElements = function (data, status){
 7+ $('input[name=orderid]').val(data['dynamic_form_elements']['orderid']);
 8+ $('input[name=token]').val(data['dynamic_form_elements']['token']);
 9+ $('input[name=contribution_tracking_id]').val(data['dynamic_form_elements']['contribution_tracking_id']);
 10+ $('input[name=utm_source]').val(data['dynamic_form_elements']['tracking_data']['utm_source']);
 11+ $('input[name=utm_medium]').val(data['dynamic_form_elements']['tracking_data']['utm_medium']);
 12+ $('input[name=utm_campaign]').val(data['dynamic_form_elements']['tracking_data']['utm_campaign']);
 13+ $('input[name=referrer]').val(data['dynamic_form_elements']['tracking_data']['referrer']);
 14+ $('input[name=language]').val(data['dynamic_form_elements']['tracking_data']['language']);
 15+ };
 16+
 17+ $.post( wgScriptPath + '/api.php', {
 18+ 'action' : 'pfp',
 19+ 'dispatch' : 'get_required_dynamic_form_elements',
 20+ 'format' : 'json',
 21+ 'tracking_data' : '{"url": "'+escape(window.location)+'", "pageref": "'+escape(document.referrer)+'"}'
 22+ }, processFormElements, 'json' );
 23+ };
 24+
 25+ return $( this );
 26+
 27+} )( jQuery );
 28+
 29+if( String(window.location).indexOf('_nocache_') == -1 ){
 30+ jQuery( document ).ready( jQuery.getDynamicFormElements );
 31+}
\ No newline at end of file

Status & tagging log