芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/myvyralapp.com/bck/app/Http/Controllers/User/AddMoneyController.php
get(); $user_currencies = Currency::whereIn('id',$user_wallets->pluck('id')->toArray())->get(); $payment_gateways_currencies = PaymentGatewayCurrency::whereHas('gateway', function ($gateway) { $gateway->where('slug', PaymentGatewayConst::add_money_slug()); $gateway->where('status', 1); })->get(); $transactions = Transaction::auth()->addMoney()->latest()->take(10)->get(); return view('user.sections.add-money.index',compact("page_title","transactions","payment_gateways_currencies")); } public function submit(Request $request) { $basic_setting = BasicSettings::first(); $user = auth()->user(); if($basic_setting->kyc_verification){ if( $user->kyc_verified == 0){ return redirect()->route('user.profile.index')->with(['error' => ['Please submit kyc information']]); }elseif($user->kyc_verified == 2){ return redirect()->route('user.profile.index')->with(['error' => ['Please wait before admin approved your kyc information']]); }elseif($user->kyc_verified == 3){ return redirect()->route('user.profile.index')->with(['error' => ['Admin rejected your kyc information, Please re-submit again']]); } } try{ $instance = PaymentGatewayHelper::init($request->all())->gateway()->render(); }catch(Exception $e) { return back()->with(['error' => [$e->getMessage()]]); } return $instance; } public function success(Request $request, $gateway){ $requestData = $request->all(); $token = $requestData['token'] ?? ""; $checkTempData = TemporaryData::where("type",$gateway)->where("identifier",$token)->first(); if(!$checkTempData) return redirect()->route('user.add.money.index')->with(['error' => ['Transaction Failed. Record didn\'t saved properly. Please try again.']]); $checkTempData = $checkTempData->toArray(); try{ PaymentGatewayHelper::init($checkTempData)->type(PaymentGatewayConst::TYPEADDMONEY)->responseReceive(); }catch(Exception $e) { return back()->with(['error' => [$e->getMessage()]]); } return redirect()->route("user.add.money.index")->with(['success' => ['Successfully added money']]); } public function cancel(Request $request, $gateway) { $token = session()->get('identifier'); if( $token){ TemporaryData::where("identifier",$token)->delete(); } return redirect()->route('user.add.money.index'); } public function manualPayment(){ $tempData = Session::get('identifier'); $hasData = TemporaryData::where('identifier', $tempData)->first(); $gateway = PaymentGateway::manual()->where('slug',PaymentGatewayConst::add_money_slug())->where('id',$hasData->data->gateway)->first(); $page_title = "Manual Payment".' ( '.$gateway->name.' )'; if(!$hasData){ return redirect()->route('user.add.money.index'); } return view('user.sections.add-money.manual.payment_confirmation',compact("page_title","hasData",'gateway')); } public function flutterwaveCallback() { $status = request()->status; //if payment is successful if ($status == 'successful') { $transactionID = Flutterwave::getTransactionIDFromCallback(); $data = Flutterwave::verifyTransaction($transactionID); $requestData = request()->tx_ref; $token = $requestData; $checkTempData = TemporaryData::where("type",'flutterwave')->where("identifier",$token)->first(); if(!$checkTempData) return redirect()->route('user.add.money.index')->with(['error' => ['Transaction Failed. Record didn\'t saved properly. Please try again.']]); $checkTempData = $checkTempData->toArray(); try{ PaymentGatewayHelper::init($checkTempData)->type(PaymentGatewayConst::TYPEADDMONEY)->responseReceive('flutterWave'); }catch(Exception $e) { return back()->with(['error' => [$e->getMessage()]]); } return redirect()->route("user.add.money.index")->with(['success' => ['Successfully added money']]); } elseif ($status == 'cancelled'){ return redirect()->route('user.add.money.index')->with(['error' => ['Add money cancelled']]); } else{ return redirect()->route('user.add.money.index')->with(['error' => ['Transaction failed']]); } } public function razorCallback() { $request_data = request()->all(); //if payment is successful if ($request_data['razorpay_payment_link_status'] == 'paid') { $token = $request_data['razorpay_payment_link_reference_id']; $checkTempData = TemporaryData::where("type",PaymentGatewayConst::RAZORPAY)->where("identifier",$token)->first(); if(!$checkTempData) return redirect()->route('user.add.money.index')->with(['error' => ['Transaction Failed. Record didn\'t saved properly. Please try again.']]); $checkTempData = $checkTempData->toArray(); try{ PaymentGatewayHelper::init($checkTempData)->type(PaymentGatewayConst::TYPEADDMONEY)->responseReceive('razorpay'); }catch(Exception $e) { return back()->with(['error' => [$e->getMessage()]]); } return redirect()->route("user.add.money.index")->with(['success' => ['Successfully added money']]); } else{ return redirect()->route('user.add.money.index')->with(['error' => ['Transaction failed']]); } } //stripe success public function stripePaymentSuccess($trx){ $token = $trx; $checkTempData = TemporaryData::where("type",PaymentGatewayConst::STRIPE)->where("identifier",$token)->first(); if(!$checkTempData) return redirect()->route('user.add.money.index')->with(['error' => ['Transaction Failed. Record didn\'t saved properly. Please try again.']]); $checkTempData = $checkTempData->toArray(); try{ PaymentGatewayHelper::init($checkTempData)->type(PaymentGatewayConst::TYPEADDMONEY)->responseReceive('stripe'); }catch(Exception $e) { return back()->with(['error' => ["Something Is Wrong..."]]); } return redirect()->route("user.add.money.index")->with(['success' => ['Successfully Added Money']]); } //sslcommerz success public function sllCommerzSuccess(Request $request){ $data = $request->all(); $token = $data['tran_id']; $checkTempData = TemporaryData::where("type",PaymentGatewayConst::SSLCOMMERZ)->where("identifier",$token)->first(); if(!$checkTempData) return redirect()->route('user.add.money.index')->with(['error' => ['Transaction Failed. Record didn\'t saved properly. Please try again.']]); $checkTempData = $checkTempData->toArray(); $creator_id = $checkTempData['data']->creator_id ?? null; $creator_guard = $checkTempData['data']->creator_guard ?? null; $user = Auth::guard($creator_guard)->loginUsingId($creator_id); if( $data['status'] != "VALID"){ return redirect()->route("user.add.money.index")->with(['error' => ['Added Money Failed']]); } try{ PaymentGatewayHelper::init($checkTempData)->type(PaymentGatewayConst::TYPEADDMONEY)->responseReceive('sslcommerz'); }catch(Exception $e) { return back()->with(['error' => ["Something Is Wrong..."]]); } return redirect()->route("user.add.money.index")->with(['success' => ['Successfully Added Money']]); } //sslCommerz fails public function sllCommerzFails(Request $request){ $data = $request->all(); $token = $data['tran_id']; $checkTempData = TemporaryData::where("type",PaymentGatewayConst::SSLCOMMERZ)->where("identifier",$token)->first(); if(!$checkTempData) return redirect()->route('user.add.money.index')->with(['error' => ['Transaction Failed. Record didn\'t saved properly. Please try again.']]); $checkTempData = $checkTempData->toArray(); $creator_id = $checkTempData['data']->creator_id ?? null; $creator_guard = $checkTempData['data']->creator_guard ?? null; $user = Auth::guard($creator_guard)->loginUsingId($creator_id); if( $data['status'] == "FAILED"){ TemporaryData::destroy($checkTempData['id']); return redirect()->route("user.add.money.index")->with(['error' => ['Added Money Failed']]); } } //sslCommerz canceled public function sllCommerzCancel(Request $request){ $data = $request->all(); $token = $data['tran_id']; $checkTempData = TemporaryData::where("type",PaymentGatewayConst::SSLCOMMERZ)->where("identifier",$token)->first(); if(!$checkTempData) return redirect()->route('user.add.money.index')->with(['error' => ['Transaction Failed. Record didn\'t saved properly. Please try again.']]); $checkTempData = $checkTempData->toArray(); $creator_id = $checkTempData['data']->creator_id ?? null; $creator_guard = $checkTempData['data']->creator_guard ?? null; $user = Auth::guard($creator_guard)->loginUsingId($creator_id); if( $data['status'] != "VALID"){ TemporaryData::destroy($checkTempData['id']); return redirect()->route("user.add.money.index")->with(['error' => ['Added Money Canceled']]); } } }