Server IP : 103.191.208.50 / Your IP : 216.73.216.53 Web Server : LiteSpeed System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64 User : celkcksm ( 1031) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, popen, exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/celkcksm/cms.ncriptech.com/app/Http/Controllers/Payment/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php namespace App\Http\Controllers\Payment; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Models\PrintSetting; use App\Traits\FeesStudent; use App\Models\Setting; use App\Models\Fee; use Stripe\Stripe; use Stripe\Charge; use Toastr; use DB; class StripeController extends Controller { use FeesStudent; /** * success response method. * * @return \Illuminate\Http\Response */ public function index() { // return view('stripe'); } /** * success response method. * * @return \Illuminate\Http\Response */ public function process(Request $request) { // try { // Payment Process Stripe::setApiKey(env('STRIPE_SECRET')); // Get Amount $amount = 0; if(isset($request->fee_id)){ $fee_id = $request->fee_id; $amount = $this->netAmount($fee_id); } // $currency = Setting::where('status', '1')->first()->currency ?? 'USD'; $print = PrintSetting::where('slug', 'fees-receipt')->first(); $fee = Fee::where('id', $fee_id)->first(); // Charge Fee If Status Is Unpaid if(isset($fee->status) && $fee->status == 0){ $charge = Charge::create ([ "amount" => $amount * 100, "currency" => $currency ?? 'USD', "source" => $request->stripeToken, "description" => __('field_receipt') .': '. ($print->prefix ?? '') . str_pad($fee_id, 6, '0', STR_PAD_LEFT), ]); } if (isset($charge) && $charge->status == 'succeeded') { // Update Fee if(isset($request->fee_id)){ $this->payStudentFee($fee_id, 7); } Toastr::success(__('msg_your_payment_successful'), __('msg_success')); return redirect()->route('student.fees.index'); } else { Toastr::error(__('msg_something_went_wrong'), __('msg_error')); } return redirect()->back(); } catch(\Exception $e) { \Log::error('Stripe Payment Error: ' . $e->getMessage()); Toastr::error(__('msg_something_went_wrong'), __('msg_error')); return redirect()->back(); } } }