public function pay($points, ContextInterface $context)
    {
        // decrease user points
        $this->userTable->payPoints($context->getUser()->getId(), $points);

        // add usage entry
        $this->usageTable->create([
            'route_id' => $context->getRouteId(),
            'user_id' => $context->getUser()->getId(),
            'app_id' => $context->getApp()->getId(),
            'points' => $points,
            'insert_date' => new \DateTime(),
        ]);

        // dispatch payed event
        $userContext = UserContext::newContext(
            $context->getUser()->getId(),
            $context->getApp()->getId()
        );

        $this->eventDispatcher->dispatch(PlanEvents::PAY, new PayedEvent($points, $userContext));
    }
public function pay($points, ContextInterface $context)
    {
        // decrease user points
        $this->userTable->payPoints($context->getUser()->getId(), $points);

        // add usage entry
        $this->usageTable->create([
            'route_id' => $context->getRouteId(),
            'user_id' => $context->getUser()->getId(),
            'app_id' => $context->getApp()->getId(),
            'points' => $points,
            'insert_date' => new \DateTime(),
        ]);

        // dispatch payed event
        $userContext = UserContext::newContext(
            $context->getUser()->getId(),
            $context->getApp()->getId()
        );

        $this->eventDispatcher->dispatch(PlanEvents::PAY, new PayedEvent($points, $userContext));
    }
public function pay ( $ points , ContextInterface $ context ) { // decrease user points $ this -> userTable -> payPoints ( $ context -> getUser ( ) -> getId ( ) , $ points ) ; // add usage entry $ this -> usageTable -> create ( [ 'route_id' => $ context -> getRouteId ( ) , 'user_id' => $ context -> getUser ( ) -> getId ( ) , 'app_id' => $ context -> getApp ( ) -> getId ( ) , 'points' => $ points , 'insert_date' => new \ DateTime ( ) , ] ) ; // dispatch payed event $ userContext = UserContext :: newContext ( $ context -> getUser ( ) -> getId ( ) , $ context -> getApp ( ) -> getId ( ) ) ; $ this -> eventDispatcher -> dispatch ( PlanEvents :: PAY , new PayedEvent ( $ points , $ userContext ) ) ; }
Method which is called in case a user visits a route which cost a
specific amount of points. This method decreases the points from the
user account

@param integer $points
@param \Fusio\Engine\ContextInterface $context
Method which is called in case a user visits a route which cost a specific amount of points . This method decreases the points from the user account