Author

Topic: Bitchain API (Read 1144 times)

newbie
Activity: 42
Merit: 0
May 29, 2013, 04:35:11 PM
#5
wow cool
hero member
Activity: 630
Merit: 502
May 29, 2013, 04:21:03 PM
#4
As Crownz81 says it may be better off just using bitcoind on your web server. I've learned it's actually relatively simple to generate an account for the user which gives them a unique deposit address and then monitor it for incoming payments with a bit of php code. The file gets refreshed by an AJAX call every 30 seconds.

This is a simple example with php using session based cookies (which is a bit wasteful as it'll create accounts for each visitor) but something you could build upon:
Code:

session_name
("unique_session_name"); // Change as appropriate
session_start();

$coin_platform="BTC";
$rpc_user=""// rpcuser value from bitcoin.conf here
$rpc_pass=""// rpcpassword value from bitcoin.conf here
$rpc_port=""// rpcport value from bitcoin.conf here
$confirmations_required=6// Minimum confirmations required.
$incoming="";
$transactions=array();

require_once(
"jsonrpcphp/includes/jsonRPCClient.php");
$client = new jsonRPCClient('http://'.$rpc_user.':'.$rpc_pass.'@127.0.0.1:'.$rpc_port.'/');

if(!isset(
$_SESSION["account_holder"]))
{
    
$_SESSION["account_holder"]="guest_".time();
    
$_SESSION["deposit_address"]=$client->getnewaddress($_SESSION["account_holder"]);
}
$transactions=$client->listtransactions($_SESSION["account_holder"]);

if(
count($transactions)>0)
{
    foreach(
$transactions as $value)
    {
        if(
$value["category"]=="receive" && $value["amount"]>&& $value["confirmations"]<$confirmations_required)
        {
            
$incoming.=$value["amount"]. " ".$coin_platform." (".$value["confirmations"]."/".$confirmations_required." confirmations)";
        }
    }
    
$incoming=trim($incoming"");
}

$account_balance=$client->getbalance($_SESSION["account_holder"], $confirmations_required);

if(
$account_balance==0)
{
    echo 
"\n\n";
    echo 
"\t\n";
    echo 
"\t\tDeposit ".$coin_platform." to\n";
    echo 
"\t\tIncoming\n";
    echo 
"\t\n";
    echo 
"\t\n";
    echo 
"\t\t".$_SESSION["deposit_address"]."\n";
    echo 
"\t\t".(($incoming=="")?"N/A":$incoming)."\n";
    echo 
"\t\n";
    echo 
"\n";
}
else
{
    
// Do something here (send emails etc?) then move it to the main account
    
mail("some@one""Payment received""This is just to let you know we've received a payment of ".$account_balance." ".$coin_platform.". etc.");
    
$client->move($_SESSION["account_holder"], ""$account_balance);
    die(
"Thanks for your payment, your order is being processed");
    
}
?>

Needs a bitcoin daemon and this
legendary
Activity: 906
Merit: 1002
May 27, 2013, 03:12:54 AM
#3
Sorry for pushing this old topic, but did they fix this issue?

Im working on my own piece of software right now and would need a reliable callback...
newbie
Activity: 7
Merit: 0
April 24, 2013, 02:20:22 AM
#2
Hi guys,

I've written a system to accept payments via Bitcoin using the API from bitchain.info and it works flawlessly except for the major issue that bitchain.info seems to be extremely flaky and most of the time their callback doesn't do anything at all so the payment never gets verified as far as the site is concerned. It seems to only ever work for a few hours of the day and is really frustrating.  Roll Eyes

Is there another more reliable API I can use to accept payments that will actually send a callback?

I suppose run bitcoin itself and use it's library calls?
hero member
Activity: 630
Merit: 502
April 24, 2013, 01:42:37 AM
#1
Hi guys,

I've written a system to accept payments via Bitcoin using the API from bitchain.info and it works flawlessly except for the major issue that bitchain.info seems to be extremely flaky and most of the time their callback doesn't do anything at all so the payment never gets verified as far as the site is concerned. It seems to only ever work for a few hours of the day and is really frustrating.  Roll Eyes

Is there another more reliable API I can use to accept payments that will actually send a callback?
Jump to: