Author

Topic: how change number of confirmation in API? [bc.i] (Read 798 times)

hero member
Activity: 560
Merit: 509
I prefer Zakir over Muhammed when mentioning me!
December 13, 2014, 04:58:59 AM
#7
yes i checked it, but all transaction needs more than 1 confirmation. i want callback url done with 1 confirmation,

PHP example from github repo (https://github.com/blockchain/receive_payment_php_demo/blob/master/callback.php):

Code:
include 'include.php';
mysql_connect($mysql_host$mysql_username$mysql_password) or die(__LINE__ ' Invalid connect: ' mysql_error());
mysql_select_db($mysql_database) or die( "Unable to select database. Run setup first.");
$invoice_id $_GET['invoice_id'];
$transaction_hash $_GET['transaction_hash'];
$value_in_btc $_GET['value'] / 100000000;
//Commented out to test, uncomment when live
if ($_GET['test'] == true) {
  echo 
'Ignoring Test Callback';
  return;
}
if (
$_GET['address'] != $my_bitcoin_address) {
    echo 
'Incorrect Receiving Address';
  return;
}
if (
$_GET['secret'] != $secret) {
  echo 
'Invalid Secret';
  return;
}
if (
$_GET['confirmations'] >= 4) {
  
//Add the invoice to the database
  
$result mysql_query("replace INTO invoice_payments (invoice_id, transaction_hash, value) values($invoice_id, '$transaction_hash', $value_in_btc)");
  
//Delete from pending
  
mysql_query("delete from pending_invoice_payments where invoice_id = $invoice_id limit 1");
  if(
$result) {
   echo "*ok*";
  }
} else {
   
//Waiting for confirmations
   //create a pending payment entry
   
mysql_query("replace INTO pending_invoice_payments (invoice_id, transaction_hash, value) values($invoice_id, '$transaction_hash', $value_in_btc)");
   echo 
"Waiting for confirmations";
}
?>


In the above code, you can see if ($_GET['confirmations'] >= 4), change 4 to 1 and try it. Smiley

P.S. After a small checking, I think if ($_GET['confirmations'] >= 1) will do it. Cheesy

   ~~MZ~~
full member
Activity: 200
Merit: 100
Presale Starting May 1st
i want when blockchain generate new address  for buyer,blockchain send all request at 1 confirmation,

I didn't get you exactly. Can you elaborate please? Smiley

BTW, did you check the github repo? PHP : https://github.com/blockchain/receive_payment_php_demo and JAVA : https://github.com/blockchain/receive_payment_java .

   ~~MZ~~
yes i checked it, but all transaction needs more than 1 confirmation. i want callback url done with 1 confirmation,
hero member
Activity: 560
Merit: 509
I prefer Zakir over Muhammed when mentioning me!
i want when blockchain generate new address  for buyer,blockchain send all request at 1 confirmation,

I didn't get you exactly. Can you elaborate please? Smiley

BTW, did you check the github repo? PHP : https://github.com/blockchain/receive_payment_php_demo and JAVA : https://github.com/blockchain/receive_payment_java .

   ~~MZ~~
full member
Activity: 200
Merit: 100
Presale Starting May 1st
i want when blockchain generate new address  for buyer,blockchain send all request at 1 confirmation,
full member
Activity: 200
Merit: 100
Presale Starting May 1st
im using this api https://blockchain.info/api for receive payments, i think confirmaton set for 6 confirm.thats correct?
i want change it to 1 confirmation. how? Smiley


Read https://blockchain.info/api/api_receive .

Quote from: blockchain.info/api/api_receive
Parameters:
  • value  --  The value of the payment received in satoshi. Divide by 100000000 to get the value in BTC.
  • input_address  --  The bitcoin address that received the transaction.
  • confirmations  --  The number of confirmations of this transaction.
  • {Custom Parameters}  --  Any parameters included in the callback URL will be passed back to the callback URL in the notification.
  • transaction_hash  --  The transaction hash.
  • input_transaction_hash  --  The original paying in hash before forwarding.
  • destination_address  --  The destination bitcoin address. Check this matches your address.

From blockchain.info/api/api_receive :

Code:
if ($_GET['confirmations'] >= 6) {
    //Insert into confirmed payments
    echo '*ok*';
} else {
    //Insert into pending payments
    //Don't print *ok* so the notification resent again on next confirmation
}


   ~~MZ~~
thank you. still not working!
hero member
Activity: 560
Merit: 509
I prefer Zakir over Muhammed when mentioning me!
im using this api https://blockchain.info/api for receive payments, i think confirmaton set for 6 confirm.thats correct?
i want change it to 1 confirmation. how? Smiley


Read https://blockchain.info/api/api_receive .

Quote from: blockchain.info/api/api_receive
Parameters:
  • value  --  The value of the payment received in satoshi. Divide by 100000000 to get the value in BTC.
  • input_address  --  The bitcoin address that received the transaction.
  • confirmations  --  The number of confirmations of this transaction.
  • {Custom Parameters}  --  Any parameters included in the callback URL will be passed back to the callback URL in the notification.
  • transaction_hash  --  The transaction hash.
  • input_transaction_hash  --  The original paying in hash before forwarding.
  • destination_address  --  The destination bitcoin address. Check this matches your address.

From blockchain.info/api/api_receive :

Code:
if ($_GET['confirmations'] >= 6) {
    //Insert into confirmed payments
    echo '*ok*';
} else {
    //Insert into pending payments
    //Don't print *ok* so the notification resent again on next confirmation
}


   ~~MZ~~
full member
Activity: 200
Merit: 100
Presale Starting May 1st
im using this api https://blockchain.info/api for receive payments, i think confirmaton set for 6 confirm.thats correct?
i want change it to 1 confirmation. how? Smiley
Jump to: