Skip to content

Commit

Permalink
Allow php74
Browse files Browse the repository at this point in the history
  • Loading branch information
moneimagento committed Apr 4, 2024
1 parent 59b0da0 commit 7886ad3
Show file tree
Hide file tree
Showing 19 changed files with 175 additions and 57 deletions.
32 changes: 24 additions & 8 deletions Controller/Payment/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,33 @@
class Callback implements CsrfAwareActionInterface, HttpPostActionInterface
{
private string $errorMessage = '';
private Context $context;
private SerializerInterface $serializer;
private MoneiPaymentModuleConfigInterface $moduleConfig;
private Logger $logger;
private StoreManagerInterface $storeManager;
private GenerateInvoiceInterface $generateInvoiceService;
private SetOrderStatusAndStateInterface $setOrderStatusAndStateService;
private MagentoRedirect $resultRedirectFactory;

public function __construct(
private readonly Context $context,
private readonly SerializerInterface $serializer,
private readonly MoneiPaymentModuleConfigInterface $moduleConfig,
private readonly Logger $logger,
private readonly StoreManagerInterface $storeManager,
private readonly GenerateInvoiceInterface $generateInvoiceService,
private readonly SetOrderStatusAndStateInterface $setOrderStatusAndStateService,
private readonly MagentoRedirect $resultRedirectFactory
Context $context,
SerializerInterface $serializer,
MoneiPaymentModuleConfigInterface $moduleConfig,
Logger $logger,
StoreManagerInterface $storeManager,
GenerateInvoiceInterface $generateInvoiceService,
SetOrderStatusAndStateInterface $setOrderStatusAndStateService,
MagentoRedirect $resultRedirectFactory
) {
$this->resultRedirectFactory = $resultRedirectFactory;
$this->setOrderStatusAndStateService = $setOrderStatusAndStateService;
$this->generateInvoiceService = $generateInvoiceService;
$this->storeManager = $storeManager;
$this->logger = $logger;
$this->moduleConfig = $moduleConfig;
$this->serializer = $serializer;
$this->context = $context;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion Controller/Payment/Complete.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class Complete implements ActionInterface
* @var OrderSender
*/
protected $orderSender;
private CreateVaultPayment $createVaultPayment;

/**
* @param Context $context
Expand All @@ -97,8 +98,9 @@ public function __construct(
MagentoRedirect $resultRedirectFactory,
PendingOrderFactory $pendingOrderFactory,
PendingOrderResource $pendingOrderResource,
private readonly CreateVaultPayment $createVaultPayment
CreateVaultPayment $createVaultPayment
) {
$this->createVaultPayment = $createVaultPayment;
$this->context = $context;
$this->orderRepository = $orderRepository;
$this->orderSender = $orderSender;
Expand Down
9 changes: 7 additions & 2 deletions Controller/Payment/FailLastOrderByStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@
*/
class FailLastOrderByStatus extends Fail
{
private Context $context;
private Session $checkoutSession;

public function __construct(
private readonly Context $context,
private readonly Session $checkoutSession,
Context $context,
Session $checkoutSession,
OrderInterfaceFactory $orderFactory,
SetOrderStatusAndStateInterface $setOrderStatusAndStateService,
ManagerInterface $messageManager,
MagentoRedirect $resultRedirectFactory
) {
$this->checkoutSession = $checkoutSession;
$this->context = $context;
parent::__construct($context, $checkoutSession, $orderFactory, $setOrderStatusAndStateService, $messageManager, $resultRedirectFactory);

}
Expand Down
21 changes: 16 additions & 5 deletions Model/CheckoutConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,25 @@
class CheckoutConfigProvider implements ConfigProviderInterface
{

private UrlInterface $urlBuilder;
private MoneiPaymentModuleConfigInterface $moneiPaymentConfig;
private MoneiCardPaymentModuleConfigInterface $moneiCardPaymentConfig;
private MoneiGoogleApplePaymentModuleConfigInterface $moneiGoogleApplePaymentConfig;
private StoreManagerInterface $storeManager;

public function __construct(
private readonly UrlInterface $urlBuilder,
private readonly MoneiPaymentModuleConfigInterface $moneiPaymentConfig,
private readonly MoneiCardPaymentModuleConfigInterface $moneiCardPaymentConfig,
private readonly MoneiGoogleApplePaymentModuleConfigInterface $moneiGoogleApplePaymentConfig,
private readonly StoreManagerInterface $storeManager,
UrlInterface $urlBuilder,
MoneiPaymentModuleConfigInterface $moneiPaymentConfig,
MoneiCardPaymentModuleConfigInterface $moneiCardPaymentConfig,
MoneiGoogleApplePaymentModuleConfigInterface $moneiGoogleApplePaymentConfig,
StoreManagerInterface $storeManager
)
{
$this->moneiGoogleApplePaymentConfig = $moneiGoogleApplePaymentConfig;
$this->moneiCardPaymentConfig = $moneiCardPaymentConfig;
$this->moneiPaymentConfig = $moneiPaymentConfig;
$this->urlBuilder = $urlBuilder;
$this->storeManager = $storeManager;
}

public function getConfig(): array
Expand Down
5 changes: 4 additions & 1 deletion Model/Config/MoneiBizumPaymentModuleConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
*/
class MoneiBizumPaymentModuleConfig implements MoneiBizumPaymentModuleConfigInterface
{
private ScopeConfigInterface $scopeConfig;

public function __construct(
private readonly ScopeConfigInterface $scopeConfig
ScopeConfigInterface $scopeConfig
) {
$this->scopeConfig = $scopeConfig;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion Model/Config/MoneiCardPaymentModuleConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
*/
class MoneiCardPaymentModuleConfig implements MoneiCardPaymentModuleConfigInterface
{
private ScopeConfigInterface $scopeConfig;

public function __construct(
private readonly ScopeConfigInterface $scopeConfig
ScopeConfigInterface $scopeConfig
) {
$this->scopeConfig = $scopeConfig;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion Model/Config/MoneiGoogleApplePaymentModuleConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
*/
class MoneiGoogleApplePaymentModuleConfig implements MoneiGoogleApplePaymentModuleConfigInterface
{
private ScopeConfigInterface $scopeConfig;

public function __construct(
private readonly ScopeConfigInterface $scopeConfig
ScopeConfigInterface $scopeConfig
) {
$this->scopeConfig = $scopeConfig;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion Model/Config/MoneiPaymentModuleConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
*/
class MoneiPaymentModuleConfig implements MoneiPaymentModuleConfigInterface
{
private ScopeConfigInterface $scopeConfig;

public function __construct(
private readonly ScopeConfigInterface $scopeConfig
ScopeConfigInterface $scopeConfig
) {
$this->scopeConfig = $scopeConfig;
}

/**
Expand Down
8 changes: 6 additions & 2 deletions Model/OrderLockManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@

class OrderLockManager implements OrderLockManagerInterface
{
private LockManagerInterface $lockManager;

public function __construct(
private readonly LockManagerInterface $lockManager
) {}
LockManagerInterface $lockManager
) {
$this->lockManager = $lockManager;
}

public function lock(string $incrementId): bool
{
Expand Down
5 changes: 4 additions & 1 deletion Model/Ui/Card/TokenUiComponentProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
class TokenUiComponentProvider implements TokenUiComponentProviderInterface
{

private TokenUiComponentInterfaceFactory $componentFactory;

public function __construct(
private readonly TokenUiComponentInterfaceFactory $componentFactory
TokenUiComponentInterfaceFactory $componentFactory
)
{
$this->componentFactory = $componentFactory;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion Observer/SaveOrderBeforeSalesModelQuoteObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

class SaveOrderBeforeSalesModelQuoteObserver implements ObserverInterface
{
public function __construct(private readonly Copy $objectCopyService)
private Copy $objectCopyService;

public function __construct(Copy $objectCopyService)
{
$this->objectCopyService = $objectCopyService;
}

/**
Expand Down
25 changes: 19 additions & 6 deletions Service/Checkout/CreateGuestMoneiPaymentInSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,27 @@
class CreateGuestMoneiPaymentInSite implements CreateGuestMoneiPaymentInSiteInterface
{

private CartRepositoryInterface $quoteRepository;
private Session $checkoutSession;
private MaskedQuoteIdToQuoteIdInterface $maskedQuoteIdToQuoteId;
private GetCustomerDetailsByQuote $getCustomerDetailsByQuote;
private GetAddressDetailsByQuoteAddress $getAddressDetailsByQuoteAddress;
private CreatePayment $createPayment;

public function __construct(
private readonly CartRepositoryInterface $quoteRepository,
private readonly Session $checkoutSession,
private readonly MaskedQuoteIdToQuoteIdInterface $maskedQuoteIdToQuoteId,
private readonly GetCustomerDetailsByQuote $getCustomerDetailsByQuote,
private readonly GetAddressDetailsByQuoteAddress $getAddressDetailsByQuoteAddress,
private readonly CreatePayment $createPayment)
CartRepositoryInterface $quoteRepository,
Session $checkoutSession,
MaskedQuoteIdToQuoteIdInterface $maskedQuoteIdToQuoteId,
GetCustomerDetailsByQuote $getCustomerDetailsByQuote,
GetAddressDetailsByQuoteAddress $getAddressDetailsByQuoteAddress,
CreatePayment $createPayment)
{
$this->createPayment = $createPayment;
$this->getAddressDetailsByQuoteAddress = $getAddressDetailsByQuoteAddress;
$this->getCustomerDetailsByQuote = $getCustomerDetailsByQuote;
$this->maskedQuoteIdToQuoteId = $maskedQuoteIdToQuoteId;
$this->checkoutSession = $checkoutSession;
$this->quoteRepository = $quoteRepository;
}

/**
Expand Down
21 changes: 16 additions & 5 deletions Service/Checkout/CreateLoggedMoneiPaymentInSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,24 @@
*/
class CreateLoggedMoneiPaymentInSite implements CreateLoggedMoneiPaymentInSiteInterface
{
private CartRepositoryInterface $quoteRepository;
private Session $checkoutSession;
private GetCustomerDetailsByQuote $getCustomerDetailsByQuote;
private GetAddressDetailsByQuoteAddress $getAddressDetailsByQuoteAddress;
private CreatePayment $createPayment;

public function __construct(
private readonly CartRepositoryInterface $quoteRepository,
private readonly Session $checkoutSession,
private readonly GetCustomerDetailsByQuote $getCustomerDetailsByQuote,
private readonly GetAddressDetailsByQuoteAddress $getAddressDetailsByQuoteAddress,
private readonly CreatePayment $createPayment)
CartRepositoryInterface $quoteRepository,
Session $checkoutSession,
GetCustomerDetailsByQuote $getCustomerDetailsByQuote,
GetAddressDetailsByQuoteAddress $getAddressDetailsByQuoteAddress,
CreatePayment $createPayment)
{
$this->createPayment = $createPayment;
$this->getAddressDetailsByQuoteAddress = $getAddressDetailsByQuoteAddress;
$this->getCustomerDetailsByQuote = $getCustomerDetailsByQuote;
$this->checkoutSession = $checkoutSession;
$this->quoteRepository = $quoteRepository;
}

/**
Expand Down
25 changes: 19 additions & 6 deletions Service/Checkout/CreateLoggedMoneiPaymentVault.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,27 @@
*/
class CreateLoggedMoneiPaymentVault implements CreateLoggedMoneiPaymentVaultInterface
{
private CartRepositoryInterface $quoteRepository;
private Session $checkoutSession;
private GetCustomerDetailsByQuote $getCustomerDetailsByQuote;
private GetAddressDetailsByQuoteAddress $getAddressDetailsByQuoteAddress;
private PaymentTokenManagementInterface $tokenManagement;
private CreatePayment $createPayment;

public function __construct(
private readonly CartRepositoryInterface $quoteRepository,
private readonly Session $checkoutSession,
private readonly GetCustomerDetailsByQuote $getCustomerDetailsByQuote,
private readonly GetAddressDetailsByQuoteAddress $getAddressDetailsByQuoteAddress,
private readonly PaymentTokenManagementInterface $tokenManagement,
private readonly CreatePayment $createPayment)
CartRepositoryInterface $quoteRepository,
Session $checkoutSession,
GetCustomerDetailsByQuote $getCustomerDetailsByQuote,
GetAddressDetailsByQuoteAddress $getAddressDetailsByQuoteAddress,
PaymentTokenManagementInterface $tokenManagement,
CreatePayment $createPayment)
{
$this->createPayment = $createPayment;
$this->tokenManagement = $tokenManagement;
$this->getAddressDetailsByQuoteAddress = $getAddressDetailsByQuoteAddress;
$this->getCustomerDetailsByQuote = $getCustomerDetailsByQuote;
$this->checkoutSession = $checkoutSession;
$this->quoteRepository = $quoteRepository;
}

/**
Expand Down
11 changes: 8 additions & 3 deletions Service/Checkout/SaveTokenization.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@

class SaveTokenization implements SaveTokenizationInterface
{
private CartRepositoryInterface $quoteRepository;
private Session $checkoutSession;

public function __construct(
private readonly CartRepositoryInterface $quoteRepository,
private readonly Session $checkoutSession)
CartRepositoryInterface $quoteRepository,
Session $checkoutSession)
{
$this->checkoutSession = $checkoutSession;
$this->quoteRepository = $quoteRepository;
}

/**
Expand All @@ -38,7 +43,7 @@ public function execute(string $cartId, int $isVaultChecked = 0): array
$this->quoteRepository->save($quote);

return [];
} catch (\Exception) {
} catch (\Exception $e) {
throw new LocalizedException(__('An error occurred trying save the card.'));
}
}
Expand Down
21 changes: 16 additions & 5 deletions Service/GenerateInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,21 @@
*/
class GenerateInvoice implements GenerateInvoiceInterface
{
private OrderInterfaceFactory $orderFactory;
private TransactionFactory $transactionFactory;
private OrderLockManagerInterface $orderLockManager;
private CreateVaultPayment $createVaultPayment;

public function __construct(
private readonly OrderInterfaceFactory $orderFactory,
private readonly TransactionFactory $transactionFactory,
private readonly OrderLockManagerInterface $orderLockManager,
private readonly CreateVaultPayment $createVaultPayment
OrderInterfaceFactory $orderFactory,
TransactionFactory $transactionFactory,
OrderLockManagerInterface $orderLockManager,
CreateVaultPayment $createVaultPayment
) {
$this->createVaultPayment = $createVaultPayment;
$this->orderLockManager = $orderLockManager;
$this->transactionFactory = $transactionFactory;
$this->orderFactory = $orderFactory;
}

/**
Expand All @@ -49,7 +58,9 @@ public function execute(array $data): void

$this->orderLockManager->lock($incrementId);
$payment = $order->getPayment();
$payment?->setLastTransId($data['id']);
if ($payment) {
$payment->setLastTransId($data['id']);
}
$invoice = $order->prepareInvoice();
if(!$invoice->getAllItems()){
return;
Expand Down
Loading

0 comments on commit 7886ad3

Please sign in to comment.