/** * Paiement accepté */ public function accepted(Request $request) { if (empty($_POST['token']) && empty($_POST['PayerID'])) { return Response::view('errors.403', array(), 403); } $id = Session::get('shop.id'); $shops = Shops::where('id', $id)->firstOrFail(); $token = Input::get('token'); $PayerID = Input::get('PayerID'); $paypal = new PaypalPayment(); $response = $paypal->request('GetExpressCheckoutDetails', array('TOKEN' => $token)); if ($response) { if ($response['CHECKOUTSTATUS'] == 'PaymentActionCompleted') { return redirect('/shop/payment/failed'); } } else { return redirect('/shop/payment/failed'); } $params = array('TOKEN' => $token, 'PAYERID' => $PayerID, 'PAYMENTACTION' => 'Sale', 'PAYMENTREQUEST_0_AMT' => $shops->price, 'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR', 'L_PAYMENTREQUEST_0_NAME0' => $shops->name, 'L_PAYMENTREQUEST_0_AMT0' => $shops->price, 'L_PAYMENTREQUEST_0_QTY0' => 1); $response = $paypal->request('DoExpressCheckoutPayment', $params); if ($response) { $transaction_id = $response['PAYMENTINFO_0_TRANSACTIONID']; $paypal_store = new Paypal(); $paypal_store->id_shop = $shops->name; $paypal_store->id_user = $request->user()->name; $paypal_store->id_arma = $request->user()->arma; $paypal_store->id_transaction = $transaction_id; $paypal_store->price = $shops->price; $paypal_store->save(); $time = time(); DB::table('players')->where('playerid', $request->user()->arma)->update(array('donatorlvl' => $shops->level, 'duredon' => $shops->time, 'timestamp' => $time)); return view('shops.accepted'); } else { return redirect('/shop/payment/failed'); } }
public function paypal() { if ($this->auth->user()->rank != 3) { abort(403); } $user = $this->auth->user(); $logs = Paypal::all(); return view('admin.paypal.index', compact('user', 'logs')); }