Bitcoin Forum
July 01, 2024, 02:19:00 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitchain API  (Read 1128 times)
Petr1fied (OP)
Hero Member
*****
Offline Offline

Activity: 630
Merit: 502


View Profile
April 24, 2013, 06: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?
Crownz81
Newbie
*
Offline Offline

Activity: 7
Merit: 0



View Profile
April 24, 2013, 07: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?
Eisenhower34
Legendary
*
Offline Offline

Activity: 906
Merit: 1002



View Profile
May 27, 2013, 08: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...
Petr1fied (OP)
Hero Member
*****
Offline Offline

Activity: 630
Merit: 502


View Profile
May 29, 2013, 09:21:03 PM
Last edit: May 30, 2013, 06:15:48 AM by Petr1fied
 #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:
<?php

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)<br />";
        }
    }
    
$incoming=trim($incoming"<br />");
}

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

if(
$account_balance==0)
{
    echo 
"\n<table border='1' bordercolor='white' cellpadding='5'>\n";
    echo 
"\t<tr>\n";
    echo 
"\t\t<th>Deposit ".$coin_platform." to</td>\n";
    echo 
"\t\t<th>Incoming</td>\n";
    echo 
"\t</tr>\n";
    echo 
"\t<tr>\n";
    echo 
"\t\t<td>".$_SESSION["deposit_address"]."</td>\n";
    echo 
"\t\t<td>".(($incoming=="")?"N/A":$incoming)."</td>\n";
    echo 
"\t</tr>\n";
    echo 
"</table>\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
kodo
Newbie
*
Offline Offline

Activity: 42
Merit: 0



View Profile
May 29, 2013, 09:35:11 PM
 #5

wow cool
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!