src/AppBundle/MainBundle/Controller/MainController.php line 47

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: apple
  5.  * Date: 23/04/19
  6.  * Time: 12:41 AM
  7.  */
  8. namespace App\AppBundle\MainBundle\Controller;
  9. use App\AppBundle\AdminBundle\Entity\AdminConfig;
  10. use App\AppBundle\AdminBundle\Services\Admin_Encryption;
  11. use App\AppBundle\APIBundle\Controller\BookingBaseController;
  12. use App\AppBundle\APIBundle\Services\Encryption;
  13. use App\AppBundle\APIBundle\Services\MailManager;
  14. use App\AppBundle\APIBundle\Services\ParkingSupplierService;
  15. use App\AppBundle\APIBundle\Services\PayoutService;
  16. use App\AppBundle\APIBundle\Services\WPGeneralService;
  17. use App\AppBundle\MainBundle\Client\StripeClient;
  18. use App\AppBundle\MainBundle\Constants\BookingType;
  19. use App\AppBundle\MainBundle\Constants\GeneralConstant;
  20. use App\AppBundle\MainBundle\Entity\Orders;
  21. use App\AppBundle\MainBundle\Entity\Orders_Suppliers_Transfers_Payout;
  22. use App\AppBundle\MainBundle\Entity\OrdersStripePaymentIntent;
  23. use App\AppBundle\MainBundle\Entity\PS_Add_Spot;
  24. use App\AppBundle\MainBundle\Entity\User;
  25. use App\AppBundle\MainBundle\Services\SendMail;
  26. use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
  27. use Knp\Snappy\Pdf;
  28. use Nelmio\ApiDocBundle\Annotation\Operation;
  29. use Stripe\Exception\ApiErrorException;
  30. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  31. use Symfony\Component\HttpFoundation\Request;
  32. use Symfony\Component\Routing\Annotation\Route;
  33. use Symfony\Component\HttpFoundation\JsonResponse;
  34. class MainController extends BookingBaseController
  35. {
  36.     /**
  37.      * @Route("home", name="home", methods={"GET"})
  38.      * @Route("home/")
  39.      * @Route("")
  40.      * @Route("/")
  41.      */
  42.     public function homeAction(Request $requestAdmin_Encryption $admin_Encryption)
  43.     {
  44.         // replace this example code with whatever you need
  45.         return $this->render('index.html.twig', [
  46.         ]);
  47.     }
  48.     /**
  49.      * @Route("/apple-app-site-association", name="apple-app-site-association", methods={"GET"})
  50.      * @Route("/.well-known/apple-app-site-association")
  51.      *
  52.      * @Operation(
  53.      *     consumes={"application/pkcs7-mime"})
  54.      *
  55.      */
  56.     public function getAppleAppSiteAssociation(Request $request) {
  57.         $responseArr = array();
  58.         $responseDetail = array();
  59.         $responseDetail[0]['appID'] = "76Y3KBZ44B.com.blueera.parkingsystem.main";
  60.         $responseDetail[0]['paths'][0] = "*";
  61.         $responseArr['applinks']['apps'] = ["76Y3KBZ44B.com.blueera.parkingsystem.main"];
  62.         $responseArr['applinks']['details'] = $responseDetail;
  63.         $responseAppsDetail = array();
  64.         $responseAppsDetail[0]['apps'] = ["76Y3KBZ44B.com.blueera.parkingsystem.main"];
  65.         $responseArr['webcredentials'] = $responseAppsDetail[0];
  66.         $jsonResponse = new JsonResponse($responseArr);
  67.         $jsonResponse->headers->set('Content-Type''application/pkcs7-mime');
  68.         return $jsonResponse;
  69.     }
  70.     /**
  71.      * @Route("test4", name="test-4", methods={"GET"})
  72.      */
  73.     public function test4Action(Request $requestStripeClient $stripeClientWPGeneralService $generalServiceParkingSupplierService $parkingSupplierServiceEncryption $encryptionSendMail $sendMailMailManager $mailManagerPdf $knpSnappyPdfPayoutService $payoutService)
  74.     {
  75.         $entityManager $this->getDoctrine()->getManager();
  76.         $orders $entityManager->getRepository(Orders::class)->findAll();
  77.         foreach ($orders as $order) {
  78.             if ($order instanceof Orders) {
  79.                 if ($order->getIsCompleted() == true && $order->getIsActive() == true) {
  80.                     if ($order->getBookingType() == BookingType::Monthly) {
  81.                         if ($order->getLatestMonthlyBookingPricingObj()->getInvoice() == NULL || $order->getLatestMonthlyBookingPricingObj()->getInvoice() == '') {
  82.                             $payoutService->createPdfCustomerInvoiceForUser($entityManager$order$knpSnappyPdf$generalService->getBaseUrl($request), $encryption);
  83.                         }
  84.                     } else {
  85.                         if ($order->getOrdersPricing()->getInvoice() == NULL || $order->getOrdersPricing()->getInvoice() == '') {
  86.                             $payoutService->createPdfCustomerInvoiceForUser($entityManager$order$knpSnappyPdf$generalService->getBaseUrl($request), $encryption);
  87.                         }
  88.                     }
  89.                 }
  90.             }
  91.         }
  92.         return $this->render('index.html.twig', [
  93.         ]);
  94.     }
  95.     /**
  96.      * @Route("test5", name="test-5", methods={"GET"})
  97.      */
  98.     public function test5(Request $requestStripeClient $stripeClientWPGeneralService $generalServiceParkingSupplierService $parkingSupplierServiceEncryption $encryptionSendMail $sendMailMailManager $mailManagerPdf $knpSnappyPdfPayoutService $payoutService)
  99.     {
  100.         $entityManager $this->getDoctrine()->getManager();
  101. //        $payouts = $entityManager->getRepository(Orders_Suppliers_Transfers_Payout::class)->findAll();
  102.         $payout $entityManager->getRepository(Orders_Suppliers_Transfers_Payout::class)->find(122);
  103.         $payouts = [$payout];
  104.         foreach ($payouts as $payout) {
  105.             if ($payout instanceof Orders_Suppliers_Transfers_Payout) {
  106. //                if ($payout->getInvoice() == NULL || $payout->getInvoice() == '') {
  107.                     echo $payout->getReferenceId();
  108.                     $payoutService->createPdfPayoutInvoiceForSupplier($entityManager$payout$knpSnappyPdf$generalService->getBaseUrl($request), $encryption);
  109.                     $supplierEmail $encryption->decryptData($payout->getSupplier()->getEmail());
  110. //                    $sendMail->sendPayoutEmailToSupplier($payout, $supplierEmail, $mailManager, $translator);
  111. //                }
  112.             }
  113.         }
  114.         return $this->render('index.html.twig', [
  115.         ]);
  116.     }
  117.     /**
  118.      * @Route("test", name="test", methods={"GET"})
  119.      */
  120.     public function testAction(Request $requestStripeClient $stripeClientWPGeneralService $generalServiceParkingSupplierService $parkingSupplierServiceEncryption $encryptionSendMail $sendMailMailManager $mailManagerPdf $knpSnappyPdf)
  121.     {
  122.         // replace this example code with whatever you need
  123. //        dump($stripeClient->getChargeDetails());
  124.         $entityManager $this->getDoctrine()->getManager();
  125. //        $userObj = $entityManager->getRepository(User::class)->find(1);
  126. //        $response = $parkingSupplierService->createChargeForSpotProvider($entityManager, $userObj, $stripeClient, $encryption, 1.0, 'chf', '0', $translator->trans('txt_manual_payout_fees', [], null, $languageCode), $languageCode, $translator);
  127. //        dump($response);
  128. //        $analytics = initializeAnalytics();
  129. //        $profile = getFirstProfileId($analytics);
  130. //        $results = getResults($analytics, $profile);
  131. //        printResults($results);
  132.         $payouts $entityManager->getRepository(Orders_Suppliers_Transfers_Payout::class)->findAll();
  133.         $objPayout $payouts[count($payouts) - 1];
  134.         $adminConfigArr $entityManager->getRepository(AdminConfig::class)->findAll();
  135.         if (count($adminConfigArr) == 0) {
  136.             $adminConfig = new AdminConfig();
  137.             $entityManager->persist($adminConfig);
  138.             $entityManager->flush();
  139.         } else {
  140.             $adminConfig $adminConfigArr[0];
  141.         }
  142. //
  143.         $html $this->renderView('invoice/index.html.twig', [
  144.             'payout' => $objPayout,
  145.             'admin_config' => $adminConfig,
  146.             'vat_rate' => GeneralConstant::VAT_PERCENTAGE_ON_COMMISSION,
  147.             'emailContent' => 'This content<br>Is sample content<br>just to check html',
  148.             'info_words' => 'This content Is sample content just to check html'
  149.         ]);
  150.         $knpSnappyPdf->setOption('lowquality'false);
  151. //
  152.         $knpSnappyPdf->setOption('no-outline'true);
  153.         $knpSnappyPdf->setOption('page-size','A4');
  154.         $knpSnappyPdf->setOption('encoding''UTF-8');
  155.         $knpSnappyPdf->setOption('margin-left'5);
  156.         $knpSnappyPdf->setOption('margin-right'5);
  157.         $footerHtml =  $this->renderView('invoice/footer.html.twig', [
  158.             'admin_config' => $adminConfig,
  159.             'baseUrl' => $generalService->getBaseUrl($request),
  160.             'locale' => $objPayout->getSupplier()->getLanguage()->getSymbol(),
  161.         ]);
  162.         $headerHtml =  $this->renderView('invoice/header.html.twig', []);
  163.         $knpSnappyPdf->setOption('header-html'$headerHtml);
  164.         $knpSnappyPdf->setOption('footer-html'$footerHtml);
  165.         $knpSnappyPdf->setOption('footer-font-size''7');
  166.         $fileName $this->getParameter('app.root_web').$this->getParameter('app.invoice_directory').time().'.pdf';
  167.         $knpSnappyPdf->generateFromHtml($html$fileName);
  168.         return $this->render('invoice/index.html.twig', [
  169.             'payout' => $objPayout,
  170.             'admin_config' => $adminConfig,
  171.             'vat_rate' => GeneralConstant::VAT_PERCENTAGE_ON_COMMISSION,
  172.             'emailContent' => 'This content<br>Is sample content<br>just to check html'
  173.         ]);
  174.     }
  175.     function initializeAnalytics()
  176.     {
  177.         // Creates and returns the Analytics Reporting service object.
  178.         // Use the developers console and download your service account
  179.         // credentials in JSON format. Place them in this directory or
  180.         // change the key file location if necessary.
  181.         $KEY_FILE_LOCATION __DIR__ '/service-account-credentials.json';
  182.         // Create and configure a new client object.
  183.         $client = new Google_Client();
  184.         $client->setApplicationName("Hello Analytics Reporting");
  185.         $client->setAuthConfig($KEY_FILE_LOCATION);
  186.         $client->setScopes(['https://www.googleapis.com/auth/analytics.readonly']);
  187.         $analytics = new Google_Service_Analytics($client);
  188.         return $analytics;
  189.     }
  190.     function getFirstProfileId($analytics) {
  191.         // Get the user's first view (profile) ID.
  192.         // Get the list of accounts for the authorized user.
  193.         $accounts $analytics->management_accounts->listManagementAccounts();
  194.         if (count($accounts->getItems()) > 0) {
  195.             $items $accounts->getItems();
  196.             $firstAccountId $items[0]->getId();
  197.             // Get the list of properties for the authorized user.
  198.             $properties $analytics->management_webproperties
  199.                 ->listManagementWebproperties($firstAccountId);
  200.             if (count($properties->getItems()) > 0) {
  201.                 $items $properties->getItems();
  202.                 $firstPropertyId $items[0]->getId();
  203.                 // Get the list of views (profiles) for the authorized user.
  204.                 $profiles $analytics->management_profiles
  205.                     ->listManagementProfiles($firstAccountId$firstPropertyId);
  206.                 if (count($profiles->getItems()) > 0) {
  207.                     $items $profiles->getItems();
  208.                     // Return the first view (profile) ID.
  209.                     return $items[0]->getId();
  210.                 } else {
  211.                     throw new Exception('No views (profiles) found for this user.');
  212.                 }
  213.             } else {
  214.                 throw new Exception('No properties found for this user.');
  215.             }
  216.         } else {
  217.             throw new Exception('No accounts found for this user.');
  218.         }
  219.     }
  220.     function getResults($analytics$profileId) {
  221.         // Calls the Core Reporting API and queries for the number of sessions
  222.         // for the last seven days.
  223.         return $analytics->data_ga->get(
  224.             'ga:' $profileId,
  225.             '7daysAgo',
  226.             'today',
  227.             'ga:sessions');
  228.     }
  229.     function printResults($results) {
  230.         // Parses the response from the Core Reporting API and prints
  231.         // the profile name and total sessions.
  232.         if (count($results->getRows()) > 0) {
  233.             // Get the profile name.
  234.             $profileName $results->getProfileInfo()->getProfileName();
  235.             // Get the entry for the first entry in the first row.
  236.             $rows $results->getRows();
  237.             $sessions $rows[0][0];
  238.             // Print the results.
  239.             print "First view (profile) found: $profileName\n";
  240.             print "Total sessions: $sessions\n";
  241.         } else {
  242.             print "No results found.\n";
  243.         }
  244.     }
  245.     /**
  246.      * @Route("test1", name="test1", methods={"GET"})
  247.      */
  248.     public function testAlphaAction(Request $requestEncryption $encryptionManagerWPGeneralService $generalServiceManager)
  249.     {
  250.         $entityManager $this->getDoctrine()->getManager();
  251. //        $userObj = $entityManager->getRepository(User::class)->find(1);
  252. //        $orderDataArray = $this->getBookingDetailsForOrderId($userObj, '10000259', $entityManager, $generalServiceManager->getBaseUrl($request), $encryptionManager, $generalServiceManager);
  253. //
  254. //        dump($orderDataArray);
  255.         // replace this example code with whatever you need
  256.         return $this->render('email-templates/basic_template.htm.twig', [
  257.             'infoWords' => 'This is test info words that are kept',
  258.             'bannerImage' => 'https://parkings.ddns.net/images/wp/email-templates/email/spot-validated.png',
  259.             'title' => 'Congratulation!! Spot Activated.',
  260.             'subTitle' => 'Your spot "Spot Title" is activated and is live.',
  261.             'showButton' => 0,
  262.             'buttonLink' => '#',
  263.             'buttonTitle' => 'Verify',
  264.         ]);
  265.     }
  266. //    /**
  267. //     * @Route("html-test", name="html_test", methods={"GET"})
  268. //     */
  269. //    public function htmlAlphaAction(Request $request, Pdf $knpSnappyPdf)
  270. //    {
  271. //        $html = $this->renderView('email-templates/order_complete_email_template.htm.twig', array(
  272. //            'full_name' => 'Darshit Shah',
  273. //            'order_number' => '23323232',
  274. //            'sub_total' => '$234',
  275. //            'tax_price' => '$30',
  276. //            'service_fee' => '$100',
  277. //            'total_price' =>  '$105',
  278. //            'user_details' => 'test',
  279. //            'booking_date' => '12-10-2022',
  280. //            'title' => 'Verify',
  281. //            'sub_title' => 'Your Mobile Number',
  282. //            'name' => 'Darshit Shah',
  283. //            'message' => 'Enter the below 4 digit code to verify your mobile number.',
  284. //            'code' => '4545',
  285. //            'spot_address' => 'Test address this is'
  286. //        ));
  287. //
  288. //        $knpSnappyPdf->setOption('lowquality', false);
  289. ////        $knpSnappyPdf->setOption('quality', 'highquality');
  290. ////        $knpSnappyPdf->setOption('no-outline', true);
  291. ////        $knpSnappyPdf->setOption('page-size','A4');
  292. ////        $knpSnappyPdf->setOption('encoding', 'UTF-8');
  293. ////        $knpSnappyPdf->setOption('print-media-type', true);
  294. //
  295. //        $knpSnappyPdf->generateFromHtml($html, $this->getParameter('app.root_web').$this->getParameter('app.invoice_directory').'23323232.pdf');
  296. //
  297. //
  298. //        // replace this example code with whatever you need
  299. //        return $this->render('email-templates/order_complete_email_template.htm.twig', [
  300. //            'full_name' => 'Darshit Shah',
  301. //            'order_number' => '23323232',
  302. //            'sub_total' => '$234',
  303. //            'tax_price' => '$30',
  304. //            'service_fee' => '$100',
  305. //            'total_price' =>  '$105',
  306. //            'user_details' => 'test',
  307. //            'booking_date' => '12-10-2022',
  308. //            'title' => 'Verify',
  309. //            'sub_title' => 'Your Mobile Number',
  310. //            'name' => 'Darshit Shah',
  311. //            'message' => 'Enter the below 4 digit code to verify your mobile number.',
  312. //            'code' => '4545',
  313. //            'spot_address' => 'Test address this is'
  314. //        ]);
  315. //    }
  316.     /**
  317.      * @Route("test-payout", name="test-payout", methods={"GET"})
  318.      */
  319.     public function testPayoutAction(Request $requestStripeClient $stripeClientWPGeneralService $generalServiceParkingSupplierService $parkingSupplierServiceEncryption $encryptionSendMail $sendMailMailManager $mailManagerPdf $knpSnappyPdf)
  320.     {
  321.         // replace this example code with whatever you need
  322. //        dump($stripeClient->getChargeDetails());
  323.         $entityManager $this->getDoctrine()->getManager();
  324. //        $userObj = $entityManager->getRepository(User::class)->find(1);
  325. //        $response = $parkingSupplierService->createChargeForSpotProvider($entityManager, $userObj, $stripeClient, $encryption, 1.0, 'chf', '0', $translator->trans('txt_manual_payout_fees', [], null, $languageCode), $languageCode, $translator);
  326. //        dump($response);
  327. //        $analytics = initializeAnalytics();
  328. //        $profile = getFirstProfileId($analytics);
  329. //        $results = getResults($analytics, $profile);
  330. //        printResults($results);
  331.         $payouts $entityManager->getRepository(Orders_Suppliers_Transfers_Payout::class)->findAll();
  332.         $objPayout $payouts[count($payouts) - 1];
  333.         $adminConfigArr $entityManager->getRepository(AdminConfig::class)->findAll();
  334.         if (count($adminConfigArr) == 0) {
  335.             $adminConfig = new AdminConfig();
  336.             $entityManager->persist($adminConfig);
  337.             $entityManager->flush();
  338.         } else {
  339.             $adminConfig $adminConfigArr[0];
  340.         }
  341. //-------Uncomment this line to generate pdf
  342. //        $html = $this->renderView('invoice/index.html.twig', [
  343. //            'payout' => $objPayout,
  344. //            'admin_config' => $adminConfig,
  345. //            'vat_rate' => GeneralConstant::VAT_PERCENTAGE_ON_COMMISSION,
  346. //            'baseUrl' => $generalService->getBaseUrl($request),
  347. //            'supplierEmail' => $encryption->decryptData($objPayout->getSupplier()->getEmail()),
  348. //            'supplierMobile' => $objPayout->getSupplier()->getCountryCode().' '.$encryption->decryptData($objPayout->getSupplier()->getMobile()),
  349. //        ]);
  350. //
  351. //        $knpSnappyPdf->setOption('lowquality', false);
  352. //
  353. //        $knpSnappyPdf->setOption('no-outline', true);
  354. //        $knpSnappyPdf->setOption('page-size','A4');
  355. //        $knpSnappyPdf->setOption('encoding', 'UTF-8');
  356. //        $knpSnappyPdf->setOption('margin-left', 5);
  357. //        $knpSnappyPdf->setOption('margin-right', 5);
  358. //
  359. //        $footerHtml =  $this->renderView('invoice/footer.html.twig', [
  360. //            'admin_config' => $adminConfig,
  361. //            'baseUrl' => $generalService->getBaseUrl($request),
  362. //            'locale' => $objPayout->getSupplier()->getLanguage()->getSymbol(),
  363. //        ]);
  364. //        $headerHtml =  $this->renderView('invoice/header.html.twig', []);
  365. //
  366. //        $knpSnappyPdf->setOption('header-html', $headerHtml);
  367. //        $knpSnappyPdf->setOption('footer-html', $footerHtml);
  368. //        $knpSnappyPdf->setOption('footer-font-size', '7');
  369. //
  370. //        $fileName = $this->getParameter('app.root_web').$this->getParameter('app.invoice_directory').time().'.pdf';
  371. //
  372. //        $knpSnappyPdf->generateFromHtml($html, $fileName);
  373.         return $this->render('invoice/index.html.twig', [
  374.             'payout' => $objPayout,
  375.             'admin_config' => $adminConfig,
  376.             'vat_rate' => GeneralConstant::VAT_PERCENTAGE_ON_COMMISSION,
  377.             'supplierEmail' => $encryption->decryptData($objPayout->getSupplier()->getEmail()),
  378.             'supplierMobile' => $objPayout->getSupplier()->getCountryCode().' '.$encryption->decryptData($objPayout->getSupplier()->getMobile()),
  379.             'baseUrl' => $generalService->getBaseUrl($request)
  380.         ]);
  381.     }
  382.     /**
  383.      * @Route("test-customer", name="test-customer", methods={"GET"})
  384.      */
  385.     public function testCustomerAction(Request $requestStripeClient $stripeClientWPGeneralService $generalServiceParkingSupplierService $parkingSupplierServiceEncryption $encryptionSendMail $sendMailMailManager $mailManagerPdf $knpSnappyPdf)
  386.     {
  387.         // replace this example code with whatever you need
  388. //        dump($stripeClient->getChargeDetails());
  389.         $entityManager $this->getDoctrine()->getManager();
  390. //        $userObj = $entityManager->getRepository(User::class)->find(1);
  391. //        $response = $parkingSupplierService->createChargeForSpotProvider($entityManager, $userObj, $stripeClient, $encryption, 1.0, 'chf', '0', $translator->trans('txt_manual_payout_fees', [], null, $languageCode), $languageCode, $translator);
  392. //        dump($response);
  393. //        $analytics = initializeAnalytics();
  394. //        $profile = getFirstProfileId($analytics);
  395. //        $results = getResults($analytics, $profile);
  396. //        printResults($results);
  397.         $orders $entityManager->getRepository(Orders::class)->findAll();
  398.         $objOrder $orders[count($orders) - 1];
  399.         $adminConfigArr $entityManager->getRepository(AdminConfig::class)->findAll();
  400.         if (count($adminConfigArr) == 0) {
  401.             $adminConfig = new AdminConfig();
  402.             $entityManager->persist($adminConfig);
  403.             $entityManager->flush();
  404.         } else {
  405.             $adminConfig $adminConfigArr[0];
  406.         }
  407. //-------Uncomment this line to generate pdf
  408. //        $html = $this->renderView('invoice/customer/index.html.twig', [
  409. //            'payout' => $objPayout,
  410. //            'admin_config' => $adminConfig,
  411. //            'vat_rate' => GeneralConstant::VAT_PERCENTAGE_ON_COMMISSION,
  412. //        ]);
  413. //
  414. //        $knpSnappyPdf->setOption('lowquality', false);
  415. //
  416. //        $knpSnappyPdf->setOption('no-outline', true);
  417. //        $knpSnappyPdf->setOption('page-size','A4');
  418. //        $knpSnappyPdf->setOption('encoding', 'UTF-8');
  419. //        $knpSnappyPdf->setOption('margin-left', 5);
  420. //        $knpSnappyPdf->setOption('margin-right', 5);
  421. //
  422. //        $footerHtml =  $this->renderView('invoice/footer.html.twig', [
  423. //            'admin_config' => $adminConfig,
  424. //        'baseUrl' => $generalService->getBaseUrl($request),
  425. //        'locale' => $objPayout->getSupplier()->getLanguage()->getSymbol(),
  426. //        ]);
  427. //        $headerHtml =  $this->renderView('invoice/header.html.twig', []);
  428. //
  429. //        $knpSnappyPdf->setOption('header-html', $headerHtml);
  430. //        $knpSnappyPdf->setOption('footer-html', $footerHtml);
  431. //        $knpSnappyPdf->setOption('footer-font-size', '7');
  432. //
  433. //        $fileName = $this->getParameter('app.root_web').$this->getParameter('app.invoice_directory').time().'.pdf';
  434. //
  435. //        $knpSnappyPdf->generateFromHtml($html, $fileName);
  436.         if ($objOrder->getBookingType() == BookingType::Monthly) {
  437.             $orderMonthlyPricing $objOrder->getLatestMonthlyBookingPricingObj();
  438.             $cardType $orderMonthlyPricing->getPayCardType();
  439.             $cardLast4 $encryption->decryptData($orderMonthlyPricing->getPayLastFour());
  440.             $durationStr '30 days';
  441.         } else {
  442.             $cardType $objOrder->getPayCardType();
  443.             $cardLast4 $encryption->decryptData($objOrder->getPayLastFour());
  444.             $dateStart $objOrder->getStartTime();
  445.             $dateEnd $objOrder->getEndTime();
  446.             $interval $dateEnd->diff($dateStart);
  447.             $days $interval->format('%D');
  448.             if ($days >= 1) {
  449.                 $hours $interval->format('%H');
  450.                 $mins $interval->format('%i');
  451.                 if ($hours 0) {
  452.                     $durationStr $interval->format('%D Day(s) %H Hrs');
  453.                 } else if ($mins 0) {
  454.                     $durationStr $interval->format('%D Day(s) %i Mins');
  455.                 } else {
  456.                     $durationStr $interval->format('%D Day(s)');
  457.                 }
  458.             } else {
  459.                 $mins $interval->format('%i');
  460.                 if ($mins 0) {
  461.                     $durationStr $interval->format('%H Hrs %i Mins');
  462.                 } else {
  463.                     $durationStr $interval->format('%H Hrs');
  464.                 }
  465.             }
  466.         }
  467.         return $this->render('invoice/customer/index.html.twig', [
  468.             'order' => $objOrder,
  469.             'admin_config' => $adminConfig,
  470.             'vat_rate' => GeneralConstant::VAT_PERCENTAGE_ON_COMMISSION,
  471.             'userEmail' => $encryption->decryptData($objOrder->getUser()->getEmail()),
  472.             'userMobile' => $objOrder->getUser()->getCountryCode().' '.$encryption->decryptData($objOrder->getUser()->getMobile()),
  473.             'baseUrl' => $generalService->getBaseUrl($request),
  474.             'card_type' => $cardType,
  475.             'card_last4' => $cardLast4,
  476.             'duration' => $durationStr
  477.         ]);
  478.     }
  479.     /**
  480.      * @Route("test-stripe", methods={"GET", "POST"})
  481.      */
  482.     public function testStripeAction(Request $requestStripeClient $stripeClientWPGeneralService $generalServiceParkingSupplierService $parkingSupplierServiceEncryption $encryptionSendMail $sendMailMailManager $mailManagerPdf $knpSnappyPdf) {
  483.         $entityManager $this->getDoctrine()->getManager();
  484.         $userObj $entityManager->getRepository(User::class)->find(1);
  485.         if ($userObj instanceof User) {
  486.             $stripeCustomerId $userObj->getStripeCustomerId();
  487.             $ephemeralKey $stripeClient->createEphemeralKeyForCustomer($stripeCustomerId);
  488.             $paymentIntent $stripeClient->createPaymentIntentForMonthlyBookingCustomer($stripeCustomerId2000'chf'0'WP''darshit261991@gmail.com''1''1''100'50);
  489.             $responseArr = [];
  490.             $responseArr['paymentIntent'] = $paymentIntent->client_secret;
  491.             $responseArr['ephemeralKey'] = $ephemeralKey->secret;
  492.             $responseArr['customer'] = $stripeCustomerId;
  493.             $responseArr['publishableKey'] = 'pk_test_51IExe2GvuHsXzhCxFYvalZTIMNiLbccXKU9ggANCJmQbOaTkPdyWtt85ylrPbhmo7qR7JLNaOKgT9q9IHsm4zgw200RoRnb09x';
  494.             dump($responseArr);
  495.             return new JsonResponse($responseArr);
  496.         }
  497.     }
  498.     /**
  499.      * @Route("test-stripe-order", methods={"GET", "POST"})
  500.      */
  501.     public function testStripeOrderAction(Request $requestStripeClient $stripeClientWPGeneralService $generalServiceParkingSupplierService $parkingSupplierServiceEncryption $encryptionSendMail $sendMailMailManager $mailManagerPdf $knpSnappyPdf) {
  502.         $entityManager $this->getDoctrine()->getManager();
  503.         $userObj $entityManager->getRepository(User::class)->find(1);
  504.         if ($userObj instanceof User) {
  505.             $stripeCustomerId $userObj->getStripeCustomerId();
  506.             $paymentIntent $stripeClient->retrivePaymentIntentForCustomer('pi_3KbHhCGvuHsXzhCx17pHlyxe');
  507.             dump($paymentIntent);
  508.             dump('Exp Month : '.$paymentIntent->charges->data[0]->payment_method_details->card->exp_month);
  509.             dump('Exp Year : '.$paymentIntent->charges->data[0]->payment_method_details->card->exp_year);
  510.             dump('Last4 : '.$paymentIntent->charges->data[0]->payment_method_details->card->last4);
  511.             dump('Name : '.$paymentIntent->charges->data[0]->billing_details->name);
  512.             dump('Brand : '.$paymentIntent->charges->data[0]->payment_method_details->card->brand);
  513.             if ($paymentIntent->charges->data[0]->payment_method_details->card->wallet != NULL) {
  514.                 dump('Card Type : '$paymentIntent->charges->data[0]->payment_method_details->card->wallet->type);
  515.             } else {
  516.                 dump('Card Type : '.$paymentIntent->charges->data[0]->payment_method_details->card->type);
  517.             }
  518.             dump('Card Type : '$paymentIntent->charges->data[0]->payment_method_details->card->funding);
  519.             dump('Customer : '$paymentIntent->charges->data[0]->customer);
  520.             dump('Payment Intent Id : '.$paymentIntent->id);
  521.             dump('Charge Id : '$paymentIntent->charges->data[0]->id);
  522.             dump('Balance Transaction : '$paymentIntent->charges->data[0]->balance_transaction);
  523.             dump($stripeClient->getChargeDetailsForChargeId($paymentIntent->charges->data[0]->id));
  524.             dump($stripeClient->getStripeBalanceTransactionDetails($paymentIntent->charges->data[0]->balance_transaction));
  525.             $responseArr = [];
  526.             $responseArr['paymentIntent'] = $paymentIntent->client_secret;
  527.             $responseArr['customer'] = $stripeCustomerId;
  528.             $responseArr['publishableKey'] = 'pk_test_51IExe2GvuHsXzhCxFYvalZTIMNiLbccXKU9ggANCJmQbOaTkPdyWtt85ylrPbhmo7qR7JLNaOKgT9q9IHsm4zgw200RoRnb09x';
  529.             return new JsonResponse($responseArr);
  530.         }
  531.     }
  532.     /**
  533.      * @Route("check-test", methods={"GET", "POST"})
  534.      */
  535.     public function checkTestAction(Request $requestStripeClient $stripeClientWPGeneralService $generalServiceParkingSupplierService $parkingSupplierServiceEncryption $encryptionSendMail $sendMailMailManager $mailManagerPdf $knpSnappyPdf) {
  536.         $entityManager $this->getDoctrine()->getManager();
  537.         $userObj $entityManager->getRepository(User::class)->find(1);
  538.         if ($userObj instanceof User) {
  539.             $stripeCustomerId $userObj->getStripeCustomerId();
  540.             dump($encryption->decryptData('LB54+mLcbANnjU0acoxzGQ=='));
  541.             $cardId 'card_1KaylKGvuHsXzhCxmiPIAWph';//$encryption->decryptData('M/6gWKqXa1KmhPrs7drcXa6oWC+HmUYWNtIfKJ8qg8U=');
  542.             try {
  543.                 $responsePaymentIntent $stripeClient->createPaymentIntentForMonthlyRenewalCustomer("cus_J1TAhT1Jp0ysew"3000'CHF''WP''darshit261991@gmail.com''1''1''100''5'$cardId);
  544.                 dump($responsePaymentIntent);
  545.             } catch (ApiErrorException $aee) {
  546.                 dump($aee);
  547.             } catch (\Exception $e) {
  548.             }
  549.         }
  550.         // replace this example code with whatever you need
  551.         return $this->render('index.html.twig', [
  552.         ]);
  553.     }
  554.     /**
  555.      * @Route("database", methods={"GET", "POST"})
  556.      */
  557.     public function databaseAction(Request $requestStripeClient $stripeClientWPGeneralService $generalServiceParkingSupplierService $parkingSupplierServiceEncryption $encryptionSendMail $sendMailMailManager $mailManagerPdf $knpSnappyPdf) {
  558.         $entityManager $this->getDoctrine()->getManager();
  559.         $spotList $entityManager->getRepository(PS_Add_Spot::class)->getSearchedSpotList(''20);
  560.         dump($spotList);
  561.         foreach ($spotList as $index => $spot) {
  562.             if ($spot instanceof PS_Add_Spot) {
  563.                 dump($spot->getPsAddSpotDefaultImage());
  564.                 break;
  565.             }
  566.         }
  567.         // replace this example code with whatever you need
  568.         return $this->render('index.html.twig', [
  569.         ]);
  570.     }
  571. }