Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php |
— | — | @@ -34,9 +34,7 @@ |
35 | 35 | * Show the special page |
36 | 36 | * |
37 | 37 | * @todo |
38 | | - * - Add transaction type handler |
39 | | - * - What should a failure on transaction_type issues do? log & message client |
40 | | - * - Set up BANK_TRANSFER: Story #308 |
| 38 | + * - Finish error handling |
41 | 39 | * |
42 | 40 | * @param $par Mixed: parameter passed to the page or null |
43 | 41 | */ |
— | — | @@ -85,18 +83,20 @@ |
86 | 84 | |
87 | 85 | // dispatch forms/handling |
88 | 86 | if ( $this->adapter->checkTokens() ) { |
89 | | - |
90 | | - //TODO: Get rid of $data out here completely, by putting this logic inside the adapter somewhere. |
91 | | - //All we seem to be doing with it now, is internal adapter logic outside of the adapter. |
92 | | - $data = $this->adapter->getDisplayData(); |
| 87 | + |
| 88 | + if ( $this->adapter->posted ) { |
93 | 89 | |
94 | | - if ( $this->adapter->posted ) { |
95 | 90 | // The form was submitted and the payment method has been set |
96 | 91 | /* |
97 | 92 | * The $payment_method should default to false. |
98 | 93 | * |
99 | 94 | * An invalid $payment_method will cause an error. |
100 | 95 | */ |
| 96 | + |
| 97 | + //TODO: Get rid of $data out here completely, by putting this logic inside the adapter somewhere. |
| 98 | + //All we seem to be doing with it now, is internal adapter logic outside of the adapter. |
| 99 | + $data = $this->adapter->getDisplayData(); |
| 100 | + |
101 | 101 | $payment_method = ( isset( $data['payment_method'] ) && !empty( $data['payment_method'] ) ) ? $data['payment_method'] : 'cc'; |
102 | 102 | $payment_submethod = ( isset( $data['payment_submethod'] ) && !empty( $data['payment_submethod'] ) ) ? $data['payment_submethod'] : ''; |
103 | 103 | |
— | — | @@ -113,14 +113,45 @@ |
114 | 114 | // allow any external validators to have their way with the data |
115 | 115 | // Execute the proper transaction code: |
116 | 116 | |
117 | | - $result = $this->adapter->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); |
118 | | - |
119 | | - $this->displayResultsForDebug( $result ); |
| 117 | + if ( $payment_method == 'cc' ) { |
120 | 118 | |
121 | | - if ( $payment_method == 'cc' ) { |
122 | | - $this->executeIframeForCreditCard( $result ); |
| 119 | + $this->adapter->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); |
| 120 | + |
| 121 | + // Display an iframe for credit cards |
| 122 | + if ( $this->executeIframeForCreditCard() ) { |
| 123 | + |
| 124 | + // Nothing left to process |
| 125 | + return; |
| 126 | + } |
123 | 127 | } |
| 128 | + elseif ( $payment_method == 'rtbt' ) { |
124 | 129 | |
| 130 | + $this->adapter->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); |
| 131 | + |
| 132 | + $formAction = $this->adapter->getTransactionDataFormAction(); |
| 133 | + |
| 134 | + // Redirect to the bank |
| 135 | + if ( !empty( $formAction ) ) { |
| 136 | + return $wgOut->redirect( $formAction ); |
| 137 | + } |
| 138 | + |
| 139 | + } |
| 140 | + elseif ( $payment_method == 'dd' ) { |
| 141 | + |
| 142 | + $this->adapter->do_transaction( 'DO_BANKVALIDATION' ); |
| 143 | + |
| 144 | + if ( $this->adapter->getTransactionStatus() ) { |
| 145 | + |
| 146 | + $this->adapter->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); |
| 147 | + } |
| 148 | + |
| 149 | + } |
| 150 | + else { |
| 151 | + $this->adapter->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); |
| 152 | + } |
| 153 | + |
| 154 | + return $this->resultHandler(); |
| 155 | + |
125 | 156 | } |
126 | 157 | } else { |
127 | 158 | // Display form |
— | — | @@ -128,8 +159,8 @@ |
129 | 160 | // See GlobalCollectAdapter::stage_returnto() |
130 | 161 | $oid = $wgRequest->getText( 'order_id' ); |
131 | 162 | if ( $oid ) { |
132 | | - $result = $this->adapter->do_transaction( 'GET_ORDERSTATUS' ); |
133 | | - $this->displayResultsForDebug( $result ); |
| 163 | + $this->adapter->do_transaction( 'GET_ORDERSTATUS' ); |
| 164 | + $this->displayResultsForDebug(); |
134 | 165 | } |
135 | 166 | |
136 | 167 | // If the result of the previous transaction was failure, set the retry message. |
— | — | @@ -151,33 +182,34 @@ |
152 | 183 | /** |
153 | 184 | * Execute iframe for credit card |
154 | 185 | * |
155 | | - * @param array $result The result array from the gateway adapter |
156 | | - * |
157 | | - * @todo |
158 | | - * - this needs to be moved out of @see GlobalCollectGateway and into the adapter. |
| 186 | + * @return boolean Returns true if formaction exists for iframe. |
159 | 187 | */ |
160 | | - public function executeIframeForCreditCard( $result ) { |
| 188 | + protected function executeIframeForCreditCard() { |
161 | 189 | |
162 | 190 | global $wgOut; |
163 | 191 | |
164 | | - if ( !empty( $result['data'] ) ) { |
| 192 | + $formAction = $this->adapter->getTransactionDataFormAction(); |
| 193 | + |
| 194 | + if ( $formAction ) { |
165 | 195 | |
166 | | - if ( array_key_exists( 'FORMACTION', $result['data'] ) ) { |
167 | | - $paymentFrame = Xml::openElement( 'iframe', array( |
168 | | - 'id' => 'globalcollectframe', |
169 | | - 'name' => 'globalcollectframe', |
170 | | - 'width' => '680', |
171 | | - 'height' => '300', |
172 | | - 'frameborder' => '0', |
173 | | - 'style' => 'display:block;', |
174 | | - 'src' => $result['data']['FORMACTION'] |
175 | | - ) |
176 | | - ); |
177 | | - $paymentFrame .= Xml::closeElement( 'iframe' ); |
| 196 | + $paymentFrame = Xml::openElement( 'iframe', array( |
| 197 | + 'id' => 'globalcollectframe', |
| 198 | + 'name' => 'globalcollectframe', |
| 199 | + 'width' => '680', |
| 200 | + 'height' => '300', |
| 201 | + 'frameborder' => '0', |
| 202 | + 'style' => 'display:block;', |
| 203 | + 'src' => $formAction, |
| 204 | + ) |
| 205 | + ); |
| 206 | + $paymentFrame .= Xml::closeElement( 'iframe' ); |
178 | 207 | |
179 | | - $wgOut->addHTML( $paymentFrame ); |
180 | | - } |
| 208 | + $wgOut->addHTML( $paymentFrame ); |
| 209 | + |
| 210 | + return true; |
181 | 211 | } |
| 212 | + |
| 213 | + return false; |
182 | 214 | } |
183 | 215 | |
184 | 216 | } |