'Updated Transaction', 'message' => 'You have successfully updated a transaction' ]; } /** @var FetchesCompany */ private $fetchesCompany; /** @var FetchesTransaction */ private $fetchesTransaction; /** @var UpdatesTransactionStatus */ private $updatesTransactionStatus; /** @var DeletesDocument */ private $deletesDocument; /** @var CreditWalletProcessor */ private $creditWalletProcessor; /** * CreatePaymentVerificationDocumentLogic constructor. * @param FetchesCompany $fetchesCompany * @param FetchesTransaction $fetchesTransaction * @param UpdatesTransactionStatus $updatesTransactionStatus * @param DeletesDocument $deletesDocument * @param CreditWalletProcessor $creditWalletProcessor */ public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, DeletesDocument $deletesDocument, CreditWalletProcessor $creditWalletProcessor) { $this->fetchesCompany = $fetchesCompany; $this->fetchesTransaction = $fetchesTransaction; $this->updatesTransactionStatus = $updatesTransactionStatus; $this->deletesDocument = $deletesDocument; $this->creditWalletProcessor = $creditWalletProcessor; } /** * @param Request $request * @return JsonResponse * @throws \App\Classes\Exceptions\MalformedRequestException */ public function logic(Request $request) : JsonResponse { $transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]); $transaction = $this->updatesTransactionStatus->execute($transaction, $request->input('status')); $booking = $transaction->owner->owner; $reference = 'Credit Voucher for Overpaid for Ref. '.$booking->marking; if ($transaction->status == ApprovalStatus::APPROVED) { $this->creditWalletProcessor->execute($booking->company, $transaction->type, $transaction->amount, $reference); } return $this->response([]); } }