Bitcoin Forum

Economy => Web Wallets => Topic started by: apoorvlathey on April 02, 2016, 07:23:22 AM



Title: [HELP] Blockchain.info API
Post by: apoorvlathey on April 02, 2016, 07:23:22 AM
I have decided to use blockcahin.info API for payment integration. I created a php to generate new address to send the BTC to. But this new generated address is not showing in my blockchain.info wallet. Is this normal?

Here are the codes for the two :

New address Generator :

Code:
<?php
$secret 
'abc';

$my_xpub 'xpub123';
$my_api_key 'api123';

$my_callback_url 'http://yoyobtcrotator.cf/callback.php?&secret='.$secret;

$root_url 'https://api.blockchain.info/v2/receive';

$parameters 'xpub=' .$my_xpub'&callback=' .urlencode($my_callback_url). '&key=' .$my_api_key;

$response file_get_contents($root_url '?' $parameters);

$object json_decode($response);

echo 
'Send Payment To : ' $object->address;
?>

Callback.php :

Code:
<?php
$real_secret 
'abc';
$transaction_hash $_GET['transaction_hash'];
$value_in_satoshi $_GET['value'];
$value_in_btc $value_in_satoshi 100000000;

if (
$_GET['test'] == true) {
    return;
}


if (
$_GET['confirmations'] >= && $_GET['value'] >=10000) {
    
    echo 
'*ok*';
} else {
   
}
?>

The secret, api, xpub are imaginary.

Working : New address is generated for each user, the user needs to pay 10k or above and the callback.php displays *ok*.
Are these codes correct ?


Title: Re: [HELP] Blockchain.info API
Post by: Monnt on April 03, 2016, 03:06:13 AM
From what I can see, they are. Your code is echoeing *OK* back to you, so everything is going as you want it to, based on your parameters.


Title: Re: [HELP] Blockchain.info API
Post by: apoorvlathey on April 03, 2016, 07:59:52 AM
I want that after receiving the payment then the user should be redirected to another url automatically. How should i edit the code to achieve it ?
Would this work ?

Code:
$URL = 'http://example.com/proceed.php';
if ($_GET['value'] >=1000) {
        echo '*ok*';
header('Location: '.$URL);
} else {
   
}


Title: Re: [HELP] Blockchain.info API
Post by: hoop on April 03, 2016, 12:46:06 PM
 Your site on shared hosting or VPS/Server


Title: Re: [HELP] Blockchain.info API
Post by: apoorvlathey on April 03, 2016, 12:51:57 PM
Your site on shared hosting or VPS/Server
Yes my site is on a hosting provide. I don't have my own dedicated server.
The hosting provider is currently free one but i would upgrade soon.


Title: Re: [HELP] Blockchain.info API
Post by: hoop on April 04, 2016, 12:38:32 AM
Your site on shared hosting or VPS/Server
Yes my site is on a hosting provide. I don't have my own dedicated server.
The hosting provider is currently free one but i would upgrade soon.
You need VPS or Server.

  more info in this topic  https://bitcointalk.org/index.php?topic=1391888.msg14150323#msg14150323