mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 19:04:41 -04:00
show btc_address
This commit is contained in:
parent
f3d12fb977
commit
2be83cb897
@ -52,6 +52,39 @@ class Blockonomics implements MethodInterface
|
||||
{
|
||||
}
|
||||
|
||||
public function getBTCAddress()
|
||||
{
|
||||
$api_key = $this->driver_class->api_key;
|
||||
$url = 'https://www.blockonomics.co/api/new_address';
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
|
||||
$header = "Authorization: Bearer " . $api_key;
|
||||
$headers = array();
|
||||
$headers[] = $header;
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
|
||||
$contents = curl_exec($ch);
|
||||
if (curl_errno($ch)) {
|
||||
echo "Error:" . curl_error($ch);
|
||||
}
|
||||
|
||||
$responseObj = json_decode($contents);
|
||||
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close ($ch);
|
||||
|
||||
if ($status == 200) {
|
||||
return $responseObj->address;
|
||||
} else {
|
||||
echo "ERROR: " . $status . ' ' . $responseObj->message;
|
||||
}
|
||||
return "Something went wrong";
|
||||
}
|
||||
|
||||
public function getBTCPrice()
|
||||
{
|
||||
$currency_code = $this->driver_class->client->getCurrencyCode();
|
||||
@ -70,6 +103,7 @@ class Blockonomics implements MethodInterface
|
||||
$data['currency'] = $this->driver_class->client->getCurrencyCode();
|
||||
$btc_amount = $data['amount'] / $this->getBTCPrice();
|
||||
$data['btc_amount'] = round($btc_amount, 10);
|
||||
$data['btc_address'] = $this->getBTCAddress();
|
||||
$data['invoice_id'] = $this->invoice_id;
|
||||
return render('gateways.blockonomics.pay', $data);
|
||||
}
|
||||
@ -81,7 +115,6 @@ class Blockonomics implements MethodInterface
|
||||
'payment_hash' => ['required'],
|
||||
'amount' => ['required'],
|
||||
'currency' => ['required'],
|
||||
'btc_amount' => ['required'],
|
||||
]);
|
||||
|
||||
$drv = $this->driver_class;
|
||||
|
@ -9,7 +9,7 @@
|
||||
<div>To pay, send exactly this BTC amount</div>
|
||||
<input name="btcAmount" value="BTC {{$btc_amount}} ≈ {{$amount}} {{$currency}}" readonly>
|
||||
<div>To this bitcoin address</div>
|
||||
<input name="btcAddress" value="WIP" readonly>
|
||||
<input name="btcAddress" value="{{$btc_address}}" readonly>
|
||||
|
||||
|
||||
<form action="{{ route('client.payments.response') }}" method="post" id="server-response">
|
||||
|
Loading…
x
Reference in New Issue
Block a user