app/Http/Controllers/TransactionController.php
/**
     * Store a newly created resource in storage.
     *
     * @param \App\Http\Requests\StoreTransactionRequest $request
     * @return TransactionResource
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(StoreTransactionRequest $request)
    {
        $transactionType = $request->transaction_type;
        DB::beginTransaction();
        try {
            if ($transactionType == 0) {
                $transaction = TransactionServices::paymentTransaction(
                    $request
                );
            } else {
                abort(422, "Transaction not supported at the moment.");
            }
            DB::commit();
            return new TransactionResource(
                Transaction::with(["bill", "account.contact"])->find(
                    $transaction->id
                )
            );
        } catch (\Exception $exception) {
            DB::rollback();
            return Helper::exceptionJSON($exception, 422, "transaction");
        }
    }
public function store ( StoreTransactionRequest $ request ) { $ transactionType = $ request -> transaction_type ; DB :: beginTransaction ( ) ; try { if ( $ transactionType == 0 ) { $ transaction = TransactionServices :: paymentTransaction ( $ request ) ; } else { abort ( 422 , " Transaction not supported at the moment. " ) ; } DB :: commit ( ) ; return new TransactionResource ( Transaction :: with ( [ " bill " , " account.contact " ] ) -> find ( $ transaction -> id ) ) ; } catch ( \ Exception $ exception ) { DB :: rollback ( ) ; return Helper :: exceptionJSON ( $ exception , 422 , " transaction " ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .
//payment request // TODO refund to be implemented