src/Controller/Website/ServiceController.php line 89

Open in your IDE?
  1. <?php
  2. namespace EADPlataforma\Controller\Website;
  3. use EADPlataforma\Error\ActionInvalidException;
  4. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use EADPlataforma\Error\AuthInvalidException;
  9. use EADPlataforma\Error\FieldException;
  10. use EADPlataforma\Error\NotFoundException;
  11. use EADPlataforma\Response\HttpOk;
  12. use EADPlataforma\Response\HttpNoContent;
  13. use EADPlataforma\Entity\Configuration;
  14. use EADPlataforma\Entity\Course;
  15. use EADPlataforma\Entity\Lesson;
  16. use EADPlataforma\Entity\Receiver;
  17. use EADPlataforma\Entity\Library;
  18. use EADPlataforma\Entity\Transaction;
  19. use EADPlataforma\Entity\UserNotify;
  20. use EADPlataforma\Enum\ServicesEnum;
  21. use EADPlataforma\Enum\ClientEnum;
  22. use EADPlataforma\Enum\CourseEnum;
  23. use EADPlataforma\Enum\ConfigurationEnum;
  24. use EADPlataforma\Enum\ContentTypeEnum;
  25. use EADPlataforma\Enum\LibraryEnum;
  26. use EADPlataforma\Enum\ErrorEnum;
  27. /**
  28.  * @Route(
  29.  *      schemes         = {"http|https"}
  30.  * )
  31.  * @Cache(
  32.  *      maxage          = "0",
  33.  *      smaxage         = "0",
  34.  *      expires         = "now",
  35.  *      public          = false
  36.  * )
  37.  */
  38. class ServiceController extends AbstractWebsiteController {
  39.     /**
  40.      * @Route(
  41.      *      path = "report/csp",
  42.      *      name = "reportCsp",
  43.      *      methods = {"POST"}
  44.      * )
  45.      */
  46.     public function reportCsp(Request $request): Response
  47.     {
  48.         if($request->headers->get('Content-Type') != ContentTypeEnum::CSP_REPORT){
  49.             return new Response('Invalid CSP Report'Response::HTTP_BAD_REQUEST);
  50.         }
  51.         $content $request->getContent();
  52.         $data json_decode($contenttrue);
  53.         if(isset($data['csp-report'])){
  54.             $dataStr "**REPORT**: {$data['csp-report']['document-uri']} \n";
  55.             unset($data['csp-report']['original-policy']);
  56.             unset($data['csp-report']['document-uri']);
  57.             unset($data['csp-report']['referrer']);
  58.             foreach ($data['csp-report'] as $key => $value) {
  59.                 $dataStr .= "{$key}{$value} \n";
  60.             }
  61.             $discordService $this->generalService->getService('DiscordService');
  62.             $discordService->setChannel('debug-csp');
  63.             $discordService->setMessage($dataStr);
  64.             $discordService->sendDiscord();
  65.             return new Response(nullResponse::HTTP_NO_CONTENT);
  66.         }
  67.         return new Response('Invalid CSP Report'Response::HTTP_BAD_REQUEST);
  68.     }
  69.     /**
  70.      * @Route(
  71.      *      path = "notify/auth",
  72.      *      name = "registerNotifyAuth",
  73.      *      methods = {"POST"}
  74.      * )
  75.      */
  76.     public function registerNotifyAuth(Request $request): Response
  77.     {
  78.         if(!$this->user){
  79.             return new Response('User not found'Response::HTTP_BAD_REQUEST);
  80.         }
  81.         $content $request->getContent();
  82.         $data json_decode($contenttrue);
  83.         if(
  84.             isset($data['endpoint']) && 
  85.             isset($data['platform']) && 
  86.             isset($data['token']) && 
  87.             isset($data['auth'])
  88.         ){
  89.             $userNotify $this->em->getRepository(UserNotify::class)->findOneBy([
  90.                 "endpoint" => $data['endpoint'],
  91.                 "token" => $data['token'],
  92.                 "platform" => $data['platform'],
  93.                 "auth" => $data['auth'],
  94.             ]);
  95.             if($userNotify){
  96.                 if($userNotify->getUser()->getId() != $this->user->getId()){
  97.                     $userNotify->setUser($this->user);
  98.                     $this->em->flush();
  99.                 }
  100.                 return new Response(nullResponse::HTTP_NO_CONTENT);
  101.             }
  102.            
  103.             $userNotify = new UserNotify();
  104.             $userNotify->setUser($this->user);
  105.             $userNotify->setEndpoint($data['endpoint']);
  106.             $userNotify->setToken($data['token']);
  107.             $userNotify->setAuth($data['auth']);
  108.             $userNotify->setPlatform($data['platform']);
  109.             $this->em->persist($userNotify);
  110.             $this->em->flush();
  111.             return new Response(nullResponse::HTTP_NO_CONTENT);
  112.         }
  113.         return new Response('Invalid notify data'Response::HTTP_BAD_REQUEST);
  114.     }
  115.     /**
  116.      * @Route(
  117.      *      path    = "cart/RequestEadCheckout/",
  118.      *      name = "processDataEadCheckoutBar",
  119.      *      methods = {"GET","POST","PUT"}
  120.      * )
  121.      * @Route(
  122.      *      path    = "cart/RequestEadCheckout",
  123.      *      name = "processDataEadCheckout",
  124.      *      methods = {"GET","POST","PUT"}
  125.      * )
  126.      */
  127.     public function processDataEadCheckout(Request $request) {
  128.         $processEad $this->generalService->getService('Transaction\\ProcessEad');
  129.         $pagarMe $this->generalService->getService('PagarMe\\PagarMe');
  130.         $this->requestUtil->setRequest($request)->setData();
  131.         $postbackPayload $request->getContent();
  132.         $data = (object)$this->requestUtil->getData();
  133.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  134.         $host $request->headers->get('host');
  135.         if(stristr($host"doubleh")){
  136.             $debug true;
  137.         }
  138.         $discordService $this->generalService->getService('DiscordService');
  139.         $discordService->setChannel('debug');
  140.         
  141.         if($debug){
  142.             $discordService->setMessage("EAD Checkout - Start");
  143.             $discordService->sendDiscord();
  144.             $discordService->setMessage(json_encode($data));
  145.             $discordService->sendDiscord();
  146.         }
  147.         sleep(rand(15));
  148.         $processEad->setDebug($debug);
  149.         if($pagarMe->isPostValid($request) && isset($data->transaction['id'])){
  150.             try{
  151.                 $processEad->processTransactionEAD($data->transaction['id']);
  152.             } catch (\Exception $e) {
  153.                 if($debug){
  154.                     $discordService->setMessage($e->getMessage());
  155.                     $discordService->sendDiscord();
  156.                 }
  157.                 return $this->eadResponse([
  158.                     "success" => ErrorEnum::NO,
  159.                     "message" => $e->getMessage(),
  160.                 ], ErrorEnum::INTERNAL_ERRORtruetrue);
  161.             }
  162.         }else{
  163.             return $this->eadResponse([
  164.                 "success" => ErrorEnum::NO
  165.             ], ErrorEnum::AUTH_INVALIDtruetrue);
  166.         }
  167.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  168.     }
  169.     /**
  170.      * @Route(
  171.      *      path = "hotmart/",
  172.      *      name = "processDataHotmartBar",
  173.      *      methods = {"GET","POST","PUT"}
  174.      * )
  175.      * @Route(
  176.      *      path = "hotmart",
  177.      *      name = "processDataHotmart",
  178.      *      methods = {"GET","POST","PUT"}
  179.      * )
  180.      */
  181.     public function processDataHotmart(Request $request) {
  182.         $processHotmart $this->generalService->getService('Transaction\\ProcessHotmart');
  183.         $this->requestUtil->setRequest($request)->setData();
  184.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  185.         $discordService $this->generalService->getService('DiscordService');
  186.         $discordService->setChannel('debug');
  187.         
  188.         $data = (object)$this->requestUtil->getData();
  189.         if($debug){
  190.             $discordService->setMessage("Hotmart - Start");
  191.             $discordService->sendDiscord();
  192.             $discordService->setMessage(json_encode($data));
  193.             $discordService->sendDiscord();
  194.         }
  195.         sleep(rand(15));
  196.         $processHotmart->setDebug($debug);
  197.         try{
  198.             $processHotmart->processTransactionHotmart($data);
  199.         } catch (\Exception $e) {
  200.             if($debug){
  201.                 $discordService->setMessage($e->getMessage());
  202.                 $discordService->sendDiscord();
  203.             }
  204.             return $this->eadResponse([
  205.                 "success" => ErrorEnum::NO,
  206.                 "message" => $e->getMessage(),
  207.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  208.         }
  209.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  210.     }
  211.     /**
  212.      * @Route(
  213.      *      path = "paypal/",
  214.      *      name = "processDataPayPalBar",
  215.      *      methods = {"GET","POST","PUT"}
  216.      * )
  217.      * @Route(
  218.      *      path = "paypal",
  219.      *      name = "processDataPayPal",
  220.      *      methods = {"GET","POST","PUT"}
  221.      * )
  222.      */
  223.     public function processDataPayPal(Request $request) {
  224.         $processPayPal $this->generalService->getService('Transaction\\ProcessPayPal');
  225.         $payPal $this->generalService->getService('PayPal\\PayPal');
  226.         $this->requestUtil->setRequest($request)->setData();
  227.         
  228.         $data $this->requestUtil->getData();
  229.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  230.         $discordService $this->generalService->getService('DiscordService');
  231.         $discordService->setChannel('debug');
  232.         if($debug){
  233.             $discordService->setMessage("Paypal - Start");
  234.             $discordService->sendDiscord();
  235.             $discordService->setMessage(json_encode((object)$data));
  236.             $discordService->sendDiscord();
  237.         }
  238.         sleep(rand(15));
  239.         $processPayPal->setDebug($debug);
  240.         try{
  241.             if($payPal->isPostValid($data)){
  242.                 $processPayPal->processTransactionPayPal((object)$data);
  243.             }
  244.         } catch (\Exception $e) {
  245.             if($debug){
  246.                 $discordService->setMessage($e->getMessage());
  247.                 $discordService->sendDiscord();
  248.             }
  249.             return $this->eadResponse([
  250.                 "success" => ErrorEnum::NO,
  251.                 "message" => $e->getMessage(),
  252.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  253.         }
  254.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  255.     }
  256.     /**
  257.      * @Route(
  258.      *      path = "pagseguro/",
  259.      *      name = "processDataPagSeguroBar",
  260.      *      methods = {"GET","POST","PUT"}
  261.      * )
  262.      * @Route(
  263.      *      path = "pagseguro",
  264.      *      name = "processDataPagSeguro",
  265.      *      methods = {"GET","POST","PUT"}
  266.      * )
  267.      */
  268.     public function processDataPagSeguro(Request $request) {
  269.         $processPagSeguro $this->generalService->getService('Transaction\\ProcessPagSeguro');
  270.         $pagSeguro $this->generalService->getService('PagSeguro\\PagSeguro');
  271.         $this->requestUtil->setRequest($request)->setData();
  272.         
  273.         $data $this->requestUtil->getData();
  274.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  275.         $discordService $this->generalService->getService('DiscordService');
  276.         $discordService->setChannel('debug');
  277.         if($debug){
  278.             $discordService->setMessage("Pagseguro - Start");
  279.             $discordService->sendDiscord();
  280.             $discordService->setMessage(json_encode((object)$data));
  281.             $discordService->sendDiscord();
  282.         }
  283.         sleep(rand(15));
  284.         $processPagSeguro->setDebug($debug);
  285.         
  286.         try{
  287.             if($pagSeguro->isPostValid($data)){
  288.                 $processPagSeguro->processTransactionPagSeguro((object)$data);
  289.             }
  290.         } catch (\Exception $e) {
  291.             if($debug){
  292.                 $discordService->setMessage($e->getMessage());
  293.                 $discordService->sendDiscord();
  294.             }
  295.             return $this->eadResponse([
  296.                 "success" => ErrorEnum::NO,
  297.                 "message" => $e->getMessage(),
  298.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  299.         }
  300.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  301.     }
  302.     /**
  303.      * @Route(
  304.      *      path = "eduzz/",
  305.      *      name = "processDataEduzzBar",
  306.      *      methods = {"GET","POST","PUT"}
  307.      * )
  308.      * @Route(
  309.      *      path = "eduzz",
  310.      *      name = "processDataEduzz",
  311.      *      methods = {"GET","POST","PUT"}
  312.      * )
  313.      */
  314.     public function processDataEduzz(Request $request) {
  315.         $processEduzz $this->generalService->getService('Transaction\\ProcessEduzz');
  316.         $this->requestUtil->setRequest($request)->setData();
  317.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  318.         $data = (object)$this->requestUtil->getData();
  319.         $discordService $this->generalService->getService('DiscordService');
  320.         $discordService->setChannel('debug');
  321.         if($debug){
  322.             $discordService->setMessage("Eduzz - Start");
  323.             $discordService->sendDiscord();
  324.             $discordService->setMessage(json_encode($data));
  325.             $discordService->sendDiscord();
  326.         }
  327.         sleep(rand(15));
  328.         $processEduzz->setDebug($debug);
  329.         try{
  330.             $processEduzz->processTransactionEduzz($data);
  331.         } catch (\Exception $e) {
  332.             if($debug){
  333.                 $discordService->setMessage($e->getMessage());
  334.                 $discordService->sendDiscord();
  335.             }
  336.             return $this->eadResponse([
  337.                 "success" => ErrorEnum::NO,
  338.                 "message" => $e->getMessage(),
  339.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  340.         }
  341.         
  342.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  343.     }
  344.     /**
  345.      * @Route(
  346.      *      path = "provi/",
  347.      *      name = "processDataProviBar",
  348.      *      methods = {"GET","POST","PUT"}
  349.      * )
  350.      * @Route(
  351.      *      path = "provi",
  352.      *      name = "processDataProvi",
  353.      *      methods = {"GET","POST","PUT"}
  354.      * )
  355.      */
  356.     public function processDataProvi(Request $request) {
  357.         $processProvi $this->generalService->getService('Transaction\\ProcessProvi');
  358.         $this->requestUtil->setRequest($request)->setData(true);
  359.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  360.         $data = (object)$this->requestUtil->getData();
  361.         $discordService $this->generalService->getService('DiscordService');
  362.         $discordService->setChannel('debug');
  363.         if($debug){
  364.             $discordService->setMessage("Provi - Start");
  365.             $discordService->sendDiscord();
  366.             $discordService->setMessage(json_encode($data));
  367.             $discordService->sendDiscord();
  368.         }
  369.         sleep(rand(15));
  370.         $processProvi->setDebug($debug);
  371.         try{
  372.             $processProvi->processTransactionProvi($data);
  373.         } catch (\Exception $e) {
  374.             if($debug){
  375.                 $discordService->setMessage($e->getMessage());
  376.                 $discordService->sendDiscord();
  377.             }
  378.             return $this->eadResponse([
  379.                 "success" => ErrorEnum::NO,
  380.                 "message" => $e->getMessage(),
  381.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  382.         }
  383.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  384.     }
  385.     /**
  386.      * @Route(
  387.      *      path = "braip/",
  388.      *      name = "processDataBraipBar",
  389.      *      methods = {"GET","POST","PUT"}
  390.      * )
  391.      * @Route(
  392.      *      path = "braip",
  393.      *      name = "processDataBraip",
  394.      *      methods = {"GET","POST","PUT"}
  395.      * )
  396.      */
  397.     public function processDataBraip(Request $request) {
  398.         $processBraip $this->generalService->getService('Transaction\\ProcessBraip');
  399.         $this->requestUtil->setRequest($request)->setData();
  400.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  401.         $data = (object)$this->requestUtil->getData();
  402.         $discordService $this->generalService->getService('DiscordService');
  403.         $discordService->setChannel('debug');
  404.         if($debug){
  405.             $discordService->setMessage("Braip - Start");
  406.             $discordService->sendDiscord();
  407.             $discordService->setMessage(json_encode($data));
  408.             $discordService->sendDiscord();
  409.         }
  410.         sleep(rand(15));
  411.         try{
  412.             $processBraip->processTransactionBraip($data);
  413.         } catch (\Exception $e) {
  414.             if($debug){
  415.                 $discordService->setMessage($e->getMessage());
  416.                 $discordService->sendDiscord();
  417.             }
  418.             return $this->eadResponse([
  419.                 "success" => ErrorEnum::NO,
  420.                 "message" => $e->getMessage(),
  421.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  422.         }
  423.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  424.     }
  425.     /**
  426.      * @Route(
  427.      *      path = "monetizze/",
  428.      *      name = "processDataMonetizzeBar",
  429.      *      methods = {"GET","POST","PUT"}
  430.      * )
  431.      * @Route(
  432.      *      path = "monetizze",
  433.      *      name = "processDataMonetizze",
  434.      *      methods = {"GET","POST","PUT"}
  435.      * )
  436.      */
  437.     public function processDataMonetizze(Request $request) {
  438.         $processMonetizze $this->generalService->getService('Transaction\\ProcessMonetizze');
  439.         $this->requestUtil->setRequest($request)->setData();
  440.         sleep(rand(15));
  441.         try{
  442.             $debug = (int)$request->get('debug') == ServicesEnum::YES;
  443.             
  444.             $data = (object)$this->requestUtil->getData();
  445.             if(!empty($data->json)){
  446.                 $data json_decode($data->jsontrue);
  447.                 $data = (object)$data;
  448.             }
  449.             $discordService $this->generalService->getService('DiscordService');
  450.             $discordService->setChannel('debug');
  451.             if($debug){
  452.                 $discordService->setMessage("Monetizze - Start");
  453.                 $discordService->sendDiscord();
  454.                 $discordService->setMessage(json_encode($data));
  455.                 $discordService->sendDiscord();
  456.             }
  457.             $processMonetizze->setDebug($debug);
  458.         
  459.             $processMonetizze->processTransactionMonetizze($data);
  460.         }catch (\Exception $e) {
  461.             if($debug){
  462.                 $discordService->setMessage($e->getMessage());
  463.                 $discordService->sendDiscord();
  464.             }
  465.             return $this->eadResponse([
  466.                 "success" => ErrorEnum::NO,
  467.                 "message" => $e->getMessage(),
  468.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  469.         }
  470.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  471.     }
  472.     /**
  473.      * @Route(
  474.      *      path = "kiwify/",
  475.      *      name = "processDataKiwifyBar",
  476.      *      methods = {"GET","POST","PUT"}
  477.      * )
  478.      * @Route(
  479.      *      path = "kiwify",
  480.      *      name = "processDataKiwify",
  481.      *      methods = {"GET","POST","PUT"}
  482.      * )
  483.      */
  484.     public function processDataKiwify(Request $request) {
  485.         $processKiwify $this->generalService->getService('Transaction\\ProcessKiwify');
  486.         $this->requestUtil->setRequest($request)->setData();
  487.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  488.         $data = (object)$this->requestUtil->getData();
  489.         $discordService $this->generalService->getService('DiscordService');
  490.         $discordService->setChannel('debug');
  491.         if($debug){
  492.             $discordService->setMessage("Kiwify - Start");
  493.             $discordService->sendDiscord();
  494.             $discordService->setMessage(json_encode($data));
  495.             $discordService->sendDiscord();
  496.         }
  497.         sleep(rand(15));
  498.         $processKiwify->setDebug($debug);
  499.         try{
  500.             $processKiwify->processTransactionKiwify($data);
  501.         }catch (\Exception $e) {
  502.             if($debug){
  503.                 $discordService->setMessage($e->getMessage());
  504.                 $discordService->sendDiscord();
  505.             }
  506.             return $this->eadResponse([
  507.                 "success" => ErrorEnum::NO,
  508.                 "message" => $e->getMessage(),
  509.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  510.         }
  511.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  512.     }
  513.     /**
  514.      * @Route(
  515.      *      path = "dmguru/",
  516.      *      name = "processDataDigitalManagerGuruBar",
  517.      *      methods = {"GET","POST","PUT"}
  518.      * )
  519.      * @Route(
  520.      *      path = "dmguru",
  521.      *      name = "processDataDigitalManagerGuru",
  522.      *      methods = {"GET","POST","PUT"}
  523.      * )
  524.      */
  525.     public function processDataDigitalManagerGuru(Request $request) {
  526.         $processDigitalManagerGuru $this->generalService->getService(
  527.             'Transaction\\ProcessDigitalManagerGuru'
  528.         );
  529.         $this->requestUtil->setRequest($request)->setData(true);
  530.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  531.         $data = (object)$this->requestUtil->getData();
  532.         $discordService $this->generalService->getService('DiscordService');
  533.         $discordService->setChannel('debug');
  534.         if($debug){
  535.             $discordService->setMessage("Guru - Start");
  536.             $discordService->sendDiscord();
  537.             $discordService->setMessage(json_encode($data));
  538.             $discordService->sendDiscord();
  539.         }
  540.         sleep(rand(15));
  541.         $processDigitalManagerGuru->setDebug($debug);
  542.         try{
  543.             $processDigitalManagerGuru->processTransactionDigitalManagerGuru($data);
  544.         }catch (\Exception $e) {
  545.             if($debug){
  546.                 $discordService->setMessage($e->getMessage());
  547.                 $discordService->sendDiscord();
  548.             }
  549.             return $this->eadResponse([
  550.                 "success" => ErrorEnum::NO,
  551.                 "message" => $e->getMessage(),
  552.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  553.         }
  554.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  555.     }
  556.     /**
  557.      * @Route(
  558.      *      path = "appmax/",
  559.      *      name = "processDataAppMaxBar",
  560.      *      methods = {"GET","POST","PUT"}
  561.      * )
  562.      * @Route(
  563.      *      path = "appmax",
  564.      *      name = "processDataAppMax",
  565.      *      methods = {"GET","POST","PUT"}
  566.      * )
  567.      */
  568.     public function processDataAppMax(Request $request) {
  569.         $processAppMax $this->generalService->getService('Transaction\\ProcessAppMax');
  570.         $this->requestUtil->setRequest($request)->setData(true);
  571.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  572.         $data = (object)$this->requestUtil->getData();
  573.         $discordService $this->generalService->getService('DiscordService');
  574.         $discordService->setChannel('debug');
  575.         if($debug){
  576.             $discordService->setMessage("AppMax - Start");
  577.             $discordService->sendDiscord();
  578.             $discordService->setMessage(json_encode($data));
  579.             $discordService->sendDiscord();
  580.         }
  581.         sleep(rand(15));
  582.         $processAppMax->setDebug($debug);
  583.         try{
  584.             $processAppMax->processTransactionAppMax($data);
  585.         }catch (\Exception $e) {
  586.             if($debug){
  587.                 $discordService->setMessage($e->getMessage());
  588.                 $discordService->sendDiscord();
  589.             }
  590.             return $this->eadResponse([
  591.                 "success" => ErrorEnum::NO,
  592.                 "message" => $e->getMessage(),
  593.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  594.         }
  595.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  596.     }
  597.     /**
  598.      * @Route(
  599.      *      path = "doppus/",
  600.      *      name = "processDataDoppusBar",
  601.      *      methods = {"GET","POST","PUT"}
  602.      * )
  603.      * @Route(
  604.      *      path = "doppus",
  605.      *      name = "processDataDoppus",
  606.      *      methods = {"GET","POST","PUT"}
  607.      * )
  608.      */
  609.     public function processDataDoppus(Request $request) {
  610.         $processDoppus $this->generalService->getService('Transaction\\ProcessDoppus');
  611.         $this->requestUtil->setRequest($request)->setData();
  612.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  613.         $token $request->headers->get('doppus-token');
  614.         $content json_decode($request->getContent());
  615.         $data = (object)$content;
  616.         
  617.         $discordService $this->generalService->getService('DiscordService');
  618.         $discordService->setChannel('debug');
  619.         if($debug){
  620.             $discordService->setMessage("Doppus - Start");
  621.             $discordService->sendDiscord();
  622.             $discordService->setMessage("Token: $token");
  623.             $discordService->sendDiscord();
  624.             $discordService->setMessage(json_encode($data));
  625.             $discordService->sendDiscord();
  626.         }
  627.         if(empty($token)){
  628.             return $this->eadResponse([ "message" => "Token empty" ], ErrorEnum::AUTH_INVALID);
  629.         }
  630.         
  631.         sleep(rand(15));
  632.         $processDoppus->setDebug($debug);
  633.         try{
  634.             $processDoppus->processTransactionDoppus($data$token);
  635.         }catch (\Exception $e) {
  636.             if($debug){
  637.                 $discordService->setMessage($e->getMessage());
  638.                 $discordService->sendDiscord();
  639.             }
  640.             return $this->eadResponse([
  641.                 "success" => ErrorEnum::NO,
  642.                 "message" => $e->getMessage(),
  643.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  644.         }
  645.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  646.     }
  647.     /**
  648.      * @Route(
  649.      *      path = "ticto/",
  650.      *      name = "processDataTictoBar",
  651.      *      methods = {"GET","POST","PUT"}
  652.      * )
  653.      * @Route(
  654.      *      path = "ticto",
  655.      *      name = "processDataTicto",
  656.      *      methods = {"GET","POST","PUT"}
  657.      * )
  658.      */
  659.     public function processDataTicto(Request $request) {
  660.         $processTicto $this->generalService->getService('Transaction\\ProcessTicto');
  661.         $this->requestUtil->setRequest($request)->setData();
  662.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  663.         $data = (object)$this->requestUtil->getData();
  664.         $discordService $this->generalService->getService('DiscordService');
  665.         $discordService->setChannel('debug');
  666.         if($debug){
  667.             $discordService->setMessage("Ticto - Start");
  668.             $discordService->sendDiscord();
  669.             $discordService->setMessage(json_encode($data));
  670.             $discordService->sendDiscord();
  671.         }
  672.         sleep(rand(15));
  673.         $processTicto->setDebug($debug);
  674.         try{
  675.             $processTicto->processTransactionTicto($data);
  676.         }catch (\Exception $e) {
  677.             if($debug){
  678.                 $discordService->setMessage($e->getMessage());
  679.                 $discordService->sendDiscord();
  680.             }
  681.             return $this->eadResponse([
  682.                 "success" => ErrorEnum::NO,
  683.                 "message" => $e->getMessage(),
  684.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  685.         }
  686.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  687.     }
  688.     /**
  689.      * @Route(
  690.      *      path = "mercadopago/",
  691.      *      name = "processDataMercadoPagoBar",
  692.      *      methods = {"GET","POST","PUT"}
  693.      * )
  694.      * @Route(
  695.      *      path = "mercadopago",
  696.      *      name = "processDataMercadoPago",
  697.      *      methods = {"GET","POST","PUT"}
  698.      * )
  699.      */
  700.     public function processDataMercadoPago(Request $request) {
  701.         $processMercadoPago $this->generalService->getService(
  702.             'Transaction\\ProcessMercadoPago'
  703.         );
  704.         $mercadoPago $this->generalService->getService('MercadoPago\\MercadoPago');
  705.         $this->requestUtil->setRequest($request)->setData();
  706.         
  707.         $data $this->requestUtil->getData();
  708.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  709.         $discordService $this->generalService->getService('DiscordService');
  710.         $discordService->setChannel('debug');
  711.         if($debug){
  712.             $discordService->setMessage("MercadoPago - Start");
  713.             $discordService->sendDiscord();
  714.             $discordService->setMessage(json_encode((object)$data));
  715.             $discordService->sendDiscord();
  716.         }
  717.         sleep(rand(15));
  718.         $processMercadoPago->setDebug($debug);
  719.         
  720.         try{
  721.             if(!$mercadoPago->isPostValid($data)){
  722.                 throw new ActionInvalidException("Only transaction requests are allowed.");
  723.             }
  724.             $processMercadoPago->processTransactionMercadoPago((object)$data);
  725.         } catch (\Exception $e) {
  726.             if($debug){
  727.                 $discordService->setMessage($e->getMessage());
  728.                 $discordService->sendDiscord();
  729.             }
  730.             return $this->eadResponse([
  731.                 "success" => ErrorEnum::NO,
  732.                 "message" => $e->getMessage(),
  733.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  734.         }
  735.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  736.     }
  737.     /**
  738.      * @Route(
  739.      *      path = "abmex/",
  740.      *      name = "processDataAbmexBar",
  741.      *      methods = {"GET","POST","PUT"}
  742.      * )
  743.      * @Route(
  744.      *      path = "abmex",
  745.      *      name = "processDataAbmex",
  746.      *      methods = {"GET","POST","PUT"}
  747.      * )
  748.      */
  749.     public function processDataAbmex(Request $request) {
  750.         $processAbmex $this->generalService->getService('Transaction\\ProcessAbmex');
  751.         $this->requestUtil->setRequest($request)->setData();
  752.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  753.         $data = (object)$this->requestUtil->getData();
  754.         $discordService $this->generalService->getService('DiscordService');
  755.         $discordService->setChannel('debug');
  756.         if($debug){
  757.             $discordService->setMessage("Abmex - Start");
  758.             $discordService->sendDiscord();
  759.             $discordService->setMessage(json_encode($data));
  760.             $discordService->sendDiscord();
  761.         }
  762.         sleep(rand(15));
  763.         $processAbmex->setDebug($debug);
  764.         try{
  765.             $processAbmex->processTransactionAbmex($data);
  766.         }catch (\Exception $e) {
  767.             if($debug){
  768.                 $discordService->setMessage($e->getMessage());
  769.                 $discordService->sendDiscord();
  770.             }
  771.             return $this->eadResponse([
  772.                 "success" => ErrorEnum::NO,
  773.                 "message" => $e->getMessage(),
  774.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  775.         }
  776.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  777.     }
  778.     /**
  779.      * @Route(
  780.      *      path = "perfectpay/",
  781.      *      name = "processDataPerfectPayBar",
  782.      *      methods = {"GET","POST","PUT"}
  783.      * )
  784.      * @Route(
  785.      *      path = "perfectpay",
  786.      *      name = "processDataPerfectPay",
  787.      *      methods = {"GET","POST","PUT"}
  788.      * )
  789.      */
  790.     public function processDataPerfectPay(Request $request) {
  791.         $processPerfectPay $this->generalService->getService(
  792.             'Transaction\\ProcessPerfectPay'
  793.         );
  794.         $this->requestUtil->setRequest($request)->setData();
  795.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  796.         $data = (object)$this->requestUtil->getData();
  797.         $discordService $this->generalService->getService('DiscordService');
  798.         $discordService->setChannel('debug');
  799.         if($debug){
  800.             $discordService->setMessage("PerfectPay - Start");
  801.             $discordService->sendDiscord();
  802.             $discordService->setMessage(json_encode($data));
  803.             $discordService->sendDiscord();
  804.         }
  805.         sleep(rand(15));
  806.         $processPerfectPay->setDebug($debug);
  807.         try{
  808.             $processPerfectPay->processTransactionPerfectPay($data);
  809.         }catch (\Exception $e) {
  810.             if($debug){
  811.                 $discordService->setMessage($e->getMessage());
  812.                 $discordService->sendDiscord();
  813.             }
  814.             return $this->eadResponse([
  815.                 "success" => ErrorEnum::NO,
  816.                 "message" => $e->getMessage(),
  817.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  818.         }
  819.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  820.     }
  821.     /**
  822.      * @Route(
  823.      *      path = "evermart/",
  824.      *      name = "processDataEvermartBar",
  825.      *      methods = {"GET","POST","PUT"}
  826.      * )
  827.      * @Route(
  828.      *      path = "evermart",
  829.      *      name = "processDataEvermart",
  830.      *      methods = {"GET","POST","PUT"}
  831.      * )
  832.      */
  833.     public function processDataEvermart(Request $request) {
  834.         $processEvermart $this->generalService->getService('Transaction\\ProcessEvermart');
  835.         $this->requestUtil->setRequest($request)->setData();
  836.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  837.         $data = (object)$this->requestUtil->getData();
  838.         $discordService $this->generalService->getService('DiscordService');
  839.         $discordService->setChannel('debug');
  840.         if($debug){
  841.             $discordService->setMessage("Evermart - Start");
  842.             $discordService->sendDiscord();
  843.             $discordService->setMessage(json_encode($data));
  844.             $discordService->sendDiscord();
  845.         }
  846.         sleep(rand(15));
  847.         $processEvermart->setDebug($debug);
  848.         try{
  849.             $processEvermart->processTransactionEvermart($data);
  850.         }catch (\Exception $e) {
  851.             if($debug){
  852.                 $discordService->setMessage($e->getMessage());
  853.                 $discordService->sendDiscord();
  854.             }
  855.             return $this->eadResponse([
  856.                 "success" => ErrorEnum::NO,
  857.                 "message" => $e->getMessage(),
  858.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  859.         }
  860.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  861.     }
  862.     /**
  863.      * @Route(
  864.      *      path = "herospark/",
  865.      *      name = "processDataHeroSparkBar",
  866.      *      methods = {"GET","POST","PUT"}
  867.      * )
  868.      * @Route(
  869.      *      path = "herospark",
  870.      *      name = "processDataHeroSpark",
  871.      *      methods = {"GET","POST","PUT"}
  872.      * )
  873.      */
  874.     public function processDataHeroSpark(Request $request) {
  875.         $processHeroSpark $this->generalService->getService('Transaction\\ProcessHeroSpark');
  876.         $this->requestUtil->setRequest($request)->setData();
  877.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  878.         $data = (object)$this->requestUtil->getData();
  879.         $discordService $this->generalService->getService('DiscordService');
  880.         $discordService->setChannel('debug');
  881.         if($debug){
  882.             $discordService->setMessage("HeroSpark - Start");
  883.             $discordService->sendDiscord();
  884.             $discordService->setMessage(json_encode($data));
  885.             $discordService->sendDiscord();
  886.         }
  887.         sleep(rand(15));
  888.         $processHeroSpark->setDebug($debug);
  889.         try{
  890.             $processHeroSpark->processTransactionHeroSpark($data);
  891.         }catch (\Exception $e) {
  892.             if($debug){
  893.                 $discordService->setMessage($e->getMessage());
  894.                 $discordService->sendDiscord();
  895.             }
  896.             return $this->eadResponse([
  897.                 "success" => ErrorEnum::NO,
  898.                 "message" => $e->getMessage(),
  899.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  900.         }
  901.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  902.     }
  903.     /**
  904.      * @Route(
  905.      *      path = "yampi/",
  906.      *      name = "processDataYampi",
  907.      *      methods = {"GET","POST","PUT"}
  908.      * )
  909.      * @Route(
  910.      *      path = "yampi",
  911.      *      name = "processDataYampiBar",
  912.      *      methods = {"GET","POST","PUT"}
  913.      * )
  914.      */
  915.     public function processDataYampi(Request $request) {
  916.         $processYampi $this->generalService->getService('Transaction\\ProcessYampi');
  917.         $this->requestUtil->setRequest($request)->setData();
  918.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  919.         $data = (object)$this->requestUtil->getData();
  920.         $discordService $this->generalService->getService('DiscordService');
  921.         $discordService->setChannel('debug');
  922.         if($debug){
  923.             $discordService->setMessage("Yampi - Start");
  924.             $discordService->sendDiscord();
  925.             $discordService->setMessage(json_encode($data));
  926.             $discordService->sendDiscord();
  927.         }
  928.         sleep(rand(15));
  929.         $processYampi->setDebug($debug);
  930.         try{
  931.             $processYampi->processTransactionYampi($data);
  932.         }catch (\Exception $e) {
  933.             if($debug){
  934.                 $discordService->setMessage($e->getMessage());
  935.                 $discordService->sendDiscord();
  936.             }
  937.             return $this->eadResponse([
  938.                 "success" => ErrorEnum::NO,
  939.                 "message" => $e->getMessage(),
  940.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  941.         }
  942.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  943.     }
  944.     /**
  945.      * @Route(
  946.      *      path = "cartpanda/",
  947.      *      name = "processDataCartPanda",
  948.      *      methods = {"GET","POST","PUT"}
  949.      * )
  950.      * @Route(
  951.      *      path = "cartpanda",
  952.      *      name = "processDataCartPandaBar",
  953.      *      methods = {"GET","POST","PUT"}
  954.      * )
  955.      */
  956.     public function processDataCartPanda(Request $request) {
  957.         $processCartPanda $this->generalService->getService('Transaction\\ProcessCartPanda');
  958.         $this->requestUtil->setRequest($request)->setData();
  959.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  960.         $data = (object)$this->requestUtil->getData();
  961.         $discordService $this->generalService->getService('DiscordService');
  962.         $discordService->setChannel('debug');
  963.         if($debug){
  964.             $discordService->setMessage("CartPanda - Start");
  965.             $discordService->sendDiscord();
  966.             $discordService->setMessage(json_encode($data));
  967.             $discordService->sendDiscord();
  968.         }
  969.         sleep(rand(15));
  970.         $processCartPanda->setDebug($debug);
  971.         try{
  972.             $processCartPanda->processTransactionCartPanda($data);
  973.         }catch (\Exception $e) {
  974.             if($debug){
  975.                 $discordService->setMessage($e->getMessage());
  976.                 $discordService->sendDiscord();
  977.             }
  978.             return $this->eadResponse([
  979.                 "success" => ErrorEnum::NO,
  980.                 "message" => $e->getMessage(),
  981.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  982.         }
  983.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  984.     }
  985.     /**
  986.      * @Route(
  987.      *      path = "kirvano/",
  988.      *      name = "processDataKirvano",
  989.      *      methods = {"GET","POST","PUT"}
  990.      * )
  991.      * @Route(
  992.      *      path = "kirvano",
  993.      *      name = "processDataKirvanoBar",
  994.      *      methods = {"GET","POST","PUT"}
  995.      * )
  996.      */
  997.     public function processDataKirvano(Request $request) {
  998.         $processKirvano $this->generalService->getService('Transaction\\ProcessKirvano');
  999.         $this->requestUtil->setRequest($request)->setData();
  1000.         $debug = (int)$request->get('debug') == ServicesEnum::YES;
  1001.         $data = (object)$this->requestUtil->getData();
  1002.         $token $request->headers->get('security-token');
  1003.         $discordService $this->generalService->getService('DiscordService');
  1004.         $discordService->setChannel('debug');
  1005.         if($debug){
  1006.             $discordService->setMessage("Kirvano - Start");
  1007.             $discordService->sendDiscord();
  1008.             $discordService->setMessage("Token: $token");
  1009.             $discordService->sendDiscord();
  1010.             $discordService->setMessage(json_encode($data));
  1011.             $discordService->sendDiscord();
  1012.         }
  1013.         if(empty($token)){
  1014.             return $this->eadResponse([ "message" => "Token empty" ], ErrorEnum::AUTH_INVALID);
  1015.         }
  1016.         sleep(rand(15));
  1017.         
  1018.         $processKirvano->setDebug($debug);
  1019.         try{
  1020.             $processKirvano->processTransactionKirvano($data$token);
  1021.         }catch (\Exception $e) {
  1022.             if($debug){
  1023.                 $discordService->setMessage($e->getMessage());
  1024.                 $discordService->sendDiscord();
  1025.             }
  1026.             return $this->eadResponse([
  1027.                 "success" => ErrorEnum::NO,
  1028.                 "message" => $e->getMessage(),
  1029.             ], ErrorEnum::INTERNAL_ERRORtruetrue);
  1030.         }
  1031.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  1032.     }
  1033.     /**
  1034.      * @Route(
  1035.      *      path = "callback/rdstation/",
  1036.      *      name = "callbackRdStationBar",
  1037.      *      methods = {"GET","POST","PUT"}
  1038.      * )
  1039.      * @Route(
  1040.      *      path = "callback/rdstation",
  1041.      *      name = "callbackRdStation",
  1042.      *      methods = {"GET","POST","PUT"}
  1043.      * )
  1044.      */
  1045.     public function callbackRdStation(Request $request){
  1046.         $token $request->headers->get('X-AUTH-TOKEN');
  1047.         if($token != $this->generalService->getTokenCron()){
  1048.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1049.         }
  1050.         $this->requestUtil->setRequest($request)->setData();
  1051.         $tokenClient $this->requestUtil->getField('token');
  1052.         if (empty($tokenClient)) {
  1053.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1054.         }
  1055.         if ($this->clientConfig->getToken() != $tokenClient) {
  1056.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1057.         }
  1058.         $code $this->requestUtil->getField('code');
  1059.         //$debug = (int)$request->get('debug') == ServicesEnum::YES;
  1060.         $debug true;
  1061.         
  1062.         $discordService $this->generalService->getService('DiscordService');
  1063.         $discordService->setChannel('debug');
  1064.         if($debug){
  1065.             $discordService->setMessage("RDStation - Start");
  1066.             $discordService->sendDiscord();
  1067.             $discordService->setMessage(json_encode($code));
  1068.             $discordService->sendDiscord();
  1069.         }
  1070.         $rdService $this->generalService->getService('Marketing\\RdStationService');
  1071.         $rdService->setDebug($debug);
  1072.        
  1073.         if(!empty($code)){
  1074.             $this->configuration->set('rdstation_code'$code);
  1075.             $this->configuration->set("app_rd_user"ConfigurationEnum::YES);
  1076.             $this->configuration->set("app_rd_product"ConfigurationEnum::YES);
  1077.             $this->configuration->set("app_rd_course"ConfigurationEnum::YES);
  1078.             $this->configuration->set("app_rd_payment"ConfigurationEnum::YES);
  1079.             $this->configuration->set("app_rd_subscription"ConfigurationEnum::YES);
  1080.             $this->configuration->set("app_rd_group"ConfigurationEnum::YES);
  1081.             $this->configuration->set("app_rd_enrollment"ConfigurationEnum::YES);
  1082.             $rdService->getTokenAccess($code);
  1083.         }
  1084.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  1085.     }
  1086.     /**
  1087.      * @Route(
  1088.      *      path = "callback/bling/",
  1089.      *      name = "callbackBlingBar",
  1090.      *      methods = {"GET","POST","PUT"}
  1091.      * )
  1092.      * @Route(
  1093.      *      path = "callback/bling",
  1094.      *      name = "callbackBling",
  1095.      *      methods = {"GET","POST","PUT"}
  1096.      * )
  1097.      */
  1098.     public function callbackBling(Request $request){
  1099.         $discordService $this->generalService->getService('DiscordService');
  1100.         $discordService->setChannel('debug');
  1101.         $debug true;
  1102.         
  1103.         $token $request->headers->get('X-AUTH-TOKEN');
  1104.         if($debug){
  1105.             $discordService->setMessage("Bling - Start");
  1106.             $discordService->sendDiscord();
  1107.             $discordService->setMessage("Token: " $token);
  1108.             $discordService->sendDiscord();
  1109.         }
  1110.         
  1111.         if($token != $this->generalService->getTokenCron()){
  1112.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1113.         }
  1114.         $this->requestUtil->setRequest($request)->setData();
  1115.         $tokenClient $this->requestUtil->getField('token');
  1116.         if($debug){
  1117.             $discordService->setMessage("Token Client: " $tokenClient);
  1118.             $discordService->setMessage("Token Client Config: " $this->clientConfig->getToken());
  1119.             $discordService->sendDiscord();
  1120.         }
  1121.         if(empty($tokenClient)){
  1122.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1123.         }
  1124.         if($this->clientConfig->getToken() != $tokenClient){
  1125.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1126.         }
  1127.         $code $this->requestUtil->getField('code');
  1128.         
  1129.         if($debug){
  1130.             $discordService->setMessage("Código: " $code);
  1131.             $discordService->sendDiscord();
  1132.         }
  1133.         $blingAuthorization $this->generalService->getService(
  1134.             'Transaction\\Invoice\\BlingAuthorization'
  1135.         );
  1136.         $blingAuthorization->setDebug($debug);
  1137.         if(!empty($code)){
  1138.             $this->configuration->set('bling_code'$code);
  1139.             $blingAuthorization->getTokenAccess($code);
  1140.         }
  1141.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  1142.     }
  1143.     /**
  1144.      * @Route(
  1145.      *      path = "callback/dinamize/",
  1146.      *      name = "callbackDinamizeBar",
  1147.      *      methods = {"GET","POST","PUT"}
  1148.      * )
  1149.      * @Route(
  1150.      *      path = "callback/dinamize",
  1151.      *      name = "callbackDinamize",
  1152.      *      methods = {"GET","POST","PUT"}
  1153.      * )
  1154.      */
  1155.     public function callbackDinamize(Request $request){
  1156.         $token $request->headers->get('X-AUTH-TOKEN');
  1157.         if($token != $this->generalService->getTokenCron()){
  1158.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1159.         }
  1160.         $this->requestUtil->setRequest($request)->setData();
  1161.         $tokenClient $this->requestUtil->getField('token');
  1162.         if (empty($tokenClient)) {
  1163.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1164.         }
  1165.         if ($this->clientConfig->getToken() != $tokenClient) {
  1166.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1167.         }
  1168.         $code $this->requestUtil->getField('code');
  1169.         
  1170.         if(!empty($code)){
  1171.             $this->configuration->set('dinamize_token'$code);
  1172.         }
  1173.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  1174.     }
  1175.     /**
  1176.      * @Route(
  1177.      *      path          = "/client/info/{clientToken}",
  1178.      *      name          = "getClientInfo",
  1179.      *      methods       = {"GET"}
  1180.      * )
  1181.      */
  1182.     public function getClientInfo(Request $request)
  1183.     {
  1184.         $token $request->headers->get('X-AUTH-TOKEN');
  1185.         if($token != $this->generalService->getTokenCron()){
  1186.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1187.         }
  1188.         if($request->get('clientToken') != $this->clientConfig->getToken()){
  1189.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1190.         }
  1191.         $fileService $this->generalService->getService('FileService');
  1192.         $diskInfo $fileService->getClientSpaceDisk();
  1193.         $courseRepository $this->em->getRepository(Course::class);
  1194.         $coursesNumber $courseRepository->countAllCourses();
  1195.         $coursesNumberPublish $courseRepository->countAllCourses(CourseEnum::PUBLISHED);
  1196.         return $this->eadResponse([
  1197.             "coursesNumber" => $coursesNumber,
  1198.             "coursesNumberPublish" => $coursesNumberPublish,
  1199.             "diskRemaining" => $diskInfo->diskRemaining,
  1200.             "diskUsed" => $diskInfo->diskUsed,
  1201.             "diskTotal" => $diskInfo->diskTotal,
  1202.             "diskRemainingText" => $diskInfo->diskRemainingText,
  1203.             "diskUsedText" => $diskInfo->diskUsedText,
  1204.             "diskTotalText" => $diskInfo->diskTotalText,
  1205.             "diskPercent" => $diskInfo->diskPercent,
  1206.         ]);
  1207.     }
  1208.     /**
  1209.      * @Route(
  1210.      *      path          = "/client/downgrade/free/{clientToken}",
  1211.      *      name          = "downgradeToFree",
  1212.      *      methods       = {"GET"}
  1213.      * )
  1214.      */
  1215.     public function downgradeToFree(Request $request)
  1216.     {
  1217.         $token $request->headers->get('X-AUTH-TOKEN');
  1218.         if($token != $this->generalService->getTokenCron()){
  1219.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1220.         }
  1221.         if($request->get('clientToken') != $this->clientConfig->getToken()){
  1222.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1223.         }
  1224.         $fileService $this->generalService->getService('FileService');
  1225.         $diskInfo $fileService->getClientSpaceDisk();
  1226.         if($diskInfo->diskUsed >= ServicesEnum::MIN_SIZE_PLAN){
  1227.             return $this->eadResponse([
  1228.                 "message" => "Disk Size"
  1229.             ], ErrorEnum::ACTION_INVALID);
  1230.         }
  1231.         $domain $this->client->getDomainSecondary();
  1232.         if(!empty($domain)){
  1233.             $error $this->em->getRepository(Configuration::class)->deleteClientDomain($domain);
  1234.             if($error){
  1235.                 return $this->eadResponse([
  1236.                     "message" => "Custom Domain"
  1237.                 ], ErrorEnum::ACTION_INVALID);
  1238.             }
  1239.             $token $this->generalService->getTokenCron();
  1240.             $linkEadmin "https://connect.eadplataforma.com/app/park";
  1241.             $params "/{$token}/{$this->clientConfig->getToken()}/{$domain}/remove";
  1242.             file_get_contents($linkEadmin $params);
  1243.             $this->client->setDomainSecondary('');
  1244.             $this->clientConfig->setRedirect(ConfigurationEnum::NO);
  1245.             $this->emEadmin->flush();
  1246.             $this->em->flush();
  1247.         }
  1248.         $this->em->getRepository(Course::class)->updateCoursesToDraft();
  1249.         $this->em->getRepository(Receiver::class)->resetReceiversToDefault();
  1250.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  1251.     }
  1252.     /**
  1253.      * @Route(
  1254.      *      path          = "/client/upgrade/receivers/{clientToken}",
  1255.      *      name          = "upgradeReceivers",
  1256.      *      methods       = {"GET"}
  1257.      * )
  1258.      */
  1259.     public function upgradeReceivers(Request $request)
  1260.     {
  1261.         $token $request->headers->get('X-AUTH-TOKEN');
  1262.         if($token != $this->generalService->getTokenCron()){
  1263.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1264.         }
  1265.         if($request->get('clientToken') != $this->clientConfig->getToken()){
  1266.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1267.         }
  1268.         if($this->configuration->isTrial()){
  1269.             return $this->eadResponse(nullErrorEnum::ACTION_INVALID);
  1270.         }
  1271.         $this->em->getRepository(Receiver::class)->resetReceiversToClientDefault();
  1272.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  1273.     }
  1274.     /**
  1275.      * @Route(
  1276.      *      path          = "/remove/client/domain/{clientToken}",
  1277.      *      name          = "removeClientCustomDomain",
  1278.      *      methods       = {"DELETE"}
  1279.      * )
  1280.      */
  1281.     public function removeClientCustomDomain(Request $request)
  1282.     {
  1283.         $token $request->headers->get('X-AUTH-TOKEN');
  1284.         if($token != $this->generalService->getTokenCron()){
  1285.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1286.         }
  1287.         if($request->get('clientToken') != $this->clientConfig->getToken()){
  1288.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1289.         }
  1290.         $domain $this->client->getDomainSecondary();
  1291.         if(empty($domain)){
  1292.             return $this->eadResponse(nullErrorEnum::ACTION_INVALID);
  1293.         }
  1294.         $configurationRepository $this->em->getRepository(Configuration::class);
  1295.         $error $configurationRepository->deleteClientDomain($domain);
  1296.         if($error){
  1297.             return $this->eadResponse([ "message" => $error ], ErrorEnum::ACTION_INVALID);
  1298.         }
  1299.         return $this->eadResponse([ "success" => ErrorEnum::YES ]);
  1300.     }
  1301.     /**
  1302.      * @Route(
  1303.      *      path          = "/recover/transaction/item/{clientToken}",
  1304.      *      name          = "recoverTransactionItem",
  1305.      *      methods       = {"GET"}
  1306.      * )
  1307.      */
  1308.     public function recoverTransactionItem(Request $request)
  1309.     {
  1310.         $token $request->headers->get('X-AUTH-TOKEN');
  1311.         if($token != $this->generalService->getTokenCron()){
  1312.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1313.         }
  1314.         if($request->get('clientToken') != $this->clientConfig->getToken()){
  1315.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1316.         }
  1317.         $transactionRepository $this->em->getRepository(Transaction::class);
  1318.         $transactions $transactionRepository->getTransactionWithoutItem();
  1319.         foreach ($transactions as $key => $transaction) {
  1320.             $transactionRepository->processTransaction($transactiontruetruetruetrue);
  1321.         }
  1322.         return $this->eadResponse([
  1323.             "success" => ErrorEnum::YES,
  1324.             "count" => count($transactions),
  1325.         ]);
  1326.     }
  1327.     /**
  1328.      * @Route(
  1329.      *      path          = "/send/cron/{clientToken}",
  1330.      *      name          = "sendCron",
  1331.      *      methods       = {"GET"}
  1332.      * )
  1333.      */
  1334.     public function sendCron(Request $request)
  1335.     {
  1336.         $token $request->headers->get('X-AUTH-TOKEN');
  1337.         if($token != $this->generalService->getTokenCron()){
  1338.             return $this->eadResponse([ 
  1339.                 "message" => "Auth Invalid" 
  1340.             ], ErrorEnum::AUTH_INVALID);
  1341.         }
  1342.         if($request->get('clientToken') != $this->clientConfig->getToken()){
  1343.             return $this->eadResponse([ 
  1344.                 "message" => "Auth Invalid" 
  1345.             ], ErrorEnum::AUTH_INVALID);
  1346.         }
  1347.         $platformStatus $this->clientConfig->getPlatformStatus();
  1348.         $suspended ClientEnum::PLATFORM_STATUS_SUSPENDED;
  1349.         $canceled ClientEnum::PLATFORM_STATUS_CANCELED;
  1350.         
  1351.         if($platformStatus == $suspended || $platformStatus == $canceled){
  1352.             return $this->eadResponse([ 
  1353.                 "message" => "Plafatorma suspensa" 
  1354.             ], ErrorEnum::ACTION_INVALID);
  1355.         }
  1356.         $cronUrl "https://{$this->eadDomain}/general/{$this->clientConfig->getToken()}";
  1357.         $sqsService $this->generalService->getService('Aws\\AwsSqs');
  1358.         $info $sqsService->sendMessageCron($cronUrl);
  1359.         if($info->error){
  1360.             return $this->eadResponse([ 
  1361.                 "message" => $info->message
  1362.             ], ErrorEnum::ACTION_INVALID);
  1363.         }
  1364.         return $this->eadResponse([
  1365.             "success" => ErrorEnum::YES,
  1366.         ]);
  1367.     }
  1368.     /**
  1369.      * @Route(
  1370.      *      path          = "/run/updater/{clientToken}",
  1371.      *      name          = "runUpdater",
  1372.      *      methods       = {"GET"}
  1373.      * )
  1374.      */
  1375.     public function runUpdater(Request $request)
  1376.     {
  1377.         $token $request->headers->get('X-AUTH-TOKEN');
  1378.         if($token != $this->generalService->getTokenCron()){
  1379.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1380.         }
  1381.         if($request->get('clientToken') != $this->clientConfig->getToken()){
  1382.             return $this->eadResponse(nullErrorEnum::AUTH_INVALID);
  1383.         }
  1384.         $databaseManagerService $this->generalService->getService('DatabaseManagerService');
  1385.         $databaseManagerService->executeMigrations(true);
  1386.         return $this->eadResponse([
  1387.             "success" => ErrorEnum::YES,
  1388.         ]);
  1389.     }
  1390.     /**
  1391.      * @Route(
  1392.      *      path          = "/info",
  1393.      *      name          = "getInfo",
  1394.      *      methods       = {"GET"}
  1395.      * )
  1396.      */
  1397.     public function getInfo(Request $request)
  1398.     {
  1399.         $token $request->headers->get('X-AUTH-TOKEN');
  1400.         if($token != $this->generalService->getTokenCron()){
  1401.             throw new AuthInvalidException('Auth Invalid');
  1402.         }
  1403.         $domains = [
  1404.             $this->client->getDomainPrimary(),
  1405.         ];
  1406.         if(!empty($this->client->getDomainSecondary())){
  1407.             $domains[] = $this->client->getDomainSecondary();
  1408.         }
  1409.         $plan $this->configuration->getPlan();
  1410.         $limit = (int)$this->clientConfig->getLimitSimultaneousAccess();
  1411.         if(empty($limit)){
  1412.             $limit $plan->getLimitSimultaneousAccess();
  1413.         }
  1414.         $data = [
  1415.             "id" => $this->client->getClientId(),
  1416.             "planId" => $plan->getId(),
  1417.             "planTitle" => $plan->getTitle(),
  1418.             "urls" => $domains,
  1419.             "limit" => $limit,
  1420.         ];
  1421.         return new HttpOk($data);
  1422.     }
  1423.     /**
  1424.      * @Route(
  1425.      *      path          = "/info/course/{clientToken}",
  1426.      *      name          = "getInfoCourse",
  1427.      *      methods       = {"GET"}
  1428.      * )
  1429.      */
  1430.     public function getInfoCourse(Request $request)
  1431.     {
  1432.         $token $request->headers->get('X-AUTH-TOKEN');
  1433.         if($token != $this->generalService->getTokenCron()){
  1434.             throw new AuthInvalidException('Auth Invalid');
  1435.         }
  1436.         if($request->get('clientToken') != $this->clientConfig->getToken()){
  1437.             throw new AuthInvalidException('Auth Invalid');
  1438.         }
  1439.         $courseRepository $this->em->getRepository(Course::class);
  1440.         $courses $courseRepository->findBy([
  1441.             "deleted" => CourseEnum::ITEM_NO_DELETED
  1442.         ]);
  1443.         $data = [];
  1444.         foreach ($courses as $key => $course) {
  1445.             $data[] = (object)[
  1446.                 "title" => $course->getTitle(),
  1447.             ];
  1448.         }
  1449.         return new HttpOk($data);
  1450.     }
  1451.     /**
  1452.      * @Route(
  1453.      *      path          = "/genereate/eadmin/sso/{clientToken}",
  1454.      *      name          = "genereateAdminSSO",
  1455.      *      methods       = {"POST"}
  1456.      * )
  1457.      *
  1458.      * @throws ActionInvalidException
  1459.      * @throws FieldException
  1460.      */
  1461.     public function genereateAdminSSO(Request $request)
  1462.     {
  1463.         $this->requestUtil->setRequest($request)->setData();
  1464.         $token $request->headers->get('X-AUTH-TOKEN');
  1465.         if($token != $this->generalService->getTokenCron()){
  1466.             throw new AuthInvalidException('Auth Invalid');
  1467.         }
  1468.         if($request->get('clientToken') != $this->clientConfig->getToken()){
  1469.             throw new AuthInvalidException('Auth Invalid');
  1470.         }
  1471.         $userId $this->requestUtil->getField('userId');
  1472.         if(empty($userId)){
  1473.             throw new FieldException("FieldException", [ "userId" => "User cannot be empty" ]);
  1474.         }
  1475.         $url $this->requestUtil->getField('url');
  1476.         $domain $request->getHost();
  1477.         $signDomain $this->generalService->signDataWithExpiration(md5($domain));
  1478.         $signId $this->generalService->signDataWithExpiration(md5($userId));
  1479.         $data = [
  1480.             "url" => "https://{$domain}/login/eadmin/sso/{$signId}/{$signDomain}?url={$url}",
  1481.         ];
  1482.         return new HttpOk($data);
  1483.     }
  1484.     /**
  1485.      * @Route(
  1486.      *      path          = "/update/live/{clientToken}/{liveId}",
  1487.      *      name          = "updateLive",
  1488.      *      methods       = {"PATCH"}
  1489.      * )
  1490.      *
  1491.      * @throws AuthInvalidException
  1492.      * @throws ActionInvalidException
  1493.      * @throws FieldException
  1494.      * @throws NotFoundException
  1495.      */
  1496.     public function updateLive(Request $request)
  1497.     {
  1498.         $this->requestUtil->setRequest($request)->setData();
  1499.         $token $request->headers->get('X-AUTH-TOKEN');
  1500.         if($token != $this->generalService->getTokenCron()){
  1501.             throw new AuthInvalidException('Auth Invalid');
  1502.         }
  1503.         if($request->get('clientToken') != $this->clientConfig->getToken()){
  1504.             throw new AuthInvalidException('Auth Invalid');
  1505.         }
  1506.         $liveId $request->get('liveId');
  1507.         if(empty($liveId)){
  1508.             throw new FieldException("FieldException", [ "liveId" => "Live cannot be empty" ]);
  1509.         }
  1510.         $libraryRepository $this->em->getRepository(Library::class);
  1511.         $library $libraryRepository->findOneBy([
  1512.             "vdocipherVideoId" => $liveId
  1513.         ]);
  1514.         if(!$library){
  1515.             throw new NotFoundException("NotFoundException");
  1516.         }
  1517.         $videoId $library->getVdocipherVideoId();
  1518.         if(empty($videoId)){
  1519.             throw new NotFoundException("NotFoundException");
  1520.         }
  1521.         try{
  1522.             $vdocipherService $this->generalService->getService('VdocipherService');
  1523.             $videoData $vdocipherService->getVideo($videoId);
  1524.             $discordService $this->generalService->getService('DiscordService');
  1525.             $discordService->setChannel('debug');
  1526.             $discordService->setMessage(json_encode($videoData));
  1527.             $discordService->sendDiscord();
  1528.             $vdocipherService->addTagInVideo($videoId"B{$library->getId()}");
  1529.             $vdocipherService->addTagInVideo($videoId"video");
  1530.             $library->setOrigin(LibraryEnum::RECORD);
  1531.             $library->setType(LibraryEnum::CONTENT_VIDEO_FILE);
  1532.             $library->setFileName("EADLIVE_RECORD_{$library->getLiveStart('d_m_Y')}.mp4");
  1533.             $library->setFileSize($videoData->totalSizeBytes);
  1534.             $library->setFileExtension('mp4');
  1535.             $dateTimeUtil $this->generalService->getUtil('DateTimeUtil');
  1536.             $duration $dateTimeUtil->secToTime($videoData->length);
  1537.             $library->setDuration($duration);
  1538.             $this->em->flush();
  1539.         }catch (\Exception $e){
  1540.             $discordService $this->generalService->getService('DiscordService');
  1541.             $discordService->setChannel('debug');
  1542.             $discordService->setMessage($e->getMessage());
  1543.             $discordService->sendDiscord();
  1544.             throw new ActionInvalidException($e->getMessage());
  1545.         }
  1546.         return new HttpNoContent;
  1547.     }
  1548.     /**
  1549.      * @Route(
  1550.      *      path          = "/meet/record/{clientToken}/{lessonId}",
  1551.      *      name          = "meetRecordRegister",
  1552.      *      methods       = {"POST"}
  1553.      * )
  1554.      *
  1555.      * @throws AuthInvalidException
  1556.      * @throws ActionInvalidException
  1557.      * @throws FieldException
  1558.      * @throws NotFoundException
  1559.      */
  1560.     public function meetRecordRegister(Request $request)
  1561.     {
  1562.         $this->requestUtil->setRequest($request)->setData();
  1563.         $token $request->headers->get('X-AUTH-TOKEN');
  1564.         if($token != $this->generalService->getTokenCron()){
  1565.             throw new AuthInvalidException('Auth Invalid');
  1566.         }
  1567.         if($request->get('clientToken') != $this->clientConfig->getToken()){
  1568.             throw new AuthInvalidException('Auth Invalid');
  1569.         }
  1570.         $lessonId $request->get('lessonId');
  1571.         if(empty($lessonId)){
  1572.             throw new FieldException("FieldException", [ "lessonId" => "Lesson cannot be empty" ]);
  1573.         }
  1574.         $lessonRepository $this->em->getRepository(Lesson::class);
  1575.         $lesson $lessonRepository->findOneBy([
  1576.             "id" => $lessonId
  1577.         ]);
  1578.         if(!$lesson){
  1579.             throw new NotFoundException("NotFoundException");
  1580.         }
  1581.         $librarySave $lesson->getLibrary();
  1582.         if(!$librarySave){
  1583.             throw new NotFoundException("NotFoundException");
  1584.         }
  1585.         $videoLink $this->requestUtil->getField('videoLink');
  1586.         $duration = (int)$this->requestUtil->getField('duration');
  1587.         if(empty($videoLink)){
  1588.             throw new FieldException("FieldException", [ "videoLink" => "VideoLink cannot be empty" ]);
  1589.         }
  1590.         if(empty($duration)){
  1591.             throw new FieldException("FieldException", [ "duration" => "Duration cannot be empty" ]);
  1592.         }
  1593.         $vdocipherService $this->generalService->getService('VdocipherService');
  1594.         $videoId $vdocipherService->getCreateVideoByUrl($videoLink);
  1595.         if(empty($videoId)){
  1596.             throw new ActionInvalidException("ActionInvalidException");
  1597.         }
  1598.         try{
  1599.             $library = new Library();
  1600.             $today date('d_m_Y_H:i:s');
  1601.             $libraryTitle "EADMEET_RECORD_{$today}";
  1602.             $library->setUser($librarySave->getUser());
  1603.             $library->setOrigin(LibraryEnum::RECORD);
  1604.             $library->setType(LibraryEnum::CONTENT_VIDEO_FILE);
  1605.             $library->setStatus(LibraryEnum::PUBLISHED);
  1606.             $library->setFileExtension("mp4");
  1607.             $library->setTitle($libraryTitle);
  1608.             $library->setLink($videoId);
  1609.             $library->setVdocipherVideoId($videoId);
  1610.             $library->setRecordLibrary($librarySave);
  1611.             $library->setFileName("{$libraryTitle}.mp4");
  1612.             $dateTimeUtil $this->generalService->getUtil('DateTimeUtil');
  1613.             $duration $dateTimeUtil->secToTime($duration);
  1614.             $library->setDuration($duration);
  1615.             $this->em->persist($library);
  1616.             $this->em->flush();
  1617.             $data $library->toReturn();
  1618.             $this->userLogService->logInsert("library"$library->getId(), $data);
  1619.             
  1620.             $vdocipherService->addTagInVideo($videoId"B{$library->getId()}");
  1621.             $vdocipherService->addTagInVideo($videoId"video");
  1622.             $vdocipherService->addTagInVideo($videoId"meet");
  1623.             $vdocipherService->addTagInVideo($videoId$this->client->getClientId());
  1624.         }catch (\Exception $e){
  1625.             $discordService $this->generalService->getService('DiscordService');
  1626.             $discordService->setChannel('debug');
  1627.             $discordService->setMessage($e->getMessage());
  1628.             $discordService->sendDiscord();
  1629.             throw new ActionInvalidException($e->getMessage());
  1630.         }
  1631.         return new HttpNoContent;
  1632.     }
  1633. }