From 1e7060c111169daaef84dea4320463b0872a0ece Mon Sep 17 00:00:00 2001 From: "WAKOYA_KUMSA\\waqo1" Date: Wed, 28 Dec 2022 19:05:14 +0300 Subject: [PATCH] cleanup the code --- .../multipleInvoicesWithOnePaymentLogic.php | 10 ++--- .../MultipleInvoiceOnePaymentController.php | 40 ------------------- routes/invoice.php | 9 ----- 3 files changed, 5 insertions(+), 54 deletions(-) diff --git a/app/Classes/Modules/Transactions/ControllersLogic/multipleInvoicesWithOnePaymentLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/multipleInvoicesWithOnePaymentLogic.php index 87b8531a..81d11476 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/multipleInvoicesWithOnePaymentLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/multipleInvoicesWithOnePaymentLogic.php @@ -138,11 +138,9 @@ class multipleInvoicesWithOnePaymentLogic extends AbstractControllerLogic public function logic( $transactionsArray) : JsonResponse { - // dd($request); + try { - - // dd(json_decode($transactionsArray)); $transactions = Transaction::whereIn('id', json_decode($transactionsArray))->where('type', TransactionType::SHIPPING_INVOICE)->get(); $total = $transactions->sum('amount'); $packingList =$transactions[1]->owner; @@ -166,8 +164,7 @@ class multipleInvoicesWithOnePaymentLogic extends AbstractControllerLogic $transaction_object = new TransactionObject($billNumber, TransactionType::TOP_UP, 1, $company->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $total, $total, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], 'test'); - // $transaction = $this->createsTransaction->execute($wallet, $transaction_object); - + $transaction = (App()->make(CreatesTransaction::class))->execute($wallet, $transaction_object); $result= (App()->make(UpdatesWalletBalance::class))->execute($wallet, $total); @@ -175,6 +172,9 @@ class multipleInvoicesWithOnePaymentLogic extends AbstractControllerLogic multipleInvoicesWithOnePayment::create([ 'topUp_request_id' => $transaction->id, 'transaction_id' => $value->id ]); } + + // payment gateway api call + return $this->response([]); ; diff --git a/app/Http/Controllers/Transactions/MultipleInvoiceOnePaymentController.php b/app/Http/Controllers/Transactions/MultipleInvoiceOnePaymentController.php index d317c10b..889b8d96 100644 --- a/app/Http/Controllers/Transactions/MultipleInvoiceOnePaymentController.php +++ b/app/Http/Controllers/Transactions/MultipleInvoiceOnePaymentController.php @@ -33,46 +33,6 @@ class MultipleInvoiceOnePaymentController extends Controller return $logic->logic($transactionsArray); } - public function getallivoiceid( $transactionsArray) - { - - - $transactions = Transaction::whereIn('id', json_decode($transactionsArray))->where('type', TransactionType::SHIPPING_INVOICE)->get(); - $total = $transactions->sum('amount'); - $packingList =$transactions[1]->owner; - $order = $packingList->owner; - $companyModule = $order->companyModule; - $company = $companyModule->company; - $wallet = $company->wallets()->first(); - // dd(json_decode($transactionsArray)); - - if (!$wallet) { - $object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute()); - /** @var Wallet $wallet */ - $wallet = $this->createsWallet->execute($object, $company); - } - - $billNumber = (App()->make(GeneratesTransactionBillNumber::class))->execute('TOPUP-'); - - if($total < 0) { - throw new MalformedRequestException('Top up credit value must be greater than zero.'); - } - $billPlzBill = (App()->make(CreatesBillplzBill::class))->execute($company->name, 'example@gmail.com', 'This payment is credit topup for company ref. ' . $company->reference, $total, $billNumber, 'bank code', true); - - - $transaction_object = new TransactionObject($billNumber, TransactionType::TOP_UP, 1, $company->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $total, $total, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], 'test'); - - // $transaction = $this->createsTransaction->execute($wallet, $transaction_object); - - $transaction = (App()->make(CreatesTransaction::class))->execute($wallet, $transaction_object); - $result= (App()->make(UpdatesWalletBalance::class))->execute($wallet, $total); - - foreach ($transactions as $key => $value) { - multipleInvoicesWithOnePayment::create([ 'topUp_request_id' => $transaction->id, 'transaction_id' => $value->id ]); - - } - dd($transaction->id); - } } diff --git a/routes/invoice.php b/routes/invoice.php index 94d68aae..f1d918b4 100644 --- a/routes/invoice.php +++ b/routes/invoice.php @@ -7,12 +7,3 @@ use Illuminate\Support\Facades\Route; Route::get('/group/paymenttransaction/{transactionsArray?}', 'Transactions\MultipleInvoiceOnePaymentController@getallivoiceid')->name('grouppayment'); - // Route::get('/refresh', 'RefreshAuthenticationTokenController@refresh')->name('refresh'); - - Route::get('/testgrouppayment', function () { - - $ids = array(1,2,9); - - - return redirect()->route('api.grouppayment',['transactionsArray' => json_encode($ids)]); - }); \ No newline at end of file