Ejemplo n.º 1
0
 /**
  * This static builder method allows the creation of the "Failed Payment" ProductBase 
  * object needed to cumpliment with the Checkout builder interface
  * 
  * @return \plenigo\models\ProductBase the object configured for the Failed Payment checkout workflow
  */
 public static function buildFailedPaymentProduct()
 {
     $res = new ProductBase("FAKE_PROD_ID");
     $res->setFailedPayment(TRUE);
     return $res;
 }
 /**
  * @param \GeorgRinger\News\Domain\Model\News $news
  * @param  integer $currentPage
  */
 public function detailActionSlot($news, $currentPage)
 {
     $plenigoFields = $this->getPlenigoFields($news->getUid());
     //        \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($plenigoFields);
     if (empty($plenigoFields)) {
         $GLOBALS['TSFE']->pageUnavailableAndExit("Plenigo Extension not configured yet or Error reading Data", 'HTTP/1.1 500 Internal Server Error');
         throw new \Exception("Plenigo Extension not configured yet or Error reading Data from News-Table");
         return true;
     }
     $this->plenigoSettings = $this->getPlenigoSettings();
     if (is_null($this->plenigoSettings)) {
         $GLOBALS['TSFE']->pageUnavailableAndExit("Plenigo Extension not configured yet or Error reading Data", 'HTTP/1.1 500 Internal Server Error');
     }
     $hasUserBought = null;
     //            $secret     = $plenigoSetting->getCompanyPrivateKey();
     //            $companyId  = $plenigoSetting->getCompanyID();
     //            $isTestMode = $plenigoSetting->isTestMode();
     $this->connect();
     // is there a category
     if ($plenigoFields['plenigo_category']) {
         $category = $this->getPlenigoCategory($plenigoFields['plenigo_category']);
         $productID = 'item-' . $news->getUid();
         // is it bought already?
         $hasUserBought = \plenigo\services\UserService::hasUserBought($productID);
         if (!$hasUserBought) {
             //creating the product ($productId, $productTitle, $price, $currency)
             try {
                 // new custom ProductID (https://github.com/plenigo/plenigo_php_sdk/wiki/Checkout#other-products)
                 $product = new \plenigo\models\ProductBase($productID, $news->getTitle());
                 $product->setCategoryId($category['plenigo_i_d']);
             } catch (\Exception $e) {
                 $GLOBALS['TSFE']->pageUnavailableAndExit("Could not create Plenigo-Product", 'HTTP/1.1 500 Internal Server Error');
             }
         }
     }
     // its not bought yet, but we have an associated product
     if (!$hasUserBought && $plenigoFields['plenigo_product']) {
         $productData = $this->getPlenigoProduct($plenigoFields['plenigo_product']);
         // ist it bought?
         $hasUserBought = \plenigo\services\UserService::hasUserBought($productData['product_i_d']);
         if (!$hasUserBought) {
             // https://github.com/plenigo/plenigo_php_sdk/wiki/Checkout#plenigo-managed-product
             try {
                 $product = new \plenigo\models\ProductBase($productData['product_i_d']);
                 //                    \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($productData);
             } catch (\Exception $e) {
                 $GLOBALS['TSFE']->pageUnavailableAndExit("Could not create Plenigo-Product", 'HTTP/1.1 500 Internal Server Error');
             }
         }
     }
     if (FALSE === $hasUserBought) {
         // inject our js-sdk into html-header
         $this->buildHeader();
         if (!is_object($product)) {
             $GLOBALS['TSFE']->pageUnavailableAndExit("Product is not bought, but no productidentity given", 'HTTP/1.1 500 Internal Server Error');
             throw new \Exception("no Product given!");
         }
         $curtain = new Curtain($this->plenigoSettings);
         $checkout = new \plenigo\builders\CheckoutSnippetBuilder($product);
         $builder = new \plenigo\builders\LoginSnippetBuilder();
         //This will generate the login snippet of the following format:
         //plenigo.login();
         $curtain->setLoginButton($builder->build());
         $curtain->setCheckoutCode($checkout->build());
         $news->setBodytext($this->getPaymentInfo($news->getBodytext()) . $curtain->getCode());
     }
     // else displaying normal news
 }