Index: branches/fundraising/extensions/DonationInterface/donationinterface.php |
— | — | @@ -61,6 +61,13 @@ |
62 | 62 | //THE GATEWAYS WILL RESET THIS when they are instantiated. You can override it, but it won't stick around that way. |
63 | 63 | $wgDonationInterfaceTest = false; |
64 | 64 | |
| 65 | + |
| 66 | +/** |
| 67 | + * Default Thank You and Fail pages for all of donationinterface - language will be calc'd and appended at runtime. |
| 68 | + */ |
| 69 | +$wgDonationInterfaceThankYouPage = 'Donate-thanks'; |
| 70 | +$wgDonationInterfaceFailPage = 'Donate-error'; |
| 71 | + |
65 | 72 | //This is going to be a little funky. |
66 | 73 | //Override this in LocalSettings.php BEFORE you include this file, if you want |
67 | 74 | //to disable gateways. |
— | — | @@ -98,7 +105,7 @@ |
99 | 106 | $wgResourceModules['iframe.liberator'] = array( |
100 | 107 | 'scripts' => 'iframe.liberator.js', |
101 | 108 | 'position' => 'top' |
102 | | -) + $wgResourceTemplate; |
| 109 | + ) + $wgResourceTemplate; |
103 | 110 | |
104 | 111 | function efDonationInterfaceUnitTests( &$files ) { |
105 | 112 | $files[] = dirname( __FILE__ ) . '/tests/GatewayAdapterTest.php'; |
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php |
— | — | @@ -41,8 +41,18 @@ |
42 | 42 | global $wgRequest, $wgOut, $wgExtensionAssetsPath, |
43 | 43 | $wgPayFlowProGatewayCSSVersion; |
44 | 44 | |
45 | | - $wgOut->allowClickjacking(); |
46 | | - $wgOut->addModules( 'iframe.liberator' ); |
| 45 | + $referrer = $wgRequest->getHeader( 'referer' ); |
| 46 | + |
| 47 | + global $wgServer; |
| 48 | + //TODO: Whitelist! We only want to do this for servers we are configured to like! |
| 49 | + //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, |
| 50 | + //and then pop out. Maybe. We're probably going to have to test it a couple different ways, for user experience. |
| 51 | + //However, we're _definitely_ going to need to pop out _before_ we redirect to the thank you or fail pages. |
| 52 | + if ( strpos( $referrer, $wgServer ) === false ) { |
| 53 | + $wgOut->allowClickjacking(); |
| 54 | + $wgOut->addModules( 'iframe.liberator' ); |
| 55 | + return; |
| 56 | + } |
47 | 57 | |
48 | 58 | $wgOut->addExtensionStyle( |
49 | 59 | $wgExtensionAssetsPath . '/DonationInterface/gateway_forms/css/gateway.css?284' . |
— | — | @@ -55,9 +65,42 @@ |
56 | 66 | if ( $this->adapter->checkTokens() ) { |
57 | 67 | // Display form for the first time |
58 | 68 | $oid = $wgRequest->getText( 'order_id' ); |
59 | | - if ( $oid && !empty( $oid ) ) { |
60 | | - $result = $this->adapter->do_transaction( 'GET_ORDERSTATUS' ); |
| 69 | + $adapter_oid = $this->adapter->getData(); |
| 70 | + $adapter_oid = $adapter_oid['order_id']; |
| 71 | + if ( $oid && !empty( $oid ) && $oid === $adapter_oid ) { |
| 72 | + if ( !array_key_exists( 'order_status', $_SESSION ) || !array_key_exists( $oid, $_SESSION['order_status'] ) ) { |
| 73 | + $_SESSION['order_status'][$oid] = $this->adapter->do_transaction( 'GET_ORDERSTATUS' ); |
| 74 | + $_SESSION['order_status'][$oid]['data']['count'] = 0; |
| 75 | + } else { |
| 76 | + $_SESSION['order_status'][$oid]['data']['count'] = $_SESSION['order_status'][$oid]['data']['count'] + 1; |
| 77 | + } |
| 78 | + $result = $_SESSION['order_status'][$oid]; |
61 | 79 | $this->displayResultsForDebug( $result ); |
| 80 | + //do the switching between the... stuff. |
| 81 | + |
| 82 | + switch ( $result['data']['WMF_STATUS'] ) { |
| 83 | + case 'complete': |
| 84 | + $wgOut->addHTML( "Add successful stomp message, go to the thank you page..." ); |
| 85 | + $go = $this->adapter->getThankYouPage(); |
| 86 | + break; |
| 87 | + case 'pending': |
| 88 | + $wgOut->addHTML( "Add pending stomp message, go to the thank you page..." ); |
| 89 | + $go = $this->adapter->getThankYouPage(); |
| 90 | + break; |
| 91 | + case 'pending-poke': |
| 92 | + $wgOut->addHTML( "Add pending stomp message, go to the thank you page, add some indicator that we need to do something." ); |
| 93 | + $go = $this->adapter->getThankYouPage(); |
| 94 | + break; |
| 95 | + case 'failed': |
| 96 | + $wgOut->addHTML( "Toss it, go to fail page..." ); |
| 97 | + $go = $this->adapter->getFailPage(); |
| 98 | + break; |
| 99 | + } |
| 100 | + |
| 101 | + //TODO: Save your user session data before you get here... |
| 102 | + $this->adapter->unsetAllGatewaySessionData(); |
| 103 | + $wgOut->addHTML( "<br>Redirecting to page $go" ); |
| 104 | + $wgOut->redirect( $go ); |
62 | 105 | } |
63 | 106 | $this->adapter->log( "Not posted, or not processed. Showing the form for the first time." ); |
64 | 107 | } else { |
— | — | @@ -97,14 +140,14 @@ |
98 | 141 | } else { |
99 | 142 | $wgOut->addHTML( "Empty Results" ); |
100 | 143 | } |
101 | | - if (array_key_exists('Donor', $_SESSION)){ |
102 | | - $wgOut->addHTML("Session Donor Vars:<ul>"); |
103 | | - foreach ($_SESSION['Donor'] as $key=>$val){ |
| 144 | + if ( array_key_exists( 'Donor', $_SESSION ) ) { |
| 145 | + $wgOut->addHTML( "Session Donor Vars:<ul>" ); |
| 146 | + foreach ( $_SESSION['Donor'] as $key => $val ) { |
104 | 147 | $wgOut->addHTML( "<li>$key: $val" ); |
105 | 148 | } |
106 | | - $wgOut->addHTML("</ul>"); |
| 149 | + $wgOut->addHTML( "</ul>" ); |
107 | 150 | } else { |
108 | | - $wgOut->addHTML("No Session Donor Vars:<ul>"); |
| 151 | + $wgOut->addHTML( "No Session Donor Vars:<ul>" ); |
109 | 152 | } |
110 | 153 | } |
111 | 154 | |
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -145,7 +145,8 @@ |
146 | 146 | ), |
147 | 147 | 'values' => array( |
148 | 148 | 'ACTION' => 'INSERT_ORDERWITHPAYMENT', |
149 | | - 'HOSTEDINDICATOR' => '1' |
| 149 | + 'HOSTEDINDICATOR' => '1', |
| 150 | + //'PAYMENTPRODUCTID' => '11', |
150 | 151 | ), |
151 | 152 | ); |
152 | 153 | |
— | — | @@ -258,7 +259,7 @@ |
259 | 260 | break; |
260 | 261 | case 'GET_ORDERSTATUS': |
261 | 262 | $data = $this->xmlChildrenToArray( $response, 'STATUS' ); |
262 | | - $data['WMF_TRANSLATEDCODE'] = $this->findCodeAction( 'GET_ORDERSTATUS', 'STATUSID', $data['STATUSID'] ); |
| 263 | + $data['WMF_STATUS'] = $this->findCodeAction( 'GET_ORDERSTATUS', 'STATUSID', $data['STATUSID'] ); |
263 | 264 | $data['ORDER'] = $this->xmlChildrenToArray( $response, 'ORDER' ); |
264 | 265 | break; |
265 | 266 | } |
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.php |
— | — | @@ -114,4 +114,10 @@ |
115 | 115 | * should be in USD. |
116 | 116 | */ |
117 | 117 | $wgGlobalCollectGatewayPriceFloor = '1.00'; |
118 | | -$wgGlobalCollectGatewayPriceCieling = '10000.00'; |
| 118 | +$wgGlobalCollectGatewayPriceCeiling = '10000.00'; |
| 119 | + |
| 120 | +/** |
| 121 | + * Thank You & Fail pages. |
| 122 | + */ |
| 123 | +$wgGlobalCollectGatewayThankYouPage = $wgDonationInterfaceThankYouPage; |
| 124 | +$wgGlobalCollectGatewayFailPage = $wgDonationInterfaceFailPage; |
\ No newline at end of file |
Index: branches/fundraising/extensions/DonationInterface/modules/iframe.liberator.js |
— | — | @@ -1,4 +1,3 @@ |
2 | | - |
3 | 2 | if (top.frames.length!=0){ |
4 | 3 | top.location=self.document.location; |
5 | 4 | } |
\ No newline at end of file |
Index: branches/fundraising/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -124,7 +124,6 @@ |
125 | 125 | * Override this in children if you want different defaults. |
126 | 126 | */ |
127 | 127 | function setPostDefaults() { |
128 | | -// $returnTitle = Title::newFromText( 'Donate-thanks/en' ); |
129 | 128 | $returnTitle = Title::newFromText( 'Special:GlobalCollectGatewayResult' ); |
130 | 129 | $returnto = $returnTitle->getFullURL(); |
131 | 130 | |
— | — | @@ -140,6 +139,24 @@ |
141 | 140 | ); |
142 | 141 | } |
143 | 142 | |
| 143 | + function getThankYouPage() { |
| 144 | + global $wgLang; |
| 145 | + $language = $wgLang->getCode(); |
| 146 | + $page = self::getGlobal( "ThankYouPage" ) . "/$language"; |
| 147 | + $returnTitle = Title::newFromText( $page ); |
| 148 | + $returnto = $returnTitle->getFullURL(); |
| 149 | + return $returnto; |
| 150 | + } |
| 151 | + |
| 152 | + function getFailPage() { |
| 153 | + global $wgLang; |
| 154 | + $language = $wgLang->getCode(); |
| 155 | + $page = self::getGlobal( "FailPage" ) . "/$language"; |
| 156 | + $returnTitle = Title::newFromText( $page ); |
| 157 | + $returnto = $returnTitle->getFullURL(); |
| 158 | + return $returnto; |
| 159 | + } |
| 160 | + |
144 | 161 | function checkTokens() { |
145 | 162 | return $this->dataObj->checkTokens(); |
146 | 163 | } |
— | — | @@ -619,9 +636,13 @@ |
620 | 637 | //if we walk straight off the end... |
621 | 638 | return null; |
622 | 639 | } |
623 | | - |
624 | | - function addDonorDataToSession(){ |
| 640 | + |
| 641 | + function addDonorDataToSession() { |
625 | 642 | $this->dataObj->addDonorDataToSession(); |
626 | 643 | } |
627 | 644 | |
| 645 | + function unsetAllGatewaySessionData() { |
| 646 | + $this->dataObj->unsetAllDDSessionData(); |
| 647 | + } |
| 648 | + |
628 | 649 | } |
Index: branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -235,15 +235,14 @@ |
236 | 236 | function setNormalizedOrderIDs() { |
237 | 237 | //basically, we need a new order_id every time we come through here, but if there's an internal already there, |
238 | 238 | //we want to use that one internally. So. |
239 | | - |
240 | 239 | //Exception: If we pass in an order ID in the querystring: Don't mess with it. |
241 | 240 | //TODO: I'm pretty sure I'm not supposed to do this directly. |
242 | | - if (array_key_exists('order_id', $_GET)){ |
| 241 | + if ( array_key_exists( 'order_id', $_GET ) ) { |
243 | 242 | $this->setVal( 'order_id', $_GET['order_id'] ); |
244 | 243 | $this->setVal( 'i_order_id', $_GET['order_id'] ); |
245 | 244 | return; |
246 | 245 | } |
247 | | - |
| 246 | + |
248 | 247 | $this->setVal( 'order_id', $this->generateOrderId() ); |
249 | 248 | |
250 | 249 | if ( !$this->isSomething( 'i_order_id' ) ) { |
— | — | @@ -651,8 +650,8 @@ |
652 | 651 | $db->update( 'contribution_tracking', $tracked_contribution, array( 'id' => $this->getVal( 'contribution_tracking_id' ) ) ); |
653 | 652 | } |
654 | 653 | } |
655 | | - |
656 | | - public function addDonorDataToSession(){ |
| 654 | + |
| 655 | + public function addDonorDataToSession() { |
657 | 656 | self::ensureSession(); |
658 | 657 | $donordata = array( |
659 | 658 | 'email', |
— | — | @@ -664,16 +663,26 @@ |
665 | 664 | 'state', |
666 | 665 | 'zip', |
667 | 666 | 'country', |
| 667 | + 'contribution_tracking_id' |
668 | 668 | ); |
669 | | - |
670 | | - foreach ($donordata as $item){ |
671 | | - if ($this->isSomething($item)){ |
672 | | - $_SESSION['Donor'][$item] = $this->getVal($item); |
| 669 | + |
| 670 | + foreach ( $donordata as $item ) { |
| 671 | + if ( $this->isSomething( $item ) ) { |
| 672 | + $_SESSION['Donor'][$item] = $this->getVal( $item ); |
673 | 673 | } |
674 | 674 | } |
675 | | - |
676 | 675 | } |
677 | 676 | |
| 677 | + /** |
| 678 | + * TODO: Consider putting all the session data for a gateway under something like |
| 679 | + * $_SESSION[$gateway_identifier] |
| 680 | + * so we can kill it all with one stroke. |
| 681 | + */ |
| 682 | + public function unsetAllDDSessionData() { |
| 683 | + unset( $_SESSION['Donor'] ); |
| 684 | + $this->unsetEditToken(); |
| 685 | + } |
| 686 | + |
678 | 687 | } |
679 | 688 | |
680 | 689 | ?> |