http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97579
Revision: 97579
Author: khorn
Date: 2011-09-19 23:48:57 +0000 (Mon, 19 Sep 2011)
Log Message:
-----------
Wraps up the basic requirements for fundraiser cards #280 and #300.
Modified Paths:
--------------
branches/fundraising/extensions/DonationInterface/donationinterface.php
branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php
branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.php
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php
branches/fundraising/extensions/DonationInterface/modules/iframe.liberator.js
Modified:
branches/fundraising/extensions/DonationInterface/donationinterface.php
===================================================================
--- branches/fundraising/extensions/DonationInterface/donationinterface.php
2011-09-19 23:41:54 UTC (rev 97578)
+++ branches/fundraising/extensions/DonationInterface/donationinterface.php
2011-09-19 23:48:57 UTC (rev 97579)
@@ -61,6 +61,13 @@
//THE GATEWAYS WILL RESET THIS when they are instantiated. You can override
it, but it won't stick around that way.
$wgDonationInterfaceTest = false;
+
+/**
+ * Default Thank You and Fail pages for all of donationinterface - language
will be calc'd and appended at runtime.
+ */
+$wgDonationInterfaceThankYouPage = 'Donate-thanks';
+$wgDonationInterfaceFailPage = 'Donate-error';
+
//This is going to be a little funky.
//Override this in LocalSettings.php BEFORE you include this file, if you want
//to disable gateways.
@@ -98,7 +105,7 @@
$wgResourceModules['iframe.liberator'] = array(
'scripts' => 'iframe.liberator.js',
'position' => 'top'
-) + $wgResourceTemplate;
+ ) + $wgResourceTemplate;
function efDonationInterfaceUnitTests( &$files ) {
$files[] = dirname( __FILE__ ) . '/tests/GatewayAdapterTest.php';
Modified:
branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php
===================================================================
---
branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php
2011-09-19 23:41:54 UTC (rev 97578)
+++
branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php
2011-09-19 23:48:57 UTC (rev 97579)
@@ -235,15 +235,14 @@
function setNormalizedOrderIDs() {
//basically, we need a new order_id every time we come through
here, but if there's an internal already there,
//we want to use that one internally. So.
-
//Exception: If we pass in an order ID in the querystring:
Don't mess with it.
//TODO: I'm pretty sure I'm not supposed to do this directly.
- if (array_key_exists('order_id', $_GET)){
+ if ( array_key_exists( 'order_id', $_GET ) ) {
$this->setVal( 'order_id', $_GET['order_id'] );
$this->setVal( 'i_order_id', $_GET['order_id'] );
return;
}
-
+
$this->setVal( 'order_id', $this->generateOrderId() );
if ( !$this->isSomething( 'i_order_id' ) ) {
@@ -651,8 +650,8 @@
$db->update( 'contribution_tracking',
$tracked_contribution, array( 'id' => $this->getVal( 'contribution_tracking_id'
) ) );
}
}
-
- public function addDonorDataToSession(){
+
+ public function addDonorDataToSession() {
self::ensureSession();
$donordata = array(
'email',
@@ -664,16 +663,26 @@
'state',
'zip',
'country',
+ 'contribution_tracking_id'
);
-
- foreach ($donordata as $item){
- if ($this->isSomething($item)){
- $_SESSION['Donor'][$item] =
$this->getVal($item);
+
+ foreach ( $donordata as $item ) {
+ if ( $this->isSomething( $item ) ) {
+ $_SESSION['Donor'][$item] = $this->getVal(
$item );
}
}
-
}
+ /**
+ * TODO: Consider putting all the session data for a gateway under
something like
+ * $_SESSION[$gateway_identifier]
+ * so we can kill it all with one stroke.
+ */
+ public function unsetAllDDSessionData() {
+ unset( $_SESSION['Donor'] );
+ $this->unsetEditToken();
+ }
+
}
?>
Modified:
branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php
===================================================================
---
branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php
2011-09-19 23:41:54 UTC (rev 97578)
+++
branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php
2011-09-19 23:48:57 UTC (rev 97579)
@@ -124,7 +124,6 @@
* Override this in children if you want different defaults.
*/
function setPostDefaults() {
-// $returnTitle = Title::newFromText( 'Donate-thanks/en' );
$returnTitle = Title::newFromText(
'Special:GlobalCollectGatewayResult' );
$returnto = $returnTitle->getFullURL();
@@ -140,6 +139,24 @@
);
}
+ function getThankYouPage() {
+ global $wgLang;
+ $language = $wgLang->getCode();
+ $page = self::getGlobal( "ThankYouPage" ) . "/$language";
+ $returnTitle = Title::newFromText( $page );
+ $returnto = $returnTitle->getFullURL();
+ return $returnto;
+ }
+
+ function getFailPage() {
+ global $wgLang;
+ $language = $wgLang->getCode();
+ $page = self::getGlobal( "FailPage" ) . "/$language";
+ $returnTitle = Title::newFromText( $page );
+ $returnto = $returnTitle->getFullURL();
+ return $returnto;
+ }
+
function checkTokens() {
return $this->dataObj->checkTokens();
}
@@ -619,9 +636,13 @@
//if we walk straight off the end...
return null;
}
-
- function addDonorDataToSession(){
+
+ function addDonorDataToSession() {
$this->dataObj->addDonorDataToSession();
}
+ function unsetAllGatewaySessionData() {
+ $this->dataObj->unsetAllDDSessionData();
+ }
+
}
Modified:
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
===================================================================
---
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
2011-09-19 23:41:54 UTC (rev 97578)
+++
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
2011-09-19 23:48:57 UTC (rev 97579)
@@ -145,7 +145,8 @@
),
'values' => array(
'ACTION' => 'INSERT_ORDERWITHPAYMENT',
- 'HOSTEDINDICATOR' => '1'
+ 'HOSTEDINDICATOR' => '1',
+ //'PAYMENTPRODUCTID' => '11',
),
);
@@ -258,7 +259,7 @@
break;
case 'GET_ORDERSTATUS':
$data = $this->xmlChildrenToArray( $response,
'STATUS' );
- $data['WMF_TRANSLATEDCODE'] =
$this->findCodeAction( 'GET_ORDERSTATUS', 'STATUSID', $data['STATUSID'] );
+ $data['WMF_STATUS'] = $this->findCodeAction(
'GET_ORDERSTATUS', 'STATUSID', $data['STATUSID'] );
$data['ORDER'] = $this->xmlChildrenToArray(
$response, 'ORDER' );
break;
}
Modified:
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.php
===================================================================
---
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.php
2011-09-19 23:41:54 UTC (rev 97578)
+++
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.php
2011-09-19 23:48:57 UTC (rev 97579)
@@ -114,4 +114,10 @@
* should be in USD.
*/
$wgGlobalCollectGatewayPriceFloor = '1.00';
-$wgGlobalCollectGatewayPriceCieling = '10000.00';
+$wgGlobalCollectGatewayPriceCeiling = '10000.00';
+
+/**
+ * Thank You & Fail pages.
+ */
+$wgGlobalCollectGatewayThankYouPage = $wgDonationInterfaceThankYouPage;
+$wgGlobalCollectGatewayFailPage = $wgDonationInterfaceFailPage;
\ No newline at end of file
Modified:
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php
===================================================================
---
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php
2011-09-19 23:41:54 UTC (rev 97578)
+++
branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php
2011-09-19 23:48:57 UTC (rev 97579)
@@ -41,8 +41,18 @@
global $wgRequest, $wgOut, $wgExtensionAssetsPath,
$wgPayFlowProGatewayCSSVersion;
- $wgOut->allowClickjacking();
- $wgOut->addModules( 'iframe.liberator' );
+ $referrer = $wgRequest->getHeader( 'referer' );
+
+ global $wgServer;
+ //TODO: Whitelist! We only want to do this for servers we are
configured to like!
+ //I didn't do this already, because this may turn out to be
backwards anyway. It might be good to do the work in the iframe,
+ //and then pop out. Maybe. We're probably going to have to test
it a couple different ways, for user experience.
+ //However, we're _definitely_ going to need to pop out _before_
we redirect to the thank you or fail pages.
+ if ( strpos( $referrer, $wgServer ) === false ) {
+ $wgOut->allowClickjacking();
+ $wgOut->addModules( 'iframe.liberator' );
+ return;
+ }
$wgOut->addExtensionStyle(
$wgExtensionAssetsPath .
'/DonationInterface/gateway_forms/css/gateway.css?284' .
@@ -55,9 +65,42 @@
if ( $this->adapter->checkTokens() ) {
// Display form for the first time
$oid = $wgRequest->getText( 'order_id' );
- if ( $oid && !empty( $oid ) ) {
- $result = $this->adapter->do_transaction(
'GET_ORDERSTATUS' );
+ $adapter_oid = $this->adapter->getData();
+ $adapter_oid = $adapter_oid['order_id'];
+ if ( $oid && !empty( $oid ) && $oid === $adapter_oid ) {
+ if ( !array_key_exists( 'order_status',
$_SESSION ) || !array_key_exists( $oid, $_SESSION['order_status'] ) ) {
+ $_SESSION['order_status'][$oid] =
$this->adapter->do_transaction( 'GET_ORDERSTATUS' );
+
$_SESSION['order_status'][$oid]['data']['count'] = 0;
+ } else {
+
$_SESSION['order_status'][$oid]['data']['count'] =
$_SESSION['order_status'][$oid]['data']['count'] + 1;
+ }
+ $result = $_SESSION['order_status'][$oid];
$this->displayResultsForDebug( $result );
+ //do the switching between the... stuff.
+
+ switch ( $result['data']['WMF_STATUS'] ) {
+ case 'complete':
+ $wgOut->addHTML( "Add
successful stomp message, go to the thank you page..." );
+ $go =
$this->adapter->getThankYouPage();
+ break;
+ case 'pending':
+ $wgOut->addHTML( "Add pending
stomp message, go to the thank you page..." );
+ $go =
$this->adapter->getThankYouPage();
+ break;
+ case 'pending-poke':
+ $wgOut->addHTML( "Add pending
stomp message, go to the thank you page, add some indicator that we need to do
something." );
+ $go =
$this->adapter->getThankYouPage();
+ break;
+ case 'failed':
+ $wgOut->addHTML( "Toss it, go
to fail page..." );
+ $go =
$this->adapter->getFailPage();
+ break;
+ }
+
+ //TODO: Save your user session data before you
get here...
+ $this->adapter->unsetAllGatewaySessionData();
+ $wgOut->addHTML( "<br>Redirecting to page $go"
);
+ $wgOut->redirect( $go );
}
$this->adapter->log( "Not posted, or not processed.
Showing the form for the first time." );
} else {
@@ -97,14 +140,14 @@
} else {
$wgOut->addHTML( "Empty Results" );
}
- if (array_key_exists('Donor', $_SESSION)){
- $wgOut->addHTML("Session Donor Vars:<ul>");
- foreach ($_SESSION['Donor'] as $key=>$val){
+ if ( array_key_exists( 'Donor', $_SESSION ) ) {
+ $wgOut->addHTML( "Session Donor Vars:<ul>" );
+ foreach ( $_SESSION['Donor'] as $key => $val ) {
$wgOut->addHTML( "<li>$key: $val" );
}
- $wgOut->addHTML("</ul>");
+ $wgOut->addHTML( "</ul>" );
} else {
- $wgOut->addHTML("No Session Donor Vars:<ul>");
+ $wgOut->addHTML( "No Session Donor Vars:<ul>" );
}
}
Modified:
branches/fundraising/extensions/DonationInterface/modules/iframe.liberator.js
===================================================================
---
branches/fundraising/extensions/DonationInterface/modules/iframe.liberator.js
2011-09-19 23:41:54 UTC (rev 97578)
+++
branches/fundraising/extensions/DonationInterface/modules/iframe.liberator.js
2011-09-19 23:48:57 UTC (rev 97579)
@@ -1,4 +1,3 @@
-
if (top.frames.length!=0){
top.location=self.document.location;
}
\ No newline at end of file
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs