public function blocknotifyUpdateDeposit($wallet_type = '') { $blockhash = isset($_GET['trxhash']) ? $_GET['trxhash'] : 0; $logFile = 'laravel_' . $wallet_type . '.log'; Log::useDailyFiles(storage_path() . '/logs/callbackdeposits/' . $logFile); Log::info("*******New Blocknotify Update Deposit: " . $blockhash . " -- wallet_type: " . $wallet_type); Log::info("\n" . "-- wallet_type: " . $wallet_type); if ($wallet_type != '') { $wallet = Wallet::where('type', strtoupper($wallet_type))->first(); $wallet->connectJsonRPCclient($wallet->wallet_username, $wallet->wallet_password, $wallet->wallet_ip, $wallet->port); $limit_confirmations = empty($wallet->limit_confirmations) || $wallet->limit_confirmations <= 0 ? 3 : $wallet->limit_confirmations; $listtrans = $wallet->getListTransactions(); @Log::info("\n" . 'Result listtrans: ', $listtrans); $balance = new Balance(); foreach ($listtrans as $key => $value) { try { $transaction_id = $value['txid']; $trans = $wallet->getTransaction($transaction_id); if ($trans != null) { $account = $trans["details"][0]["account"]; $category = $trans["details"][0]["category"]; $confirms = $trans["confirmations"]; //send,receive $address_ = $trans["details"][0]["address"]; $amount = $trans["amount"]; Log::info("\n" . "transaction: ", $trans); Log::info("\n" . "------Account: " . $account . " -- category:" . $category . " --address: " . $address_); //mail("*****@*****.**", 'Deposit Cron: ', var_export($trans, true)); $deposit = Deposit::where('transaction_id', $transaction_id)->first(); $user = User::where('username', $account)->first(); if (isset($deposit->transaction_id)) { if ($deposit->paid == 0) { if ($category == "receive" && $confirms >= $limit_confirmations && isset($user->id)) { Deposit::where('id', $deposit->id)->update(array('paid' => 1, 'confirmations' => $confirms)); $balance->addMoney($amount, $wallet->id, $user->id); $message .= "<br>" . $amount . " " . $wallet->type . " was credited to your account"; Log::info("\n" . $amount . " " . $wallet->type . " was credited to your account"); } } else { Deposit::where('id', $deposit->id)->update(array('confirmations' => $confirms)); Log::info("\n" . $amount . " " . $wallet->type . " was already credited to your account. contact support if you need further assistance."); } } else { if ($category == "receive" && isset($user->id)) { if ($confirms >= $limit_confirmations) { Deposit::insert(array('user_id' => $user->id, 'wallet_id' => $wallet->id, 'transaction_id' => $transaction_id, 'amount' => $amount, 'paid' => 1, 'confirmations' => $confirms, 'address' => $address_, 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s'))); $balance->addMoney($amount, $wallet->id, $user->id); Log::info("\n" . $amount . " " . $wallet->type . " was credited to your account"); } else { Deposit::insert(array('user_id' => $user->id, 'wallet_id' => $wallet->id, 'transaction_id' => $transaction_id, 'amount' => $amount, 'paid' => 0, 'confirmations' => $confirms, 'address' => $address_, 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s'))); Log::info("\n" . "This Deposit is unconfirmed. Current confirmations:" . $confirms . ". Required : 3."); } } else { Log::info("\n" . "transaction is not a deposit or account is invalid."); } } } else { Log::info("\n" . "We can't find any information about this deposit. contact support."); } //trans } catch (Exception $e) { Log::info('Caught exception: ' . $e->getMessage() . "\n"); } } } else { Log::info('------------------- Error: not param wallet_type from _GET'); } Log::info("*******Stop New Blocknotify Update Deposit*************"); }