mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-21 13:33:57 +00:00
31 lines
838 B
PHP
31 lines
838 B
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Billplzs\Services;
|
|
|
|
use App\Classes\Exceptions\MalformedRequestException;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
class GetBillplzBill
|
|
{
|
|
|
|
/**
|
|
* @param string $billPlzId
|
|
* @return null|object
|
|
* @throws MalformedRequestException
|
|
*/
|
|
public function execute(string $billPlzId) {
|
|
try{
|
|
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$billPlzId);
|
|
|
|
if($response->successful()){
|
|
$data = $response->json();
|
|
|
|
return (object) $data;
|
|
}else{
|
|
return null;
|
|
}
|
|
}catch(\Exception $exception){
|
|
throw new MalformedRequestException('Unable to get correct response from billplz server');
|
|
}
|
|
}
|
|
} |