r97102 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97101‎ | r97102 | r97103 >
Date:21:29, 14 September 2011
Author:kaldari
Status:ok
Tags:fundraising 
Comment:
implement basic iframe solution, add some comments
Modified paths:
  • /branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php (modified) (history)

Diff [purge]

Index: branches/fundraising/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php
@@ -174,7 +174,7 @@
175175 /**
176176 * Hook to supply the page address of the payment gateway
177177 *
178 - * The user will redirected here with supplied data with input data appended (GET).
 178+ * The user will be redirected here with supplied data with input data appended (GET).
179179 * For example, if $url[$key] = index.php?title=Special:PayflowProGateway
180180 * the result might look like this: http://www.yourdomain.com/index.php?title=Special:PayflowProGateway&amount=75.00&currency_code=USD&payment_method=payflow
181181 */
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php
@@ -20,7 +20,7 @@
2121 * Holds the GlobalCollect response from a transaction
2222 * @var array
2323 */
24 - public $payflow_response = array( );
 24+ public $payflow_response = array();
2525
2626 /**
2727 * A container for the form class
@@ -34,7 +34,7 @@
3535 * An array of form errors
3636 * @var array
3737 */
38 - public $errors = array( );
 38+ public $errors = array();
3939
4040 /**
4141 * Constructor - set up the new special page
@@ -53,7 +53,7 @@
5454 */
5555 public function execute( $par ) {
5656 global $wgRequest, $wgOut, $wgExtensionAssetsPath,
57 - $wgPayFlowProGatewayCSSVersion;
 57+ $wgPayFlowProGatewayCSSVersion;
5858
5959 $wgOut->addExtensionStyle(
6060 $wgExtensionAssetsPath . '/DonationInterface/gateway_forms/css/gateway.css?284' .
@@ -80,6 +80,7 @@
8181
8282 $wgOut->addScript( Skin::makeVariablesScript( $scriptVars ) );
8383
 84+ // Make the wiki logo not clickable.
8485 // @fixme can this be moved into the form generators?
8586 $js = <<<EOT
8687 <script type="text/javascript">
@@ -89,9 +90,9 @@
9091 </script>
9192 EOT;
9293 $wgOut->addHeadItem( 'logolinkoverride', $js );
93 -
 94+
9495 $this->setHeaders();
95 -
 96+
9697 //TODO: This is short-circuiting what I really want to do here.
9798 //so stop it.
9899 $data = $this->adapter->getDisplayData();
@@ -99,13 +100,16 @@
100101 // dispatch forms/handling
101102 if ( $this->adapter->checkTokens() ) {
102103 if ( $this->adapter->posted && $data['payment_method'] == 'processed' ) {
103 - $this->adapter->log( "Posted and processed." );
 104+ // The form was submitted and the payment method has been set
 105+ $this->adapter->log("Form posted and payment method set.");
104106
105107 // increase the count of attempts
106108 //++$data['numAttempt'];
107 - // Check form for errors and redisplay with messages
 109+
 110+ // Check form for errors
108111 $form_errors = $this->fnPayflowValidateForm( $data, $this->errors );
109112
 113+ // If there were errors, redisplay form, otherwise proceed to next step
110114 if ( $form_errors ) {
111115 $this->fnPayflowDisplayForm( $data, $this->errors );
112116 } else { // The submitted form data is valid, so process it
@@ -113,25 +117,44 @@
114118 $result = $this->adapter->do_transaction( 'INSERT_ORDERWITHPAYMENT' );
115119 //$result = $this->adapter->do_transaction( 'TEST_CONNECTION' );
116120
117 - $wgOut->addHTML( $result['message'] );
118 - if ( !empty( $result['errors'] ) ) {
119 - $wgOut->addHTML( "<ul>" );
120 - foreach ( $result['errors'] as $code => $value ) {
121 - $wgOut->addHTML( "<li>Error $code: $value" );
 121+ if (!empty($result['errors'])){
 122+ $wgOut->addHTML("<ul>");
 123+ foreach ($result['errors'] as $code => $value){
 124+ $wgOut->addHTML("<li>Error $code: $value");
122125 }
123 - $wgOut->addHTML( "</ul>" );
 126+ $wgOut->addHTML("</ul>");
124127 }
125 -
126 - if ( !empty( $result['data'] ) ) {
127 - $wgOut->addHTML( "<ul>" );
128 - foreach ( $result['data'] as $key => $value ) {
129 - $wgOut->addHTML( "<li>$key: $value" );
 128+
 129+ if (!empty($result['data'])){
 130+ // Create new page here with iframe.
 131+ $paymentFrame = Xml::openElement( 'iframe',
 132+ array(
 133+ 'id' => 'globalcollectframe',
 134+ 'name' => 'globalcollectframe',
 135+ 'width' => '680',
 136+ 'height' => '300',
 137+ 'frameborder' => '0',
 138+ 'style' => 'display:block;',
 139+ 'src' => $result['data']['FORMACTION']
 140+ )
 141+ );
 142+ $paymentFrame .= Xml::closeElement( 'iframe' );
 143+
 144+ $wgOut->addHTML( $paymentFrame );
 145+ }
 146+
 147+ /*
 148+ $wgOut->addHTML($result['message']);
 149+ if (!empty($result['data'])){
 150+ $wgOut->addHTML("<ul>");
 151+ foreach ($result['data'] as $key => $value){
 152+ $wgOut->addHTML("<li>$key: $value");
130153 }
131 - $wgOut->addHTML( "</ul>" );
 154+ $wgOut->addHTML("</ul>");
132155 }
 156+ */
133157
134158
135 -
136159 // self::log( $data[ 'order_id' ] . " Preparing to query MaxMind" );
137160 // wfRunHooks( 'PayflowGatewayValidate', array( &$this, &$data ) );
138161 // self::log( $data[ 'order_id' ] . ' Finished querying Maxmind' );
@@ -325,7 +348,7 @@
326349 */
327350 private function fnPayflowGetResults( $data, $result ) {
328351 // prepare NVP response for sorting and outputting
329 - $responseArray = array( );
 352+ $responseArray = array();
330353
331354 /**
332355 * The result response string looks like:
@@ -451,7 +474,7 @@
452475 public function prepareStompTransaction( $data, $responseArray, $responseMsg ) {
453476 $countries = $this->getCountries();
454477
455 - $transaction = array( );
 478+ $transaction = array();
456479
457480 // include response message
458481 $transaction['response'] = $responseMsg;

Status & tagging log