r73506 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73505‎ | r73506 | r73507 >
Date:01:14, 22 September 2010
Author:awjrichards
Status:deferred (Comments)
Tags:
Comment:
Fixed wonky session handling for cc form; Made small edits to CC form and messaging
Modified paths:
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumn.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.css (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js
@@ -1,5 +1,28 @@
22 //<![CDATA[
33
 4+function addEvent(obj, evType, fn){
 5+ if (obj.addEventListener){
 6+ obj.addEventListener(evType, fn, false);
 7+ return true;
 8+ } else if (obj.attachEvent){
 9+ var r = obj.attachEvent("on"+evType, fn);
 10+ return r;
 11+ } else {
 12+ return false;
 13+ }
 14+}
 15+addEvent( window, 'load', getIfSessionSet );
 16+
 17+function getIfSessionSet() {
 18+ sajax_do_call( 'efPayflowGatewayCheckSession', [], checkSession );
 19+}
 20+
 21+function checkSession( request ) {
 22+ if ( request.responseText == "no" ) {
 23+ window.location = document.location.href;
 24+ }
 25+}
 26+
427 function validate_form( form ) {
528 var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'State', 'Zip', 'CardNum', 'Cvv', 'Amount' ];
629
@@ -66,5 +89,4 @@
6790 }
6891
6992 window.onfocus = CloseCVV;
70 -
7193 //]]>
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -57,9 +57,6 @@
5858 $this->fnPayflowEnsureSession();
5959 $this->setHeaders();
6060
61 - $wgOut->addHeadItem( 'validatescript', '<script type="text/javascript" language="javascript" src="' .
62 - $wgScriptPath .
63 - '/extensions/DonationInterface/payflowpro_gateway/validate_input.js"></script>' );
6461
6562 $wgOut->addExtensionStyle(
6663 "{$wgScriptPath}/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.css?" .
@@ -155,7 +152,6 @@
156153 // expose a hook for external handling of trxns ready for processing
157154 wfRunHooks( 'PayflowGatewayProcess', array( &$this, &$data ));
158155 $this->fnPayflowProcessTransaction( $data, $payflow_data );
159 - $this->fnPayflowUnsetEditToken();
160156 }
161157
162158 // expose a hook for any post processing
@@ -181,8 +177,13 @@
182178 * The message at the top of the form can be edited in the payflow_gateway.i18.php file
183179 */
184180 public function fnPayflowDisplayForm( &$data, &$error ) {
185 - global $wgOut;
 181+ global $wgOut, $wgScriptPath;
186182
 183+ // we only want to load this JS if the form is being rendered
 184+ $wgOut->addHeadItem( 'validatescript', '<script type="text/javascript" language="javascript" src="' .
 185+ $wgScriptPath .
 186+ '/extensions/DonationInterface/payflowpro_gateway/validate_input.js"></script>' );
 187+
187188 // save contrib tracking id early to track abondonment
188189 if ( $data[ 'numAttempt' ] == '0' ) {
189190 if ( !$tracked = $this->fnPayflowSaveContributionTracking( $data ) ) {
@@ -559,7 +560,7 @@
560561 $responseMsg = wfMsg( 'payflowpro_gateway-response-default' );
561562 $errorCode = '4';
562563 }
563 -
 564+
564565 return $errorCode;
565566 }
566567
@@ -611,6 +612,8 @@
612613 // if we want to show the response
613614 $wgOut->addHTML( Xml::buildTable( $rows, array( 'class' => 'submitted-response' ) ) );
614615 }
 616+ // unset edit token
 617+ $this->fnPayflowUnsetEditToken();
615618 }
616619
617620 /**
@@ -626,6 +629,9 @@
627630
628631 // display response message
629632 $wgOut->addHTML( '<h3 class="response_message">' . $declinedDefault . ' ' . $responseMsg . '</h3>' );
 633+
 634+ // unset edit token
 635+ $this->fnPayflowUnsetEditToken();
630636 }
631637
632638 /**
@@ -641,6 +647,9 @@
642648
643649 // display response message
644650 $wgOut->addHTML( '<h3 class="response_message">' . $declinedDefault . ' ' . $responseMsg . '</h3>' );
 651+
 652+ // unset edit token
 653+ $this->fnPayflowUnsetEditToken();
645654 }
646655
647656 function fnPayflowDisplayPending( $data, $responseArray, $responseMsg ) {
@@ -669,6 +678,8 @@
670679 $wgOut->addHTML( '<h2 class="response_message">' . $thankyou . '</h2>' );
671680 $wgOut->addHTML( '<p>' . $responseMsg );
672681
 682+ // unset edit token
 683+ $this->fnPayflowUnsetEditToken();
673684 }
674685
675686 function fnPayflowSaveContributionTracking( &$data ) {
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter.css
@@ -32,3 +32,12 @@
3333 float: left;
3434 margin-right: 2em;
3535 }
 36+
 37+#payflowpro_gateway-cc_form_letter_inside {
 38+ padding-top: .5em;
 39+}
 40+
 41+#payflowpro_gateway-cc_otherways {
 42+ padding-top: .5em;
 43+ display: block;
 44+}
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumn.php
@@ -29,7 +29,7 @@
3030 $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit'));
3131 $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' ));
3232 //$form .= Xml::submitButton( wfMsg( 'payflowpro_gateway-submit-button' ));
33 - $form .= Xml::openElement( 'input', array( 'class' => 'input-button button-navyblue', 'value' => wfMsg( 'payflowpro_gateway-submit-button'), 'onclick' => 'form.submit()'));
 33+ $form .= Xml::openElement( 'input', array( 'class' => 'input-button button-navyblue', 'value' => wfMsg( 'payflowpro_gateway-submit-button'), 'onclick' => 'form.submit()', 'type' => 'submit'));
3434 $form .= Xml::closeElement( 'div' );
3535 $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) .
3636 wfMsg( 'payflowpro_gateway-donate-click' );
@@ -50,10 +50,9 @@
5151 $form .= Xml::tags( 'p', array( 'class' => '' ), Xml::openElement( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/rapidssl_ssl_certificate.gif" )));
5252 $form .= Xml::closeElement( 'div' );
5353 $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-donate-addl-info-text' ));
54 - $form .= Xml::tags( 'p', array( 'class' => '' ),
55 - wfMsg( 'payflowpro_gateway-credit-storage-processing' ) ) .
56 - Xml::tags( 'p', array( 'class' => ''),
57 - wfMsg( 'payflowpro_gateway-question-comment' ) );
 54+ $form .= Xml::tags( 'p', array( 'class' => '' ), wfMsg( 'payflowpro_gateway-otherways' ));
 55+ $form .= Xml::tags( 'p', array( 'class' => '' ), wfMsg( 'payflowpro_gateway-credit-storage-processing' ) );
 56+ $form .= Xml::tags( 'p', array( 'class' => ''), wfMsg( 'payflowpro_gateway-question-comment' ) );
5857 $form .= Xml::closeElement( 'div' );
5958 $form .= Xml::closeElement( 'div' );
6059
@@ -210,12 +209,6 @@
211210 '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['card_num'] . '</span></td>';
212211 $form .= '</tr>';
213212
214 - // card error
215 - $form .= '<tr>';
216 - $form .= '<td></td>';
217 - $form .= '<td>' . '<span class="creditcard-error-msg">' . ' ' . $this->form_errors['card'] . '</span></td>';
218 - $form .= '</tr>';
219 -
220213 // expiry
221214 $form .= '<tr>';
222215 $form .= '<td>' . Xml::label( wfMsg( 'payflowpro_gateway-donor-expiration' ), 'expiration' ) . '</td>';
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php
@@ -2,7 +2,7 @@
33
44 class PayflowProGateway_Form_TwoColumnLetter extends PayflowProGateway_Form_TwoColumn {
55
6 - public function __construct( &$form_data, &$form_errors ) {
 6+ public function __construct( &$form_data, &$form_errors ) {
77 global $wgOut, $wgScriptPath;
88 parent::__construct( $form_data, $form_errors );
99
@@ -19,7 +19,8 @@
2020 $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_container'));
2121
2222 $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_form', 'class' => 'payflowpro_gateway-cc_form_column'));
23 - $form .= parent::generatePersonalContainerTop();
 23+ $form .= Xml::Tags( 'p', array( 'id' => 'payflowpro_gateway-cc_otherways' ), wfMsg( 'payflowpro_gateway-otherways' ));
 24+ $form .= parent::generatePersonalContainerTop();
2425 $form .= parent::generatePersonalFields();
2526 $form .= Xml::closeElement( 'table' );
2627 $form .= Xml::closeElement( 'div' );
@@ -36,11 +37,12 @@
3738 $form = parent::generateFormSubmit();
3839
3940 $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_letter', 'class' => 'payflowpro_gateway-cc_form_column'));
40 -
 41+ $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_letter_inside' ));
4142 $text_template = $wgRequest->getText( 'text_template' );
4243 if ( $wgRequest->getText( 'language' )) $text_template .= '/' . $wgRequest->getText( 'language' );
4344
4445 $form .= ( strlen( $text_template )) ? $wgOut->parse( '{{'.$text_template.'}}' ) : '';
 46+ $form .= Xml::closeElement( 'div' );
4547 $form .= Xml::closeElement( 'div' );
4648
4749 $form .=Xml::closeElement( 'div' );
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.i18n.php
@@ -13,7 +13,8 @@
1414 'payflowprogateway' => 'Support Wikimedia',
1515 'payflowpro_gateway-desc' => 'PayPal Payflow Pro credit card processing',
1616 'payflowpro_gateway-accessible' => 'This page is only accessible from the donation page.',
17 -# 'payflowpro_gateway-form-message' => '',
 17+ 'payflowpro_gateway-form-message' => 'Use the form below to donate with a credit card, or ',
 18+ 'payflowpro_gateway-paypal-button' => 'Donate via PayPal',
1819 'payflowpro_gateway-form-message-2' => 'To change amount or currency, return to <a href="https://www.mediawiki.org/index.php?title=Donate">the donation page</a>',
1920 'payflowpro_gateway-donor-legend' => 'Donor information',
2021 'payflowpro_gateway-card-legend' => 'Credit card information',
@@ -94,8 +95,8 @@
9596 In some instances, the code is located on the left side of the card, but is always above the account number.</p><br />',
9697 'payflowpro_gateway-question-comment' => 'Questions or comments? Contact: <a href="mailto:donate@wikimedia.org">donate@wikimedia.org</a>',
9798 'payflowpro_gateway-donate-click' => 'After clicking "{{int:payflowpro_gateway-donor-submit}}", your credit card information will be processed.',
98 - 'payflowpro_gateway-credit-storage-processing' => 'There are <a href="http://wikimediafoundation.org/wiki/Ways_to_Give/en">other ways to give, including PayPal, check, or mail</a>.<br />
99 -We do not store your credit card information, and your personal data is subject to our <a href="http://wikimediafoundation.org/wiki/Donor_Privacy_Policy">privacy policy</a>.',
 99+ 'payflowpro_gateway-otherways' => 'There are <a href="http://wikimediafoundation.org/wiki/Ways_to_Give/en">other ways to give, including PayPal, check, or mail</a>.',
 100+ 'payflowpro_gateway-credit-storage-processing' => 'We do not store your credit card information, and your personal data is subject to our <a href="http://wikimediafoundation.org/wiki/Donor_Privacy_Policy">privacy policy</a>.',
100101 'donate_interface-GBP' => 'GBP: British Pound',
101102 'donate_interface-EUR' => 'EUR: Euro',
102103 'donate_interface-USD' => 'USD: U.S. Dollar',
@@ -103,7 +104,7 @@
104105 'donate_interface-CAD' => 'CAD: Canadian Dollar',
105106 'donate_interface-JPY' => 'JPY: Japanese Yen',
106107 'payflowpro_gateway-token-mismatch' => 'Your session has expired. Please try filling out and submitting the form again.',
107 - 'payflowpro_gateway-cc-form-header-personal' => 'Personal information',
 108+ 'payflowpro_gateway-cc-form-header-personal' => 'Billing information',
108109 'payflowpro_gateway-cc-form-header-payment' => 'Payment information',
109110 );
110111
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php
@@ -85,6 +85,28 @@
8686 $wgPayflowGatewayUseHTTPProxy = FALSE;
8787 $wgPayflowGatewayHTTPProxy = '';
8888
 89+/**
 90+ * Hooks required to interface with the donation extension (include <donate> on page)
 91+ *
 92+ * gwValue supplies the value of the form option, the name that appears on the form
 93+ * and the currencies supported by the gateway in the $values array
 94+ */
 95+$wgHooks['DonationInterface_Value'][] = 'pfpGatewayValue';
 96+$wgHooks['DonationInterface_Page'][] = 'pfpGatewayPage';
 97+$wgUseAjax = true;
 98+$wgAjaxExportList[] = 'efPayflowGatewayCheckSession';
 99+
 100+/**
 101+ * Return whether or not payflowEditToken is set in the session
 102+ */
 103+function efPayflowGatewayCheckSession() {
 104+ $token_set = ( isset( $_SESSION[ 'payflowEditToken' ] )) ? 'yes' : 'no';
 105+ $ajax = new AjaxResponse( $token_set );
 106+ // if we don't explicitly set the content type, things break
 107+ $ajax->setContentType( 'text/plain' );
 108+ return $ajax;
 109+}
 110+
89111 function payflowGatewayConnection() {
90112 global $wgPayflowGatewayDBserver, $wgPayflowGatewayDBname;
91113 global $wgPayflowGatewayDBuser, $wgPayflowGatewayDBpassword;
@@ -103,14 +125,6 @@
104126 return $db;
105127 }
106128
107 -/**
108 - * Hooks required to interface with the donation extension (include <donate> on page)
109 - *
110 - * gwValue supplies the value of the form option, the name that appears on the form
111 - * and the currencies supported by the gateway in the $values array
112 - */
113 -$wgHooks['DonationInterface_Value'][] = 'pfpGatewayValue';
114 -$wgHooks['DonationInterface_Page'][] = 'pfpGatewayPage';
115129
116130 /**
117131 * Hook to register form value and display name of this gateway
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.css
@@ -48,13 +48,6 @@
4949 text-align: left;
5050 }
5151
52 -/*
53 -#payflow-table-donor label {
54 - text-align: right;
55 - display: block;
56 -}
57 -*/
58 -
5952 #payflowpro_gateway-donate-addl-info {
6053 clear: both;
6154 }
@@ -86,3 +79,7 @@
8780 vertical-align:middle;
8881 width:204px;
8982 }
 83+
 84+#ca-special {
 85+ display: none;
 86+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r79687Followup r73506, removed errant i18n messages mentioned by Siebrandawjrichards23:36, 5 January 2011

Comments

#Comment by Siebrand (talk | contribs)   20:46, 17 October 2010
  • 'payflowpro_gateway-form-message': not being used in the code as far as I can see. Where is it used? Also: i18n fixme. Patchwork message, where ever it is used. Please fix. Please also document usage in 'qqq' language, if really used.
  • 'payflowpro_gateway-form-message-2': not being used in the code as far as I can see. Where is it used? Please document usage in 'qqq' language, if really used.
#Comment by Nikerabbit (talk | contribs)   10:21, 25 December 2010

Can someone please look at this, it's not fun to waste translators time and the trailing whitespace causes problems for twn.

#Comment by Awjrichards (talk | contribs)   23:37, 5 January 2011

This is resolved in r79687 - sorry that took so long!

#Comment by Catrope (talk | contribs)   12:24, 6 January 2011

Setting back to new. Please don't set your revisions to 'resolved' unless you've also reviewed them (which you can't do with your own revs). After fixing fixme's, set them back to 'new'.

Status & tagging log