Ejemplo n.º 1
0
 public function withdraw()
 {
     $user = User::whereType('twitcher')->where('balance', '>', 0.1)->get();
     if (count($user) > 10) {
         $user = $user->random(10);
     }
     $faker = $this->faker;
     foreach ($user as $u) {
         try {
             $account = $faker->freeEmail;
             $amount = rand(3, $u->availableBalance());
             PaymentMapper::withdrawPaypalPrepare($u, $account, $amount);
             NotificationMapper::withdraw($u, $amount, 'USD', 'paypal', $account);
             LogMapper::log('withdraw', $u->id, 'request', ['account' => $account, 'merchant' => 'paypal', 'amount' => $amount]);
         } catch (\Exception $e) {
             dd($e->getTraceAsString());
         }
     }
 }
Ejemplo n.º 2
0
 public function withdraw(Request $request)
 {
     $min = PaymentMapper::getMinWithdraw($this->user);
     $rules = ['amount' => 'required|numeric|min:' . $min . '|max:1000', 'account' => 'required|email'];
     $this->validate($request, $rules);
     $amount = floatval($request->get('amount'));
     if ($amount > $this->user->availableBalance()) {
         return redirect('/user/twitcher/billing')->withErrors(['amount' => 'You have no such money']);
     }
     $account = $request->get('account');
     PaymentMapper::withdrawPaypalPrepare($this->user, $account, $amount);
     NotificationMapper::withdraw($this->user, $amount, 'USD', 'paypal', $account);
     LogMapper::log('withdraw', $this->user->id, 'request', ['account' => $account, 'merchant' => 'paypal', 'amount' => $amount]);
     $coupon = CouponMapper::byCode('ADD25USD');
     if ($coupon) {
         if (!CouponMapper::paidByUser($this->user, $coupon)) {
             CouponMapper::pay($this->user, $coupon);
         }
     }
     return redirect('/user/twitcher/billing')->with(['success' => 'You required withdrawal']);
 }
Ejemplo n.º 3
0
 public function transfers()
 {
     $transfers = PaymentMapper::transfers($this->user);
     return view('app.pages.user.client.billing.transfers', compact('transfers'));
 }