Coder Social home page Coder Social logo

receive-payments-demos's Introduction

Notes

This repository contains simple examples of how to use the blockchain.info receive payments API V2 to process bitcoin payments.

To use Receive Payments v2 you'll need an xPub address corresponding to an HD wallet. If you don't already have this, you can obtain one by creating a new wallet. You'll also need a V2 API Key — please note that this new API key is mandatory for Receive API v2, and is distinct from the (optional) API key you might already use elsewhere in the Blockchain API.

Further documentation & explanation can be found at: https://blockchain.info/api/api_receive

You'll find samples written in several languages in this repository. The workflow implemented in all these samples is:

  • Show the user an invoice with a javascript payment button.
  • On receiving payment, redirect to a status page
  • When the payment is fully confirmed, give the user the product (in this case, show the user nutsandbolts.jpg)

This code is intended as educational reference material and is not written for production use.

receive-payments-demos's People

Contributors

assafy avatar conejoninja avatar crashworksllc avatar kristovatlas avatar mpfluger avatar pdpi avatar tuzzolo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

receive-payments-demos's Issues

Test payment

is there way to test the API without real payments?

Using wallet api for receiving payment

I am exploring wallet api of blockchain to receive payment where putting guid is necessary. I think that id can only be obtained if the wallet is created using Createwallet api provided by blockchain only.

As my wallet and address is created from other code, I have private key, public key, ext pub key and password etc. How may I use http://localhost:3000/merchant/$guid/balance?password=$main_password api.

Also, the url seems of localhost which is only possible if I setup a node. So, is there any url of blockchain.info which I can use instead.

Like listed here https://blockchain.info/merchant/$guid/.

I think the documentation like to show the endpoints only and localhost will be replaced by the above url.

=====

Another api is also with blockchain from there balance can be obtained from the address itself but new address is getting generated everytime whereas I have to use same address everytime.

Please help.

Callback not getting on Update Balance Api

Am using your wallet api and its working fine, but to monitor particular address for payment receive which is not added in wallet api , for this am using payment received api v2 , and making call Balance Updates api and pasing my address and my call with extra parameters mention in the documentoin like (api key, onNotification etc). but calling that api m getting succes response but not getting the call back...even i check calbacklog which giving me empty.
Can you guys help me .

No call backs ?

I have developed an app in laravel and call backs are not working ?

When I try to get callback logs its only returning "[]"

Please advice

Error receiving on API

I was getting normal for the API and is still receiving, however I can not access my wallet either through the application or the site, only shows me the error: Wallets are limited to 20000

And it does not let you complete the access, and I need to manage the Bitcoin received, are from clients that receive payments by bitcoin, how can we correct this error and I get to have urgent access in my portfolio again?

Secret is sent to user

I installed this demo. Using Firebug I looked at what was being sent to the user's browser. And here it is (in redacted and expanded form):

{"input_address":"1CuUmZkeS--------DsLesY87qV9JZc3iR",
"callback_url":"http://domain.com/blockchain_php_demo
/callback.php?invoice_id=

&secret=this_is_the_secret_I_chose", <==== LOOOK!!!!!!!

"fee_percent":0,
"destination":"1FTM7Z6xjkV--------yBt583d1wqqV5A"}

I really hope nobody has used this demo code as the basis for a production site!

blockchain recieve api is giving me error.

Hi,I want to know i have downloaded the blockchain recieve api demo clone from github and changed the bitcoin address and secret and uploaded it to validcc.ru/shop/btc/ ....Now when i click on bicoin paynow button it is giving me unknown error.So please help me out in solving and detecting what going wrong.Thanks and sorry for my bad english.Waiting for someone answer.....

callback doesn't works

payments works, money arrive... but..
callback.php is not called after payment, i know that becouse the dabase invoice_payment and pending_invoice_payment is still empty

create.php return a string with a lot of backslashes (is normal?)
{"input_address":"1C33usmpnF5XXXXXXXhv6jcmfqi2ro4fQ","callback_url":"http://www.XXXXXX.com/bitcoin/callback.php?invoice_id=7771&secret=pg65hXXXXXX... etc..

i've to set some standard parameters on callback_url?

after a REAL payment i can see for 1 second "thank u" and after that order_status.php is loaded... but DB is empty and order_status.php says
Amount Pending : 0 BTC
Amount Confirmed : 0 BTC
Payment not received.

is not a problem with database, its working... invoices table works...

could u please write a complete documentation for install and test this script?

Api key

I am unable to get an api key, I have followed the link and filled the form but received no mail after 2 to 3 days. Is there something I am missing ?

how to recieve bitcoin not usd?

currently with this api is ,is ticker api which is converting to btc to usd how to recieve bitcoin without conversion mean amount should be show in bitcoin .

blockchain callback is running only once..

maybe... blockchain callback has running only once. (or something strange..)

I did not response "ok".
but callback is running once.

please look this Order.
https://blockchain.info/ko/tx/e59b48c1cf33cbaf3d3e4177e8b63c53a85acad222856d82df500ffb33fa095c

Setting callback when over 3 confirmations.
And I response "ok" over 6 confirmations.
(insert every confirmations to my database. but I can see that only 3 confirmation's callback.)

what's wrong?
pre thanks for your help.

Receive payments not work

Make the configuration of receive balance update so that at the time of receiving a transaction this will be stored in my database, it was working until today that I have not received the corresponding notifications, these are the parameters I sent:

POST: https://api.blockchain.info/v2/receive/balance_update

{
     "key": "key"
     "addr": "address"
     "callback": "http://45.33.87.135:9094/api/v1/recivePayment?secret=secret&index=index"
     "confs": "3"
     "onNotification": "KEEP"
     "op": "RECEIVE"
}

I would like to know what the problem is.

Gap in https://api.blockchain.info/v2/receive

what if N (N>20) customers begin to pay on our website within short time (for example, 20 minutes) and we generate new addresses for them using https://api.blockchain.info/v2/receive, but the first 20 of them didn't finish payment yet? Does it mean that gap go over 20 and 21st user cannot have an addr for payment because of "this API will return an error and refuse to generate new addresses if it detects it would create a gap of over 20 unused addresses" (from your API docs)?

Callback Issues

I was carrying out tests with the methods of notification of payment and in none of the cases does it reach the callback, I do not know if I am doing the wrong procedure, but I am following all the documentation, my use cases are:

Receive method:
https://api.blockchain.info/v2/receive

Parameters:

xpub=key public
key=api_code
callback = http%3A%2F%2F45.33.87.135%3A9094%2Fapi%2Fv1%2FrecivePayment%3Finvoice_id%3D59%26secret%3Dpassword

this generates the addres and at the time of making a payment to that address they do not notify me of the callback;

Then I use the receive / balance_update method:
https://api.blockchain.info/v2/receive/balance_update

Parameters:

{
"key": "asdasdadsasdas",
"addr": "my address",
"callback": "http://45.33.87.135:9094/api/v1/recivePayment?invoice_id=59&secret=password",
"confs": 1,
"onNotification": "KEEP",
"op": "ALL"
}

None of these methods worked for me. Could you help me?

One php short tag in index.php

I have replaced

<script type="text/javascript" src="<? echo $blockchain_root ?>Resources/wallet/pay-now-button-v2.js"></script>

by:

<script type="text/javascript" src="<?php echo $blockchain_root ?>Resources/wallet/pay-now-button-v2.js"></script>

If you do not have short tag enabled the sample does not work.

Absturz des Pc Privat Schlüssel weg / Crash the pc private key away

Hallo, ich habe ein sehr großes Problem, ich habe einen bitaddress.org meinen eigene bitaddresse und dazu den Privat Schlüssel erstellt.
Ich hatte gerade meine Adresse kopiert und gespeichert und wollte dann meinen Privat Schlüssel kopieren das hat aber leider nicht mehr funktioniert da ist der PC Abgestürzt , Strom Ausfall, somit ist mein Privat Schlüssel weg, wie kann ich diesen Schlüssel wieder bekommen die Adresse habe ich , wer kann mir Helfen?

Siggi

Hello, I have a very big problem, I have created a bitaddress.org my own bitaddresse and the private key.
I just had my address copied and saved and then wanted to copy my private key but has not worked anymore since the PC crashes, power failure, so my private key is gone, how can I get this key again the address I have, who can help me?

Siggi

if ($_SERVER['REMOTE_ADDR'] == $ip)

Now this is not worked. I check at this time $_SERVER['REMOTE_ADDR'] is another IP and gethostbynamel('blockchain.info') return another IP's.

Issues in Receive Payments API V2 with .onion site

Hi! I am trying to get my Receive Payments API V2 integration to work on an .onion site but I get an error: "Error creating payment address on Blockchain: Malformed callback URL"

If I try the very same implementation on a .com site, it works.

Is there any special treatment for .onion sites in the callback API GET param?

I'm contacting the API like this using PHP:

curl_setopt($curl, CURLOPT_URL, 'https://api.blockchain.info/v2/receive?xpub='.$this->payment_params->xpub.'&callback='.urlencode($callback_url).'&key='.$this->payment_params->api_key);

Thanks in advise!

MSYQLI Issues On Order Status Page

Anyone else have issues with the MYSQLI calls ??

Example

Fatal error: Call to undefined method mysqli_stmt::get_result() in /...../order_status.php on line 23

Can't seem to figure any of this out, not only that it doesn't seem to use the callback ever.

2 issues on index.php

Hello,

  1. Resources/buttons/pay_now_64.png

    This button does not exists (anymore)

  2. Payment Received [[value]] BTC. Thank You.

    does not work. This stage never meets although callback.php returns OK .

Please advise.

Code susceptible to DoS attacks.

Hello, i noticed a problem with this code.

As Blockchain API documentation says, if you reach the gap limit with 20 (or whatever the gap limit is) unused addresses, the API will refuse to give you new addresses unless you increase the gap limit or change your xpub.

This can be abused by malicious users by requesting "/create.php?invoice_id=XXX" enough times to reach the gap limit and let the payment system unavailable until the administrator fixes the issue.

I understand that this is intended to be a demonstration code and not for production, but i see many people using this code as is and i want to let them know.

create.php

create.php still reveals the callback URL it is just masked better. I used the follow modification in my implementation of your code.

$response = json_decode(file_get_contents($blockchain_root . "api/receive?method=create&callback=" . urlencode($callbackURL) . "&address=" . $GATEWAY["bitcoin_addr"]));
print json_encode(array('input_address' => $response->input_address ));

Receive payments address gap issue

Below is my current setup :

  1. New addresses are generated using the wallet api and users pay to those addresses. I'm using a legacy wallet, so the callback url is already setup inside the notifications settings area in the legacy wallet.
  2. I receive the payments into the generated address from users and affiliates gets paid out using the wallet api. I don't have any issue so far but now I need to create an other setup like the same but unfortunately the legacy wallet cannot be created anymore which leaves me with only one option, that is to create the new HD blockchain wallet.

So my question is If I'm using receive payments api with the xpub key from the new hd wallet then there will be thousands of addresses created and there will be many address gaps which leaves the funds being unusable or not shows up inside the new wallet.

  1. Each address I generate will be generated with a different callback urls based on the different order id's so that I can trace and create memberships based on the order data which was generated and saved for future use if a user actually pays for example : order_id : 1234 points to Order data : { username : xyz, duration: 2 months, membership_type: platinum } etc ..... so callback urls change for each users who is going to generate those new addresses which puts many address gaps. I know I can reuse the already generated address but is there is a way to change the callback_url of the already generated address ?
  2. If there is no option to change the callback_url of an existing address which received no funds yet then is there a way to retrieve the funds that sits after the gap like programmatically accessing those funds etc ...
  3. I know I can pass a gap limit parameter but still thousands of users means there will be atleast one gap created when users browse the site. I checked the gap checker by using "Check address gap" and currently it shows me 98 gaps.

Please let me know a solution so that I can move forward.

Callback Delay

I am trying Receive Payment API. But I faced a log delay in being called callback function. The delay is about 4 hours. Is it a common issue? How can I solve this problem?

Callback only once ?

Hey Guys!
Anyone else ever have an issue where the callback was only ever hit once ? I mean it's sit up fine, hits it ....

[ {
  "callback" : "http://XXXX.com/apitesting/bc-api/callback.php?invoice_id=22&secret=XXXX",
  "calledAt" : 1510207257000,
  "responseCode" : 200,
  "rawResponse" : "Waiting for confirmations"
} ]

And that's it - never comes back to tell me how many confirmations or anything. Thoughts ?

Always Payment not received..

Hi, congratulations for this good work.
I´m writing to ask, i recently testing the receive_payment_php_demo i saw it in bloackchain.

I put it in my PC, inside /var/www/ (linux debian) doing a git clone, i´ve setup a dyndns account to manage a domain name, change the name of directory from /var/www/receive_payment_php_demo to other name, short, chmod -R 755 the directory, so i write my conf in the includes.php, run the setup.php in the browser and check it in mysql, all fine.

After that try myDomainName/pathToReceive_payment_php_demo/

show the invoice, i make the transfer for the $0.15 example, (from other wallet) and receive it in my wallet in blockchain.. but appear "payment not received" i see in blockchain and have more than 4 confirmations...

is there other conf tha i missed?
please Excuse my poor English

Very thanks. waiting for some help

Danilo

Payment not coming in main wallet v2 API

I am using blockchain receive payment v2 API for receiving payments https://blockchain.info/api/api_receive.

Every thing is working fine i.e Generate new Address,Callback etc. But new generated address not shows in my main wallet account. I make payment to generated addresses with v2 API. Payment paid successfully. confirmation received as well. But payment stuck in that address not coming to my main wallet.

I am getting private key of my address using this code in chrome console
Blockchain.MyWallet.wallet._getPrivateKey(0,"M/0/",100) and then transfer to my main wallet.

why not it's coming to my Main Wallet automatically. I am surprised about this. Anybody knows why it's not going to my main wallet when i receive payment from my client. Thanks

What is Secret key? How can i find our Secret and how to add secret Key in our php code

What is Secret key? How can i find our Secret and how to add secret Key in our php code

$mysite_root = "localhost/admin/blockchain";
$secret = "SECRET-KEY";
$my_xpub = "xpub6CKJvsdvsdvsdvT8FA64vsdHXdnvsdmKxsdvsdP6gpDiEWPENPgjzpG";
$my_api_key = "dvsDFFEFvfffffffzezfsefsfvr";

Getting this Error:(Due to invalid Secret)
failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request

API Key request

I have requested for API Key for months now, but no response yet from blockchain.
I tried to make another request but got a message "Error Request already present. "
How I get an API key

Handle partial payments

Right now we have no mechanism for handling partial payments. Those can and do happen in the wild, so it would be good to have sample code to handle those in the samples.

Number of addresses must be between 1 and 30000

I am using Blockchain.com Receive Payments API V2 with my xPub to receive payments from customers.

My wallets balances no longer shows in my account. I am unable to generate new receive addresses for the existing wallets unless i archive them and create a new wallet. From settings (https://login.blockchain.com/en/#/settings/addresses/btc), I see the error message: {here is an issue with the wallet and this page may have limited functionality, such as balances not showing. Message: Number of addresses must be between 1 and 30000. Is 30122}.
Screen Shot 2019-11-30 at 2 54 54 PM

The issue is It appears i have hit my blockchain wallet threshold (maximum number of bitcoin addresses) of 30,000 addresses. This limit I never previously knew about until i experienced it for the first time.

When I realised it for the first time, the trick i started using is to always keep an additional (secondary) wallet with few addresses (about 100 - 500 used addresses) whiles i use the main (primary) wallet should in case I hit my overall blockchain bitcoin wallet addresses limit of the 30000. In case i hit my limit all i needed to do is to archive the secondary wallet to free up addresses space so I can get my funds from the primary one since there will still be a number of free space left after archiving the secondary wallet (about 100 - 500 used addresses). When am done recovering my funds, I archive that primary one and create a new wallet and make the new wallet a primary one and then I unarchive the secondary one (about 100 - 500 used addresses). However I made a mistake one day and I forgot to unarchive the secondary wallet (about 100 - 500 used addresses) after I recovered my funds and kept using the new primary one I had created without the secondary wallet unarchived and since then i have never been able to recover from this. I still have quite some amount of bitcoins still held up in this account waiting for a solution.

I contacted Blockchain.com support center (via tickets) multiple times and i never got a working solution after waiting for a response sometimes 2 months or more from them.

Can anyone be of help?

BUG REPORT: Gap limit is not counted correctly

Hi,
I'm seeing an issue where calls to the /v2/receive API are reaching the gap limit even though there are incoming payments to most or all of the generated addresses. I believe a recent change broke how the gap limit is counted and this means that all xpubs became limited to 20 total transactions.

Any help/feedback would be appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.