Author

Topic: Simple donation system in PHP (Read 933 times)

Zz
legendary
Activity: 1820
Merit: 1077
January 11, 2017, 03:17:50 AM
#6
There's really no need for PHP, you could do it client-side with javascript and websocket. In fact I just did a blog post for blockchain.info on how to do this. https://blog.blockchain.com/2017/01/04/intro-to-bitcoin-development/

However if you really want PHP it's easy enough, but new donations won't show up LIVE unless you use something like websocket or AJAX.


The information you gave me solved my problem.
thank you so much I'm very happy Smiley




I will continue to work to resolve this issue in php language.


member
Activity: 160
Merit: 10
Cryptocurrency Developer
January 10, 2017, 01:14:30 PM
#5
Yes its possible with PHP. I have done this with PHP, very simple and straight forward.

Hit me up for learning cost Grin
legendary
Activity: 1442
Merit: 1186
January 08, 2017, 12:09:55 PM
#4
There's really no need for PHP, you could do it client-side with javascript and websocket. In fact I just did a blog post for blockchain.info on how to do this. https://blog.blockchain.com/2017/01/04/intro-to-bitcoin-development/

However if you really want PHP it's easy enough, but new donations won't show up LIVE unless you use something like websocket or AJAX.

Code:
$address "YOUR_BTC_ADDRESS";

$qrurl "http://chart.googleapis.com/chart?chs=125x125&cht=qr&chl=".$address;
$qrcode ".$qrurl."'>";
//this is just an image created using google charts API

//get JSON data on address using blockchain.info free public API
$url "https://blockchain.info/address/".$address."?format=json";
$json json_decode(file_get_contents($url), true);

?>



Bitcoin Donations Accepted


echo $qrcode?>




  
  

//loop through the last 4 received donations
for($i=0;$i<5;$i++){
   
$outputs count($json["txs"][$i]["out"]);
   
//loop through each output of the tx
   
for($ii=0;$ii<$outputs;$ii++){
      
//check if output addy matches our donation addy
      
$outaddy $json["txs"][$i]["out"][$ii]["addr"];
      
$value $json["txs"][$i]["out"][$ii]["value"];
      
$value $value 100000000;
      if(
$outaddy == $address){
          echo 
"
";
      }
   }
}
?>
Received FromAmount
".$json['txs'][$i]['inputs'][0]['prev_out']['addr']."".$value."BTC





Example output:
staff
Activity: 3500
Merit: 6152
January 08, 2017, 12:05:41 PM
#3
Since you are not looking to generate a unique address for each user then you should simply put an address that fits you and then gather transactions that gets sent to it with the balance , I suggest using the blocktrail API here : https://www.blocktrail.com/api/docs and you could use the sample given and explained here : http://bitcoin.stackexchange.com/questions/34300/how-to-get-the-list-of-transactions-that-has-gone-into-an-address-with-the-amoun
sr. member
Activity: 364
Merit: 250
January 08, 2017, 08:31:41 AM
#2
I want to write a donation system with the simplest form of PHP programming language.
The first step is to generate a bitcoin address.
I will generate the QR code for this bitcoin address and put it on the site.
The screen I imagine is as follows:

I'm investigating an this matter.
There are also ready services for this matters, but I want to code myself.
how to list bitcoin transactions in PHP
I need suggestions.

thanks in advance

You could use a coinbase wallet users send donations to and use the Coinbase API to get the transactions.
Zz
legendary
Activity: 1820
Merit: 1077
January 08, 2017, 07:37:53 AM
#1
I want to write a donation system with the simplest form of PHP programming language.
The first step is to generate a bitcoin address.
I will generate the QR code for this bitcoin address and put it on the site.
The screen I imagine is as follows:

I'm investigating an this matter.
There are also ready services for this matters, but I want to code myself.
how to list bitcoin transactions in PHP
I need suggestions.

thanks in advance
Jump to: