!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/sms.picotech.app/public_html/Modules/PaymentGateway/Http/Controllers/   drwxr-xr-x
Free 28.6 GB of 117.98 GB (24.24%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     PaymentGatewayController.php (35.31 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

namespace Modules\PaymentGateway\Http\Controllers;

use 
App\Events\SendMail;
use 
App\Models\BillingRequest;
use 
App\Models\Customer;
use 
App\Models\CustomerPlan;
use 
App\Models\Domain;
use 
App\Models\EmailTemplate;
use 
App\Models\Plan;
use 
App\Models\Report;
use 
App\Models\TopUpRequest;
use 
App\Models\Transactions;
use 
Illuminate\Http\Request;
use 
Illuminate\Routing\Controller;
use 
Illuminate\Support\Carbon;
use 
Illuminate\Support\Facades\DB;
use 
Illuminate\Support\Facades\Log;
use 
Modules\PaymentGateway\PaymentGatewayProvider\ProcessPayment;
use 
Modules\PaymentGateway\Services\PaymentCredentials;
use 
Omnipay\Omnipay;
use 
PayPal\Api\Payment;
use 
paytm\paytmchecksum\PaytmChecksum;

class 
PaymentGatewayController extends Controller
{
    public function 
index()
    {
        return 
view('paymentgateway::index');
    }

    public function 
email_payment_process(Request $request)
    {
        
$data['plan'] = Plan::find($request->id);

        return 
view('customer.default_plan_submit_form',$data);
    }

    public function 
process(Request $request)
    {
        
$customer=auth('customer')->user();        
        
$planReq BillingRequest::where(['plan_id'=>$request->id,'customer_id'=> $customer->id])->where('status''pending')->first();
        if(
$customer->plan &&  $planReq){
            
$data['plan'] = Plan::find($planReq->plan_id);
            return 
redirect()->back()->withErrors(['fail'=> 'You already have a pending request with this plan. Please wait for the approval or upgrade to a new plan']);
        }else{
            
$data['plan'] = Plan::find($request->id);
            return 
view('paymentgateway::process'$data);
        }

    }

    public function 
payNow(Request $request)
    {

        try{
        if (
env("APP_DEMO")){
            return 
redirect()->route('customer.billing.index')->withErrors(['msg' => trans('admin.app_demo_message')]);
        }
        
$plan Plan::find($request->plan);
        if (!
$plan) return redirect()->route('customer.billing.index')->withErrors(['msg' => trans('Plan not found')]);


            if (
$plan->price 0) {
//            $request->validate([
//                'payment_type' => 'required|in:paypal,card,offline,paytm,mollie,paystack'
//            ]);
            
}
            
$user auth('customer')->user();
            
$pre_plan $user->plan;

            if (isset(
$pre_plan) && $pre_plan->plan_id == $request->id && $pre_plan->expire_date now()) {
                return 
redirect()->route('customer.billing.index')->with('fail''You are already subscribed to this plan');
            }
            
BillingRequest::where('customer_id'$user->id)->where('plan_id','!=',$plan->id)->where('status''pending')->update(['status'=>'cancelled']);
            if (
$request->payment_type == 'offline') {
                
$preBilling BillingRequest::where(['plan_id'=>$plan->id,'customer_id' => $user->id'status' => 'pending'])->first();
                if (
$preBilling) {
                    return 
redirect()->route('customer.billing.index')->with('fail'trans('You already have a pending request. Please wait for the approval.'));
                }
            }
            if (
$request->transactionId) {
                
$transactionId $request->transactionId;
            } else {
                
$transactionId $request->transaction_id;
            }

            
$preBilling BillingRequest::where('customer_id'$user->id)->where('plan_id'$plan->id)->where('status''pending')->first();
            
$planReq $preBilling $preBilling : (new BillingRequest());
            
$planReq->admin_id $plan->admin_id;
            
$planReq->customer_id $user->id;
            
$planReq->plan_id $plan->id;
            
$planReq->other_info json_encode($request->only('payment_type'));
            
$planReq->transaction_id $transactionId;
            
$planReq->save();

            
//Transaction Report
            
$transaction= new Transactions();
            
$transaction->customer_id=$user->id;
            
$transaction->type='plan';
            
$transaction->added_by=auth('customer')->user()->type;
            
$transaction->amount=$request->credit?$request->credit:0;
            
$transaction->status='unpaid';
            
$transaction->transaction_id=$transactionId;
            
$transaction->ref_id=$planReq->id;
            
$transaction->save();

            
//        Customer Brand
            
$host $request->getHost();
            
$domain Domain::where('host'$host)->where('status''approved')->first();
            if (
$domain) {
                
$reseller Customer::find($domain->customer_id);
            }
            if (isset(
$reseller)) {
                
$mailSett $reseller->settings()->where('name''smtp_setting')->first();
                
$mailSett = isset($mailSett->value) ? json_decode($mailSett->value) : '';
                
$config = array(
                    
'driver' => 'smtp',
                    
'host' => $mailSett->host,
                    
'port' => $mailSett->port,
                    
'from' => array('address' => $mailSett->from'name' => $mailSett->name),
                    
'encryption' => $mailSett->encryption,
                    
'username' => $mailSett->username,
                    
'password' => $mailSett->password,
                );
                
$emailTemplate EmailTemplate::where('added_by'$reseller->type)->where('type''plan_request')->where('user_id'$reseller->id)->first();
                if (
$emailTemplate) {
                    
$regTemp str_replace('{customer_name}'$user->first_name ' ' $user->last_name$emailTemplate->body);
                    
SendMail::dispatch($user->email$emailTemplate->subject$regTemp$config);
                }
            } else {
                
$emailTemplate get_email_template('plan_request');
                if (
$emailTemplate) {
                    
$regTemp str_replace('{customer_name}'$user->first_name ' ' $user->last_name$emailTemplate->body);
                    
SendMail::dispatch($user->email$emailTemplate->subject$regTemp);
                }
            }


            if (
$plan->price <= 0) {
                
$planReq->status 'accepted';
                
$planReq->save();

                
$pre_plan $user->plan;
                if (
$pre_plan) {
                    
$pre_plan->update(['is_current' => 'no']);
                }
                if (
$plan->recurring_type == 'weekly') {
                    
$time \Illuminate\Support\Carbon::now()->addWeek();
                } else if (
$plan->recurring_type == 'monthly') {
                    
$time \Carbon\Carbon::now()->addMonth();
                } else if (
$plan->recurring_type == 'yearly') {
                    
$time Carbon::now()->addYear();
                } else if (
$plan->recurring_type == 'custom') {
                    
$date json_decode($plan->custom_date);
                    
$time = isset($date->from) ? new \DateTime($date->from) : '';
                }

                
$user->plan()->create([
                    
'is_current' => 'yes''price' => $plan->price'expire_date' => $time'plan_id' => $plan->id,
                    
'sms_sending_limit' => $plan->sms_sending_limit'max_contact' => $plan->max_contact'contact_group_limit' => $plan->contact_group_limit,
                    
'sms_unit_price' => $plan->sms_unit_price'free_sms_credit' => $plan->free_sms_credit'country' => $plan->country'coverage_ids' => $plan->coverage_ids,
                    
'api_availability' => $plan->api_availability'sender_id_verification' => $plan->sender_id_verification,
                    
'unlimited_sms_send' => $plan->unlimited_sms_send'unlimited_contact' => $plan->unlimited_contact'unlimited_contact_group' => $plan->unlimited_contact_group
                
]);


                return 
redirect()->route('customer.billing.index')->with('success'trans('Congratulations! Your plan successfully changed'));
            }

            if (!
in_array($request->payment_type, ['flutterwave''vogue_pay''offline''coinpay'])) {
                
$processPayment = new ProcessPayment();
                
$processResult $processPayment->set_gateway($request->payment_type)
                    ->
set_plan($plan)
                    ->
plan_request($planReq)
                    ->
request($request)
                    ->
process();
                if (
$processResult->error_message) {
                    return 
redirect()->route('customer.billing.index')->withErrors(['failed' => $processResult->error_message]);
                }

                if (
$processResult->return_view) {
                    return 
$processResult->return_view;
                } elseif (
$processResult->will_redirect && $processResult->redirect_url) {
                    return 
redirect()->to($processResult->redirect_url);
                } else {
                    return 
redirect()->route('customer.billing.index')->with('success'trans('Congratulations! Your plan successfully changed'));
                }
            }
            else{

                return 
redirect()->route('customer.billing.index')->with('success'trans('Congratulations! Your plan request has been sent successfully'));
            }
        } catch (
\Exception $ex) {
            
Log::error($ex);
            return 
redirect()->route('customer.billing.index')->withErrors(['msg' => trans('Invalid Payment')]);
        }
    }


    public function 
paymentSuccess(Request $request)
    {
        try {
            
$credentials PaymentCredentials::get();

            if (!isset(
$credentials) || !isset($credentials->paypal_payment_mode) || !$credentials->paypal_payment_mode || (!$credentials->paypal_client_id || !$credentials->paypal_client_secret)) {
                throw new 
\Exception('Credentials not found. Please contact with the administrator');
            }
            
$mode = isset($credentials->paypal_payment_mode) && $credentials->paypal_payment_mode && $credentials->paypal_payment_mode == 'live' 'false' 'true';
            
$gateway Omnipay::create('PayPal_Rest');
            
$gateway->setClientId($credentials->paypal_client_id);
            
$gateway->setSecret($credentials->paypal_client_secret);
            
$gateway->setTestMode($mode);


            if (
$request->paymentId && $request->PayerID) {
                
$transaction $gateway->completePurchase(array(
                    
'payer_id' => $request->input('PayerID'),
                    
'transactionReference' => $request->input('paymentId'),
                ));
                
$response $transaction->send();


                if (!
$response->isSuccessful()) {
                    return 
redirect()->route('customer.billing.index')->withErrors(['msg' => trans('Invalid payment')]);
                }
            } else {
                return 
redirect()->route('customer.billing.index')->withErrors(['msg' => trans('Transaction is declined')]);
            }


            
$paymentId $request->paymentId;
            
$user_plan_id $request->plan;
            
$user $request->user;
            if (!
$paymentId || !$user_plan_id || !$user) {
                return 
redirect()->route('customer.billing.index')->withErrors(['msg' => trans('Invalid payment')]);
            }


            if (!
$response) return redirect()->route('customer.billing.index')->withErrors(['msg' => trans('Invalid payment')]);


//        DB::beginTransaction();
            
try {
                
$billingRequest BillingRequest::where(['id' => $user_plan_id'customer_id' => $user])->where(function ($q) use ($paymentId) {
                    
$q->whereNotIn('transaction_id', [$paymentId])->orWhereNull('transaction_id');
                })->
first();

                if (!
$billingRequest) {
                    return 
redirect()->route('customer.billing.index')->withErrors(['msg' => trans('Invalid payment')]);
                }

                
$transaction Transactions::where('type''plan')->where('ref_id'$billingRequest->id)
                    ->
where('customer_id'$billingRequest->customer_id)->first();

                if (
$transaction) {
                    
$transaction->transaction_id $paymentId;
                    
$transaction->status 'paid';
                    
$transaction->save();
                }

                
$plan Plan::where('id'$billingRequest->plan_id)->first();
                if (!
$plan) {
                    return 
redirect()->route('customer.billing.index')->withErrors(['msg' => trans('Invalid payment')]);
                }

                
$billingRequest->status 'accepted';
                
$billingRequest->payment_status 'paid';
                
$billingRequest->transaction_id $paymentId;
                
$billingRequest->save();

                
$customer Customer::where('id'$billingRequest->customer_id)->first();

                if(!
$customer){
                    return 
redirect()->route('customer.billing.index')->withErrors(['failed'=>'Invalid Customer']);
                }

                
$customer->customer_plans()->update(['is_current' => 'no']);

                if (
$plan->recurring_type == 'weekly') {
                    
$time \Illuminate\Support\Carbon::now()->addWeek();
                } else if (
$plan->recurring_type == 'monthly') {
                    
$time \Carbon\Carbon::now()->addMonth();
                } else if (
$plan->recurring_type == 'yearly') {
                    
$time Carbon::now()->addYear();
                } else if (
$plan->recurring_type == 'custom') {
                    
$date json_decode($plan->custom_date);
                    
$time = isset($date->from) ? new \DateTime($date->from) : '';
                }
                
$customer->plan()->create([
                    
'is_current' => 'yes''price' => $plan->price'expire_date' => $time'plan_id' => $plan->id,
                    
'sms_sending_limit' => $plan->sms_sending_limit'max_contact' => $plan->max_contact'contact_group_limit' => $plan->contact_group_limit,
                    
'sms_unit_price' => $plan->sms_unit_price'free_sms_credit' => $plan->free_sms_credit'country' => $plan->country'coverage_ids' => $plan->coverage_ids,
                    
'api_availability' => $plan->api_availability'sender_id_verification' => $plan->sender_id_verification,
                    
'unlimited_sms_send' => $plan->unlimited_sms_send'unlimited_contact' => $plan->unlimited_contact'unlimited_contact_group' => $plan->unlimited_contact_group
                
]);

                if(
$plan && $plan->enable_for=='reseller' && $customer->type=='normal'){
                    
$customer->type='reseller';
                    
$customer->save();
                }

//            Manage Free Credit
                
$wallet $customer->wallet()->first();
                if (
$customer->added_by == 'admin') {
                    if (
$plan->free_sms_credit 0) {
                        
$wallet->credit $wallet->credit $plan->free_sms_credit;
                        
$wallet->save();
                        
//Report
                        
$report = new Report();
                        
$report->customer_id $customer->id;
                        
$report->ref_id $plan->id;
                        
$report->type 'topup';
                        
$report->sub_type 'topup';
                        
$report->amount '+' $plan->free_sms_credit;
                        
$report->save();
                    }

                } else {
                    
$seller Customer::where('id'$customer->admin_id)->where('type'$customer->added_by)->first();
                    if (!
$seller) {
                        throw new 
\Exception('Seller not available');
                    }
                    
$sellerWallet $seller->wallet()->first();

                    if (
$plan->free_sms_credit 0) {
                        if (
$sellerWallet->credit $plan->free_sms_credit) {
                            
$wallet->credit $wallet->credit $plan->free_sms_credit;
                            
$wallet->save();

                            
$sellerWallet->credit $sellerWallet->credit $plan->free_sms_credit;
                            
$sellerWallet->save();

                            
//                    For Customer
                            //Report
                            
$report = new Report();
                            
$report->customer_id $customer->id;
                            
$report->ref_id $plan->id;
                            
$report->type 'topup';
                            
$report->sub_type 'topup';
                            
$report->amount '+' $plan->free_sms_credit;
                            
$report->save();
//                    For Seller
                            //Report
                            
$report = new Report();
                            
$report->customer_id $sellerWallet->customer_id;
                            
$report->ref_id $plan->id;
                            
$report->type 'topup';
                            
$report->sub_type 'topop';
                            
$report->amount '-' $plan->free_sms_credit;
                            
$report->save();
                        } else {
                            
$topUpReq = new TopUpRequest();
                            
$topUpReq->credit $plan->free_sms_credit;
                            
$topUpReq->credit_type 'non_masking';
                            
$topUpReq->customer_id $customer->id;
                            
$topUpReq->admin_id $customer->admin_id;
                            
$topUpReq->payment_status 'unpaid';
                            
$topUpReq->customer_type $customer->type;
                            
$topUpReq->transaction_id $request->transaction_id;
                            
$topUpReq->save();
                        }
                    }
                }
                
cache()->forget('wallet_' $customer->id);
                
BillingRequest::where(['customer_id' => $user'status' => 'pending'])->update(['status' => 'rejected']);
                return 
redirect()->route('customer.billing.index')->with('success'trans('Congratulations! Your plan successfully changed'));

            } catch (
\Exception $ex) {
//            DB::rollBack();
                
return redirect()->route('customer.billing.index')->withErrors(['failed' => 'Something went wrong try again']);
            }
            return 
redirect()->route('customer.billing.index')->with('success'trans('Congratulations! Your plan successfully changed'));
        } catch (
\Exception $ex) {
            return 
redirect()->route('customer.sender-id.index')->withErrors(['errors' => $ex->getMessage()]);
        }
    }
    function 
PayPalPayment($plan$planReq)
    {
        
$credentials json_decode(get_settings('payment_gateway'));
        if (!isset(
$credentials) || (!$credentials->paypal_client_id || !$credentials->paypal_client_secret)) {
            return 
redirect()->route('customer.billing.index')->withErrors(['msg' => trans('Invalid payment')]);
        }
        
$apiContext $this->getPayPalApiContext($credentials->paypal_client_id$credentials->paypal_client_secret);
        
$payer = new \PayPal\Api\Payer();
        
$payer->setPaymentMethod('paypal');

        
$amount = new \PayPal\Api\Amount();
        
$amount->setTotal($plan->price);
        
$amount->setCurrency('USD'); //TODO:: get the currency

        
$transaction = new \PayPal\Api\Transaction();
        
$transaction->setAmount($amount);

        
$redirectUrls = new \PayPal\Api\RedirectUrls();
        
$redirectUrls->setReturnUrl(route('paymentgateway::payment.process.success', ['plan' => $planReq->id'user' => $planReq->customer_id]))
            ->
setCancelUrl(route('paymentgateway::payment.process.cancel'));

        
$payment = new \PayPal\Api\Payment();
        
$payment->setIntent('sale')
            ->
setPayer($payer)
            ->
setTransactions(array($transaction))
            ->
setRedirectUrls($redirectUrls);

        try {
            
$payment->create($apiContext);
            return 
$payment;
        } catch (
\PayPal\Exception\PayPalConnectionException $ex) {
            
// This will print the detailed information on the exception.
            //REALLY HELPFUL FOR DEBUGGING
            
Log::error($ex->getData());
        }
        return 
null;
    }

    function 
getPayPalApiContext($client_id$secret_key)
    {

        return new 
\PayPal\Rest\ApiContext(
            new 
\PayPal\Auth\OAuthTokenCredential(
                
$client_id,     // ClientID
                
$secret_key      // ClientSecret
            
)
        );
    }



    public function 
paymentCancel()
    {
        return 
redirect()->route('customer.billing.index')->withErrors(['msg' => trans('Payment has been cancelled')]);
    }


    public function 
checkValidPayment(Request $request){
        
$plan Plan::where('id'$request->plan_id)->first();
        if (
$plan->price==$request->price){
            return 
response()->json(['status'=>'success']);
        }else{
            return 
abort(404);
        }
    }

    function 
edie($error_msg)
    {
        
\Log::error($error_msg);
        exit();
    }

    public function 
webhook(Request $request){
        
$settings json_decode(get_settings('payment_gateway'));
        
$merchant_id = isset($settings->merchate_id)?$settings->merchate_id:'';
        
$ipn_secret = isset($settings->ipn_secret)?$settings->ipn_secret:'';


        
$txn_id = isset($request->txn_id)?$request->txn_id:'';
        if(
$txn_id){
            
$payment BillingRequest::where("transaction_id"$txn_id)->first();
            
$plan Plan::where("id"$payment->plan_id)->first();
        }else{
            
abort('404');
        }

        
$order_total = isset($plan->price)?$plan->price:0//BTC
        
if (!isset($request->ipn_mode) || $request->ipn_mode != 'hmac') {
            
$this->edie("IPN Mode is not HMAC");
        }

        if (!isset(
$_SERVER['HTTP_HMAC']) || empty($_SERVER['HTTP_HMAC'])) {
            
$this->edie("No HMAC Signature Sent.");
        }


        if (!isset(
$request->merchant) || $request->merchant != trim($merchant_id)) {
            
$this->edie("No or incorrect merchant id.");
        }

        
$hmac =  hash_hmac("sha512"$requesttrim($ipn_secret));
        if (!
hash_equals($hmac$_SERVER['HTTP_HMAC'])) {
            
$this->edie("HMAC signature does not match.");
        }

        
$amount1 floatval($request->amount1); //IN USD
        
$amount2 floatval($request->amount2); //IN BTC

        
$status intval($request->status);


        if (
$amount1 $order_total) {
            
$this->edie("Amount is lesser than order total");
        }

        if (
$status >= 100 || $status == 2) {
            
// Payment is complete
            
$payment->status 'accepted';
            
$payment->save();
        }
        die(
"IPN OK");
    }


    public function 
coinPayment(Request $request){
        
$user auth('customer')->user();
        
$plan Plan::find($request->plan_id);
        if (!
$plan) return response()->json(['status'=>'failed','message' => trans('Plan not found')]);

        if (isset(
$pre_plan) && $pre_plan->plan_id == $request->id) {
            return 
response()->json(['status'=>'failed','message''You are already subscribed to this plan']);
        }
        if (
$request->payment_type == 'offline') {
            
$preBilling BillingRequest::where(['customer_id' => $user->id'status' => 'pending'])->first();
            if (
$preBilling) {
                return 
response()->json(['status'=>'failed','message'=> trans('You already have a pending request. Please wait for the admin reply.')]);
            }
        }
        
$planReq = new BillingRequest();
        
$planReq->admin_id $plan->admin_id;
        
$planReq->customer_id $user->id;
        
$planReq->plan_id $plan->id;
        
$planReq->other_info json_encode($request->only('payment_type'));
        
$planReq->save();

        
$settings json_decode(get_settings('payment_gateway'));
        
$private_key = isset($settings->private_key)?$settings->private_key:'';
        
$public_key = isset($settings->public_key)?$settings->public_key:'';

        
$cps_api = new \CoinpaymentsAPI($private_key$public_key,'json');

// Enter amount for the transaction
        
$settings json_decode(get_settings('local_setting'));
        
$currency1=isset($settings->currency_code)?$settings->currency_code:'USD';
        
$currency2=isset($request->coin_payment_type)?strtoupper($request->coin_payment_type):'BTC';

// Enter buyer email below
        
$amount $plan->price;


        
$urlroute('paymentgateway::coin.payment');
        
$userName$user->full_name;
        
$userEmail$user->email;
        
$itemName$plan->title;

        
$data=[
            
'amount'=>$amount,
            
'currency1'=>$currency1,
            
'currency2'=>$currency2,
            
'buyer_name'=>$userName,
            
'buyer_email'=>$userEmail,
            
'item_name'=>$itemName,
            
'ipn_url'=>$url,
        ];

        
$transaction_response $cps_api->CreateCustomTransaction($data);

        if (
$transaction_response['error'] == 'ok') {

            if(isset(
$transaction_response['result']) && isset($transaction_response['result']['txn_id'])) {
                
$planReq->transaction_id $transaction_response['result']['txn_id'];
                
$planReq->save();
            }

            
$status_url = isset($transaction_response['result']) && isset($transaction_response['result']['status_url']) ? $transaction_response['result']['status_url'] : '';
            
$responseAmount=isset($transaction_response['result']) && isset($transaction_response['result']['amount'])?$transaction_response['result']['amount']:'';

            
$data=[
                
'status_url'=>$status_url,
                
'amount'=>$responseAmount,
                
'currency'=>$currency2,
            ];
            return 
response()->json(['status'=>'success''data'=>$data]);
        } else {
            throw new 
\Exception($transaction_response['error']);
            return 
response()->json(['status'=>'failed''message'=>$transaction_response['error']]);
        }
    }

    public function 
sslSuccess(Request $request){
try {
    
$amount $request->amount;
    if (!
$request->value_b || !$request->value_a || !$amount) {
        return 
abort(404);
    }
    
$plan Plan::where('id'$request->value_a)->first();

    if (!
$plan) {
        return 
abort(404);
    }
    if (
$amount != $plan->price) {
        return 
redirect()->route('customer.billing.index')->withErrors(['failed' => 'Invalid payment']);
    }
    
$customer Customer::where('id'$request->value_c)->firstOrFail();
    if (
$customer->type == 'normal') {
        
$customer->type $plan->plan_type;
        
$customer->save();
    }

    if (
$customer->type == 'master_reseller_customer' && $plan->plan_type == 'reseller') {
        
$customer->type 'reseller';
        
$customer->save();
    }

    
auth('customer')->loginUsingId($customer->id);
    
$billingRequest BillingRequest::where('id'$request->value_b)->where('plan_id'$plan->id)->where('customer_id'$request->value_c)->first();
    if (
$billingRequest) {
        
$billingRequest->status 'accepted';
        
$billingRequest->payment_status 'paid';
        
$billingRequest->save();
    }
    
$customer->customer_plans()->update(['is_current' => 'no']);

    if (
$plan->recurring_type == 'weekly') {
        
$time Carbon::now()->addWeek();
    } else if (
$plan->recurring_type == 'monthly') {
        
$time Carbon::now()->addMonth();
    } else if (
$plan->recurring_type == 'yearly') {
        
$time Carbon::now()->addYear();
    } else if (
$plan->recurring_type == 'custom') {
        
$date json_decode($plan->custom_date);
        
$time = isset($date->from) ? new DateTime($date->from) : '';
    }

    
$newPlan $customer->plan()->create(['is_current' => 'yes''plan_id' => $plan->id'price' => $plan->price'masking_rate' => $plan->masking_rate,
        
'non_masking_rate' => $plan->non_masking_rate'module' => $plan->module'expire_date' => $time]);
    
$wallet $customer->wallet()->first();
    if (
$customer->added_by == 'admin') {
        if (
$plan->masking_credit 0) {
            
$wallet->masking_credit $wallet->masking_credit $plan->masking_credit;
            
$wallet->save();
        }
        if (
$plan->non_masking_credit 0) {
            
$wallet->non_masking_credit $wallet->non_masking_credit $plan->non_masking_credit;
            
$wallet->save();
        }
    } else {
        
$seller Customer::where('id'$customer->admin_id)->where('type'$customer->added_by)->first();
        if (!
$seller) {
            throw new 
\Exception('Seller not available');
        }
        
$sellerWallet $seller->wallet()->first();

        if (
$plan->masking_credit 0) {
            if (
$sellerWallet->masking_credit $plan->masking_credit) {
                
$wallet->masking_credit $wallet->masking_credit $plan->masking_credit;
                
$wallet->save();

                
$sellerWallet->masking_credit $sellerWallet->masking_credit $plan->masking_credit;
                
$sellerWallet->save();
            } else {
                
$topUpReq = new TopUpRequest();
                
$topUpReq->credit $plan->masking_credit;
                
$topUpReq->credit_type 'masking';
                
$topUpReq->customer_id $customer->id;
                
$topUpReq->admin_id $customer->admin_id;
                
$topUpReq->payment_status 'unpaid';
                
$topUpReq->customer_type $customer->type;
                
$topUpReq->transaction_id $request->transaction_id;
                
$topUpReq->save();
            }
        }
        if (
$plan->non_masking_credit 0) {
            if (
$sellerWallet->non_masking_credit $plan->non_masking_credit) {
                
$wallet->non_masking_credit $wallet->non_masking_credit $plan->non_masking_credit;
                
$wallet->save();

                
$sellerWallet->non_masking_credit $sellerWallet->non_masking_credit $plan->non_masking_credit;
                
$sellerWallet->save();
            } else {
                
$topUpReq = new TopUpRequest();
                
$topUpReq->credit $plan->non_masking_credit;
                
$topUpReq->credit_type 'non_masking';
                
$topUpReq->customer_id $customer->id;
                
$topUpReq->admin_id $customer->admin_id;
                
$topUpReq->payment_status 'unpaid';
                
$topUpReq->customer_type $customer->type;
                
$topUpReq->transaction_id $request->transaction_id;
                
$topUpReq->save();
            }
        }
    }

    return 
redirect()->route('customer.billing.index')->with('success''Congratulations! Your plan successfully changed');
    } catch (
\Exception $ex) {
        
Log::error($ex);
        return 
redirect()->route('customer.billing.index')->withErrors(['msg' => $ex->getMessage()]);
    }
    }


    function 
planProcessPaytmRedirect(Request $request)
    {
        if (!
$this->request->ORDERID || !$this->request->TXNID || !$this->request->TXNAMOUNT || !$this->request->STATUS) {
            return 
redirect()->route('login')->withErrors(['msg' => trans('layout.message.invalid_payment')]);
        }

        
$credentials json_decode(get_settings('payment_gateway'));
        if (!
$credentials->paytm_secret_key) {
            return 
redirect()->route('login')->withErrors(['msg' => trans('invalid Payment')]);
        }

        
$paytmParams $_POST;

        
$paytmChecksum $_POST['CHECKSUMHASH'];
        unset(
$paytmParams['CHECKSUMHASH']);

        
$isVerifySignature PaytmChecksum::verifySignature($paytmParams$credentials->paytm_secret_key$paytmChecksum);
        if (!
$isVerifySignature) return redirect()->route('login')->withErrors(['msg' => trans('Invalid Payment')]);


        
$orderId $request->ORDERID;
        
$orderId explode('_'$orderId)[1];

        
$billingRequestBillingRequest::find($orderId);
        if (!
$billingRequest) return redirect()->route('login')->withErrors(['msg' => trans('Invalid Payment')]);
        
$planPlan::where('id',$billingRequest->id)->first();
        if (
$request->TXNAMOUNT != format_number($plan->price2)) return redirect()->route('login')->withErrors(['msg' => trans('Invalid Payment')]);


        
$customerPlan= new CustomerPlan();
        
$customerPlan->is_current='yes';
        
$customerPlan->customer_id=$billingRequest->customer_id;
        
$customerPlan->plan_id=$plan->id;
        
$customerPlan->price=$plan->price;
        
$customerPlan->masking_rate=$plan->masking_rate;
        
$customerPlan->non_masking_rate=$plan->non_masking_rate;
        
$customerPlan->module=$plan->module;
        
$customerPlan->save();


        if (
$request->STATUS != 'TXN_SUCCESS') return redirect()->route('login')->withErrors(['msg' => trans('Invalid Payment')]);

        
$billingRequest->status 'accepted';
        
$billingRequest->save();

        return 
redirect()->route('login')->with('success'trans('Payment Success'));

    }

    public function 
uddoktapaySuccess(Request $request){
        
$customerId=$request->customer_id;
        
auth('customer')->loginUsingId($customerId);

        return 
redirect()->route('customer.billing.index')->with('success''Congratulations! Your plan successfully changed');
    }

    public function 
uddoktapayWebhook(Request $request){
        if(isset(
$request->product_id) && isset($request->transaction_id)){
            
$billRequest=BillingRequest::where('id'$request->product_id)->first();
            if (
$billRequest){
                
$billRequest->transaction_id=$request->transaction_id;
                
$billRequest->status='accepted';
                
$billRequest->payment_status='paid';
                
$billRequest->save();

                
$planPlan::where('id'$request->value_a)->first();

                if(!
$plan){
                    return  
abort(404);
                }

                
$customer=Customer::where('id'$billRequest->customer_id)->firstOrFail();
                if(
$customer->type=='normal'){
                    
$customer->type=$plan->plan_type;
                    
$customer->save();
                }

                if(
$customer->type=='master_reseller_customer' && $plan->plan_type=='reseller'){
                    
$customer->type='reseller';
                    
$customer->save();
                }

                
$customer->customer_plans()->update(['is_current'=>'no']);

               
$customer->plan()->create(['is_current'=>'yes','plan_id' => $plan->id'price' => $plan->price,'masking_rate'=>$plan->masking_rate,
                    
'non_masking_rate'=>$plan->non_masking_rate,'module'=>$plan->module]);
            }
        }
        return 
redirect()->route('customer.billing.index')->with('success''Congratulations! Your plan successfully changed');
    }

//    PayStack
    
public function paystackPaymentBack(Request $request)
    {
        
$credentials json_decode(get_settings('payment_gateway'));

        if (!isset(
$request->plan_req) || !isset($request->trxref)) {
            throw new 
\Exception(trans('layout.message.invalid_request'));
        }
        if (
$request->trxref && $request->plan_req) {
            if (
$request->plan_req) {
                
$userPlan BillingRequest::find($request->plan_req);
                if (!
$userPlan) {
                    
Log::info("user plan not found -" $request->plan_req);
                    exit;
                };

                
$userPlan->transaction_id $request->trxref;
                
$userPlan->save();
                return 
redirect()->route('customer.billing.index')->with('success''Congratulations! Your plan successfully changed');
            }
            
Log::info("CallBack data not found");
            exit;
        } else {
            return 
redirect()->route('customer.billing.index')->withErrors(['msg' => 'Imvalid payment']);
        }
    }

}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0058 ]--