I'm trying to accept bitcoin payments on my website using blockchain.info's API. However, I'm confused with their callback.

I've read through their callback, but how would I know if the transaction was successful or not ?

2 Answers 2


The callback lets you know the payment has been recieved. The confirmations are also included in the callback

When a payment is received blockchain.info will notify the callback URL passed using the create method. The parameters will be supplied in a http GET request. The callback url is limited to 255 characters in length.


  • 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.

A double spend occurs when a malicious user spends the same BTC twice. A payment that initial appears successful could be reversed at a later date. This is counteracted by waiting for the transaction to be included in the blockchain and reaching a number of confirmations. 6 confirmations is generally considered safe for high value transactions.

Validate the transaction confirmations in the callback script by checking $_GET['confirmations'] parameter. It is recommended you acknowledge the transaction at zero confirmations but only trust the transaction after one confirmation. For example, if purchasing a product, we would show the order as successful at zero confirmations, but only ship the product when 6 or more confirmations are reached. See the PHP demo callback.php for an example.

sourced from: https://blockchain.info/api/api_receive


Alright, after some thinking, I finally understood how will I use the callback. Blockchain's API will only send a callback if there has been a transaction. What you need to track here is, that the amount the user sends should be equal to what you've requested.

Let's take a scenario:

  1. I sell an online product worth $5 and use blockchain’s payment receiving API to receive the money.

  2. The user sends an amount less than $5 (suppose $0.05), we then get a callback and assume that the transaction was successful. However, the user paid less amount that he requested. Therefore, we need to keep track of the amount and verify it with the original amount. If both the amount matches, then only you should proceed further.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.