我正在尝试整合硬币支付。通过使用此-https://github.com/hexters/CoinPayment
但是我说错了
例外:“ ErrorException” 文件:“ C:\ xampp \ htdocs \ coinpayment \ vendor \ hexters \ coinpayment \ src \ Http \ Controllers \ CoinPaymentController.php” 线:45 消息:“被零除”
答案 0 :(得分:1)
在更新包https://github.com/hexters/CoinPayment/commit/cf7de99e18948fe385e75dfa8ded0fb378c33ad4
时,请参考git存储库中的作者新提交。如果链接不起作用,则转到您的应用程序路径,然后转到vendor文件夹,并遵循vendor / hexters / coinpayment / src / Http / Controllers路径,并使用以下内容更新CoinPaymentController.php文件的公共函数ajax_rates()函数给定代码
public function ajax_rates(Request $req, $usd){
$coins = [];
$aliases = [];
$rates = CoinPayment::api_call('rates', [
'accepted' => 1
])['result'];
$rateBtc = $rates['BTC']['rate_btc'];
$rateUsd = $rates[config('coinpayment.default_currency')]['rate_btc'];
$rateAmount = $rateUsd * $usd;
$fiat = [];
$coins_accept = [];
foreach($rates as $i => $coin){
if((FLOAT) $rates[$i]['rate_btc'] > 0) {
if((INT) $coin['is_fiat'] === 0){
$rate = ($rateAmount / $rates[$i]['rate_btc']);
$coins[] = [
'name' => $coin['name'],
'rate' => number_format($rate,8,'.',''),
'iso' => $i,
'icon' => 'https://www.coinpayments.net/images/coins/' . $i . '.png',
'selected' => $i == 'BTC' ? true : false,
'accepted' => $coin['accepted']
];
$aliases[$i] = $coin['name'];
}
if((INT) $coin['is_fiat'] === 0 && $coin['accepted'] == 1){
$rate = ($rateAmount / $rates[$i]['rate_btc']);
$coins_accept[] = [
'name' => $coin['name'],
'rate' => number_format($rate,8,'.',''),
'iso' => $i,
'icon' => 'https://www.coinpayments.net/images/coins/' . $i . '.png',
'selected' => $i == 'BTC' ? true : false,
'accepted' => $coin['accepted']
];
}
if((INT) $coin['is_fiat'] === 1){
$fiat[$i] = $coin;
}
}
}
return response()->json([
'coins' => $coins,
'coins_accept' => $coins_accept,
'aliases' => $aliases,
'fiats' =>$fiat
]);
}