<?php

include "includes/config.php";

echo '<pre>';
print_r($_REQUEST);
echo '</pre>';



// return Code Below

include 'includes/dwolla.php';

// example successful request:  https://www.myurl.com/redirect?signature=c50e4b2a4c50ad795c3ee31370aec1a563565aa4&orderId=&amount=0.01&checkoutId=f32b1e55-9612-4b6d-90f9-1c1519e588da&status=Completed&clearingDate=8/28/2012%203:17:18%20PM&transaction=1312616&postback=success
// example failure: https://www.myurl.com/redirect?error=failure&error_description=User+Cancelled

$error_description = '';
// first, check for any errors
if (array_key_exists("error", $_GET)) {
	// find out what happened:
	$error_description = $_GET['error_description']; // "User Cancelled"
	//exit($error_description);
}


if($error_description!=''){
//Below

?>	
		<div align="left" class="content_area">
		<!--content area start -->
		<div align="left">
			<table width="100%"  border="0" cellpadding="0" cellspacing="0" class="form_tbl">
				<tr>
					<th>
						Payment Status
					</th>
				</tr>	
				<tr>
				  <td>
				  <table width="625"  border="0" cellspacing="0" cellpadding="0" class="form_tbl">
					<tr class="even">
						<td>
							Payment Failure. Try again later
						</td>
					</tr>
					<tr class="odd">
						<td>&nbsp;</td>
					</tr>
					<tr class="even">
						<td class="text_information">Your order cannot be processed. <?php echo $error_description; ?></td>
					</tr>		
					<tr class="odd">
						<td align="center">
							<input type='button' value='Home'  class='button' onClick="window.location.href='index.php'">&nbsp;&nbsp;<input type='button' value='Continue Payment'  class='button' onClick="window.location.href='registration_payment.php'">
						</td>	
					</tr>
				</table>
			  </td>
			</tr>
		  </table>			
		</div>   
<!--content area end-->
</div>
<div align="left" class="clear_float"><img src="<?php echo $imagefolder;?>/clear.gif" alt="" width="1" height="1" /></div>
<!--main body end -->
</div>
<SCRIPT>		  
document.frmPayment.submit();
</SCRIPT>	
<?php
	include "includes/footer.php";

//Above
        exit;
}


// second, extract the checkoutId, amount, and signature of the checkout:

$checkoutId = $_GET['checkoutId'];
$amount = $_GET['amount'];
$signature = $_GET['signature'];

// third, validate the signature before you do anything with the data.

$signatureValid = verifyGatewaySignature($signature, $checkoutId, $amount);

if (!$signatureValid) {
	exit("Bad signature!");
}

$status = $_GET['status'];

if ($status == "Completed") {
	// do something useful with the checkout results:
	echo $status;
}


// return Code Above






echo '<pre>';
print_r($_REQUEST);
echo '</pre>';

echo '<pre>';
print_r($_SESSION);
echo '</pre>';



    
exit;