'Create Payment Transactions', 'message' => 'You have successfully created currency supplier transactions' ]; } /** @var FetchesTransaction */ private $fetchesTransaction; /** @var FetchesSegmentConstant */ private $fetchesSegmentConstant; /** @var GeneratesTransactionBillNumber */ private $generatesTransactionBillNumber; /** @var CreatesPaymentTransaction */ private $createsPaymentTransaction; /** @var CreatesBillplzBill */ private $createsBillplzBill; /** @var CreatesTransactionDetail */ private $createsTransactionDetail; public function __construct( FetchesTransaction $fetchesTransaction, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesPaymentTransaction $createsPaymentTransaction, CreatesTransactionDetail $createsTransactionDetail, CreatesBillplzBill $createsBillplzBill ) { $this->fetchesTransaction = $fetchesTransaction; $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; $this->createsPaymentTransaction = $createsPaymentTransaction; $this->createsTransactionDetail = $createsTransactionDetail; $this->createsBillplzBill = $createsBillplzBill; } public function logic(Request $request) : JsonResponse { $invoice_transaction = $this->fetchesTransaction->execute(['id' => $request->input('transaction_id')]); $amount = $request->input('amount'); $company_module = $invoice_transaction->owner()->first()->owner()->first()->companyModule()->first(); $billNumber = $this->generatesTransactionBillNumber->execute('PYMT-'); $payment_reference = null; if ($request->input('payment_method') == 5) { $payment_method = PaymentMethodType::PAYMENT_GATEWAY; $billPlzBill = $this->createsBillplzBill->execute( $company_module->name, (app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com', 'This payment is for the invoice number . ' . $invoice_transaction->bill_no, $amount, $billNumber, $request->input('bank_code'), true ); $payment_reference = $billPlzBill->id; } else { $payment_method = PaymentMethodType::CASH; } $object = new TransactionObject( $billNumber, TransactionType::PAYMENT, $company_module->id, 1, 1, $payment_method, $request->input('amount'), $request->input('amount'), 1, 1, 0, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, null, $payment_reference ); $payment_transaction = $this->createsPaymentTransaction->execute($invoice_transaction, $object); return $this->resourceResponse(new TransactionResource($payment_transaction)); } }