app/Http/Controllers/GenericController.php
/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
Show the form for creating a new resource.
@return \Illuminate\Http\Response
Show the form for creating a new resource . @return \ Illuminate \ Http \ Response
public function callBack(Request $request)
    {
        $status = $request->status;
        $txn_ref = $request->tx_ref;
        $get_payment = Order::firstWhere('refrences', $txn_ref);
        if ($get_payment->refrences == $txn_ref) {
            if ($status == 'successful') {
                $get_payment->is_paid = true;
                $get_payment->save();
                $transaction = new Transactions();
                $transaction->txn_ref = $txn_ref;
                $transaction->amount_paid = $get_payment->product->unite_price * $get_payment->product_quantity;
                $transaction->order_id = $get_payment->id;
                $transaction->save();
                Mail::to($get_payment->customer_email)->send(new ConfirmedOrder($get_payment));
                return redirect()->route('paymentSuccess', $request->tx_ref);
            } elseif ($status == 'cancelled') {
                return redirect()->route('checkOutPage', $request->tx_ref)
                    ->with('warning', 'Hey!! ' . ', we are very sorry the payment was cancelled. You can click on the Make Payment button to try again or contact us for alternative means of payment. ');
            } else {
                return redirect()->route('checkOutPage', $request->tx_ref)
                    ->with('warning', 'Hey!! ' . ', looks like something might have interupted the payment process. Your transaction reference is ' . $get_payment->tx_ref);
            }
        } else {
            return redirect()->route('checkOutPage', $request->tx_ref)
                ->with('warning', 'Hey!! ' . 'this transaction have been manupulated some how. (transaction reference ' . $get_payment->tx_ref . ') Please contact the admin for support.');
        }
    }
public function callBack ( Request $ request ) { $ status = $ request -> status ; $ txn_ref = $ request -> tx_ref ; $ get_payment = Order :: firstWhere ( 'refrences' , $ txn_ref ) ; if ( $ get_payment -> refrences == $ txn_ref ) { if ( $ status == 'successful' ) { $ get_payment -> is_paid = true ; $ get_payment -> save ( ) ; $ transaction = new Transactions ( ) ; $ transaction -> txn_ref = $ txn_ref ; $ transaction -> amount_paid = $ get_payment -> product -> unite_price * $ get_payment -> product_quantity ; $ transaction -> order_id = $ get_payment -> id ; $ transaction -> save ( ) ; Mail :: to ( $ get_payment -> customer_email ) -> send ( new ConfirmedOrder ( $ get_payment ) ) ; return redirect ( ) -> route ( 'paymentSuccess' , $ request -> tx_ref ) ; } elseif ( $ status == 'cancelled' ) { return redirect ( ) -> route ( 'checkOutPage' , $ request -> tx_ref ) -> with ( 'warning' , 'Hey!! ' . ', we are very sorry the payment was cancelled. You can click on the Make Payment button to try again or contact us for alternative means of payment. ' ) ; } else { return redirect ( ) -> route ( 'checkOutPage' , $ request -> tx_ref ) -> with ( 'warning' , 'Hey!! ' . ', looks like something might have interupted the payment process. Your transaction reference is ' . $ get_payment -> tx_ref ) ; } } else { return redirect ( ) -> route ( 'checkOutPage' , $ request -> tx_ref ) -> with ( 'warning' , 'Hey!! ' . 'this transaction have been manupulated some how. (transaction reference ' . $ get_payment -> tx_ref . ') Please contact the admin for support.' ) ; } }
Show the form for creating a new resource.
Show the form for creating a new resource .
// save to trasaction history // publish to history // send user and admin an email // send a fund email to this customer