Exemple #1
0
 public static function refillFromStripe(User $user, StripePaymentService $stripeService)
 {
     $amount = floatval($stripeService->response->amount / 100);
     $currency = $stripeService->response->currency;
     $transaction_number = $stripeService->response->id;
     $cart = [$stripeService->response->description];
     $response = $stripeService->response->__toArray();
     $payment = UserPayment::create(['user_id' => $user->id, 'merchant' => 'stripe', 'transaction_number' => $transaction_number, 'title' => 'refill', 'amount' => $amount, 'currency' => $currency, 'response' => $response, 'cart' => $cart]);
     $balance = $user->balance;
     $user->balance = $balance + $amount;
     $user->save();
     return $payment;
 }
 public function stripe()
 {
     $user = User::whereType('client')->get()->random(8);
     $faker = $this->faker;
     foreach ($user as $u) {
         try {
             $amount = rand(5, 50);
             $payment = UserPayment::create(['user_id' => $u->id, 'merchant' => 'stripe', 'transaction_number' => rand(1000000, 2000000), 'title' => 'refill', 'amount' => $amount, 'currency' => 'USD']);
             LogMapper::log('payment', $amount, 'refilled', ['payment_id' => $payment->id, 'merchant' => 'stripe']);
             NotificationMapper::refilled($payment);
         } catch (\Exception $e) {
             dd($e->getTraceAsString());
         }
     }
 }