Beispiel #1
0
 public static function createTimeBased($name, $trialPeriod, $lockoutPeriod)
 {
     $accessToken = new TPAccessToken(new TPRID($name));
     $accessToken->getTokenData()->addField(TPTokenData::METER_TYPE, TPTokenData::METER_REMINDER);
     $trialPeriodParsed = TPUtils::parseLoosePeriodInSecs($trialPeriod);
     $lockoutPeriodParsed = TPUtils::parseLoosePeriodInSecs($lockoutPeriod);
     $trialEndTime = TPUtils::now() + $trialPeriodParsed;
     $lockoutEndTime = $trialEndTime + $lockoutPeriodParsed;
     $accessToken->getTokenData()->addField(TPTokenData::METER_TRIAL_ENDTIME, $trialEndTime);
     $accessToken->getTokenData()->addField(TPTokenData::METER_LOCKOUT_ENDTIME, $lockoutEndTime);
     return new TPMeter($accessToken);
 }
 public function buildRequest(TPPurchaseRequest $request)
 {
     $ticketMap = array();
     $ticketMap["o1"] = $this->buildOffer($request->getPrimaryOffer());
     $ticketMap["t"] = TPUtils::now();
     $ticketMap["v"] = TPConfig::$MSG_VERSION;
     $ticketMap["cb"] = $request->getCallback();
     if ($request->getClientIP()) {
         $ticketMap["ip"] = $request->getClientIP();
     }
     if ($request->getUserRef() != null) {
         $ticketMap["uref"] = $request->getUserRef();
     }
     if ($request->getOptions() != null && count($request->getOptions()) > 0) {
         $ticketMap["opts"] = $request->getOptions();
     }
     if ($request->getSecondaryOffer() != null) {
         $ticketMap["o2"] = $this->buildOffer($request->getSecondaryOffer());
     }
     return $ticketMap;
 }
Beispiel #3
0
 public function isLockoutPeriodActive()
 {
     if ($this->isMetered()) {
         $expires = $this->getLockoutEndTimeSecs();
         if ($this->isTrialPeriodActive()) {
             return false;
         }
         if ($expires == null || $expires == 0) {
             return false;
         }
         return TPUtils::now() <= $expires;
     }
     return false;
 }