where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->get(); $i = 0; $totalAmount = 0; foreach ($transactions as $transaction){ $response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference); // dd($response); // dd($transaction->owner->owner->owner->reference); if($response->successful()){ $data = $response->json(); if($data['paid']){ if (!in_array($transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) { $this->returnLog('Paid transaction', $transaction); } } // else { // $totalAmount += $transaction->amount; // $this->returnLog('Unpaid Transaction', $transaction); // } }else{ $this->returnLog('billplz error', $transaction); } } } public function returnLog($text, $transaction) { $approvalStatusArray = ApprovalStatus::APPROVAL_STATUS_ID; $this->info($text . ' - id: '. $transaction->id . '. Order Marking: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . '. Current Status: ' . $approvalStatusArray[$transaction->status]); } }