我想在我的网站中集成区块链我是从开发人员开发的。 problemm是区块链将输入的金额转换为usd。意思是如果我想在我的网络账户上存入0.001 btc它显示0.00000006btc平均价格0.001美元。请告诉我如何解决它在btc中显示金额的问题,不要把它转换成usd。我的Blockchain preivew代码如下所列。
public function btcPreview(Request $request)
{
$data['amount'] = $request->amount;
$data['charge'] = $request->charge;
$data['transaction_id'] = $request->transaction_id;
$pay = Payment::first();
$tran = FundLog::whereTransaction_id($data['transaction_id'])->first();
$blockchain_root = "https://blockchain.info/";
$blockchain_receive_root = "https://api.blockchain.info/";
$mysite_root = url('/');
$secret = "ABIR";
$my_xpub = $pay->btc_xpub;
$my_api_key = $pay->btc_api;
$am = $data['amount'];
$invoice_id = $tran->transaction_id;
$callback_url = route('btc_ipn',['invoice_id'=>$invoice_id,'secret'=>$secret]);
if ($tran->btc_acc == null){
$resp = file_get_contents($blockchain_receive_root . "v2/receive?key=" . $my_api_key . '&callback=' . urlencode($callback_url) . '&xpub=' . $my_xpub);
$response = json_decode($resp);
$sendto = $response->address;
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();
}else{
session()->flash('message', "SOME ISSUE WITH API");
Session::flash('type', 'warning');
return redirect()->back();
}
}else{
$usd = $tran->btc_amo;
$sendto = $tran->btc_acc;
}
/*$sendto = "1HoPiJqnHoqwM8NthJu86hhADR5oWN8qG7";
$usd =100;*/
/*if ($tran->btc_acc == null){
if (file_exists($blockchain_receive_root . "v2/receive?key=" . $my_api_key . '&callback=' . urlencode($callback_url) . '&xpub=' . $my_xpub)) {
$resp = file_get_contents($blockchain_receive_root . "v2/receive?key=" . $my_api_key . '&callback=' . urlencode($callback_url) . '&xpub=' . $my_xpub);
$response = json_decode($resp);
$sendto = $response->address;
$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();
}else{
session()->flash('message', 'BlockChain API or XPUB not Correct.');
Session::flash('type', 'warning');
Session::flash('title', 'Opps');
return redirect()->back();
}
}else{
$usd = $tran->btc_amo;
$sendto = $tran->btc_acc;
}*/
/*$sendto = "1HoPiJqnHoqwM8NthJu86hhADR5oWN8qG7";
$usd =100;*/
$var = "bitcoin:$sendto?amount=$usd";
$data['code'] = "<img src=\"https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=$var&choe=UTF-8\" title='' style='width:300px;' />";
$data['general'] = GeneralSetting::first();
$data['site_title'] = $data['general']->title;
$data['basic'] = BasicSetting::first();
$data['page_title'] = "BTC Send Preview";
$data['payment_type'] = 3;
$data['payment'] = Payment::first();
$data['btc'] = $usd;
$data['add'] = $sendto;
$data['fund'] = $tran;
return view('user.btc-send',$data);
}