<style>
.alert {
    padding: 20px;
    background-color:#090;
    color: white;
}

.closebtn {
    margin-left: 15px;
    color: white;
    font-weight: bold;
    float: right;
    font-size: 22px;
    line-height: 20px;
    cursor: pointer;
    transition: 0.3s;
}

.closebtn:hover {
    color: black;
}
</style>

<?php
ob_start(); 
error_reporting(0);
if(!isset($_GET["sc"]) || !$_GET["sc"]){ 
echo "<script type=text/javascript>
              alert('Transaction Not Found!');
              window.close()
              </script>";		
	  
	exit;
}else{
$sc = $_GET["sc"]; 
$ccc="sc";

	require_once( "paybox/lib/cryptobox.class.php" );
	
if(!$privatekeys || !$publickeys){ 
echo "<script type=text/javascript>
              alert('payment system is undermaintenance! Please try again later!');
              window.close()
              </script>";		
	  
	exit;
}else{	
	
	


$sql2 = "SELECT * FROM dataewalet2 WHERE kode='$sc'";
$result2 = $conn->query($sql2);
if ($result2->num_rows > 0) {
    while($row2 = $result2->fetch_assoc()) {
$username = $row2['username'];
$jumlah = $row2['jumlah'];
$uraian = $row2['uraian'];
$jenis = $row2['jenis'];
$kode = $row2['kode'];
$tgl = $row2['tgl'];
$status = $row2['status'];	 
$tglproses = $row2['tglproses'];




$jumlahdepone = rupiah($jumlah);
$prodd="Add Deposit";
}
}

$sql3 = "SELECT nama, email, hp, accid FROM member WHERE username='$username'";
$result3 = $conn->query($sql3);
if ($result3->num_rows > 0) {
    while($row3 = $result3->fetch_assoc()) {
   $nama = $row3['nama'];
   $email = $row3['email'];
   $hp = $row3['hp'];
   $alamat = $row3['alamat'];
   $accid = $row3['accid'];
}
  }
     
   
setcookie("Amounts",$jumlah, time()+3600);
setcookie("Email",$email, time()+3600);
setcookie("Nama",$nama, time()+3600);


  
   if(!$result2){
	  
	  echo "<script type=text/javascript>
              alert('Transaction Not Found!');
              window.close()
              </script>";		
	  
	exit;
} else {	
  
?>

<?php
/**
 * @category    Example11 - Pay-Per-Membership (single crypto currency in payment box)
 * @package     GoUrl Cryptocurrency Payment API 
 * copyright 	(c) 2014-2018 Delta Consultants
 * @crypto      Supported Cryptocoins -	Bitcoin, BitcoinCash, Litecoin, Dash, Dogecoin, Speedcoin, Reddcoin, Potcoin, Feathercoin, Vertcoin, Peercoin, MonetaryUnit, UniversalCurrency
 * @website     https://gourl.io/bitcoin-payment-gateway-api.html#p6
 * @live_demo   https://gourl.io/lib/examples/pay-per-membership.php
 */ 

	/********************** NOTE - 2018 YEAR *******************************************************************************/ 
	/*****                                                                                                             *****/ 
	/*****     This is iFrame Bitcoin Payment Box Example (2014 - 2017)                                                *****/ 
	/*****                                                                                                             *****/ 
	/*****     Available - new 2018 version; mobile friendly JSON payment box (own logo, white label product)          *****/
	/*****     New Demo with generation php payment box code - https://gourl.io/lib/examples/example_customize_box.php *****/
	/*****         White Theme - https://gourl.io/lib/examples/example_customize_box.php?theme=black                   *****/
	/*****         Black Theme - https://gourl.io/lib/examples/example_customize_box.php?theme=default     		   *****/
	/*****         Your Own Logo - https://gourl.io/lib/examples/example_customize_box.php?theme=default&logo=custom   *****/
	/*****                                                                                                             *****/ 
	/***********************************************************************************************************************/


	
	

	
	/**** CONFIGURATION VARIABLES ****/ 
	
	$userID 		= $username."_".$kode;							// place your registered userID or md5(userID) here (user1, user7, ko43DC, etc).
													// your user should have already registered on your website before   
	$userFormat		= "COOKIE";						// this variable ignored when you use $userID 
	$orderID 		= "ADD_DEPOSIT";			// premium membership order
	$amountUSD		= $jumlah;							// price per membership - 79 USD
	$period			= "NOEXPIRY";					// one month membership; after need to pay again
	$def_language	= "en";				// default Payment Box Language
	$public_key		= $publickeys; // from gourl.io
	$private_key	= $privatekeys;// from gourl.io

	// IMPORTANT: Please read description of options here - https://gourl.io/api-php.html#options  
	
	/********************************/


	
	
	
	/** PAYMENT BOX **/
	$options = array(
			"public_key"  => $public_key, 	// your public key from gourl.io
			"private_key" => $private_key, 	// your private key from gourl.io
			"webdev_key"  => "", 		// optional, gourl affiliate key
			"orderID"     => $orderID, 		// order id
			"userID"      => $userID, 		// unique identifier for every user
			"userFormat"  => $userFormat, 	// save userID in COOKIE, IPADDRESS or SESSION
			"amount"   	  => 0,				// price in coins OR in USD below
			"amountUSD"   => $amountUSD,	// we use price in USD
			"period"      => $period, 		// payment valid period
			"language"	  => $def_language  // text on EN - english, FR - french, etc
	);

	// Initialise Payment Class
	$box = new Cryptobox ($options);
	
	// coin name
	$coinName = $box->coin_name(); 
	
	
	// Successful Cryptocoin Payment received
	// Please use also IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") for update db records, etc
	if ($box->is_paid())
	{
		// one time action
		

		$clientdate = (date ("Y-m-d H:i:s"));
		$updatedataewalet2 = "UPDATE dataewalet2 SET status='1', tglproses='$clientdate', accid2='$sd' WHERE kode='$kode'";
        $conn->query($updatedataewalet2);
		
		$sqlxc = "SELECT * FROM dataewalet WHERE kode='$kode' and tujuan='$username'";
        $resultxc = $conn->query($sqlxc);
        if ($resultxc->num_rows == 0) {
		$insertdatawalet = "INSERT INTO dataewalet (kode, username, jumlah, uraian, tujuan, tgl, status, tglproses, accid, accid2)
         VALUES ('$kode', 'administrator', '$jumlah', '$orderID', '$username', '$clientdate', '1', '$clientdate', 'administrator', '$accid')";
         $conn->query($insertdatawalet);
		
		 
require '../dt_page/mail/PHPMailerAutoload.php';
		 
		 $isimail="<a href='http://".$domain."'><img src='http://".$domain."/images/banner/".$invlogos."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Helo ".$nama." (".$username."),</p>
<p>Your Add balance deposit has been processed.</p>
<p><strong>No: ".$kode."<br>
Amount: ".$jumlahdepone."<br>
Fee: -<br>
Add: ".$jumlahdepone."<br>
Date: ".$tgl."<br>
</p>
<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";
	   
	    $mail3 = new PHPMailer;
        $mail3->setFrom($emailadmin, $bisnisname);
        $mail3->addAddress($email, $nama);
	    $mail3->IsHTML(true);       
        $mail3->Subject = ''.$nama.', Your Add balance deposit has been processed';
        $mail3->msgHTML($isimail);
	   // $mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
        $mail3->send();	
		}
		
		
		
		if (!$box->is_processed())
		{
			// One time action after payment has been made
		
		$clientdate = (date ("Y-m-d H:i:s"));
		$updatedataewalet2 = "UPDATE dataewalet2 SET status='1', tglproses='$clientdate', accid2='$sd' WHERE kode='$kode'";
        $conn->query($updatedataewalet2);
		
		$sqlxc = "SELECT * FROM dataewalet WHERE kode='$kode' and tujuan='$username'";
        $resultxc = $conn->query($sqlxc);
        if ($resultxc->num_rows == 0) {
		$insertdatawalet = "INSERT INTO dataewalet (kode, username, jumlah, uraian, tujuan, tgl, status, tglproses, accid, accid2)
         VALUES ('$kode', 'administrator', '$jumlah', '$orderID', '$username', '$clientdate', '1', '$clientdate', 'administrator', '$accid')";
         $conn->query($insertdatawalet);
		
		 
require '../dt_page/mail/PHPMailerAutoload.php';
		 
		 $isimail="<a href='http://".$domain."'><img src='http://".$domain."/images/banner/".$invlogos."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Helo ".$nama." (".$username."),</p>
<p>Your Add balance deposit has been processed.</p>
<p><strong>No: ".$kode."<br>
Amount: ".$jumlahdepone."<br>
Fee: -<br>
Add: ".$jumlahdepone."<br>
Date: ".$tgl."<br>
</p>
<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";
	   
	    $mail3 = new PHPMailer;
        $mail3->setFrom($emailadmin, $bisnisname);
        $mail3->addAddress($email, $nama);
	    $mail3->IsHTML(true);       
        $mail3->Subject = ''.$nama.', Your Add balance deposit has been processed';
        $mail3->msgHTML($isimail);
	   // $mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
        $mail3->send();	
		}
					

		 
			
			$message = "<div class='alert'>Thank you (".$orderID.", ".$kode."). We have added the value of your deposit</div>";
	
			// Set Payment Status to Processed
			$box->set_status_processed();
		}
		else $message = "<div class='alert'>You have successfully added a deposit</div>";
	}
	
	
	// Optional - Language selection list for payment box (html code)
	$languages_list = display_language_box($def_language);





	// ...
	// Also you need to use IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") 
	// for send confirmation email, update database, update user membership, etc.
	// You need to modify file - cryptobox.newpayment.php, read more - https://gourl.io/api-php.html#ipn
	// ...
		
	
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Payment</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='Expires' content='-1'>
<meta name='robots' content='all'>
 <link href="../css/invoice.css" rel="stylesheet">
<script src='paybox/js/cryptobox.min.js' type='text/javascript'></script>
</head>

<body style='font-family:Arial,Helvetica,sans-serif;font-size:14px;color:#666;margin:0'>
      <style>
.table					{ margin:0 0 15px 0; padding:0px; width:100%; font-size:12px; border-collapse:collapse; box-shadow:0px 5px 0px #f4f4f4; }
.table th				{ padding:7px 5px; font-family:"Oswald", Tahoma; color:#3074bb; text-shadow:1px 1px rgba(255,255,255,0.2); text-align:center;
						  text-transform: uppercase; font-weight:500; border:1px solid #ded9e4; box-shadow:inset 0px 1px 0px #fff,inset 0px 0px 0px 1px #f3f7fb;
						  background:#eceaee; background:-moz-linear-gradient(top, #f8fafd 0%, #eff0f1 100%); background:-webkit-linear-gradient(top, #f8fafd 0%, #eff0f1 100%); }
.table td				{ padding:7px; border:1px solid #ded9e4; font-weight:; text-align:center; }
.table tr					{ background:#f8f8f9; }
.table tr:nth-of-type(even)	{ background:#f3f4f5; } 
.table tr:hover				{ background:#fff; color:#3074bb; }

@media only screen and (min-width: 0px) and (max-width: 767px) {
	.table, .table thead, .table tbody, .table th, .table td, .table tr { display: block; }
	.table thead tr 		{ position: absolute; top: -9999px; left: -9999px; } 
	.table tr				{ border: 1px solid #ddd; border-bottom:0px; margin-bottom:5px; } 
	.table td				{ border: none; border-bottom: 1px solid #ddd; position: relative; padding-left:45%; text-align:left; } 
	
	.table td:before		{ position: absolute; top:5px; left:10px; width:39%; padding-right: 10px; color:#3074bb; white-space:nowrap; }
	.table td:before		{ content: attr(data-title); }
	.table tr:hover td:before	{ color:#555; }
}



			
  </style>








<div class="wrapper">


<table class="header"><tr><td width="50%" nowrap>

<p><img src="../images/banner/<?php echo $invlogos; ?>" title="<?php echo $bisnisname;?>" width="200px"/></p>
</td><td width="50%" align="center">

<br /><br />
<table width="200" border="0">
  <tr>
    <td align="center" ><?php  if($status == 1){ ?>
    <font style="font-size:20px; color:#060; font-weight:bold;">PAID</font><br /><?php echo $tglproses;?>
    <?php } else { ?>
    <font style="font-size:20px; color:#D70000; font-weight:bold;">UNPAID</font>
    <?php } ?></td>
    </tr>
  <tr>
    <td align="center">
    
    </td>
  </tr>
  </table>
<p>&nbsp;</p>

</td></tr></table>



<table class="items"><tr><td width="50%">

<div class="addressbox">

<strong>Invoiced To</strong><br />
<?php echo $nama;?><br />
<?php echo $alamat;?><br />
Email: <?php echo $email;?>

</div>

</td><td width="50%">

<div class="addressbox">

<strong>Payment To</strong><br />
<?php echo $bisnisname;?><br />
<?php echo $alamat_bisnis;?><br />
Email: <?php echo $email_bisnis;?><br />
Website: www.<?php echo $domain;?>

</div>

</td></tr></table>

<div class="row">
<span class="title">Invoice No: <?= $kode; ?></span><br />
Invoice Date: <?php echo $tgle;?>
</div>

<table class="items">
    <tr class="title textcenter">
        <td width="70%">Description</td>
        <td width="30%">Amount</td>
    </tr>
    <tr>
        <td align="center"><?= $prodd; ?></td>
        <td class="textcenter"><?= $jumlahdepone; ?></td>
    </tr>
    <tr class="title">
        <td class="textright">Sub Total:</td>
        <td class="textcenter"><?= $jumlahdepone; ?></td>
    </tr>
            <tr class="title">
        <td class="textright">Credit:</td>
        <td class="textcenter"><?= rupiah(0); ?></td>
    </tr>
    <tr class="title">
        <td class="textright">Total:</td>
        <td class="textcenter"><?= $jumlahdepone; ?></td>
    </tr>
</table>


<?php if ($box->is_paid()): ?>

	<!-- User already paid premium membership -->
	<!-- You can use this function - $box->is_paid() on all other your premium webpages, it will return true during all user paid period (1 month) --> 
	<!-- Your Premium Pages Code Here -->

	<br>
	<?php echo $message; ?>
	<br>
	
	
<?php else: ?>

	 <!-- Awaiting Payment -->
	
	
<?php endif; ?> 	

	<div style='font-size:12px;margin:50px 0 5px 370px'>Language: &#160; <?php echo $languages_list; ?></div>
	<?php echo $box->display_cryptobox(true, 540, 230, "padding:3px 6px;margin:10px;border:10px solid #f7f5f2;"); ?>


</div>


	

</div>


</body>
</html>
<?php
}
}
}
?>
<?php ob_flush(); ?>