Fix billplz transaction summary not working
This commit is contained in:
@@ -12,14 +12,17 @@ class BillplzController extends Controller
|
|||||||
public function __invoke(Request $request)
|
public function __invoke(Request $request)
|
||||||
{
|
{
|
||||||
$companyMapping = [
|
$companyMapping = [
|
||||||
CompanyStatus::COM_PKB,
|
'PKB',
|
||||||
// CompanyStatus::COM_KOOPPKB,
|
'KOPKB',
|
||||||
];
|
];
|
||||||
|
|
||||||
$bills = array_map(function($company_code) use($request){
|
$bills = array_map(function($company_code) use($request){
|
||||||
$billplzService = new BillplzService($company_code);
|
$billplzService = new BillplzService($company_code);
|
||||||
$billIdArray = json_decode($request->bill_ids);
|
$billIdArray = json_decode($request->bill_ids);
|
||||||
return $billplzService->getBills($billIdArray);
|
$billIdArray = $billplzService->getBills($billIdArray);
|
||||||
|
return array_filter($billIdArray, function($bill) {
|
||||||
|
return $bill !== [];
|
||||||
|
});
|
||||||
}, $companyMapping);
|
}, $companyMapping);
|
||||||
|
|
||||||
return array_merge(...$bills);
|
return array_merge(...$bills);
|
||||||
|
|||||||
@@ -267,7 +267,13 @@ class BillplzService
|
|||||||
|
|
||||||
public function getBills($billIds)
|
public function getBills($billIds)
|
||||||
{
|
{
|
||||||
return array_map(fn($x) => $this->client->bill()->get($x)->toArray(), $billIds);
|
return array_map(function($x){
|
||||||
|
try{
|
||||||
|
return $this->client->bill()->get($x)->toArray();
|
||||||
|
}catch(\Exception $e){
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}, $billIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setupBillplzClient($company)
|
protected function setupBillplzClient($company)
|
||||||
|
|||||||
Reference in New Issue
Block a user