Example #1
0
 public function createButtonHTML($request)
 {
     $options = $request->getOptions();
     $rid = $request->getPrimaryOffer()->getResource()->getRID();
     $builder = new TPClientBuilder();
     $rdata = $builder->buildPurchaseRequest($request);
     $sb = "";
     $sb .= "<tp:request type=\"purchase\" ";
     $sb .= "rid=\"" . $rid . "\"";
     $sb .= " url=\"" . $this->config->getEndPoint() . TPConfig::$CONTEXT . "\"";
     $sb .= " rdata=\"" . preg_replace('/"/', '\\"', $rdata) . "\"";
     $sb .= " aid=\"" . $this->config->AID . "\"";
     $sb .= " cn=\"" . TPConfig::getTokenCookieName($this->config->AID) . "\"";
     $sb .= " v=\"" . TPConfig::$VERSION . "\"";
     if ($request->getCallback()) {
         $sb .= " oncheckaccess=\"" . $request->getCallback() . "\"";
     }
     if ($options != null) {
         if (isset($options["button.html"])) {
             $sb .= " custom=\"" . preg_replace('/"/', '&quot;', $options["button.html"]) . "\"";
         } elseif (isset($options["button.link"])) {
             $sb .= " link=\"" . preg_replace('/"/', '&quot;', $options["button.link"]) . "\"";
         }
     }
     $sb .= ">";
     $sb .= "</tp:request>";
     return $sb;
 }
 public function loadTokensFromCookie($cookies, $cookieName = null)
 {
     if ($cookieName == null) {
         $cookieName = TPConfig::getAppPrefix($this->config->AID) . TPConfig::$COOKIE_SUFFIX;
     }
     $unparsedTokenValue = '';
     if (is_array($cookies)) {
         foreach ($cookies as $name => $value) {
             if ($name == $cookieName) {
                 $unparsedTokenValue = $value;
                 break;
             }
         }
     } else {
         $unparsedTokenValue = $cookies;
     }
     $this->rawCookie = $unparsedTokenValue;
     if ($unparsedTokenValue != null) {
         $parser = new TPClientParser();
         $this->tokens = $parser->parseAccessTokens(urldecode($unparsedTokenValue));
     }
 }