Support the ongoing development of Laravel.io →
API Routing Laravel
0

Please verify if your $gateway variable is initialized with the correct transaction object before using its properties.

xpdeal liked this reply

1

$gateway->charge is not object

check exist before use obj

like this if (!empty($gateway->charge))

0

Can you show me were you actually initialize the $gateway variable?

0

@faisal

` public function manualPaymentAccept(Request $request) { $booking = Payment::where('transaction_id', $request->trx)->firstOrFail(); $general = GeneralSetting::first(); $gateway = Gateway::where('gateway_name', 'bank')->first();

    $booking->payment_status = 1;
    $booking->save();

    refferMoney($booking->user_id, 'invest', $booking->amount);


    Transaction::create([
        'trx' => $booking->transaction_id,
        'gateway_id' => $booking->gateway_id,
        'amount' => $booking->amount,
        'currency' => $general->site_currency,
        'details' => 'Payment Successfull',
        'charge' => $gateway->charge,
        'type' => '-',
        'user_id' => $booking->user_id,
        'payment_status' => 1
    ]);`
Last updated 1 year ago.
0

I think there is no gateway created in the database with the name bank that's why you are receiving the error message.

The solution to your problem is to check the $gateway variable does not contain null value before using it or the other simple way is to use firstOrFail method instead of first method as shown below:

$gateway = Gateway::where('gateway_name', 'bank')->firstOrFail();

This way you will get a 404 page intead of the error.

0

@faisal

Thanks alot . i will do that

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Kanu Chisom kanusblog Joined 27 Feb 2023

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.