r101064 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101063‎ | r101064 | r101065 >
Date:21:37, 27 October 2011
Author:jpostlethwaite
Status:resolved (Comments)
Tags:fundraising 
Comment:
Added front end debugging to select form payment types to load. Enabled javascript in r101063.
Modified paths:
  • /trunk/extensions/DonationInterface/globalcollect_gateway/forms/TwoStepAmount.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/TwoStepAmount.php
@@ -51,15 +51,22 @@
5252 $this->loadValidateJs();
5353 }
5454
 55+ /**
 56+ * Load extra javascript
 57+ */
5558 protected function loadValidateJs() {
5659 global $wgOut;
5760 $wgOut->addModules( 'gc.form.core.validate' );
58 - $wgOut->addHeadItem( 'donationinterface_validate', "\n" . '<script type="text/javascript" src="/extensions/DonationInterface/globalcollect_gateway/modules/js/validate.js"></script>' );
59 - $wgOut->addHeadItem( 'donationinterface_js_validate', "\n" . '<script type="text/javascript" src="/extensions/DonationInterface/globalcollect_gateway/modules/js/jquery.validate.js"></script>' );
60 - $wgOut->addHeadItem( 'donationinterface_js_validate_additional', "\n" . '<script type="text/javascript" src="/extensions/DonationInterface/globalcollect_gateway/modules/js/jquery.validate.additional-methods.js"></script>' );
6161
62 - $js = "\n" . '<script type="text/javascript">' . "validateForm( { validate: { address: true, amount: true, creditCard: false, email: true, name: true, }, payment_method: '" . $this->getPaymentMethod() . "', payment_submethod: '" . $this->getPaymentSubmethod() . "', formId: '" . $this->getFormId() . "' } );" . '</script>' . "\n";
63 - $wgOut->addHeadItem( 'placeholders', $js );
 62+ //$js = "\n" . '<script type="text/javascript">' . "validateForm( { validate: { address: true, amount: true, creditCard: false, email: true, name: true, }, payment_method: '" . $this->getPaymentMethod() . "', payment_submethod: '" . $this->getPaymentSubmethod() . "', formId: '" . $this->getFormId() . "' } );" . '</script>' . "\n";
 63+ $js = "\n" . '<script type="text/javascript">'
 64+ . "var validatePaymentForm = {
 65+ formId: '" . $this->getFormId() . "',
 66+ payment_method: '" . $this->getPaymentMethod() . "',
 67+ payment_submethod: '" . $this->getPaymentSubmethod() . "',
 68+ }"
 69+ . '</script>' . "\n";
 70+ $wgOut->addHeadItem( 'loadValidateJs', $js );
6471 }
6572
6673 /**
@@ -74,7 +81,170 @@
7582 return $form;
7683 }
7784
 85+ public $payment_methods = array();
 86+ public $payment_submethods = array();
 87+
7888 /**
 89+ * Generate the payment information
 90+ *
 91+ * @todo
 92+ * - a large part of this method is for debugging and may need to be removed.
 93+ */
 94+ public function generateFormPaymentInformation() {
 95+
 96+ $form = '';
 97+
 98+ // Payment debugging information
 99+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-payment-information' ) );
 100+
 101+ $form .= Xml::tags( 'h2', array(), 'Payment debugging information' );
 102+
 103+ $form .= Xml::openElement( 'ul', array() ); // open div#mw-payment-information ul
 104+ $form .= Xml::tags( 'li', array(), 'payment_method: ' . $this->getPaymentMethod() );
 105+ $form .= Xml::tags( 'li', array(), 'payment_submethod: ' . $this->getPaymentSubmethod() );
 106+
 107+ if ( isset( $this->form_data['issuer_id'] ) ) {
 108+ $form .= Xml::tags( 'li', array(), 'issuer_id: ' . $this->form_data['issuer_id'] );
 109+ }
 110+
 111+ $form .= Xml::closeElement( 'ul' ); // close div#mw-payment-information ul
 112+
 113+ $form .= Xml::tags( 'h3', array(), 'Payment choices' );
 114+
 115+ $form .= Xml::tags( 'h4', array(), 'Payment method:' );
 116+
 117+ // Bank Transfers
 118+ $this->payment_methods['bt'] = array(
 119+ 'label' => 'Bank transfer',
 120+ 'types' => array( 'bt', ),
 121+ 'validation' => array( 'creditCard' => false, )
 122+ //'forms' => array( 'Gateway_Form_TwoStepAmount', ),
 123+ );
 124+
 125+ // Credit Cards
 126+ //$this->payment_methods['cc'] = array(
 127+ // 'label' => 'Credit Cards',
 128+ // 'types' => array( '', 'visa', 'mc', 'amex', 'discover', 'maestro', 'solo', 'laser', 'jcb,', 'cb', ),
 129+ //);
 130+
 131+ // Direct Debit
 132+ $this->payment_methods['dd'] = array(
 133+ 'label' => 'Direct Debit',
 134+ 'types' => array( 'dd_johnsen_nl', 'dd_johnsen_de', 'dd_johnsen_at', 'dd_johnsen_fr', 'dd_johnsen_gb', 'dd_johnsen_be', 'dd_johnsen_ch', 'dd_johnsen_it', 'dd_johnsen_es', ),
 135+ 'validation' => array( 'creditCard' => false, )
 136+ //'forms' => array( 'Gateway_Form_TwoStepAmount', ),
 137+ );
 138+
 139+ // Real Time Bank Transfers
 140+ $this->payment_methods['rtbt'] = array(
 141+ 'label' => 'Real time bank transfer',
 142+ 'types' => array( 'rtbt_ideal', 'rtbt_eps', 'rtbt_sofortuberweisung', 'rtbt_nordea_sweeden', 'rtbt_enets', ),
 143+ );
 144+
 145+ // Ideal
 146+ $this->payment_submethods['rtbt_ideal'] = array(
 147+ 'paymentproductid' => 809,
 148+ 'label' => 'Ideal',
 149+ 'group' => 'rtbt',
 150+ 'validation' => array(),
 151+ 'issuerids' => array(
 152+ 771 => 'RegioBank',
 153+ 161 => 'Van Lanschot Bankiers',
 154+ 31 => 'ABN AMRO',
 155+ 761 => 'ASN Bank',
 156+ 21 => 'Rabobank',
 157+ 511 => 'Triodos Bank',
 158+ 721 => 'ING',
 159+ 751 => 'SNS Bank',
 160+ 91 => 'Friesland Bank',
 161+ )
 162+ );
 163+ // eps Online-Überweisung
 164+ $this->payment_submethods['rtbt_eps'] = array(
 165+ 'paymentproductid' => 856,
 166+ 'label' => 'eps Online-Überweisung',
 167+ 'group' => 'rtbt',
 168+ 'validation' => array(),
 169+ 'issuerids' => array(
 170+ 824 => 'Bankhaus Spängler',
 171+ 825 => 'Hypo Tirol Bank',
 172+ 822 => 'NÖ HYPO',
 173+ 823 => 'Voralberger HYPO',
 174+ 828 => 'P.S.K.',
 175+ 829 => 'Easy',
 176+ 826 => 'Erste Bank und Sparkassen',
 177+ 827 => 'BAWAG',
 178+ 820 => 'Raifeissen',
 179+ 821 => 'Volksbanken Gruppe',
 180+ 831 => 'Sparda-Bank',
 181+ )
 182+ );
 183+
 184+ $form .= Xml::openElement( 'ul', array() ); // open div#mw-payment-information ul
 185+ //<a href="http://wikimediafoundation.org/wiki/Ways_to_Give/en">Other ways to give</a>
 186+
 187+ foreach ( $this->payment_methods as $payment_method => $payment_methodMeta ) {
 188+
 189+ $form .= Xml::openElement( 'li', array() );
 190+
 191+ $form .= Xml::tags( 'span', array(), $payment_method );
 192+
 193+ foreach ( $payment_methodMeta['types'] as $payment_submethod ) {
 194+ $form .= ' - ' . Xml::tags( 'a', array('href'=>'?form_name=TwoStepAmount&payment_method=' . $payment_method . '&payment_submethod=' . $payment_submethod), $payment_submethod );
 195+ }
 196+
 197+ $form .= Xml::closeElement( 'li' );
 198+ }
 199+
 200+ $form .= Xml::closeElement( 'ul' ); // close div#mw-payment-information ul
 201+
 202+ $form .= Xml::closeElement( 'div' ); // close div#mw-payment-information
 203+
 204+ return $form;
 205+ }
 206+
 207+ /**
 208+ * Generate the issuerId for real time bank transfer
 209+ */
 210+ public function generateFormIssuerIdDropdown() {
 211+
 212+ $form = '';
 213+
 214+ if ( !isset( $this->payment_submethods[ $this->getPaymentSubmethod() ] ) ) {
 215+
 216+ // No issuer_id to load
 217+ return $form;
 218+ }
 219+
 220+ $selectOptions = '';
 221+
 222+ // generate dropdown of issuer_ids
 223+ foreach ( $this->payment_submethods[ $this->getPaymentSubmethod() ]['issuerids'] as $issuer_id => $issuer_id_label ) {
 224+ $selected = ( $this->form_data['issuer_id'] == $value ) ? true : false;
 225+ //$selectOptions .= Xml::option( wfMsg( 'donate_interface-rtbt-' . $issuer_id ), $issuer_id_label, $selected );
 226+ $selectOptions .= Xml::option( $issuer_id_label, $issuer_id_label, $selected );
 227+ }
 228+ $form .= '<tr>';
 229+ $form .= '<td class="label">' . Xml::label( wfMsg( 'donate_interface-donor-issuer_id' ), 'issuer_id' ) . '</td>';
 230+
 231+ $form .= '<td>';
 232+ $form .= Xml::openElement(
 233+ 'select',
 234+ array(
 235+ 'name' => 'issuer_id',
 236+ 'id' => 'issuer_id',
 237+ 'onchange' => '',
 238+ ) );
 239+ $form .= $selectOptions;
 240+ $form .= Xml::closeElement( 'select' );
 241+
 242+ $form .= '</td>';
 243+ $form .= '</tr>';
 244+
 245+ return $form;
 246+ }
 247+
 248+ /**
79249 * Generate the first part of the form
80250 */
81251 public function generateFormStart() {
@@ -100,6 +270,8 @@
101271
102272 // add noscript tags for javascript disabled browsers
103273 $form .= $this->getNoScript();
 274+
 275+ $form .= $this->generateFormPaymentInformation();
104276
105277 // open form
106278 $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard-form' ) );
@@ -210,6 +382,8 @@
211383 ' ' . $this->generateCurrencyDropdown( array( 'showCardsOnCurrencyChange' => false, ) ) . '</td>';
212384 $form .= '</tr>';
213385
 386+ $form .= $this->generateFormIssuerIdDropdown();
 387+
214388 return $form;
215389 }
216390 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r102236MFT r90286, r100671, r100837, r100950, r101060, r101063, r101064, r101073, r1......khorn03:06, 7 November 2011
r102237MFT r90286, r100671, r100837, r100950, r101060, r101063, r101064, r101073, r1......khorn03:07, 7 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101063Refactored to work with ResourceLoader module: gc.form.core.validate. See r10...jpostlethwaite21:34, 27 October 2011

Comments

#Comment by Jpostlethwaite (talk | contribs)   21:41, 27 October 2011

Some of this data is placeholder. This is referring to:

+ public $payment_methods = array(); + public $payment_submethods = array();

This information needs to be available to the form, especially for the issuer_id dropdown.

Status & tagging log