Esempio n. 1
0
 public function getSuccessPayment(Request $request)
 {
     $admin = User::where(['type' => 'admin'])->first();
     $gateway = Omnipay::create('PayPal_Express');
     $gateway->setUsername('fai1999.fa_api1.gmail.com');
     $gateway->setPassword('N8MALTPJ39RD3MG7');
     $gateway->setSignature('AVieiSDlpAV8gE.TnT6kpOEjJbTKAJJakY.PKQSfbkf.rc2Gy1N7vumm');
     $gateway->setTestMode(true);
     $params = Session::get('params');
     $response = $gateway->completePurchase($params)->send();
     $paypalResponse = $response->getData();
     // this is the raw response object
     if (isset($paypalResponse['PAYMENTINFO_0_ACK']) && $paypalResponse['PAYMENTINFO_0_ACK'] === 'Success') {
         // Response
         // print_r($paypalResponse);
     } else {
         //Failed transaction
     }
     $count = Transaction::where(['transactionid' => $paypalResponse['PAYMENTINFO_0_TRANSACTIONID']])->count();
     if ($count < 1) {
         Transaction::create(['senderid' => Auth::user()->id, 'transactionid' => $paypalResponse['PAYMENTINFO_0_TRANSACTIONID'], 'amount' => $paypalResponse['PAYMENTINFO_0_AMT'], 'recipientid' => $admin->id]);
         $balance = Balance::where(['userid' => Auth::user()->id])->first();
         $balance = $balance->balance + $paypalResponse['PAYMENTINFO_0_AMT'];
         Balance::where(['userid' => Auth::user()->id])->update(['balance' => $balance]);
     }
     if (Auth::user()->type != 'admin') {
         return redirect()->route('transactions');
     }
 }
Esempio n. 2
0
 public function getTransactions()
 {
     if (Auth::user()->type != 'admin') {
         $transactions = Transaction::where(['senderid' => Auth::user()->id])->orWhere(['recipientid' => Auth::user()->id])->get();
         $balance = Balance::where(['userid' => Auth::user()->id])->first();
         return view('project.main.transactions')->with('transactions', $transactions)->withbalance($balance)->with('title', 'Transactions | ' . $this->sitename);
     } else {
         $transaction = $transactions = Transaction::where(['senderid' => Auth::user()->id])->orWhere(['recipientid' => Auth::user()->id])->get();
         return view('project.main.admin.transactions')->with('transactions', $transactions)->with('title', 'Transactions | ' . $this->sitename);
     }
 }
Esempio n. 3
0
 public function getAdminPayments()
 {
     if (Auth::user()->type == 'admin') {
         $transactions = Transaction::where(['senderid' => Auth::user()->id])->orWhere(['recipientid' => Auth::user()->id])->get();
         return view('project.main.admin.payments')->with('transactions', $transactions)->with('title', 'Admin Payments | ' . $this->sitename);
     } else {
         return redirect()->route('auth.login');
     }
 }