Japanese English

PHP deobfuscation, decryption, reconstruction tool

De-obfuscate PHP malware/viruses and tampering code on Wordpress to original readable code.

*Please note that not all obfuscation codes can be decoded.

Decoded the code below.

<?php /* __________________________________________________ | Obfuscated by YAK Pro - Php Obfuscator 2.0.3 | | on 2023-07-05 10:12:25 | | GitHub: https://github.com/pk-fr/yakpro-po | |__________________________________________________| */ namespace Plugin\AmazonPayV2_42\Service; use Doctrine\ORM\...



Obfuscated php code

<?php
/*   __________________________________________________
    |  Obfuscated by YAK Pro - Php Obfuscator  2.0.3   |
    |              on 2023-07-05 10:12:25              |
    |    GitHub: https://github.com/pk-fr/yakpro-po    |
    |__________________________________________________|
*/

namespace Plugin\AmazonPayV2_42\Service;

use Doctrine\ORM\EntityManagerInterface;
use Eccube\Common\EccubeConfig;
use Eccube\Entity\Master\OrderStatus;
use Eccube\Repository\BaseInfoRepository;
use Eccube\Repository\CustomerRepository;
use Eccube\Repository\Master\OrderStatusRepository;
use Eccube\Service\CartService;
use Eccube\Service\PurchaseFlow\PurchaseContext;
use Eccube\Service\PurchaseFlow\PurchaseFlow;
use Eccube\Service\PurchaseFlow\Processor\StockReduceProcessor;
use Eccube\Service\PurchaseFlow\Processor\PointProcessor;
use Plugin\AmazonPayV2_42\Entity\Master\AmazonStatus;
use Plugin\AmazonPayV2_42\Exception\AmazonException;
use Plugin\AmazonPayV2_42\Exception\AmazonPaymentException;
use Plugin\AmazonPayV2_42\Repository\ConfigRepository;
use Plugin\AmazonPayV2_42\Amazon\Pay\API\Client as AmazonPayClient;
use Plugin\AmazonPayV2_42\Repository\Master\AmazonStatusRepository;
use GuzzleHttp\Client;
use Guzzle\Http\Exception\BadResponseException;
use Guzzle\Http\Exception\CurlException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Carbon\Carbon;

class AmazonRequestService extends AbstractController
{
    protected $entityManager;
    protected $baseInfoRepository;
    protected $customerRepository;
    protected $cartService;
    protected $purchaseFlow;
    protected $eccubeConfig;
    protected $configRepository;
    protected $Config;
    protected $amazonApi;
    protected $amazonApiConfig;
    protected $session;
    protected $tokenStorage;
    protected $container;
    private $pointProcessor;
    private $stockReduceProcessor;
    private $amazonStatusRepository;
    private $orderStatusRepository;
    public function __construct(EntityManagerInterface $entityManager, BaseInfoRepository $baseInfoRepository, CustomerRepository $customerRepository, CartService $cartService, PurchaseFlow $cartPurchaseFlow, EccubeConfig $eccubeConfig, ConfigRepository $configRepository, SessionInterface $session, TokenStorageInterface $tokenStorage, OrderStatusRepository $orderStatusRepository, AmazonStatusRepository $amazonStatusRepository, StockReduceProcessor $stockReduceProcessor, PointProcessor $pointProcessor, ContainerInterface $container)
    {
        goto tOeUB;
        PoaB0:
        $this->pointProcessor = $pointProcessor;
        goto rgEdG;
        rylCc:
        qPJzJ:
        goto zEDky;
        Ean20:
        $this->Config = $this->configRepository->get();
        goto ZUO6C;
        aF_fJ:
        $this->eccubeConfig = $eccubeConfig;
        goto GxHuO;
        zEDky:
        $this->amazonApi = $this->eccubeConfig['amazon_pay_v2']['api']['prod'];
        goto b30at;
        sii_H:
        $this->BaseInfo = $baseInfoRepository->get();
        goto QGeh3;
        QGeh3:
        $this->customerRepository = $customerRepository;
        goto tmj1k;
        cDArN:
        $this->amazonApiConfig = $this->eccubeConfig['amazon_pay_v2']['api']['config'];
        goto wPAvt;
        S9yVl:
        $this->amazonApi = $this->eccubeConfig['amazon_pay_v2']['api']['sandbox'];
        goto L6vSc;
        tmj1k:
        $this->cartService = $cartService;
        goto OGRlZ;
        Z1Q1Z:
        $this->tokenStorage = $tokenStorage;
        goto LtCe9;
        rgEdG:
        $this->container = $container;
        goto Ean20;
        b30at:
        eSuHI:
        goto cDArN;
        LtCe9:
        $this->orderStatusRepository = $orderStatusRepository;
        goto Byw8C;
        tOeUB:
        $this->entityManager = $entityManager;
        goto sii_H;
        ZUO6C:
        if ($this->Config->getAmazonAccountMode() == $this->eccubeConfig['amazon_pay_v2']['account_mode']['owned'] && $this->Config->getEnv() == $this->eccubeConfig['amazon_pay_v2']['env']['prod']) {
            goto qPJzJ;
        }
        goto S9yVl;
        pveo7:
        $this->session = $session;
        goto Z1Q1Z;
        L6vSc:
        goto eSuHI;
        goto rylCc;
        vmmhn:
        $this->stockReduceProcessor = $stockReduceProcessor;
        goto PoaB0;
        Byw8C:
        $this->amazonStatusRepository = $amazonStatusRepository;
        goto vmmhn;
        OGRlZ:
        $this->purchaseFlow = $cartPurchaseFlow;
        goto aF_fJ;
        GxHuO:
        $this->configRepository = $configRepository;
        goto pveo7;
        wPAvt:
    }
    private function payoutSellerOrderId($orderId, $request_type = '')
    {
        goto Q4Vjp;
        oxvl0:
        $timestamp = '';
        goto DJG1m;
        mVlWW:
        return $timestamp . $prefix . $request_attr . $orderId;
        goto SyHqU;
        yQY0S:
        $timestamp = $timestamp === '' ? '' : $timestamp . '_';
        goto mVlWW;
        SHrCp:
        $arrInit = parse_ini_file($iniFile);
        goto YmSoI;
        Q4Vjp:
        $request_attr = $request_type === '' ? '' : strtoupper($request_type) . '_';
        goto U0Agw;
        Mepfb:
        $timestamp = Carbon::now()->timestamp;
        goto dM2NF;
        U0Agw:
        $prefix = '';
        goto Q3X2t;
        YmSoI:
        $prefix = $arrInit['prefix'];
        goto FE1ww;
        DJG1m:
        if (!($this->Config->getAmazonAccountMode() === $this->eccubeConfig['amazon_pay_v2']['account_mode']['shared'])) {
            goto mpbQ9;
        }
        goto Mepfb;
        dM2NF:
        mpbQ9:
        goto yQY0S;
        FlFUk:
        if (!file_exists($iniFile)) {
            goto glbcK;
        }
        goto SHrCp;
        FE1ww:
        glbcK:
        goto LVEvp;
        Q3X2t:
        $iniFile = dirname(__FILE__) . '/../amazon_pay_config.ini';
        goto FlFUk;
        LVEvp:
        $prefix = $prefix === '' ? '' : $prefix . '_';
        goto oxvl0;
        SyHqU:
    }
    protected function getAmazonPayConfig()
    {
        goto rWO1Z;
        xNL8_:
        $config = ['public_key_id' => $Config->getPublicKeyId(), 'private_key' => $this->eccubeConfig->get('kernel.project_dir') . '/' . $Config->getPrivateKeyPath(), 'sandbox' => $Config->getEnv() == $this->eccubeConfig['amazon_pay_v2']['env']['sandbox'] ? true : false, 'region' => 'jp'];
        goto MWd9w;
        rWO1Z:
        $Config = $this->configRepository->get();
        goto xNL8_;
        MWd9w:
        return $config;
        goto HfnGY;
        HfnGY:
    }
    public function createCheckoutSessionPayload($cart_key)
    {
        goto soQtp;
        PLZhu:
        $payload = ['webCheckoutDetails' => ['checkoutReviewReturnUrl' => $router->generate('amazon_checkout_review', ['cart' => $cart_key], UrlGeneratorInterface::ABSOLUTE_URL)], 'paymentDetails' => ['allowOvercharge' => true], 'storeId' => $Config->getClientId(), 'deliverySpecifications' => ['addressRestrictions' => ['type' => 'Allowed', 'restrictions' => ['JP' => []]]]];
        goto LXTqS;
        LXTqS:
        return json_encode($payload, JSON_FORCE_OBJECT);
        goto xOkQB;
        tHuvY:
        $router = $this->container->get('router');
        goto PLZhu;
        soQtp:
        $Config = $this->configRepository->get();
        goto tHuvY;
        xOkQB:
    }
    public function createUpdateCheckoutSessionPayload($Order)
    {
        goto RJFTq;
        NEmuj:
        $paymentIntent = 'AuthorizeWithCapture';
        goto ASmqf;
        ASmqf:
        XpWQf:
        goto yDPqI;
        HmC01:
        if (!($Order->getPaymentTotal() == 0)) {
            goto QY7Ze;
        }
        goto Q6tN8;
        mcO3s:
        $paymentIntent = 'Authorize';
        goto ydtOp;
        lCvme:
        $config = $this->configRepository->get();
        goto Di0Zs;
        YL4pU:
        if ($config->getSale() == $this->eccubeConfig['amazon_pay_v2']['sale']['capture']) {
            goto LG0lB;
        }
        goto nFiUv;
        T3c97:
        Adh5d:
        goto Bc548;
        NygwJ:
        QY7Ze:
        goto lCvme;
        yDPqI:
        $payload = ['webCheckoutDetails' => ['checkoutResultReturnUrl' => $router->generate('amazon_pay_shopping_checkout_result', [], UrlGeneratorInterface::ABSOLUTE_URL)], 'paymentDetails' => ['paymentIntent' => $paymentIntent, 'canHandlePendingAuthorization' => false, 'chargeAmount' => ['amount' => (int) $Order->getPaymentTotal(), 'currencyCode' => "JPY"]], 'merchantMetadata' => ['merchantReferenceId' => $this->payoutSellerOrderId($Order->getId()), 'noteToBuyer' => ''], "platformId" => "A1LODGGQOBGE66"];
        goto rXgEv;
        ydtOp:
        goto XpWQf;
        goto zeo9F;
        nFiUv:
        goto XpWQf;
        goto ln_sX;
        Q6tN8:
        throw AmazonPaymentException::create(AmazonPaymentException::ZERO_PAYMENT);
        goto NygwJ;
        RJFTq:
        $router = $this->container->get('router');
        goto HmC01;
        Bc548:
        return json_encode($payload, JSON_FORCE_OBJECT);
        goto g0mWC;
        LAPTE:
        $payload['merchantMetadata']['merchantStoreName'] = $this->BaseInfo->getShopName();
        goto T3c97;
        zeo9F:
        LG0lB:
        goto NEmuj;
        rXgEv:
        if (!(mb_strlen($this->BaseInfo->getShopName()) < 51)) {
            goto Adh5d;
        }
        goto LAPTE;
        Di0Zs:
        if ($config->getSale() == $this->eccubeConfig['amazon_pay_v2']['sale']['authori']) {
            goto ub9jF;
        }
        goto YL4pU;
        ln_sX:
        ub9jF:
        goto mcO3s;
        g0mWC:
    }
    public function createCompleteCheckoutSessionPayload($Order)
    {
        $payload = ['chargeAmount' => ['amount' => (int) $Order->getPaymentTotal(), 'currencyCode' => 'JPY']];
        return json_encode($payload, JSON_FORCE_OBJECT);
    }
    public function createCaptureChargePayload($Order, $billingAmount = null)
    {
        $payload = ['captureAmount' => ['amount' => is_null($billingAmount) ? (int) $Order->getPaymentTotal() : $billingAmount, 'currencyCode' => 'JPY']];
        return json_encode($payload, JSON_FORCE_OBJECT);
    }
    public function createCancelChargePayload($cancellationReason = null)
    {
        $payload = ['cancellationReason' => $cancellationReason];
        return json_encode($payload, JSON_FORCE_OBJECT);
    }
    public function createCloseChargePermissionPayload($closureReason = null, $cancelPendingCharges = null)
    {
        $payload = ['closureReason' => $closureReason, 'cancelPendingCharges' => $cancelPendingCharges];
        return json_encode($payload, JSON_FORCE_OBJECT);
    }
    public function createCreateRefundPayload($chargeId, $refundAmount)
    {
        $payload = ['chargeId' => $chargeId, 'refundAmount' => ['amount' => $refundAmount, 'currencyCode' => $this->eccubeConfig['amazon_pay_v2']['api']['payload']['currency_code']]];
        return json_encode($payload, JSON_FORCE_OBJECT);
    }
    public function createCreateChargePayload($chargePermissionId, $paymentTotal, $CaptureNow = false, $canHandlePendingAuthorization = false)
    {
        $payload = ['chargePermissionId' => $chargePermissionId, 'chargeAmount' => ['amount' => $paymentTotal, 'currencyCode' => $this->eccubeConfig['amazon_pay_v2']['api']['payload']['currency_code']], 'captureNow' => $CaptureNow, 'canHandlePendingAuthorization' => $canHandlePendingAuthorization];
        return json_encode($payload, JSON_FORCE_OBJECT);
    }
    public function updateCheckoutSession($Order, $amazonCheckoutSessionId)
    {
        goto BtHaE;
        BtHaE:
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        goto qdDAx;
        PtkrW:
        return json_decode($result['response']);
        goto h3H_2;
        qdDAx:
        $result = $client->updateCheckoutSession($amazonCheckoutSessionId, $this->createUpdateCheckoutSessionPayload($Order));
        goto PtkrW;
        h3H_2:
    }
    public function signaturePayload($payload)
    {
        goto CCHPE;
        GON56:
        return $signature;
        goto mTNNm;
        CCHPE:
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        goto mtTTg;
        mtTTg:
        $signature = $client->generateButtonSignature($payload);
        goto GON56;
        mTNNm:
    }
    public function getCheckoutSession($amazonCheckoutSessionId)
    {
        goto siamk;
        k8V47:
        return json_decode($result['response']);
        goto durDR;
        siamk:
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        goto WThTx;
        WThTx:
        $result = $client->getCheckoutSession($amazonCheckoutSessionId);
        goto k8V47;
        durDR:
    }
    public function completeCheckoutSession($Order, $amazonCheckoutSessionId)
    {
        goto hBo1T;
        ZbLYI:
        goto yzNd8;
        goto bGOt4;
        DTx9K:
        if ($result['status'] == 200 || $result['status'] == 202) {
            goto kjDvA;
        }
        goto I_p6w;
        lUwzh:
        $this->cancelOrder($Order);
        goto i6le2;
        B4sO2:
        if (!($checkoutSession && isset($checkoutSession->statusDetails->reasonCode))) {
            goto J8QPJ;
        }
        goto uV0qX;
        PwNnB:
        if (!$errorCode) {
            goto B9AK6;
        }
        goto yKJ6K;
        zimPs:
        yzNd8:
        goto ES8We;
        lEGF_:
        B9AK6:
        goto RUIvH;
        hBo1T:
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        goto k2O9Q;
        zQ3vB:
        return $response;
        goto BgSJS;
        yKJ6K:
        throw AmazonPaymentException::create($errorCode);
        goto lEGF_;
        bGOt4:
        kjDvA:
        goto UxvVD;
        mi4J2:
        ywfhX:
        goto GXFm7;
        k2O9Q:
        $result = $client->completeCheckoutSession($amazonCheckoutSessionId, $this->createCompleteCheckoutSessionPayload($Order));
        goto yvUFf;
        X2oPA:
        u2Elz:
        goto zimPs;
        RUIvH:
        J8QPJ:
        goto X2oPA;
        zGFNH:
        logs('amazon_pay_v2')->info('▼completeCheckoutSession statusDetails = ' . var_export($checkoutSession->statusDetails, true));
        goto lUwzh;
        M2wle:
        goto yzNd8;
        goto mi4J2;
        GXFm7:
        logs('amazon_pay_v2')->info('▼completeCheckoutSession reasonCode = ' . $response->reasonCode . ', order_id = ' . $Order->getId());
        goto j1bhp;
        BgSJS:
        yfKbb:
        goto M2wle;
        I_p6w:
        if (isset($response->reasonCode)) {
            goto ywfhX;
        }
        goto ZbLYI;
        wnFur:
        $checkoutSession = $this->getCheckoutSession($amazonCheckoutSessionId);
        goto B4sO2;
        uV0qX:
        $errorCode = AmazonPaymentException::getErrorCode($checkoutSession->statusDetails->reasonCode);
        goto zGFNH;
        i6le2:
        logs('amazon_pay_v2')->info('▼completeCheckoutSession 受注をキャンセルしました' . 'order_id = ' . $Order->getId());
        goto PwNnB;
        yvUFf:
        $response = json_decode($result['response']);
        goto lnNYo;
        UxvVD:
        if (!($response->statusDetails->state == 'Completed')) {
            goto yfKbb;
        }
        goto zQ3vB;
        ES8We:
        throw new AmazonException();
        goto ZCuVt;
        lnNYo:
        logs('amazon_pay_v2')->info('▼completeCheckoutSession http-status = ' . $result['status'] . ', order_id = ' . $Order->getId());
        goto DTx9K;
        j1bhp:
        if (!($response->reasonCode == 'CheckoutSessionCanceled')) {
            goto u2Elz;
        }
        goto wnFur;
        ZCuVt:
    }
    private function cancelOrder($Order)
    {
        goto EZ1rY;
        EZ1rY:
        $OrderStatus = $this->orderStatusRepository->find($this->orderStatusRepository->find(OrderStatus::CANCEL));
        goto R3Mi0;
        XZ3i3:
        $AmazonStatus = $this->amazonStatusRepository->find(AmazonStatus::CANCEL);
        goto FY3yP;
        FY3yP:
        $Order->setAmazonPayV2AmazonStatus($AmazonStatus);
        goto P2InY;
        R3Mi0:
        $Order->setOrderStatus($OrderStatus);
        goto XZ3i3;
        P2InY:
        $this->entityManager->flush();
        goto CFzva;
        CFzva:
    }
    public function captureCharge($chargeId, $Order, $billingAmount = null)
    {
        goto D8Mi8;
        xc2Zm:
        return json_decode($result['response']);
        goto Sy6lF;
        D8Mi8:
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        goto G2xXw;
        G2xXw:
        $headers = ['x-amz-pay-Idempotency-Key' => uniqid()];
        goto hg8AC;
        hg8AC:
        $result = $client->captureCharge($chargeId, $this->createCaptureChargePayload($Order, $billingAmount), $headers);
        goto xc2Zm;
        Sy6lF:
    }
    public function cancelCharge($chargeId, $cancellationReason = null)
    {
        goto kAMpg;
        HhZoD:
        $result = $client->cancelCharge($chargeId, $payload);
        goto qSsR2;
        kAMpg:
        $payload = $this->createCancelChargePayload($cancellationReason);
        goto GezlN;
        qSsR2:
        return json_decode($result['response']);
        goto BGVHg;
        GezlN:
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        goto HhZoD;
        BGVHg:
    }
    public function closeChargePermission($chargePermissionId, $closureReason = null, $cancelPendingCharges = true)
    {
        goto yKpvP;
        yKpvP:
        $payload = $this->createCloseChargePermissionPayload($closureReason, $cancelPendingCharges);
        goto SLC37;
        SLC37:
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        goto fbwOj;
        Y0Rsz:
        return json_decode($result['response']);
        goto ZkyYI;
        fbwOj:
        $result = $client->closeChargePermission($chargePermissionId, $payload);
        goto Y0Rsz;
        ZkyYI:
    }
    public function createRefund($chargeId, $refundAmount, $softDescriptor = null, $idempotencyKey = null)
    {
        goto kWqNS;
        DxlUa:
        OEXa0:
        goto mFRx3;
        ReKJF:
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        goto wE8EG;
        AVzeC:
        $idempotencyKey = uniqid();
        goto Y32Om;
        ndDDC:
        $payload = array_merge($payload, ["softDescriptor" => $softDescriptor]);
        goto DxlUa;
        h_f2b:
        $headers = ['x-amz-pay-Idempotency-Key' => $idempotencyKey];
        goto ReKJF;
        wE8EG:
        $result = $client->createRefund($payload, $headers);
        goto kwjCg;
        mFRx3:
        if (!($idempotencyKey == null)) {
            goto yiNKI;
        }
        goto AVzeC;
        Y32Om:
        yiNKI:
        goto h_f2b;
        kWqNS:
        $payload = $this->createCreateRefundPayload($chargeId, $refundAmount);
        goto Zfzr1;
        kwjCg:
        return json_decode($result['response']);
        goto Ejmbg;
        Zfzr1:
        if (!(null != $softDescriptor)) {
            goto OEXa0;
        }
        goto ndDDC;
        Ejmbg:
    }
    public function createCharge($chargePermissionId, $paymentTotal, $CaptureNow = false, $softDescriptor = null, $canHandlePendingAuthorization = false, $merchantMetadataMerchantReferenceId = null, $idempotencyKey = null)
    {
        goto ex62Z;
        HH9TK:
        ax77O:
        goto ia7Jx;
        Ot8Ln:
        N4NAQ:
        goto IezIE;
        yUNmv:
        $result = $client->createCharge($payload, $headers);
        goto TWpsr;
        Z9vft:
        $payload = array_merge($payload, ["merchantMetadata" => ["merchantReferenceId" => $merchantMetadataMerchantReferenceId]]);
        goto A9lJn;
        ia7Jx:
        if (!($idempotencyKey == null)) {
            goto N4NAQ;
        }
        goto KA8d3;
        KA8d3:
        $idempotencyKey = uniqid();
        goto Ot8Ln;
        czGYj:
        $payload = array_merge($payload, ["softDescriptor" => $softDescriptor]);
        goto HH9TK;
        J9FP3:
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        goto yUNmv;
        ex62Z:
        $payload = $this->createCreateChargePayload($chargePermissionId, $paymentTotal, $CaptureNow, $canHandlePendingAuthorization);
        goto c3vnf;
        IezIE:
        $headers = ['x-amz-pay-Idempotency-Key' => $idempotencyKey];
        goto J9FP3;
        c3vnf:
        if (!(null != $merchantMetadataMerchantReferenceId)) {
            goto I58cu;
        }
        goto Z9vft;
        TWpsr:
        return json_decode($result['response']);
        goto DcHOl;
        Udol1:
        if (!(null != $softDescriptor)) {
            goto ax77O;
        }
        goto czGYj;
        A9lJn:
        I58cu:
        goto Udol1;
        DcHOl:
    }
    public function getCharge($chargeId)
    {
        goto CJ9sJ;
        CJ9sJ:
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        goto CGJ0T;
        CGJ0T:
        $result = $client->getCharge($chargeId);
        goto I_u5p;
        I_u5p:
        return json_decode($result['response']);
        goto EME0h;
        EME0h:
    }
    public function createSigninPayload($returnUrl)
    {
        goto NdVL6;
        bkBlY:
        return json_encode($payload, JSON_FORCE_OBJECT);
        goto rRPl4;
        PO4ZM:
        $payload = ['signInReturnUrl' => $returnUrl, 'storeId' => $Config->getClientId()];
        goto bkBlY;
        NdVL6:
        $Config = $this->configRepository->get();
        goto PO4ZM;
        rRPl4:
    }
    public function getBuyer($buyerToken, $headers = null)
    {
        goto gh1MS;
        cVlY7:
        $result = $client->getBuyer($buyerToken, $headers);
        goto C3sAb;
        C3sAb:
        if (!($result['status'] != 200)) {
            goto sisLr;
        }
        goto aVsN3;
        aVsN3:
        throw new AmazonException();
        goto WwiaV;
        LgNiq:
        return json_decode($result['response']);
        goto S0tPc;
        WwiaV:
        sisLr:
        goto LgNiq;
        gh1MS:
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        goto cVlY7;
        S0tPc:
    }
    public function loginWithBuyerId(Request $request, $buyerId)
    {
        goto hTwGl;
        cs7z9:
        foreach ($this->cartService->getCarts() as $Cart) {
            $this->purchaseFlow->validate($Cart, new PurchaseContext($Cart, $Customers[0]));
            jr2Jk:
        }
        goto ssLTs;
        zdSb1:
        $request->getSession()->migrate(true);
        goto pRwAa;
        F9Xyz:
        $this->cartService->save();
        goto ISyWL;
        ssLTs:
        hnFZj:
        goto F9Xyz;
        hTwGl:
        $Customers = $this->customerRepository->getNonWithdrawingCustomers(['v2_amazon_user_id' => $buyerId]);
        goto hCkN5;
        pYjI1:
        $this->tokenStorage->setToken($token);
        goto zdSb1;
        ISyWL:
        return true;
        goto p5tE0;
        pRwAa:
        $this->cartService->mergeFromPersistedCart();
        goto cs7z9;
        Q3LQd:
        return false;
        goto abW0M;
        D85Xj:
        $token = new UsernamePasswordToken($Customers[0], null, 'customer', ['ROLE_USER']);
        goto pYjI1;
        abW0M:
        zgxv1:
        goto D85Xj;
        hCkN5:
        if (!(empty($Customers[0]) || !$Customers[0] instanceof \Eccube\Entity\Customer)) {
            goto zgxv1;
        }
        goto Q3LQd;
        p5tE0:
    }
}

Decoded(de-Obfuscated) php code

<?php

/*   __________________________________________________
    |  Obfuscated by YAK Pro - Php Obfuscator  2.0.3   |
    |              on 2023-07-05 10:12:25              |
    |    GitHub: https://github.com/pk-fr/yakpro-po    |
    |__________________________________________________|
*/
namespace Plugin\AmazonPayV2_42\Service;

use Doctrine\ORM\EntityManagerInterface;
use Eccube\Common\EccubeConfig;
use Eccube\Entity\Master\OrderStatus;
use Eccube\Repository\BaseInfoRepository;
use Eccube\Repository\CustomerRepository;
use Eccube\Repository\Master\OrderStatusRepository;
use Eccube\Service\CartService;
use Eccube\Service\PurchaseFlow\PurchaseContext;
use Eccube\Service\PurchaseFlow\PurchaseFlow;
use Eccube\Service\PurchaseFlow\Processor\StockReduceProcessor;
use Eccube\Service\PurchaseFlow\Processor\PointProcessor;
use Plugin\AmazonPayV2_42\Entity\Master\AmazonStatus;
use Plugin\AmazonPayV2_42\Exception\AmazonException;
use Plugin\AmazonPayV2_42\Exception\AmazonPaymentException;
use Plugin\AmazonPayV2_42\Repository\ConfigRepository;
use Plugin\AmazonPayV2_42\Amazon\Pay\API\Client as AmazonPayClient;
use Plugin\AmazonPayV2_42\Repository\Master\AmazonStatusRepository;
use GuzzleHttp\Client;
use Guzzle\Http\Exception\BadResponseException;
use Guzzle\Http\Exception\CurlException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Carbon\Carbon;
class AmazonRequestService extends AbstractController
{
    protected $entityManager;
    protected $baseInfoRepository;
    protected $customerRepository;
    protected $cartService;
    protected $purchaseFlow;
    protected $eccubeConfig;
    protected $configRepository;
    protected $Config;
    protected $amazonApi;
    protected $amazonApiConfig;
    protected $session;
    protected $tokenStorage;
    protected $container;
    private $pointProcessor;
    private $stockReduceProcessor;
    private $amazonStatusRepository;
    private $orderStatusRepository;
    public function __construct(EntityManagerInterface $entityManager, BaseInfoRepository $baseInfoRepository, CustomerRepository $customerRepository, CartService $cartService, PurchaseFlow $cartPurchaseFlow, EccubeConfig $eccubeConfig, ConfigRepository $configRepository, SessionInterface $session, TokenStorageInterface $tokenStorage, OrderStatusRepository $orderStatusRepository, AmazonStatusRepository $amazonStatusRepository, StockReduceProcessor $stockReduceProcessor, PointProcessor $pointProcessor, ContainerInterface $container)
    {
        $this->entityManager = $entityManager;
        $this->BaseInfo = $baseInfoRepository->get();
        $this->customerRepository = $customerRepository;
        $this->cartService = $cartService;
        $this->purchaseFlow = $cartPurchaseFlow;
        $this->eccubeConfig = $eccubeConfig;
        $this->configRepository = $configRepository;
        $this->session = $session;
        $this->tokenStorage = $tokenStorage;
        $this->orderStatusRepository = $orderStatusRepository;
        $this->amazonStatusRepository = $amazonStatusRepository;
        $this->stockReduceProcessor = $stockReduceProcessor;
        $this->pointProcessor = $pointProcessor;
        $this->container = $container;
        $this->Config = $this->configRepository->get();
        if ($this->Config->getAmazonAccountMode() == $this->eccubeConfig['amazon_pay_v2']['account_mode']['owned'] && $this->Config->getEnv() == $this->eccubeConfig['amazon_pay_v2']['env']['prod']) {
            $this->amazonApi = $this->eccubeConfig['amazon_pay_v2']['api']['prod'];
            goto b30at;
        }
        $this->amazonApi = $this->eccubeConfig['amazon_pay_v2']['api']['sandbox'];
        b30at:
        $this->amazonApiConfig = $this->eccubeConfig['amazon_pay_v2']['api']['config'];
    }
    private function payoutSellerOrderId($orderId, $request_type = '')
    {
        $request_attr = $request_type === '' ? '' : strtoupper($request_type) . '_';
        $prefix = '';
        $iniFile = "/var/www/html/../amazon_pay_config.ini";
        if (!file_exists($iniFile)) {
            goto glbcK;
        }
        $arrInit = parse_ini_file($iniFile);
        $prefix = $arrInit['prefix'];
        glbcK:
        $prefix = $prefix === '' ? '' : $prefix . '_';
        $timestamp = '';
        if (!($this->Config->getAmazonAccountMode() === $this->eccubeConfig['amazon_pay_v2']['account_mode']['shared'])) {
            goto mpbQ9;
        }
        $timestamp = Carbon::now()->timestamp;
        mpbQ9:
        $timestamp = $timestamp === '' ? '' : $timestamp . '_';
        return $timestamp . $prefix . $request_attr . $orderId;
    }
    protected function getAmazonPayConfig()
    {
        $Config = $this->configRepository->get();
        $config = ['public_key_id' => $Config->getPublicKeyId(), 'private_key' => $this->eccubeConfig->get('kernel.project_dir') . '/' . $Config->getPrivateKeyPath(), 'sandbox' => $Config->getEnv() == $this->eccubeConfig['amazon_pay_v2']['env']['sandbox'] ? true : false, 'region' => 'jp'];
        return $config;
    }
    public function createCheckoutSessionPayload($cart_key)
    {
        $Config = $this->configRepository->get();
        $router = $this->container->get('router');
        $payload = ['webCheckoutDetails' => ['checkoutReviewReturnUrl' => $router->generate('amazon_checkout_review', ['cart' => $cart_key], UrlGeneratorInterface::ABSOLUTE_URL)], 'paymentDetails' => ['allowOvercharge' => true], 'storeId' => $Config->getClientId(), 'deliverySpecifications' => ['addressRestrictions' => ['type' => 'Allowed', 'restrictions' => ['JP' => []]]]];
        return json_encode($payload, JSON_FORCE_OBJECT);
    }
    public function createUpdateCheckoutSessionPayload($Order)
    {
        $router = $this->container->get('router');
        if (!($Order->getPaymentTotal() == 0)) {
            $config = $this->configRepository->get();
            if ($config->getSale() == $this->eccubeConfig['amazon_pay_v2']['sale']['authori']) {
                $paymentIntent = 'Authorize';
                goto XpWQf;
            }
            if ($config->getSale() == $this->eccubeConfig['amazon_pay_v2']['sale']['capture']) {
                $paymentIntent = 'AuthorizeWithCapture';
                goto ASmqf;
            }
            ASmqf:
            XpWQf:
            $payload = ['webCheckoutDetails' => ['checkoutResultReturnUrl' => $router->generate('amazon_pay_shopping_checkout_result', [], UrlGeneratorInterface::ABSOLUTE_URL)], 'paymentDetails' => ['paymentIntent' => $paymentIntent, 'canHandlePendingAuthorization' => false, 'chargeAmount' => ['amount' => (int) $Order->getPaymentTotal(), 'currencyCode' => "JPY"]], 'merchantMetadata' => ['merchantReferenceId' => $this->payoutSellerOrderId($Order->getId()), 'noteToBuyer' => ''], "platformId" => "A1LODGGQOBGE66"];
            if (!(mb_strlen($this->BaseInfo->getShopName()) < 51)) {
                goto Adh5d;
            }
            $payload['merchantMetadata']['merchantStoreName'] = $this->BaseInfo->getShopName();
            Adh5d:
            return json_encode($payload, JSON_FORCE_OBJECT);
        }
        throw AmazonPaymentException::create(AmazonPaymentException::ZERO_PAYMENT);
    }
    public function createCompleteCheckoutSessionPayload($Order)
    {
        $payload = ['chargeAmount' => ['amount' => (int) $Order->getPaymentTotal(), 'currencyCode' => 'JPY']];
        return json_encode($payload, JSON_FORCE_OBJECT);
    }
    public function createCaptureChargePayload($Order, $billingAmount = null)
    {
        $payload = ['captureAmount' => ['amount' => is_null($billingAmount) ? (int) $Order->getPaymentTotal() : $billingAmount, 'currencyCode' => 'JPY']];
        return json_encode($payload, JSON_FORCE_OBJECT);
    }
    public function createCancelChargePayload($cancellationReason = null)
    {
        $payload = ['cancellationReason' => $cancellationReason];
        return json_encode($payload, JSON_FORCE_OBJECT);
    }
    public function createCloseChargePermissionPayload($closureReason = null, $cancelPendingCharges = null)
    {
        $payload = ['closureReason' => $closureReason, 'cancelPendingCharges' => $cancelPendingCharges];
        return json_encode($payload, JSON_FORCE_OBJECT);
    }
    public function createCreateRefundPayload($chargeId, $refundAmount)
    {
        $payload = ['chargeId' => $chargeId, 'refundAmount' => ['amount' => $refundAmount, 'currencyCode' => $this->eccubeConfig['amazon_pay_v2']['api']['payload']['currency_code']]];
        return json_encode($payload, JSON_FORCE_OBJECT);
    }
    public function createCreateChargePayload($chargePermissionId, $paymentTotal, $CaptureNow = false, $canHandlePendingAuthorization = false)
    {
        $payload = ['chargePermissionId' => $chargePermissionId, 'chargeAmount' => ['amount' => $paymentTotal, 'currencyCode' => $this->eccubeConfig['amazon_pay_v2']['api']['payload']['currency_code']], 'captureNow' => $CaptureNow, 'canHandlePendingAuthorization' => $canHandlePendingAuthorization];
        return json_encode($payload, JSON_FORCE_OBJECT);
    }
    public function updateCheckoutSession($Order, $amazonCheckoutSessionId)
    {
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        $result = $client->updateCheckoutSession($amazonCheckoutSessionId, $this->createUpdateCheckoutSessionPayload($Order));
        return json_decode($result['response']);
    }
    public function signaturePayload($payload)
    {
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        $signature = $client->generateButtonSignature($payload);
        return $signature;
    }
    public function getCheckoutSession($amazonCheckoutSessionId)
    {
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        $result = $client->getCheckoutSession($amazonCheckoutSessionId);
        return json_decode($result['response']);
    }
    public function completeCheckoutSession($Order, $amazonCheckoutSessionId)
    {
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        $result = $client->completeCheckoutSession($amazonCheckoutSessionId, $this->createCompleteCheckoutSessionPayload($Order));
        $response = json_decode($result['response']);
        logs('amazon_pay_v2')->info('▼completeCheckoutSession http-status = ' . $result['status'] . ', order_id = ' . $Order->getId());
        if ($result['status'] == 200 || $result['status'] == 202) {
            if (!($response->statusDetails->state == 'Completed')) {
                goto yzNd8;
            }
            return $response;
        }
        if (isset($response->reasonCode)) {
            logs('amazon_pay_v2')->info('▼completeCheckoutSession reasonCode = ' . $response->reasonCode . ', order_id = ' . $Order->getId());
            if (!($response->reasonCode == 'CheckoutSessionCanceled')) {
                goto u2Elz;
            }
            $checkoutSession = $this->getCheckoutSession($amazonCheckoutSessionId);
            if (!($checkoutSession && isset($checkoutSession->statusDetails->reasonCode))) {
                goto J8QPJ;
            }
            $errorCode = AmazonPaymentException::getErrorCode($checkoutSession->statusDetails->reasonCode);
            logs('amazon_pay_v2')->info('▼completeCheckoutSession statusDetails = ' . var_export($checkoutSession->statusDetails, true));
            $this->cancelOrder($Order);
            logs('amazon_pay_v2')->info('▼completeCheckoutSession 受注をキャンセルしましたorder_id = ' . $Order->getId());
            if (!$errorCode) {
                J8QPJ:
                u2Elz:
                goto zimPs;
            }
            throw AmazonPaymentException::create($errorCode);
        }
        zimPs:
        yzNd8:
        throw new AmazonException();
    }
    private function cancelOrder($Order)
    {
        $OrderStatus = $this->orderStatusRepository->find($this->orderStatusRepository->find(OrderStatus::CANCEL));
        $Order->setOrderStatus($OrderStatus);
        $AmazonStatus = $this->amazonStatusRepository->find(AmazonStatus::CANCEL);
        $Order->setAmazonPayV2AmazonStatus($AmazonStatus);
        $this->entityManager->flush();
    }
    public function captureCharge($chargeId, $Order, $billingAmount = null)
    {
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        $headers = ['x-amz-pay-Idempotency-Key' => uniqid()];
        $result = $client->captureCharge($chargeId, $this->createCaptureChargePayload($Order, $billingAmount), $headers);
        return json_decode($result['response']);
    }
    public function cancelCharge($chargeId, $cancellationReason = null)
    {
        $payload = $this->createCancelChargePayload($cancellationReason);
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        $result = $client->cancelCharge($chargeId, $payload);
        return json_decode($result['response']);
    }
    public function closeChargePermission($chargePermissionId, $closureReason = null, $cancelPendingCharges = true)
    {
        $payload = $this->createCloseChargePermissionPayload($closureReason, $cancelPendingCharges);
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        $result = $client->closeChargePermission($chargePermissionId, $payload);
        return json_decode($result['response']);
    }
    public function createRefund($chargeId, $refundAmount, $softDescriptor = null, $idempotencyKey = null)
    {
        $payload = $this->createCreateRefundPayload($chargeId, $refundAmount);
        if (!(null != $softDescriptor)) {
            goto OEXa0;
        }
        $payload = array_merge($payload, ["softDescriptor" => $softDescriptor]);
        OEXa0:
        if (!($idempotencyKey == null)) {
            goto yiNKI;
        }
        $idempotencyKey = uniqid();
        yiNKI:
        $headers = ['x-amz-pay-Idempotency-Key' => $idempotencyKey];
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        $result = $client->createRefund($payload, $headers);
        return json_decode($result['response']);
    }
    public function createCharge($chargePermissionId, $paymentTotal, $CaptureNow = false, $softDescriptor = null, $canHandlePendingAuthorization = false, $merchantMetadataMerchantReferenceId = null, $idempotencyKey = null)
    {
        $payload = $this->createCreateChargePayload($chargePermissionId, $paymentTotal, $CaptureNow, $canHandlePendingAuthorization);
        if (!(null != $merchantMetadataMerchantReferenceId)) {
            goto I58cu;
        }
        $payload = array_merge($payload, ["merchantMetadata" => ["merchantReferenceId" => $merchantMetadataMerchantReferenceId]]);
        I58cu:
        if (!(null != $softDescriptor)) {
            goto ax77O;
        }
        $payload = array_merge($payload, ["softDescriptor" => $softDescriptor]);
        ax77O:
        if (!($idempotencyKey == null)) {
            goto N4NAQ;
        }
        $idempotencyKey = uniqid();
        N4NAQ:
        $headers = ['x-amz-pay-Idempotency-Key' => $idempotencyKey];
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        $result = $client->createCharge($payload, $headers);
        return json_decode($result['response']);
    }
    public function getCharge($chargeId)
    {
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        $result = $client->getCharge($chargeId);
        return json_decode($result['response']);
    }
    public function createSigninPayload($returnUrl)
    {
        $Config = $this->configRepository->get();
        $payload = ['signInReturnUrl' => $returnUrl, 'storeId' => $Config->getClientId()];
        return json_encode($payload, JSON_FORCE_OBJECT);
    }
    public function getBuyer($buyerToken, $headers = null)
    {
        $client = new AmazonPayClient($this->getAmazonPayConfig());
        $result = $client->getBuyer($buyerToken, $headers);
        if (!($result['status'] != 200)) {
            return json_decode($result['response']);
        }
        throw new AmazonException();
    }
    public function loginWithBuyerId(Request $request, $buyerId)
    {
        $Customers = $this->customerRepository->getNonWithdrawingCustomers(['v2_amazon_user_id' => $buyerId]);
        if (!(empty($Customers[0]) || !$Customers[0] instanceof \Eccube\Entity\Customer)) {
            $token = new UsernamePasswordToken($Customers[0], null, 'customer', ['ROLE_USER']);
            $this->tokenStorage->setToken($token);
            $request->getSession()->migrate(true);
            $this->cartService->mergeFromPersistedCart();
            foreach ($this->cartService->getCarts() as $Cart) {
                $this->purchaseFlow->validate($Cart, new PurchaseContext($Cart, $Customers[0]));
            }
            $this->cartService->save();
            return true;
        }
        return false;
    }
}


Malware detection & removal plugin for WordPress

(C)2020 Wordpress Doctor All rights reserved.