1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Switch to HTTP facade

This commit is contained in:
David Bomba 2024-09-16 09:30:05 +10:00
parent 3cfffa09c4
commit 2464556ef2
4 changed files with 7 additions and 26 deletions

View File

@ -23,6 +23,7 @@ use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
use App\Exceptions\PaymentFailed;
use App\Jobs\Util\SystemLogger;
use App\Jobs\Mail\PaymentFailureMailer;
use Illuminate\Support\Facades\Http;
class Blockonomics implements MethodInterface
{
@ -55,32 +56,14 @@ class Blockonomics implements MethodInterface
// TODO: remove ?reset=1 before marking PR as ready
$url = 'https://www.blockonomics.co/api/new_address?reset=1';
$ch = curl_init();
$r = Http::withToken($api_key)
->post($url, []);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
if($r->successful())
return $r->object()->address ?? 'Something went wrong';
$header = "Authorization: Bearer " . $api_key;
$headers = array();
$headers[] = $header;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
return $r->object()->message ?? 'Something went wrong';
$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()

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -240,7 +240,7 @@
"src": "resources/js/setup/setup.js"
},
"resources/sass/app.scss": {
"file": "assets/app-039bd735.css",
"file": "assets/app-61bfe239.css",
"isEntry": true,
"src": "resources/sass/app.scss"
}