/** * @param $user * @param $amount * @return void */ private function setupNewMember(User $user, $amount) { //At this point the day of the month hasn't been set for the user, set it now $user->updateSubscription('paypal', Carbon::now()->day); //if this is blank then the user hasn't been setup yet $subCharge = $this->subscriptionChargeRepository->createCharge($user->id, Carbon::now(), $amount); }
/** * Create the sub charge for each member, only do this for members with dates matching the supplied date * * @param Carbon $targetDate */ public function createSubscriptionCharges($targetDate) { $users = $this->userRepository->getBillableActive(); foreach ($users as $user) { if ($user->payment_day == $targetDate->day && !$this->subscriptionChargeRepository->chargeExists($user->id, $targetDate)) { $this->subscriptionChargeRepository->createCharge($user->id, $targetDate); } } }