Index: trunk/extensions/DonationInterface/payflowpro_gateway/api_payflowpro_gateway.php |
— | — | @@ -135,19 +135,20 @@ |
136 | 136 | * pageref => the url-encoded referrer to the full user-requested URL |
137 | 137 | */ |
138 | 138 | $tracking_data = $this->parseTrackingData( json_decode( $params[ 'tracking_data' ], true )); |
139 | | - |
| 139 | + |
140 | 140 | // clean up tracking data to make sure everything is set correctly |
141 | 141 | $tracking_data = PayflowProGateway::cleanTrackingData( $tracking_data, true ); |
142 | | - |
| 142 | + |
143 | 143 | // fetch the contribution_tracking_id by inserting tracking data to contrib tracking table |
144 | 144 | $contribution_tracking_id = PayflowProGateway::insertContributionTracking( $tracking_data ); |
145 | 145 | |
146 | 146 | // this try/catch design pattern stolen from ClickTracking/ApiSpecialClickTracking.php |
147 | 147 | try { |
148 | 148 | // 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 ); |
150 | 150 | $this->getResult()->addValue( array( 'dynamic_form_elements' ), 'token', $token ); |
151 | 151 | $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 ); |
152 | 153 | } catch ( Exception $e ) { |
153 | 154 | /* no result */ |
154 | 155 | } |
— | — | @@ -161,7 +162,7 @@ |
162 | 163 | */ |
163 | 164 | protected function parseTrackingData( $unparsed_tracking_data ) { |
164 | 165 | // 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' ] )); |
166 | 167 | $tracking_data = wfCgiToArray( $url_bits[ 'query' ] ); |
167 | 168 | |
168 | 169 | // add the referrer to the tracked_data array |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js |
— | — | @@ -15,14 +15,6 @@ |
16 | 16 | sajax_do_call( 'efPayflowGatewayCheckSession', [], checkSession ); |
17 | 17 | } |
18 | 18 | |
19 | | -addEvent( window, 'load', getIfSessionSet ); |
20 | | - |
21 | | -function checkSession( request ) { |
22 | | - if ( request.responseText == "no" ) { |
23 | | - window.location = document.location.href; |
24 | | - } |
25 | | -} |
26 | | - |
27 | 19 | function clearField( field, defaultValue ) { |
28 | 20 | if (field.value == defaultValue) { |
29 | 21 | field.value = ''; |
— | — | @@ -53,8 +45,8 @@ |
54 | 46 | |
55 | 47 | |
56 | 48 | // 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("."); |
59 | 51 | |
60 | 52 | if( apos < 1 || dotpos-apos < 2 ) { |
61 | 53 | output += payflowproGatewayErrorMsgEmail; |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -56,7 +56,11 @@ |
57 | 57 | $wgPayFlowProGatewayCSSVersion, $wgPayflowGatewayPaypalURL, |
58 | 58 | $wgPayflowGatewaySalt; |
59 | 59 | |
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 | + |
61 | 65 | $this->fnPayflowEnsureSession(); |
62 | 66 | $this->setHeaders(); |
63 | 67 | |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumn.php |
— | — | @@ -2,205 +2,205 @@ |
3 | 3 | |
4 | 4 | class PayflowProGateway_Form_TwoStepTwoColumn extends PayflowProGateway_Form { |
5 | 5 | |
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 |
18 | 18 | <script type="text/javascript"> |
19 | 19 | 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 | + } |
31 | 31 | } |
32 | 32 | addEvent( window, 'load', loadPlaceholders ); |
33 | 33 | </script> |
34 | 34 | 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 | + } |
70 | 37 | |
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 | + } |
87 | 51 | |
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(); |
116 | 55 | |
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' ) ); |
127 | 57 | |
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 | + } |
130 | 70 | |
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' ) ); |
137 | 73 | |
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' ) ); |
140 | 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 |
141 | 81 | |
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(); |
153 | 84 | |
154 | | - return $form; |
155 | | - } |
| 85 | + return $form; |
| 86 | + } |
156 | 87 | |
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 | + } |
168 | 101 | |
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 | + } |
171 | 116 | |
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' ) ); |
174 | 122 | |
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(); |
204 | 124 | |
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 @@ |
54 | 54 | |
55 | 55 | // Xml::element seems to convert html to htmlentities |
56 | 56 | $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' ) ); |
58 | 58 | |
59 | 59 | $form .= $this->generateBillingContainer(); |
60 | 60 | return $form; |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnPayPal.php |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | |
33 | 33 | // Xml::element seems to convert html to htmlentities |
34 | 34 | $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' ) ); |
36 | 36 | |
37 | 37 | $form .= Xml::openElement( 'div', array( 'id' => 'left-column', 'class' => 'payflow-cc-form-section')); |
38 | 38 | $form .= $this->generatePersonalContainer(); |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php |
— | — | @@ -634,4 +634,39 @@ |
635 | 635 | $form .= '</tr>'; |
636 | 636 | return $form; |
637 | 637 | } |
| 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 | + } |
638 | 673 | } |
\ No newline at end of file |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/OneStepTwoColumn.php |
— | — | @@ -1,244 +1,244 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | 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 |
6 | 6 | |
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; |
56 | 9 | |
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 ); |
109 | 11 | |
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(); |
128 | 14 | |
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 | + } |
147 | 20 | |
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 | + } |
150 | 34 | |
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; |
168 | 37 | |
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 ); |
177 | 39 | |
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(); |
188 | 41 | |
189 | | - return $form; |
190 | | - } |
| 42 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) ); |
191 | 43 | |
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 | + } |
194 | 56 | |
195 | | - $form = ''; |
196 | | - |
197 | | - // card logos |
198 | | - $form .= '<tr>'; |
199 | | - $form .= '<td />'; |
200 | | - $form .= '<td> <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' ) ); |
214 | 59 | |
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' ) ); |
217 | 63 | |
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(); |
226 | 66 | |
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 |
235 | 69 | |
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 | + } |
238 | 73 | |
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> <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 @@ |
46 | 46 | |
47 | 47 | // Xml::element seems to convert html to htmlentities |
48 | 48 | $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' ) ); |
50 | 50 | |
51 | 51 | $form .= $this->generateBillingContainer(); |
52 | 52 | return $form; |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php |
— | — | @@ -2,20 +2,20 @@ |
3 | 3 | |
4 | 4 | # Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly. |
5 | 5 | if( !defined( 'MEDIAWIKI' ) ) { |
6 | | - echo <<<EOT |
| 6 | + echo <<<EOT |
7 | 7 | To install PayflowPro Gateway extension, put the following line in LocalSettings.php: |
8 | 8 | require_once( "\$IP/extensions/payflowpro_gateway/payflowpro_gateway.php" ); |
9 | 9 | EOT; |
10 | | - exit( 1 ); |
| 10 | + exit( 1 ); |
11 | 11 | } |
12 | 12 | |
13 | 13 | // Extension credits that will show up on Special:Version |
14 | 14 | $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', |
20 | 20 | ); |
21 | 21 | |
22 | 22 | // Set up the new special page |
— | — | @@ -95,7 +95,7 @@ |
96 | 96 | * The URL to redirect a transaction to PayPal |
97 | 97 | */ |
98 | 98 | $wgPayflowGatewayPaypalURL = ''; |
99 | | - |
| 99 | + |
100 | 100 | /** |
101 | 101 | * Hooks required to interface with the donation extension (include <donate> on page) |
102 | 102 | * |
— | — | @@ -105,64 +105,49 @@ |
106 | 106 | $wgHooks['DonationInterface_Value'][] = 'pfpGatewayValue'; |
107 | 107 | $wgHooks['DonationInterface_Page'][] = 'pfpGatewayPage'; |
108 | 108 | |
109 | | -// use sajax |
110 | | -$wgUseAjax = true; |
111 | | -$wgAjaxExportList[] = 'efPayflowGatewayCheckSession'; |
112 | | - |
113 | 109 | // enable the API |
114 | 110 | $wgAPIModules[ 'pfp' ] = 'ApiPayflowProGateway'; |
115 | 111 | $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 | | -} |
126 | 112 | |
127 | 113 | function payflowGatewayConnection() { |
128 | | - global $wgPayflowGatewayDBserver, $wgPayflowGatewayDBname; |
129 | | - global $wgPayflowGatewayDBuser, $wgPayflowGatewayDBpassword; |
| 114 | + global $wgPayflowGatewayDBserver, $wgPayflowGatewayDBname; |
| 115 | + global $wgPayflowGatewayDBuser, $wgPayflowGatewayDBpassword; |
130 | 116 | |
131 | | - static $db; |
| 117 | + static $db; |
132 | 118 | |
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 | + } |
141 | 127 | |
142 | | - return $db; |
| 128 | + return $db; |
143 | 129 | } |
144 | 130 | |
145 | | - |
146 | 131 | /** |
147 | 132 | * Hook to register form value and display name of this gateway |
148 | 133 | * also supplies currencies supported by this gateway |
149 | 134 | */ |
150 | 135 | function pfpGatewayValue( &$values ) { |
151 | 136 | |
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 | + ); |
165 | 150 | |
166 | | - return true; |
| 151 | + return true; |
167 | 152 | } |
168 | 153 | |
169 | 154 | /** |
— | — | @@ -173,8 +158,15 @@ |
174 | 159 | * the result might look like this: http://www.yourdomain.com/index.php?title=Special:PayflowPro&amount=75.00¤cy_code=USD&payment_method=payflow |
175 | 160 | */ |
176 | 161 | function pfpGatewayPage( &$url ) { |
177 | | - global $wgScript; |
| 162 | + global $wgScript; |
178 | 163 | |
179 | | - $url['payflow'] = $wgScript . "?title=Special:PayflowProGateway"; |
180 | | - return true; |
| 164 | + $url['payflow'] = $wgScript . "?title=Special:PayflowProGateway"; |
| 165 | + return true; |
181 | 166 | } |
| 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 |