Awight has uploaded a new change for review.
https://gerrit.wikimedia.org/r/189136
Change subject: Use common code for Adyen form handling
......................................................................
Use common code for Adyen form handling
Bug: T86251
Change-Id: I111e34ab3323888980470760fb44ef108ff25315
---
M adyen_gateway/adyen_gateway.body.php
M adyen_gateway/adyen_resultswitcher.body.php
2 files changed, 10 insertions(+), 100 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/36/189136/1
diff --git a/adyen_gateway/adyen_gateway.body.php
b/adyen_gateway/adyen_gateway.body.php
index 05a37ae..ba2fb47 100644
--- a/adyen_gateway/adyen_gateway.body.php
+++ b/adyen_gateway/adyen_gateway.body.php
@@ -30,38 +30,12 @@
parent::__construct(); //the next layer up will know who we are.
}
- /**
- * Show the special page
- *
- * @todo
- * - Finish error handling
- */
- protected function handleRequest() {
+ /**
+ * TODO: Finish Adyen error handling
+ */
+ protected function handleRequest() {
$this->getOutput()->addModules( 'adyen.js' );
- $this->setHeaders();
-
- // dispatch forms/handling
- if ( $this->adapter->checkTokens() ) {
-
- if ( $this->adapter->posted ) {
-
- // Check form for errors
- $form_errors = $this->validateForm();
-
- // If there were errors, redisplay form,
otherwise proceed to next step
- if ( $form_errors ) {
- $this->displayForm();
- }
- }
- else {
- $this->displayForm();
- }
- } else { //token mismatch
- $error['general']['token-mismatch'] = wfMsg(
'donate_interface-token-mismatch' );
- $this->adapter->addManualError( $error );
- $this->displayForm();
- }
- }
-
+ $this->handleDonationRequest();
+ }
}
diff --git a/adyen_gateway/adyen_resultswitcher.body.php
b/adyen_gateway/adyen_resultswitcher.body.php
index 72bbe5a..4a29198 100644
--- a/adyen_gateway/adyen_resultswitcher.body.php
+++ b/adyen_gateway/adyen_resultswitcher.body.php
@@ -11,6 +11,7 @@
*
* Hooks are exposed to handle the different actions.
*
+ * FIXME: sketchy to have a default value.
* Defaults to 'process'.
* @var string
*/
@@ -27,72 +28,7 @@
parent::__construct();
}
- /**
- * Show the special page
- */
- protected function handleRequest() {
-
- //no longer letting people in without these things. If this is
- //preventing you from doing something, you almost certainly
want to be
- //somewhere else.
- $forbidden = false;
- if ( !$this->adapter->session_hasDonorData() ) {
- $forbidden = true;
- $f_message = 'No active donation in the session';
- }
-
- if ( $forbidden ){
- wfHttpError( 403, 'Forbidden', wfMsg(
'donate_interface-error-http-403' ) );
- }
- $oid = $this->adapter->getData_Unstaged_Escaped( 'order_id' );
-
- $referrer = $this->getRequest()->getHeader( 'referer' );
- $liberated = false;
- if ( $this->adapter->session_getData( 'order_status', $oid )
=== 'liberated' ) {
- $liberated = true;
- }
-
- global $wgServer;
- if ( ( strpos( $referrer, $wgServer ) === false ) &&
!$liberated ) {
- $_SESSION[ 'order_status' ][ $oid ] = 'liberated';
- $this->adapter->log("Resultswitcher: Popping out of
iframe for Order ID " . $oid);
- //TODO: Move the $forbidden check back to the beginning
of this if block, once we know this doesn't happen a lot.
- //TODO: If we get a lot of these messages, we need to
redirect to something more friendly than FORBIDDEN, RAR RAR RAR.
- if ( $forbidden ) {
- $this->adapter->log("Resultswitcher: $oid
SHOULD BE FORBIDDEN. Reason: $f_message", LOG_ERR);
- }
- $this->getOutput()->allowClickjacking();
- $this->getOutput()->addModules( 'iframe.liberator' );
- return;
- }
-
- $this->setHeaders();
-
- if ( $forbidden ){
- $this->adapter->log( "Resultswitcher: Request
forbidden. " . $f_message . " Adapter Order ID: $oid", LOG_CRIT );
- return;
- } else {
- $this->adapter->log( "Resultswitcher: OK to process
Order ID: " . $oid );
- }
-
- if ( $this->adapter->checkTokens() ) {
-
- if ( $this->adapter->isResponse() ) {
- $this->getOutput()->allowClickjacking();
- $this->getOutput()->addModules(
'iframe.liberator' );
- if ( NULL === $this->adapter->processResponse()
) {
- switch (
$this->adapter->getFinalStatus() ) {
- case 'complete':
- case 'pending':
- $this->getOutput()->redirect(
$this->adapter->getThankYouPage() );
- return;
- }
- }
- $this->getOutput()->redirect(
$this->adapter->getFailPage() );
- }
- } else {
- $this->adapter->log( "Resultswitcher: Token Check
Failed. Order ID: $oid", LOG_ERR );
- }
- }
-
+ protected function handleRequest() {
+ $this->handleResultRequest();
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/189136
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I111e34ab3323888980470760fb44ef108ff25315
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits