Results 1 to 2 of 2

Thread: bitcoin payment gateway

  1. #1
    Join Date
    May 2016
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default bitcoin payment gateway

    I need help to upgrade this old bitcoin api payment version to new version

    ================================================================
    Code:
    <?php
    error_reporting(0); ini_set('display_errors', 0);
    // auto rate
    			$url_btc =    'https://blockchain.info/ticker';
    
    						$response_btc = file_get_contents($url_btc);
    						$object_btc = json_decode($response_btc);
    							//print_r($object_btc);
    							
    						$usdprice = $object_btc->{"USD"}->{"last"};
    						$rate['rate'] =  $object_btc->{"USD"}->{"last"};
    // config Blockchain account
    $btc = $rate['rate'];
    $guid = 'd4f0f';  // Blockchain account
    $main_password = 'passss'; // Blockchain pass
    $second_password = ''; // Blockchain pass
    $rate = $rate['rate'];
    
    $result = $db->query("SELECT balance,amount_purchased FROM users WHERE username='$userid'") or die("ERROR! CONTACT SUPPORT!");
    $row = $result->fetch_row();
    $balance = $row[0];
    $amountp = $row[1];
    $ip = $db->real_escape_string(VisitorIP());
    $url = "https://blockchain.info/merchant/$guid/new_address?password=$main_password&second_password=$second_password&label=$userid";
    if (isset($_POST['amount'])){
        $_SESSION['USD_amount'] = $db->real_escape_string($_POST['amount']);
        $_SESSION['BTC_amount'] = number_format($_SESSION['USD_amount']/$rate+0.0010, 8, '.', '');
        $temp = _curl($url, '', '');
        $_SESSION['BTC_Address'] = get_string_between($temp, 'address":"', '"');  	
    }
    if (!isset($_SESSION['USD_amount']) || $_SESSION['USD_amount'] < 10)
        die("WRONG AMOUNT MINIMUM IS 10$");
    if (!isset($_SESSION['USD_amount']) || $_SESSION['USD_amount'] > 5000)
        die("WRONG AMOUNT MAXIMUM IS 5000$");
    
    
    if (isset($_POST['bitcoin']))
    {
        $a = $db->real_escape_string($_SESSION['BTC_Address']);
        $url = "https://blockchain.info/q/addressbalance/$a?confirmations=0";
        $page = _curl($url, '', '');
        if ($page > 0) {
            $amount = $page/100000000;
    
            if($amount>= $_SESSION['BTC_amount']){
            $y = $db->real_escape_string($_SESSION['USD_amount']);
                  $x = $balance+$y;
    	      $c = $amountp + $y;
    	    $btc_amount = $db->real_escape_string($_SESSION['BTC_amount']);
                $sql = "UPDATE users SET balance=$x, amount_purchased=$c WHERE username='$userid'";
                $db->query($sql);
    
                $sql2 = "INSERT INTO orders(amount,btc_amount,username,address,ip,method,date) VALUES('$y', '$btc_amount', '$userid','$a','$ip','Bitcoin',now())";
                $db->query($sql2);
                unset($_SESSION['USD_amount']);
    		header("Location: success");
    		die;
              }else { $failed = 1; 
    		$messages = "<font size=2 color=red>Payment not yet completed, the amount you sent is too low . </font>"; }
        }else { $failed = 1;
    		 $messages = "<font size=3 color=red>Payment not yet completed, No payment received .</font>"; }
    }
    
    ?>
    <?php
    echo '
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta name="robots" content="noindex,nofollow">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    	<title>Hvault | BitCoin</title>
    	<link href="m/pstyles.css" rel="stylesheet" type="text/css">
    	<link href="m/prompt.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="m/jquery-1.9.1.min.js"></script>
    <script src="m/jquery-migrate-1.2.1.js"></script>
    <script type="text/javascript" src="m/prompt.js"></script><script type="text/javascript" src="m/jquery.bgiframe.min.js"></script>
    <script type="text/javascript" src="m/jqDnR.min.js"></script>
    <script type="text/javascript" src="m/jquery.jqpopup.min.js"></script>
    
    <script type="text/javascript">
        setTimeout(function() { window.location.href = "logout"; }, 60 * 54000);
    </script>
    </head>
    
    
    <body onbeforeunload="beforeunload(event);">
    <br>
    	<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center">
    		<tr>
    			<td style="width:100px;" ></td>
    			<td style="width:1100px;" align="center">
    
    				<table border="0" cellpadding="0" cellspacing="0" class="main_container">
    					<tr>
    						<td align="left">
    							
    							<table width="100%" cellpadding="0" cellspacing="0" border="0" class="header">
    								<tr>
    									<td class="hello_block" align="center">
    										
    										Hello, <b>'.$username.'</b><br>Your last visit: <b>'.$lastlogin.'</b><br>Balance:
     <b>$'.$balance.'</b><br />
    
    
    											
    									</td>
    									<td width="33%"  class="logo" align="center"  >
    									
            <a href="home" target="_blank"><img align="left" src="'.$sitelogo.'"></a><!--<a href="http://lampeduza.net/" target="_blank"><img src="/banner.gif" /></a>-->
    									</td>
    									<td class="hello_block" width="33%"  align="center">
    									
    										<table>
    											<tr>
    												<td>
    													<a href="cart" ><img src="img/cart.png" hspace="2" /></a> 
    												</td>
    												<td>
    
    													<a href="myaccounts" > Items purchased: '; $itemsquery = $db->query("SELECT items_purchased FROM users WHERE username='$userid'") or die(mysqli_error()); $items = $itemsquery->fetch_row(); echo $items[0]; echo ' </a><br /><br />Current time: <b>';
    echo(date('l jS \of F Y h:i:s A'));  echo '</b>														</tr>
    											</tr>
    										</table>
    									
    									</td>
    								</tr>
    							</table>
    
    							'.menu('balance').'<div class="main">
    <!-- start content -->
    
    <div class="content">
     <form action="" name="fcaptcha" method="post">
                <p>Please send : <input type="text" name="sometext" size="10" value="'.($_SESSION["BTC_amount"]).'" onClick="selectText(this);"> <font color="black"><b>BTC</b></font> to the following address:</p>
           
    
    <script language="JavaScript">
      function selectText(textField) 
      {
        textField.focus();
        textField.select();
      }
    </script>
    
    BTC Address : <input type="text" name="sometext" size="37" value="'.$_SESSION["BTC_Address"].'" onClick="selectText(this);"></br>
    <br>
              </h3> 
    <font color="orange">Rate: 1BTC = '.$rate.'  USD</font></br>
    &nbsp;</br>
    <font color="black">Please use this BTC Address once , for the other transactions new BTC Addresses will be generated.</font></br>
    <input type="hidden" id="bitcoin" name="bitcoin">
      </form>
    &nbsp;</br>
    <font color="green"><b>Status of Your Payment is Loading : </b></font></br>
      <p><input type="hidden" id="pmconfirm" name="pmconfirm" src="http://www.mvixusa.com/newsletter/2010/11/newsletter-membership-confirmation/images/confirm-button.png" alt="Submit Form" onclick=\"document.getElementById("fcaptcha").submit()\"/></p>
    <h3></br>
    
    '; 
    if($failed == 1) echo $messages; 
    echo '
    </br>
    </h3>
    </br>
    <script type="text/javascript">
        $("#pmconfirm").click(function(){
           $("#fcaptcha").submit();
        });
             
    </script> 
    
    <script language="JavaScript"><!--
    
    setTimeout("document.fcaptcha.submit()",20000);
    //--></script>
    <img src="img/preloader.gif" witdh="173" height="150"></br>
    
    <center><h3><font size=3 color="black"><img src="img/warning.png">Do not close this Page if the status of Your payment is not yet completed !</font></h3></br></center>
    </div>
    
    									</div> 
    <!-- end content -->
    
    							</div>
    
    						</td>
    					</tr>
    				</table>
    				<br>
    
    			</td>
    			<td style="width:100px;" ></td>
    		</tr>
    	</table>
    	<center>
    &copy; Hvault 2013 - 2016</center>
    <br>
    
    </body>
    </html>';
    ?>
    <?php
    
    
    function _curl($url, $post = "", $sock, $usecookie = false)
    {
        $ch = curl_init();
        if ($post) {
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
        }
        if (!empty($sock)) {
            curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true);
            curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
            curl_setopt($ch, CURLOPT_PROXY, $sock);
        }
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_TIMEOUT, 60);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_USERAGENT,
            "Mozilla/6.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3");
        if ($usecookie) {
            curl_setopt($ch, CURLOPT_COOKIEJAR, $usecookie);
            curl_setopt($ch, CURLOPT_COOKIEFILE, $usecookie);
        }
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }
    function get_string_between($string, $start, $end)
    {
        $string = " " . $string;
        $ini = strpos($string, $start);
        if ($ini == 0)
            return "";
        $ini += strlen($start);
        $len = strpos($string, $end, $ini) - $ini;
        return substr($string, $ini, $len);
    }
    function VisitorIP()
    { 
        if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        else $ip = $_SERVER['REMOTE_ADDR'];
     
    	return trim($ip);
    }
    ?>
    ========================================================
    Last edited by Beverleyh; 06-02-2016 at 08:20 AM. Reason: Formatting

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    And what is the new version? Or what about this old script has stopped working? How should we know how to upgrade this script without knowing where it came from, server requirements, user requirements (e.g. a unique API key) or installation/upgrade instructions? And how are we to test this in own environment (full demo pack? DB structure?)?

    There are many questions to answer and unfortunately we can't really help you without you providing us with *lots* more information.

    At the end of the day, I'm not confident that DD is the place to get help for this script and certainly, with so little information, it is very unlikely that anyone will be able to provide help. This is one of those times where it may be better to go back to the source to see if they have updated their documentation or check if they have a help forum/support system of their own.

    By all means, please post back with more information, then our members can further assess if they can assist you with you problem.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Similar Threads

  1. Network payment gateway API
    By mutago in forum PHP
    Replies: 4
    Last Post: 01-15-2014, 09:45 PM
  2. automatic payment
    By alexdog1805 in forum PHP
    Replies: 1
    Last Post: 11-12-2009, 05:55 PM
  3. 2checkout payment system
    By balusamy in forum PHP
    Replies: 0
    Last Post: 10-30-2007, 05:33 AM
  4. payment and password
    By queerfm in forum PHP
    Replies: 0
    Last Post: 11-16-2006, 05:51 PM
  5. Online Payment with PHP
    By baltazhor200401 in forum PHP
    Replies: 3
    Last Post: 11-14-2006, 12:22 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •