Файловый менеджер - Редактировать - /home/clickysoft/public_html/somni.clickysoft.net/app/Http/Controllers/PaymentController.php
Назад
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Repositories\TenantRepository; use App\Repositories\NotificationRepository; use App\Repositories\UserRepository; use App\Repositories\PaymentRepository; use App\Repositories\TransactionRepository; use App\Interfaces\TenantRepositoryInterface; use App\Interfaces\NotificationRepositoryInterface; use App\Interfaces\UserRepositoryInterface; use App\Interfaces\PaymentRepositoryInterface; use App\Interfaces\TransactionRepositoryInterface; class PaymentController extends Controller { private TenantRepositoryInterface $tenantInterfaceObj; //Tenant Interface Object private NotificationRepositoryInterface $notificationInterfaceObj; private UserRepositoryInterface $userInterfaceObj; private PaymentRepositoryInterface $paymentInterfaceObj; private TransactionRepositoryInterface $transactionInterfaceObj; private $secret; public function __construct(TenantRepository $tenantRepo, NotificationRepository $notificationRepo, UserRepository $userRepo,PaymentRepository $paymentRepo, TransactionRepository $transactionRepo) { $this->tenantInterfaceObj = $tenantRepo; $this->notificationInterfaceObj = $notificationRepo; $this->userInterfaceObj = $userRepo; $this->paymentInterfaceObj = $paymentRepo; $this->transactionInterfaceObj = $transactionRepo; $this->secret = config('constants.stripe.secret_key'); \Stripe\Stripe::setApiKey($this->secret); } public function saveCard(Request $request) { // dd($request->all()); try { $user = auth()->user(); $methods = $user->paymentMethods(); if(count($methods) > 2){ return back()->with('error', 'Limit Reached'); } $user->createOrGetStripeCustomer(); // Ensure the user is a Stripe customer $user->addPaymentMethod($request->paymentMethodId); return redirect()->route('tenant.payment')->with('success', 'Card Saved'); } catch (\Throwable $th) { //throw $th; return back()->with('error','Error saving card: ' . $th->getMessage()); } } public function payRent(Request $request){ // dd($request->all()); $user = auth()->user(); $bank_intent = ($request->bank_intent) ?? null; $setup_intent_id = null; if($request->payment_through == 'bank'){ $customer = auth()->user(); $intent = \Stripe\SetupIntent::create([ 'payment_method_types' => ['us_bank_account'], 'customer' => $customer->stripe_id, ]); $setup_intent_id = $intent->id; } $nCount = $this->notificationInterfaceObj->unreadCount($user->id); $notifications = $this->notificationInterfaceObj->recentNotifications($user->id); if($request->payment_type == 'other_payment' || $request->payment_type == 'other_balance'){ $capture = $this->paymentInterfaceObj->captureTransaction($request->payment_type, $request->payment_amount, $request->payment_method_id, $request->rented_unit_id, $user,$request->note_for_other,$request->payment_through,$bank_intent, $setup_intent_id); }else{ $capture = $this->paymentInterfaceObj->captureTransaction($request->payment_type, $request->payment_amount, $request->payment_method_id, $request->rented_unit_id, $user,null,$request->payment_through,$bank_intent, $setup_intent_id); // dd('Hellow'); } // dd($capture); if($capture['code'] == 200){ $amount = $capture['amount']; $transaction_id = $capture['transaction_id']; $payment_through = $capture['payment_through']; return view('tenant.payment-thankyou',compact('user','nCount','notifications','amount','transaction_id','payment_through')); }else{ return redirect()->route('tenant.payment')->with('error',$capture['message']->getMessage()); } } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка