Results 1 to 2 of 2

Thread: bitcoin payment gateway

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

    Default bitcoin payment gateway

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

    error_reporting(0); ini_set('display_errors', 0);
    // auto rate
    			$url_btc =    '';
    						$response_btc = file_get_contents($url_btc);
    						$object_btc = json_decode($response_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 = "$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 = "$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'";
                $sql2 = "INSERT INTO orders(amount,btc_amount,username,address,ip,method,date) VALUES('$y', '$btc_amount', '$userid','$a','$ip','Bitcoin',now())";
    		header("Location: success");
              }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>"; }
    echo '
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
    <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);
    <body onbeforeunload="beforeunload(event);">
    	<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center">
    			<td style="width:100px;" ></td>
    			<td style="width:1100px;" align="center">
    				<table border="0" cellpadding="0" cellspacing="0" class="main_container">
    						<td align="left">
    							<table width="100%" cellpadding="0" cellspacing="0" border="0" class="header">
    									<td class="hello_block" align="center">
    										Hello, <b>'.$username.'</b><br>Your last visit: <b>'.$lastlogin.'</b><br>Balance:
     <b>$'.$balance.'</b><br />
    									<td width="33%"  class="logo" align="center"  >
            <a href="home" target="_blank"><img align="left" src="'.$sitelogo.'"></a><!--<a href="" target="_blank"><img src="/banner.gif" /></a>-->
    									<td class="hello_block" width="33%"  align="center">
    													<a href="cart" ><img src="img/cart.png" hspace="2" /></a> 
    													<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>
    							'.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) 
    BTC Address : <input type="text" name="sometext" size="37" value="'.$_SESSION["BTC_Address"].'" onClick="selectText(this);"></br>
    <font color="orange">Rate: 1BTC = '.$rate.'  USD</font></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">
    <font color="green"><b>Status of Your Payment is Loading : </b></font></br>
      <p><input type="hidden" id="pmconfirm" name="pmconfirm" src="" alt="Submit Form" onclick=\"document.getElementById("fcaptcha").submit()\"/></p>
    if($failed == 1) echo $messages; 
    echo '
    <script type="text/javascript">
    <script language="JavaScript"><!--
    <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>
    <!-- end content -->
    			<td style="width:100px;" ></td>
    &copy; Hvault 2013 - 2016</center>
    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);
        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()
            $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
    Derbyshire, UK
    Thanked 599 Times in 575 Posts
    Blog Entries


    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


Posting Permissions

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