Bitcoin Forum
April 20, 2024, 06:52:34 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Blockchain.info HTTP JSON String for Payement notifications  (Read 1143 times)
bat1 (OP)
Newbie
*
Offline Offline

Activity: 32
Merit: 0


View Profile
June 05, 2012, 10:14:12 AM
 #1

Hi Bitcoin fans Smiley

I am currently building a website with PHP/SQL to sell products in Bitcoins (Nice Swiss stuff...watch out!) and am willing to verify if an amount has been sent to a bitcoin adress I provide when submitting a form.

I have to list the adresses which contains Bitcoins along with their payement status(show amount if verified), so I am looking for the simplest way of doing this.

I found out this piece of code, regarding blockexplorer:

Quote
$Awallets = $row['wallet'];
$Live_Address_Scan = "http://blockexplorer.com/q/getreceivedbyaddress/$Awallets";
$ch = curl_init($Live_Address_Scan);
curl_setopt($ch, CURLOPT_REFERER, 'Mozilla/5.0 (compatible; GetReceivedBy; '.php_uname('s').'; PHP/'.phpversion().')');
curl_setopt($ch, CURLOPT_USERAGENT, "CakeScript/0.1");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$Donated_Bitcoins = curl_exec($ch);
curl_close($ch);

But eventually there are some 'moments' where blockexplorer cannot be sollicited so an error message shows up in the field where the amount should appear  Embarrassed

'Database overload...'

I then came up about blockchain and I have to use this specific code:

Quote
HTTP Post

A HTTP POST request will be made on payment sent or received to URL provided on your My Account page. The POST body will contain one "payload" variable which contains JSON data about the transaction. Any effect on your wallet will need to be calculated by your server.

e.g. Access JSON using php

$_POST['payload']

{
    "hash": "bf8648b06160ded3274d6054cfeadd95f762271170070429ef40d62ac5452c4b",
    "ver": 1,
    "vin_sz": 1,
    "vout_sz": 2,
    "lock_time": "Unavailable",
    "size": 258,
    "relayed_by": "71.238.174.98",
    "tx_index": 13903761,
    "time": 1325700693,
    "inputs": [
        {
            "prev_out": {
                "hash": "e417eb0889a1870e6b500ad8769cb7110739749e",
                "addr": "1Mo3ibZuqZpsBGimyfmUnYDiZoU44VbAJV",
                "value": 438000000,
                "tx_index": 13902462,
                "n": 1
            }
        }
    ],
    "out": [
        {
            "value": 215000000,
            "hash": "6c835372a306b2e253f896801cb0b5703d60114c",
            "addr": "1AtmJQYUCVZSwoLkQvEvFhtoRfwn4Eumuu"
        },
        {
            "value": 222000000,
            "hash": "60ce49cd97aa152e1db8a76c1b62c55ae3b059d3",
            "addr": "19przaW7NeE96SEVtKGWdGM3CuKVaSYhrS"
        }
    ]
}
         

As a rudimentary form of verification the HTTP server should respond by printing the user's wallet identifier.

echo '0aef6e46-2422-6d4c-772c-bacccf378b6b';


I managed to have a recognized listener adress along with the echo 'wallet', but then, how do I parse this JSON string? May I ask if someone could point me to the right direction or even show me some code? I do not know how to 'begin', like is it in a <?php tag or something different?

A thousands thanks in advance,

 Smiley
1713595954
Hero Member
*
Offline Offline

Posts: 1713595954

View Profile Personal Message (Offline)

Ignore
1713595954
Reply with quote  #2

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

Posts: 1713595954

View Profile Personal Message (Offline)

Ignore
1713595954
Reply with quote  #2

1713595954
Report to moderator
1713595954
Hero Member
*
Offline Offline

Posts: 1713595954

View Profile Personal Message (Offline)

Ignore
1713595954
Reply with quote  #2

1713595954
Report to moderator
Stephen Gornick
Legendary
*
Offline Offline

Activity: 2506
Merit: 1010


View Profile
June 05, 2012, 11:23:37 AM
 #2

I am currently building a website with PHP/SQL to sell products in Bitcoins (Nice Swiss stuff...watch out!) and am willing to verify if an amount has been sent to a bitcoin adress I provide when submitting a form.

JSON PHP lib might be what you are looking for. Link to it is in here:
 - http://en.bitcoin.it/wiki/PHP_developer_intro

But to do a shopping cart, you might want to look at using an existing shopping cart tools:
 - http://en.bitcoin.it/wiki/Category:Shopping_Cart_Interfaces




Unichange.me

            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █


bat1 (OP)
Newbie
*
Offline Offline

Activity: 32
Merit: 0


View Profile
June 05, 2012, 03:30:34 PM
Last edit: June 05, 2012, 05:13:52 PM by bat1
 #3

But if I have to run bitcoin daemon, this would mean that I would be headed to an online wallet?

Here is what I would like to do:

A user orders smthg on the website, then gets:
'Here is your wallet adress for the payement : 333hghgksuzwzarat678ajhsgjsjs8'

> This adress is recorded in my database in an 'wallet' field, and next to it, a 'verif' field.

Then, a cron job is runned, checking if this adress has been credited, and if yes, the cron job changes the value of the 'verif' field.

Isn't there a way to achieve this without all the bitcoin setup?

Thanks in advance!
Stephen Gornick
Legendary
*
Offline Offline

Activity: 2506
Merit: 1010


View Profile
June 05, 2012, 07:21:38 PM
Last edit: June 06, 2012, 09:47:36 PM by Stephen Gornick
 #4

But if I have to run bitcoin daemon, this would mean that I would be headed to an online wallet?

BlockExplorer and Blockchain.info are nowhere near reliable enough to use as a blockchain database tool for use for ecommerce.

If you don't want to run bitcoind, then perhaps:

 - Bit-Pay
 --  https://bit-pay.com/
 - Mt. Gox Pay Now
 --  http://bitcointalk.org/index.php?topic=85520.0
 - Paysius
 - or the other hosted merchant methods?

Unichange.me

            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █


bat1 (OP)
Newbie
*
Offline Offline

Activity: 32
Merit: 0


View Profile
June 06, 2012, 01:04:35 PM
 #5

Quote
BlockExplorer and Blockchain.info are nowhere near ready reliable enough to use as a blockchain database tool for used in ecommerce

Undecided

Okay...

Thank you very much!
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!