JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbrcoingate_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(); $payment_setting = Utility::getAdminPaymentSetting(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($request->plan_id); $plan = Plan::find($planID); $authuser = Auth::user(); $coupons_id = ''; 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; 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 = $plan->id; $authuser->save(); $assignPlan = $authuser->assignPlan($plan->id); if($assignPlan['is_success'] == true && !empty($plan)) { $orderID = time(); PlanOrder::create( [ 'order_id' => $orderID, 'name' => null, '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($payment_setting['CURRENCY']) ? $payment_setting['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.')); } } try{ CoinGate::config( array( 'environment' => $this->mode, 'auth_token' => $this->coingate_auth_token, 'curlopt_ssl_verifypeer' => FALSE, ) ); // $client = new Client(config('environment',$this->mode), config('auth_token',$this->coingate_auth_token), config('curlopt_ssl_verifypeer', FALSE)); $post_params = array( 'order_id' => time(), 'price_amount' => $price, 'price_currency' => $payment_setting['CURRENCY'], 'receive_currency' => $payment_setting['CURRENCY'], 'callback_url' => route( 'plan.coingate', [ $request->plan_id, 'coupon_id=' . $coupons_id, ] ), 'cancel_url' => route('stripe', [$request->plan_id]), 'success_url' => route( 'plan.coingate', [ $request->plan_id, 'coupon_id=' . $coupons_id, ] ), 'title' => 'Plan #' . time(), ); // $order = \CoinGate\Merchant\Order::create($post_params); $order = Coingate::coingatePayment($post_params, 'POST'); } catch(\Exception $e) { return redirect()->back()->with('error', $e); } if($order['status_code'] === 200) { $response = $order['response']; return redirect($response['payment_url']); } else { return redirect()->back()->with('error', __('Opps something went wrong.')); } } else { return redirect()->back()->with('error', 'Plan is deleted.'); } } public function getPaymentStatus(Request $request,$plan) { $user = Auth::user(); $planID = \Illuminate\Support\Facades\Crypt::decrypt($plan); $plan_id = $planID; $store_id = \Auth::user()->current_store; $payment_setting = Utility::getAdminPaymentSetting(); $plan = Plan::find($plan_id); $price = $plan->price; if($plan) { $orderID = time(); if($request->has('coupon_id') && $request->coupon_id != '') { $coupons = Coupon::find($request->coupon_id); if(!empty($coupons)) { $userCoupon = new UserCoupon(); $userCoupon->user = $user->id; $userCoupon->coupon = $coupons->id; $userCoupon->order = $orderID; $userCoupon->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 PlanOrder(); $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 = $price; $order->price_currency = $payment_setting['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(); Utility::referralTransaction($plan); $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']); } } else { return redirect()->route('plans.index')->with('error', __('Plan is deleted.')); } } }