Bitcoin Forum
June 16, 2024, 03:13:07 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: blockchain.info receive payments API problem  (Read 6743 times)
Daily Anarchist (OP)
Hero Member
*****
Offline Offline

Activity: 614
Merit: 500



View Profile WWW
November 18, 2012, 04:05:00 AM
 #1

I currently have a donation page on my website here:

http://dailyanarchist.com/contribute/

It's using a static address and it looks hokey. Needless to say the donate bitcoin button javascript offered by blockchain.info is pretty badass. So, I tried to implement it. But I ran into problems.

First thing I did was copy this:

Code:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript" src="https://blockchain.info//Resources/wallet/pay-now-button.js"></script>

into my header.php. That's where my head tag is.

Then I went into my word press page that allows me to put in HTML in to the contributor page I have set up. So, I copied this:
Code:
[code]<div style="font-size:16px;margin:10px;width:300px" class="blockchain-btn"
     data-address="1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq"
     data-anonymous="false"
     data-callback="https://mydomain.com/callback_url">
    <div class="blockchain stage-begin">
        <img src="https://blockchain.info//Resources/buttons/pay_now_64.png">
    </div>
    <div class="blockchain stage-loading" style="text-align:center">
        <img src="https://blockchain.info//Resources/loading-large.gif">
    </div>
    <div class="blockchain stage-ready">
        Please send payment to bitcoin address <b>[[address]]</b>
    </div>
    <div class="blockchain stage-paid">
        Payment Received <b>[[value]] BTC</b>. Thank You.
    </div>
    <div class="blockchain stage-error">
        <font color="red">[[error]]</font>
    </div>
</div>
[/code]

Then I modified the data-address to one of my own. I also toggled the false to true and I removed the callback command since it's just a donation button.

Then I previewd the changes and I got the pay now button, with other problems. No problem. With a little playing around I switched the .png to the donate bitcoin .png. Then I previewed again. For some reason the div style, class, address etc were appearing in plain text. Long story short: I'm still having difficulties. I got it to show the right donation image, but when I click the button it gives me an error code. Is there something I'm missing? Also, is there a .js for the donate bitcoin? Because what is offered looks like it's pay with bitcoin specific javascript.

Discover anarcho-capitalism today!
Crypt_Current
Hero Member
*****
Offline Offline

Activity: 686
Merit: 500


Shame on everything; regret nothing.


View Profile
November 20, 2012, 08:15:05 PM
 #2

what browser are you using to test the code?

10% off at CampBX for LIFE:  https://campbx.com/main.php?r=C9a5izBQ5vq  ----  Authorized BitVoucher MEGA reseller (& BTC donations appreciated):  https://bitvoucher.co/affl/1HkvK8o8WWDpCTSQGnek7DH9gT1LWeV5s3/
LTC:  LRL6vb6XBRrEEifB73DiEiYZ9vbRy99H41  NMC:  NGb2spdTGpWj8THCPyCainaXenwDhAW1ZT
Daily Anarchist (OP)
Hero Member
*****
Offline Offline

Activity: 614
Merit: 500



View Profile WWW
November 20, 2012, 08:17:23 PM
 #3

what browser are you using to test the code?

FF 16.0.2

Discover anarcho-capitalism today!
Nyhm
Full Member
***
Offline Offline

Activity: 216
Merit: 100



View Profile WWW
November 21, 2012, 02:51:43 PM
 #4

I was just trying to integrate blockchain.info receive payments as well, and discovered this same problem: "Unknown Error" when you click their JS button. Even the buttons on their own page fail the same way: http://blockchain.info/api/api_receive

I'm also in FF 16.0.2. I tested with jQuery 1.7.1, 1.8.0, and 1.8.2. jQuery 1.7.x does not work at all. The 1.8.x fail with "Unknown Error".

I read the JS and it appears to be constructing a valid URL to the receive api. Constructing my own URL (https://blockchain.info/api/receive?method=create&address...) woks fine and a JSON object is returned, which appears to have the input_address field the JS is expecting.

The failure is that the "response" variable is not set after the URL call in the JS code. I have no further information why.

I hope this helps someone identify the issue. Thanks for any feedback. In the meantime, maybe I'll just implement a non-JS approach.

[Bitcoin Game List] ~ [BitcoinGalaxy.net Live Bitcoin Visualization] ~ [PotentialGames.com]
Daily Anarchist (OP)
Hero Member
*****
Offline Offline

Activity: 614
Merit: 500



View Profile WWW
November 22, 2012, 03:55:10 AM
 #5

Well, I thought I had figured it out. I realized that I had two instances of script linking to the jquery library, and older version and the newer version. I thought, and hoped, that that was the problem. So, I removed the instance of the older jquery library( and edited all of the links in my website to the newer library) but it didn't fix anything. I still get errors.

Now, when I load the page I get plain text of data address and data anonymous and then below that is the donate image. But when I click on the donate image I get this:

data-address="1JoyZBGXKdSSeTpLHMLGTSLUDKbLLjWqjt"
data-anonymous="true">
Error Invalid Destination Bitcoin Address

Discover anarcho-capitalism today!
piuk
Hero Member
*****
Offline Offline

Activity: 910
Merit: 1005



View Profile WWW
November 23, 2012, 11:24:54 AM
 #6

Well, I thought I had figured it out. I realized that I had two instances of script linking to the jquery library, and older version and the newer version. I thought, and hoped, that that was the problem. So, I removed the instance of the older jquery library( and edited all of the links in my website to the newer library) but it didn't fix anything. I still get errors.

Now, when I load the page I get plain text of data address and data anonymous and then below that is the donate image. But when I click on the donate image I get this:

data-address="1JoyZBGXKdSSeTpLHMLGTSLUDKbLLjWqjt"
data-anonymous="true">
Error Invalid Destination Bitcoin Address

What browsers are you using? Clicking the Donation button on may be easier than using the API docs  http://blockchain.info/address/1JoyZBGXKdSSeTpLHMLGTSLUDKbLLjWqjt

Nyhm
Full Member
***
Offline Offline

Activity: 216
Merit: 100



View Profile WWW
November 23, 2012, 02:59:33 PM
Last edit: November 23, 2012, 03:21:19 PM by Nyhm
 #7

Well, I thought I had figured it out. I realized that I had two instances of script linking to the jquery library, and older version and the newer version. I thought, and hoped, that that was the problem. So, I removed the instance of the older jquery library( and edited all of the links in my website to the newer library) but it didn't fix anything. I still get errors.

Now, when I load the page I get plain text of data address and data anonymous and then below that is the donate image. But when I click on the donate image I get this:

data-address="1JoyZBGXKdSSeTpLHMLGTSLUDKbLLjWqjt"
data-anonymous="true">
Error Invalid Destination Bitcoin Address

What browsers are you using? Clicking the Donation button on may be easier than using the API docs  http://blockchain.info/address/1JoyZBGXKdSSeTpLHMLGTSLUDKbLLjWqjt


Two of us reported FF 16.0.2 above. Today I'm running FF 17.0 with the same problem. There are two sample buttons on the API docs page that fail this way: http://blockchain.info/api/api_receive

Update: The buttons work in Chrome! Thanks for your attention to this.

UPDATE: I just noticed that it works now in FF! I look forward to hearing the fix. Thanks!

[Bitcoin Game List] ~ [BitcoinGalaxy.net Live Bitcoin Visualization] ~ [PotentialGames.com]
Daily Anarchist (OP)
Hero Member
*****
Offline Offline

Activity: 614
Merit: 500



View Profile WWW
November 23, 2012, 07:41:49 PM
 #8

Nope. I'm still getting the same problem. Even after using the code from the donate button instead of just manually editing it, it still fails.

The real potential problem I see is that I'm using this code:

Code:
<script type="text/javascript" src="https://blockchain.info//Resources/wallet/pay-now-button.js"></script>

For a donate button. Shouldn't there be some unique javascript for a donate button. Or are we really just using the same javascript for a donate button as the pay now button?

Discover anarcho-capitalism today!
Daily Anarchist (OP)
Hero Member
*****
Offline Offline

Activity: 614
Merit: 500



View Profile WWW
November 23, 2012, 10:05:58 PM
 #9

Okay, I've fixed half of my problems. My stupid page editor for Wordpress was inserting
Code:
<br />
breaks in places it shouldn't have, and causing errors.

After removing those breaks the button now works. However, the QR code is not showing up. It gives me a new address, which is nice, but not the QR part, which is essential.

Also, when setting the anonymous address to "true," I still don't see how it's that anonymous if any old bloke can just view the page source and see the final address that the donation will be going to. Any way to conceal that a little better?

Discover anarcho-capitalism today!
Nyhm
Full Member
***
Offline Offline

Activity: 216
Merit: 100



View Profile WWW
November 25, 2012, 02:10:52 PM
 #10

WordPress: I use the TRUEedit WordPress plugin (prevents WP from editing your page code).

QR Code: The documentation for blockchain.info's receive API is a bit lacking. The PHP example code includes the following, which gets turned into the QR code:

Code:
<p align="center" class="qr-code"></p>

Anonymous: I don't think the anonymous feature works the way you want. I think it's meant for you to receive an anonymous payment, rather than the sender paying to an anonymous address. However, that doesn't seem very useful... not sure what their intent is.

BTW, I decided to scrap the JS button code and implemented my own PHP processing. It still calls the blockchain.info API to create addresses and set the callback, but it does not rely on any JS. All the logic is server-side.

[Bitcoin Game List] ~ [BitcoinGalaxy.net Live Bitcoin Visualization] ~ [PotentialGames.com]
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!