Awight has uploaded a new change for review. https://gerrit.wikimedia.org/r/292272
Change subject: Wrap gateway URL in an accessor function ...................................................................... Wrap gateway URL in an accessor function This makes it simple to override. Bug: T136743 Change-Id: Ib2865d971baac57b3b6b5e53bd8f060e52171477 --- M adyen_gateway/adyen.adapter.php M gateway_common/gateway.adapter.php M worldpay_gateway/worldpay.adapter.php 3 files changed, 19 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/72/292272/1 diff --git a/adyen_gateway/adyen.adapter.php b/adyen_gateway/adyen.adapter.php index fe8d623..3aed537 100644 --- a/adyen_gateway/adyen.adapter.php +++ b/adyen_gateway/adyen.adapter.php @@ -193,7 +193,7 @@ switch ( $transaction ) { case 'donate': - $formaction = $this->url . '/hpp/pay.shtml'; + $formaction = $this->getCommunicationUrl() . '/hpp/pay.shtml'; // Run API call hooks here because we don't cURL anything $this->runApiCallHooks(); $this->runAntifraudHooks(); diff --git a/gateway_common/gateway.adapter.php b/gateway_common/gateway.adapter.php index 67860d6..8ca6001 100644 --- a/gateway_common/gateway.adapter.php +++ b/gateway_common/gateway.adapter.php @@ -83,7 +83,6 @@ protected $account_name; protected $account_config; protected $accountInfo; - protected $url; protected $transactions; /** @@ -242,12 +241,6 @@ $this->profiler = DonationLoggerFactory::getProfiler( $this ); - if ( !self::getGlobal( 'Test' ) ) { - $this->url = self::getGlobal( 'URL' ); - } else { - $this->url = self::getGlobal( 'TestingURL' ); - } - // so we know we can skip all the visual stuff. if ( $options['api_request'] ) { $this->setApiRequest(); @@ -318,6 +311,22 @@ return $this->config[$key]; } return null; + } + + /** + * Return the base URL to use for the current transaction. + * + * Some adapters will append a path component and query parameters. + * That variation should be handled by the request controller. Customize + * things like varying server endpoints by overriding this function. + */ + protected function getCommunicationUrl() { + if ( !self::getGlobal( 'Test' ) ) { + $url = self::getGlobal( 'URL' ); + } else { + $url = self::getGlobal( 'TestingURL' ); + } + return $url; } // For legacy support. @@ -1026,7 +1035,7 @@ $this->session_pushFormName( $this->getData_Unstaged_Escaped( 'ffname' ) ); $this->transaction_response->setCommunicationStatus( true ); - $this->transaction_response->setRedirect( $this->url ); + $this->transaction_response->setRedirect( $this->getCommunicationUrl() ); return $this->transaction_response; } elseif ( $commType === 'xml' ) { @@ -1159,7 +1168,7 @@ $path = ''; } $opts = array( - CURLOPT_URL => $this->url . $path, + CURLOPT_URL => $this->getCommunicationUrl() . $path, CURLOPT_USERAGENT => WmfFramework::getUserAgent(), CURLOPT_HEADER => 1, CURLOPT_RETURNTRANSFER => 1, diff --git a/worldpay_gateway/worldpay.adapter.php b/worldpay_gateway/worldpay.adapter.php index b80209d..86bf074 100644 --- a/worldpay_gateway/worldpay.adapter.php +++ b/worldpay_gateway/worldpay.adapter.php @@ -521,8 +521,6 @@ * @return PaymentTransactionResponse */ public function do_transaction( $transaction ) { - $this->url = $this->getGlobal( 'URL' ); - if ( $this->isESOP() ) { // This needs to go in every ESOP request because otherwise // they return "Transaction NOT Authorized" -- To view, visit https://gerrit.wikimedia.org/r/292272 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib2865d971baac57b3b6b5e53bd8f060e52171477 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Awight <awi...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits