[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: PaymentsTrait.php
<?php namespace App\Http\Controllers\Web\traits; use App\Models\PaymentChannel; use App\Models\Product; use App\Models\ProductOrder; use App\Models\Reward; use App\Models\RewardAccounting; use App\PaymentChannels\ChannelManager; use Illuminate\Http\Request; trait PaymentsTrait { /* * | this methode only run for payku.result * */ public function paykuPaymentVerify(Request $request, $id) { $paymentChannel = PaymentChannel::where('class_name', PaymentChannel::$payku) ->where('status', 'active') ->first(); try { $channelManager = ChannelManager::makeChannel($paymentChannel); $request->request->add(['transaction_id' => $id]); $order = $channelManager->verify($request); return $this->paymentOrderAfterVerify($order); } catch (\Exception $exception) { $toastData = [ 'title' => trans('cart.fail_purchase'), 'msg' => trans('cart.gateway_error'), 'status' => 'error' ]; return redirect('cart')->with(['toast' => $toastData]); } } /* * | this methode only run for Chapa.result * */ public function chapaPaymentVerify(Request $request, $reference) { $paymentChannel = PaymentChannel::where('class_name', PaymentChannel::$chapa) ->where('status', 'active') ->first(); try { $channelManager = ChannelManager::makeChannel($paymentChannel); $request->replace([ 'reference' => $reference, ]); $order = $channelManager->verify($request); return $this->paymentOrderAfterVerify($order); } catch (\Exception $exception) { $toastData = [ 'title' => trans('cart.fail_purchase'), 'msg' => trans('cart.gateway_error'), 'status' => 'error' ]; return redirect('cart')->with(['toast' => $toastData]); } } private function handleMeetingReserveReward($user) { if ($user->isUser()) { $type = Reward::STUDENT_MEETING_RESERVE; } else { $type = Reward::INSTRUCTOR_MEETING_RESERVE; } $meetingReserveReward = RewardAccounting::calculateScore($type); RewardAccounting::makeRewardAccounting($user->id, $meetingReserveReward, $type); } private function updateProductOrder($sale, $orderItem) { $product = $orderItem->product; $status = ProductOrder::$waitingDelivery; if ($product and $product->isVirtual()) { $status = ProductOrder::$success; } ProductOrder::where('product_id', $orderItem->product_id) ->where(function ($query) use ($orderItem) { $query->where(function ($query) use ($orderItem) { $query->whereNotNull('buyer_id'); $query->where('buyer_id', $orderItem->user_id); }); $query->orWhere(function ($query) use ($orderItem) { $query->whereNotNull('gift_id'); $query->where('gift_id', $orderItem->gift_id); }); }) ->update([ 'sale_id' => $sale->id, 'status' => $status, ]); if ($product and $product->getAvailability() < 1) { $notifyOptions = [ '[p.title]' => $product->title, ]; sendNotification('product_out_of_stock', $notifyOptions, $product->creator_id); } } private function updateInstallmentOrder($orderItem, $sale) { $installmentPayment = $orderItem->installmentPayment; if (!empty($installmentPayment)) { $installmentOrder = $installmentPayment->installmentOrder; $installmentPayment->update([ 'sale_id' => $sale->id, 'status' => 'paid', ]); /* Notification Options */ $notifyOptions = [ '[u.name]' => $installmentOrder->user->full_name, '[installment_title]' => $installmentOrder->installment->main_title, '[time.date]' => dateTimeFormat(time(), 'j M Y - H:i'), '[amount]' => handlePrice($installmentPayment->amount), ]; if ($installmentOrder and $installmentOrder->status == 'paying' and $installmentPayment->type == 'upfront') { $installment = $installmentOrder->installment; if ($installment) { if ($installment->needToVerify()) { $status = 'pending_verification'; sendNotification("installment_verification_request_sent", $notifyOptions, $installmentOrder->user_id); sendNotification("admin_installment_verification_request_sent", $notifyOptions, 1); // Admin } else { $status = 'open'; sendNotification("paid_installment_upfront", $notifyOptions, $installmentOrder->user_id); } $installmentOrder->update([ 'status' => $status ]); if ($status == 'open' and !empty($installmentOrder->product_id) and !empty($installmentOrder->product_order_id)) { $productOrder = ProductOrder::query()->where('installment_order_id', $installmentOrder->id) ->where('id', $installmentOrder->product_order_id) ->first(); $product = Product::query()->where('id', $installmentOrder->product_id)->first(); if (!empty($product) and !empty($productOrder)) { $productOrderStatus = ProductOrder::$waitingDelivery; if ($product->isVirtual()) { $productOrderStatus = ProductOrder::$success; } $productOrder->update([ 'status' => $productOrderStatus ]); } } } } if ($installmentPayment->type == 'step') { sendNotification("paid_installment_step", $notifyOptions, $installmentOrder->user_id); sendNotification("paid_installment_step_for_admin", $notifyOptions, 1); // For Admin } } } }
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.85 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