How to use Blockchain receive API without exchange rate

0 votes

i have integrated blockchain recieve api for blockchain payment gateway. but when i go to pay enter amount to add balance it converts that amount into usd

i want to receive directly in BTC not in usd . when i remove below URL from my coding it gives error please help:

if ($sendto!="") {
                $api = "https://blockchain.info/tobtc?currency=USD&value=".$data['amount'];

                $usd = file_get_contents($api );
                $tran->btc_amo = $usd;
                $tran->btc_acc = $sendto;
                $tran->save();

Aug 17, 2018 in Blockchain by sabby
• 4,390 points
596 views

1 answer to this question.

0 votes

Your code contains the amount in USD in the first place. You can use the inverse of the original formula, like this:

const bitcoinrate;

function usd_to_btc($usd) {
    $btc = $usd * bitcoinrate;
}

Or maybe like the following line of code i found somehwere:

$one_usd_in_btc = https://blockchain.info/tobtc?currency=USD&value=1
$usd_to_btc     = $one_usd_in_btc * your_usd
answered Aug 21, 2018 by Perry
• 17,100 points

Related Questions In Blockchain

0 votes
1 answer

How do I use hyperledger fabric blockchain to build my own application?

To use fabric I would recommend you ...READ MORE

answered May 17, 2018 in Blockchain by Johnathon
• 9,090 points
914 views
0 votes
1 answer
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,706 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,740 points
44,007 views
0 votes
1 answer

Send Payment error in Blockchain API

The following code should help: $address = null; try ...READ MORE

answered Jul 6, 2018 in Blockchain by Perry
• 17,100 points
1,580 views
0 votes
1 answer

I want to use Blockchain receive API without exchange rate

You are not using receive API you are using Exchange ...READ MORE

answered Aug 1, 2018 in Blockchain by Perry
• 17,100 points
402 views
+1 vote
1 answer

Hyperledger - How can I use transaction certificates to enforce privacy?

The transaction certificates don't actually address privacy ...READ MORE

answered Apr 17, 2018 in Blockchain by Perry
• 17,100 points
674 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP