⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.142
Server IP:
217.76.53.76
Server:
Linux vmi1397931.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64
Server Software:
Apache
PHP Version:
8.2.27
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
www
/
wwwroot
/
softpos.com.ng
/
app
/
Http
/
Controllers
/
View File Name :
CoingatePaymentController.php
isOwner()) { $payment_setting = Utility::getAdminPaymentSetting(); } else { $payment_setting = Utility::getCompanyPaymentSetting(); } $this->coingate_auth_token = isset($payment_setting['coingate_auth_token']) ? $payment_setting['coingate_auth_token'] : ''; $this->mode = isset($payment_setting['coingate_mode']) ? $payment_setting['coingate_mode'] : 'off'; $this->is_enabled = isset($payment_setting['is_coingate_enabled']) ? $payment_setting['is_coingate_enabled'] : 'off'; return $this; } public function planPayWithCoingate(Request $request) { $payment = $this->paymentConfig(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $plan = Plan::find($planID); $authuser = Auth::user(); $coupons_id = 0; if ($plan) { $price = $plan->price; if (isset($request->coupon) && !empty($request->coupon)) { $request->coupon = trim($request->coupon); $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if (!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($price / 100) * $coupons->discount; $plan->discounted_price = $price - $discount_value; $coupons_id = $coupons->id; // dd($coupons_id); if ($usedCoupun >= $coupons->limit) { return redirect()->back()->with('error', __('This coupon code has expired.')); } $price = $price - $discount_value; } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } if ($price <= 0) { $authuser->plan_id = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if ($assignPlan['is_success'] == true && !empty($plan)) { $orderID = time(); if ($coupons_id != '') { $userCoupon = new UsersCoupons();//UsersCoupons $userCoupon->user_id = $authuser->id; $userCoupon->coupon_id = $coupons->id; $userCoupon->order_id = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } } Order::create( [ 'order_id' => $orderID, 'name' => $authuser->name, 'email' => null, 'card_number' => null, 'card_exp_month' => null, 'card_exp_year' => null, 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $price == null ? 0 : $price, 'price_currency' => !empty(env('CURRENCY')) ? env('CURRENCY') : 'USD', 'txn_id' => '', 'payment_type' => 'coingate', 'payment_status' => 'succeeded', 'receipt' => null, 'user_id' => $authuser->id, ] ); $assignPlan = $authuser->assignPlan($plan->id); return redirect()->route('plans.index')->with('success', __('Plan activated Successfully!')); } else { return redirect()->back()->with('error', __('Plan fail to upgrade.')); } } CoinGate::config( array( 'environment' => $this->mode, 'auth_token' => $this->coingate_auth_token, 'curlopt_ssl_verifypeer' => FALSE, ) ); $post_params = array( 'order_id' => time(), 'price_amount' => $price, 'price_currency' => env('CURRENCY'), 'receive_currency' => env('CURRENCY'), 'callback_url' => route( 'plan.coingate', [ $request->plan_id, $coupons_id, ] ), 'cancel_url' => route('stripe', [$request->plan_id]), 'success_url' => route( 'plan.coingate', [ $request->plan_id, $coupons_id, ] ), 'title' => 'Plan #' . time(), ); try { $order = \CoinGate\Merchant\Order::create($post_params); } catch (\Exception $e) { return redirect()->back()->with('error', __('BadAuthToken Auth Token is not valid.')); } if ($order) { return redirect($order->payment_url); } else { return redirect()->back()->with('error', __('opps something wren wrong.')); } } else { return redirect()->back()->with('error', 'Plan is deleted.'); } } public function getPaymentStatus(Request $request, $plan,$coupons_id) { // dd($coupons_id); $payment = $this->paymentConfig(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($plan); $plan = Plan::find($planID); $user = Auth::user(); $orderID = time(); if ($plan) { // try { $orderID = time(); if ($coupons_id != '') { $price = $plan->price; $coupons = Coupon::find($coupons_id); // dd($coupons); if (!empty($coupons)) { $userCoupon = new UsersCoupons(); $userCoupon->user_id = $user->id; $userCoupon->coupon_id = $coupons->id; $userCoupon->order_id = $orderID; $userCoupon->save(); $usedCoupun = $coupons->used_coupon(); if ($coupons->limit <= $usedCoupun) { $coupons->is_active = 0; $coupons->save(); } // $usedCoupun = $coupons->used_coupon(); // $discount_value = ($price / 100) * $coupons->discount; // $plan->discounted_price = $price - $discount_value; // $coupons_id = $coupons->id; // if ($usedCoupun >= $coupons->limit) { // return redirect()->back()->with('error', __('This coupon code has expired.')); // } // $price = $price - $discount_value; } } $order = new Order(); $order->order_id = $orderID; $order->name = $user->name; $order->card_number = ''; $order->card_exp_month = ''; $order->card_exp_year = ''; $order->plan_name = $plan->name; $order->plan_id = $plan->id; $order->price = $plan->price; $order->price_currency = env('CURRENCY'); $order->txn_id = isset($request->transaction_id) ? $request->transaction_id : ''; $order->payment_type = __('Coingate'); $order->payment_status = 'success'; $order->receipt = ''; $order->user_id = $user->id; $order->save(); $assignPlan = $user->assignPlan($plan->id); if ($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan activated Successfully.')); } else { return redirect()->route('plans.index')->with('error', $assignPlan['error']); } // } catch (\Exception $e) { // return redirect()->route('plans.index')->with('error', __('Transaction has been failed.')); // } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } }