<?php
/* __________________________________________________
| Obfuscated by YAK Pro - Php Obfuscator 2.0.3 |
| on 2023-10-31 14:25:56 |
| GitHub: https://github.com/pk-fr/yakpro-po |
|__________________________________________________|
*/
namespace Plugin\AmazonPayV2_42;use Eccube\Event\TemplateEvent;use Eccube\Event\EventArgs;use Eccube\Event\EccubeEvents;use Eccube\Common\EccubeConfig;use Eccube\Repository\PaymentRepository;use Eccube\Repository\PluginRepository;use Eccube\Service\OrderHelper;use Eccube\Service\CartService;use Plugin\AmazonPayV2_42\Repository\ConfigRepository;use Plugin\AmazonPayV2_42\Service\AmazonRequestService;use Plugin\AmazonPayV2_42\Service\Method\AmazonPay;use Plugin\AmazonPayV2_42\phpseclib\Crypt\Random;use Symfony\Component\DependencyInjection\ContainerInterface;use Symfony\Component\EventDispatcher\EventSubscriberInterface;use Symfony\Component\HttpFoundation\RequestStack;use Symfony\Component\HttpFoundation\Session\SessionInterface;use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;use Symfony\Component\Routing\Generator\UrlGeneratorInterface;use Eccube\Repository\DeliveryRepository;use Eccube\Repository\PaymentOptionRepository;use Plugin\AmazonPayV2_42\Entity\AmazonBanner;use Plugin\AmazonPayV2_42\Service\AmazonBannerService;class AmazonPayEvent implements EventSubscriberInterface{private $sessionAmazonProfileKey = 'amazon_pay_v2.profile';private $sessionAmazonCheckoutSessionIdKey = 'amazon_pay_v2.checkout_session_id';private $sessionAmazonLoginStateKey = 'amazon_pay_v2.amazon_login_state';protected $eccubeConfig;private $router;protected $configRepository;protected $amazonRequestService;protected $deliveryRepository;protected $paymentOptionRepository;protected $amazonBannerService;public function __construct(RequestStack $requestStack, SessionInterface $session, TokenStorageInterface $tokenStorage, EccubeConfig $eccubeConfig, UrlGeneratorInterface $router, PaymentRepository $paymentRepository, PluginRepository $pluginRepository, ConfigRepository $configRepository, ContainerInterface $container, OrderHelper $orderHelper, CartService $cartService, AmazonRequestService $amazonRequestService, DeliveryRepository $deliveryRepository, PaymentOptionRepository $paymentOptionRepository, AmazonBannerService $amazonBannerService){goto xkSA0;DSdZ5:$this->paymentRepository = $paymentRepository;goto XhJrz;SDNSx:$this->session = $session;goto JzVPS;kka2d:$this->deliveryRepository = $deliveryRepository;goto CBWG7;JzVPS:$this->tokenStorage = $tokenStorage;goto GKPus;vs5mD:$this->amazonRequestService = $amazonRequestService;goto kka2d;Gvry1:$this->orderHelper = $orderHelper;goto mUhBT;g3P_7:$this->container = $container;goto Gvry1;Jm1Yz:$this->configRepository = $configRepository;goto g3P_7;upHRw:$this->router = $router;goto DSdZ5;mUhBT:$this->cartService = $cartService;goto vs5mD;xkSA0:$this->requestStack = $requestStack;goto SDNSx;X71aI:$this->amazonBannerService = $amazonBannerService;goto UNQYy;GKPus:$this->eccubeConfig = $eccubeConfig;goto upHRw;CBWG7:$this->paymentOptionRepository = $paymentOptionRepository;goto X71aI;XhJrz:$this->pluginRepository = $pluginRepository;goto Jm1Yz;UNQYy:}public static function getSubscribedEvents(){return [EccubeEvents::FRONT_CART_BUYSTEP_COMPLETE => 'amazon_cart_buystep', 'Cart/index.twig' => 'cart', 'Shopping/index.twig' => 'amazon_pay_shopping', 'Mypage/login.twig' => 'mypage_login', 'Shopping/confirm.twig' => 'amazon_pay_shopping_confirm', 'index.twig' => 'add_banner_on_top'];}public function add_banner_on_top(TemplateEvent $event){goto G4kVu;MJZ9o:rzND4:goto tW9tC;tW9tC:if (!($Config->getAmazonBannerPlaceOnTop() == $this->eccubeConfig['amazon_pay_v2']['button_place']['auto'])) {goto bESpt;}goto DyLqQ;L0hrd:return;goto MJZ9o;Ig7TE:$event->addSnippet($this->amazonBannerService->getBannerCodeOnTop(), false);goto rMOzz;G4kVu:$Config = $this->configRepository->get();goto P6TUA;P6TUA:if (!($Config->getUseAmazonBannerOnTop() == $this->eccubeConfig['amazon_pay_v2']['toggle']['off'])) {goto rzND4;}goto L0hrd;DyLqQ:$event->addSnippet('@AmazonPayV2_42/default/amazon_banner_auto_on_top.twig');goto CAcZM;CAcZM:bESpt:goto Ig7TE;rMOzz:}public function cart(TemplateEvent $event){goto sOyw1;dzxiQ:xTh_n:goto snBFn;j7l3d:$event->addSnippet('@AmazonPayV2_42/default/Cart/amazon_pay_js.twig');goto vivyj;kqnON:foreach ($parameters['Carts'] as $Cart) {goto FgVlC;FgVlC:$cartKey = $Cart->getCartKey();goto LB_62;LB_62:$payload = $this->amazonRequestService->createCheckoutSessionPayload($Cart->getCartKey());goto BEJGA;uZgSF:$parameters['cart'][$cartKey]['payload'] = $payload;goto oW9HK;oW9HK:$parameters['cart'][$cartKey]['signature'] = $signature;goto AePgk;AePgk:RvDeo:goto t_eEL;BEJGA:$signature = $this->amazonRequestService->signaturePayload($payload);goto uZgSF;t_eEL:}goto yC2Yc;xcybQ:$parameters['AmazonSaleTypes'] = $AmazonSaleTypes;goto kqnON;vivyj:if (!($Config->getCartButtonPlace() == $this->eccubeConfig['amazon_pay_v2']['button_place']['auto'])) {goto CZ5z0;}goto Tfw4g;iqQQi:W4r5Y:goto SeyM5;VFiHV:$Payment = $this->paymentRepository->findOneBy(['method_class' => AmazonPay::class]);goto B6szE;fqp7K:$AmazonSaleTypes = [];goto gU_Qq;TcOcJ:$parameters['AmazonPayV2Api'] = $this->eccubeConfig['amazon_pay_v2']['api']['prod'];goto iqQQi;z7pdg:return;goto fEH4e;vjwq7:return;goto a_8mh;klW0P:$event->addSnippet('@AmazonPayV2_42/default/amazon_banner_auto_on_cart.twig');goto dzxiQ;zLoOX:$parameters['AmazonPayV2Api'] = $this->eccubeConfig['amazon_pay_v2']['api']['sandbox'];goto xsk1j;SeyM5:$event->setParameters($parameters);goto j7l3d;CTJdF:if (!($Config->getUseCartButton() == $this->eccubeConfig['amazon_pay_v2']['toggle']['off'])) {goto j58p7;}goto vjwq7;gU_Qq:foreach ($AmazonDeliveries as $AmazonDelivery) {goto zzzST;zzzST:$Delivery = $this->deliveryRepository->findOneBy(['id' => $AmazonDelivery->getDelivery()->getId()]);goto SyUqe;Eci4D:TpVx4:goto MFEEi;SyUqe:$AmazonSaleTypes[] = $Delivery->getSaleType()->getId();goto Eci4D;MFEEi:}goto RTxCA;B6szE:$AmazonDeliveries = $this->paymentOptionRepository->findBy(['payment_id' => $Payment->getId()]);goto fqp7K;MfmFM:$parameters = $event->getParameters();goto kp3RP;snBFn:$event->addSnippet($this->amazonBannerService->getBannerCodeOnCart(), false);goto EUFGj;kp3RP:if (!empty($parameters['Carts'])) {goto IZLlF;}goto z7pdg;yC2Yc:t6pvx:goto Qil_0;sOyw1:$Config = $this->configRepository->get();goto mNibs;fEH4e:IZLlF:goto CTJdF;a_8mh:j58p7:goto VFiHV;n3HbN:if (!($Config->getAmazonBannerPlaceOnCart() == $this->eccubeConfig['amazon_pay_v2']['button_place']['auto'])) {goto xTh_n;}goto klW0P;BdL3L:if ($Config->getEnv() == $this->eccubeConfig['amazon_pay_v2']['env']['prod']) {goto RQm1m;}goto zLoOX;mNibs:if (!($Config->getUseAmazonBannerOnCart() != $this->eccubeConfig['amazon_pay_v2']['toggle']['off'])) {goto x1wB2;}goto n3HbN;G5iDt:CZ5z0:goto Ca80y;xsk1j:goto W4r5Y;goto fTEHp;Tfw4g:$event->addSnippet('@AmazonPayV2_42/default/Cart/button.twig');goto G5iDt;EUFGj:x1wB2:goto MfmFM;Qil_0:$parameters['AmazonPayV2Config'] = $Config;goto BdL3L;fTEHp:RQm1m:goto TcOcJ;RTxCA:ozluk:goto xcybQ;Ca80y:}public function amazon_cart_buystep(EventArgs $event){goto UkPjx;elxnI:$this->cartService->save();goto tmlwv;jPo3R:$this->cartService->setPreOrderId(null);goto elxnI;UkPjx:if (!($this->orderHelper->getNonmember() && $this->session->get($this->sessionAmazonProfileKey))) {goto YFqBd;}goto hSLKE;tmlwv:YFqBd:goto t3DeV;nkYQR:$this->session->remove($this->sessionAmazonProfileKey);goto jPo3R;hSLKE:$this->session->remove(OrderHelper::SESSION_NON_MEMBER);goto nkYQR;t3DeV:}public function amazon_pay_shopping(TemplateEvent $event){goto bGzzA;KN3eQ:sACnq:goto Q9S0Q;Q9S0Q:$parameters['useMailMagazine'] = $useMailMagazine;goto rfJWJ;YxUye:$useMailMagazine = false;goto rUDqC;b9NiD:if ($this->pluginRepository->findOneBy(['code' => 'MailMagazine42', 'enabled' => true]) || $this->pluginRepository->findOneBy(['code' => 'PostCarrier42', 'enabled' => true])) {goto hwlKD;}goto YxUye;pYjkG:if (!(preg_match('/shopping\\/amazon_pay/', $uri) == false)) {goto tjTOq;}goto KQFro;W1xdN:$uri = $request->getUri();goto eJFOa;QjTIR:$event->setParameters($parameters);goto RmyMP;eJFOa:$parameters = $event->getParameters();goto pYjkG;KQFro:$referer = $request->headers->get('referer');goto CFj2W;oPw1l:return;goto jgd9l;DFpV6:exit;goto SFml4;qETFC:hwlKD:goto MzQLP;hNIt3:$parameters['AmazonPayV2Config'] = $Config;goto b9NiD;RVwf7:F5m3z:goto QjTIR;jgd9l:tjTOq:goto U28In;aP3PA:$parameters['AmazonPayV2Api'] = $this->eccubeConfig['amazon_pay_v2']['api']['sandbox'];goto oY_gY;rUDqC:goto sACnq;goto qETFC;BW8Q3:$event->addSnippet('@AmazonPayV2_42/default/Shopping/customer_regist_v2.twig');goto JTx8r;Ri6dW:$parameters['amazonCheckoutSessionId'] = $amazonCheckoutSessionId;goto hNIt3;bGzzA:$request = $this->requestStack->getMasterRequest();goto W1xdN;Tzmk0:$parameters = $event->getParameters();goto Ri6dW;SFml4:k8JH2:goto oPw1l;X0JYx:if (!($Payment && $Payment->getMethodClass() === AmazonPay::class && preg_match('/shopping_coupon/', $referer))) {goto k8JH2;}goto g7Uiw;JTx8r:$amazonCheckoutSessionId = $this->session->get($this->sessionAmazonCheckoutSessionIdKey);goto Tzmk0;ikdv2:$parameters['AmazonPayV2Api'] = $this->eccubeConfig['amazon_pay_v2']['api']['prod'];goto RVwf7;rfJWJ:if ($Config->getEnv() == $this->eccubeConfig['amazon_pay_v2']['env']['prod']) {goto qtYyY;}goto aP3PA;MzQLP:$useMailMagazine = true;goto KN3eQ;CFj2W:$Order = $parameters['Order'];goto zO2Jn;U28In:$Config = $this->configRepository->get();goto NHVwX;NHVwX:$event->addSnippet('@AmazonPayV2_42/default/Shopping/widgets.twig');goto BW8Q3;zO2Jn:$Payment = $Order->getPayment();goto X0JYx;g7Uiw:header("Location:" . $this->container->get('router')->generate('amazon_pay_shopping'));goto DFpV6;ZIt9t:qtYyY:goto ikdv2;oY_gY:goto F5m3z;goto ZIt9t;RmyMP:}public function amazon_pay_shopping_confirm(TemplateEvent $event){goto o3A1j;YvnEC:goto wjyob;goto fp1pO;QBky2:if ($this->pluginRepository->findOneBy(['code' => 'MailMagazine42', 'enabled' => true]) || $this->pluginRepository->findOneBy(['code' => 'PostCarrier42', 'enabled' => true])) {goto b3ZLq;}goto g7qHm;naUfV:$parameters['AmazonPayV2Api'] = $this->eccubeConfig['amazon_pay_v2']['api']['sandbox'];goto PxOK2;o3A1j:$request = $this->requestStack->getMasterRequest();goto RlTio;VRFs8:if ($Config->getEnv() == $this->eccubeConfig['amazon_pay_v2']['env']['prod']) {goto bCV1N;}goto naUfV;T9wHo:$parameters['AmazonPayV2Api'] = $this->eccubeConfig['amazon_pay_v2']['api']['prod'];goto O8WWs;zUMhm:$event->setParameters($parameters);goto Oam2n;OcnKO:$event->addSnippet('@AmazonPayV2_42/default/Shopping/confirm_widgets.twig');goto GAaBT;jnpbB:if (!(preg_match('/shopping\\/amazon_pay/', $uri) == false)) {goto AK_U7;}goto uHiqG;spzD2:$Config = $this->configRepository->get();goto OcnKO;phbGQ:$parameters = $event->getParameters();goto el_i4;PxOK2:goto TM19Z;goto gPKuN;O8WWs:TM19Z:goto zUMhm;GmqRb:wjyob:goto WVgBl;thoKO:$useMailMagazine = true;goto GmqRb;GAaBT:$event->addSnippet('@AmazonPayV2_42/default/Shopping/confirm_customer_regist_v2.twig');goto phbGQ;el_i4:$parameters['AmazonPayV2Config'] = $Config;goto QBky2;WVgBl:$parameters['useMailMagazine'] = $useMailMagazine;goto VRFs8;gPKuN:bCV1N:goto T9wHo;RlTio:$uri = $request->getUri();goto jnpbB;g7qHm:$useMailMagazine = false;goto YvnEC;uHiqG:return;goto TtYyI;TtYyI:AK_U7:goto spzD2;fp1pO:b3ZLq:goto thoKO;Oam2n:}public function mypage_login(TemplateEvent $event){goto xBakv;rlmNp:rJTNK:goto cZHwu;AZawQ:$parameters['AmazonPayV2Config'] = $Config;goto oXSYE;EIvw2:goto C7J8B;goto eigg9;eigg9:RKTha:goto cY918;q_QUL:$returnUrl = $this->router->generate('login_with_amazon', ['state' => $state], UrlGeneratorInterface::ABSOLUTE_URL);goto wkP4j;cZHwu:$event->addSnippet('@AmazonPayV2_42/default/Mypage/amazon_login_js.twig');goto LuzyW;s7qkV:$parameters['signature'] = $signature;goto xUeM_;cY918:$parameters['AmazonPayV2Api'] = $this->eccubeConfig['amazon_pay_v2']['api']['prod'];goto ikHpL;GStda:return;goto NeVR5;GJe7C:$signature = $this->amazonRequestService->signaturePayload($payload);goto uV0iB;NeVR5:evkbR:goto nfOYi;oXSYE:if ($Config->getEnv() == $this->eccubeConfig['amazon_pay_v2']['env']['prod']) {goto RKTha;}goto L3NPk;Qzn6E:$event->setParameters($parameters);goto SD05Q;xUeM_:$parameters['buttonColor'] = $Config->getMypageLoginButtonColor();goto AZawQ;excHG:$event->addSnippet('@AmazonPayV2_42/default/Mypage/login_page_button.twig');goto rlmNp;ikHpL:C7J8B:goto Qzn6E;xBakv:$Config = $this->configRepository->get();goto JO5JW;HpyBK:sTlCJ:goto q_QUL;wkP4j:$parameters = $event->getParameters();goto DgDrK;DgDrK:$payload = $this->amazonRequestService->createSigninPayload($returnUrl);goto GJe7C;FJB21:if ($state) {goto sTlCJ;}goto mzShN;L3NPk:$parameters['AmazonPayV2Api'] = $this->eccubeConfig['amazon_pay_v2']['api']['sandbox'];goto EIvw2;uV0iB:$parameters['payload'] = $payload;goto s7qkV;SD05Q:if (!($Config->getMypageLoginButtonPlace() == $this->eccubeConfig['amazon_pay_v2']['button_place']['auto'])) {goto rJTNK;}goto excHG;mzShN:$state = bin2hex(Random::string(16));goto Nc2kH;JO5JW:if (!($Config->getUseMypageLoginButton() == $this->eccubeConfig['amazon_pay_v2']['toggle']['off'])) {goto evkbR;}goto GStda;Nc2kH:$this->session->set($this->sessionAmazonLoginStateKey, $state);goto HpyBK;nfOYi:$state = $this->session->get($this->sessionAmazonLoginStateKey);goto FJB21;LuzyW:}}