/** * * @return true * @author **/ public function handlingnotif() { // Set our server key Veritrans_Config::$serverKey = env('VERITRANS_KEY', 'VT_KEY'); // Uncomment for production environment Veritrans_Config::$isProduction = env('VERITRANS_PRODUCTION', false); $waiting_transaction = Sale::status('payment_process')->get(); foreach ($waiting_transaction as $key => $value) { $notif = new Veritrans_Notification(['transaction_id' => $value['ref_number']]); $transaction = $notif->transaction_status; if ($transaction == 'settlement') { $paid_data = new \App\Models\Payment(); $payment['transaction_id'] = $value['id']; $payment['method'] = $notif->payment_type; $payment['destination'] = 'Veritrans'; $payment['account_name'] = $notif->masked_card; $payment['account_number'] = $notif->approval_code; $payment['ondate'] = \Carbon\Carbon::parse($notif->transaction_time)->format('Y-m-d H:i:s'); $payment['amount'] = $notif->gross_amount; $paid_data = $paid_data->fill($payment); if (!$paid_data->save()) { \Log::error(json_encode($paid_data)); return false; } } } return true; }