Bitcoin Forum
September 24, 2019, 10:08:13 AM *
News: If you like a topic and you see an orange "bump" link, click it. More info.
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Simple donation system in PHP  (Read 878 times)
Zz
Legendary
*
Offline Offline

Activity: 1778
Merit: 1071


View Profile
January 08, 2017, 12:37:53 PM
 #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
1569319693
Hero Member
*
Offline Offline

Posts: 1569319693

View Profile Personal Message (Offline)

Ignore
1569319693
Reply with quote  #2

1569319693
Report to moderator
1569319693
Hero Member
*
Offline Offline

Posts: 1569319693

View Profile Personal Message (Offline)

Ignore
1569319693
Reply with quote  #2

1569319693
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1569319693
Hero Member
*
Offline Offline

Posts: 1569319693

View Profile Personal Message (Offline)

Ignore
1569319693
Reply with quote  #2

1569319693
Report to moderator
1569319693
Hero Member
*
Offline Offline

Posts: 1569319693

View Profile Personal Message (Offline)

Ignore
1569319693
Reply with quote  #2

1569319693
Report to moderator
1569319693
Hero Member
*
Offline Offline

Posts: 1569319693

View Profile Personal Message (Offline)

Ignore
1569319693
Reply with quote  #2

1569319693
Report to moderator
Moritz30
Sr. Member
****
Offline Offline

Activity: 378
Merit: 250


View Profile
January 08, 2017, 01:31:41 PM
 #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.
OmegaStarScream
Staff
Legendary
*
Offline Offline

Activity: 1778
Merit: 1459



View Profile
January 08, 2017, 05: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

coinableS
Legendary
*
Offline Offline

Activity: 1092
Merit: 1001



View Profile WWW
January 08, 2017, 05: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:
<?php
$address 
"YOUR_BTC_ADDRESS";

$qrurl "http://chart.googleapis.com/chart?chs=125x125&cht=qr&chl=".$address;
$qrcode "<img src='".$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);

?>

<html>
<body>
Bitcoin Donations Accepted
<br>
<?php echo $qrcode?>
<br>
<table>
<tr>
   <td>Received From</td>
   <td>Amount</td>
</tr>
<?php
//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 
"<tr><td>".$json['txs'][$i]['inputs'][0]['prev_out']['addr']."</td><td>".$value."BTC</td></tr>";
      }
   }
}
?>

</table>
</body>
</html>


Example output:

AikFrank
Member
**
Offline Offline

Activity: 161
Merit: 10

Cryptocurrency Developer


View Profile
January 10, 2017, 06: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

Contact me for your Cryptocurrency Development. Linux, Web, Windows, Mac, Android, and Electrum Wallets Can all be developed!
Zz
Legendary
*
Offline Offline

Activity: 1778
Merit: 1071


View Profile
January 11, 2017, 08: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.


Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!