Skip to content

Commit

Permalink
Release version 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
afterpayplugins committed Jan 12, 2022
1 parent fc42986 commit 0be8af7
Show file tree
Hide file tree
Showing 83 changed files with 272 additions and 231 deletions.
7 changes: 3 additions & 4 deletions Block/Adminhtml/System/Config/Fieldset/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@

class Payment extends \Magento\Config\Block\System\Config\Form\Fieldset
{
private \Magento\Payment\Model\MethodInterface $afterpay;
private \Afterpay\Afterpay\Model\Config $config;
private $afterpay;
private $config;

public function __construct(
\Magento\Backend\Block\Context $context,
\Magento\Backend\Model\Auth\Session $authSession,
\Magento\Framework\View\Helper\Js $jsHelper,
\Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer,
\Magento\Payment\Model\MethodInterface $afterpay,
\Afterpay\Afterpay\Model\Config $config,
array $data = []
) {
parent::__construct($context, $authSession, $jsHelper, $data, $secureRenderer);
parent::__construct($context, $authSession, $jsHelper, $data);
$this->afterpay = $afterpay;
$this->config = $config;
}
Expand Down
8 changes: 3 additions & 5 deletions Block/Adminhtml/System/Config/Form/Field/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@
namespace Afterpay\Afterpay\Block\Adminhtml\System\Config\Form\Field;

use Magento\Backend\Block\Template\Context;
use Magento\Framework\View\Helper\SecureHtmlRenderer;

class Version extends \Magento\Config\Block\System\Config\Form\Field
{
const MODULE_NAME = "Afterpay_Afterpay";

private \Magento\Framework\Module\ResourceInterface $resource;
private $resource;

public function __construct(
\Magento\Framework\Module\ResourceInterface $resource,
Context $context,
array $data = [],
?SecureHtmlRenderer $secureRenderer = null
array $data = []
) {
parent::__construct($context, $data, $secureRenderer);
parent::__construct($context, $data);
$this->resource = $resource;
}

Expand Down
8 changes: 4 additions & 4 deletions Controller/Adminhtml/MerchantConfiguration/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

class Update implements \Magento\Framework\App\Action\HttpPostActionInterface
{
private \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory;
private \Magento\Framework\Message\ManagerInterface $messageManager;
private \Magento\Framework\App\RequestInterface $request;
private \Magento\Payment\Gateway\CommandInterface $merchantConfigurationCommand;
private $resultJsonFactory;
private $messageManager;
private $request;
private $merchantConfigurationCommand;

public function __construct(
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
Expand Down
12 changes: 6 additions & 6 deletions Controller/Express/CreateCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

class CreateCheckout implements \Magento\Framework\App\Action\HttpPostActionInterface
{
private \Afterpay\Afterpay\Api\CheckoutManagementInterface $checkoutManagement;
private \Magento\Checkout\Model\Session $checkoutSession;
private \Magento\Framework\UrlInterface $url;
private \Magento\Framework\Controller\Result\JsonFactory $jsonResultFactory;
private \Magento\Framework\Message\ManagerInterface $messageManager;
private \Psr\Log\LoggerInterface $logger;
private $checkoutManagement;
private $checkoutSession;
private $url;
private $jsonResultFactory;
private $messageManager;
private $logger;

public function __construct(
\Afterpay\Afterpay\Api\CheckoutManagementInterface $checkoutManagement,
Expand Down
14 changes: 7 additions & 7 deletions Controller/Express/GetShippingOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

class GetShippingOptions implements \Magento\Framework\App\Action\HttpPostActionInterface
{
private \Magento\Checkout\Model\Session $checkoutSession;
private \Magento\Framework\Controller\Result\JsonFactory $jsonResultFactory;
private \Magento\Framework\App\RequestInterface $request;
private \Afterpay\Afterpay\Model\Shipment\Express\ShippingListProvider $shippingListProvider;
private \Afterpay\Afterpay\Model\Shipment\Express\ShippingAddressUpdater $shippingAddressUpdater;
private \Psr\Log\LoggerInterface $logger;
private \Magento\Framework\Message\ManagerInterface $messageManager;
private $checkoutSession;
private $jsonResultFactory;
private $request;
private $shippingListProvider;
private $shippingAddressUpdater;
private $logger;
private $messageManager;

public function __construct(
\Magento\Framework\App\RequestInterface $request,
Expand Down
14 changes: 7 additions & 7 deletions Controller/Express/PlaceOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ class PlaceOrder implements \Magento\Framework\App\Action\HttpPostActionInterfac
{
const CANCELLED_STATUS = 'CANCELLED';

private \Magento\Framework\App\RequestInterface $request;
private \Magento\Framework\Message\ManagerInterface $messageManager;
private \Magento\Checkout\Model\Session $checkoutSession;
private \Magento\Framework\Controller\Result\JsonFactory $jsonFactory;
private \Magento\Framework\UrlInterface $url;
private \Afterpay\Afterpay\Model\Payment\Capture\PlaceOrderProcessor $placeOrderProcessor;
private \Magento\Payment\Gateway\CommandInterface $syncCheckoutDataCommand;
private $request;
private $messageManager;
private $checkoutSession;
private $jsonFactory;
private $url;
private $placeOrderProcessor;
private $syncCheckoutDataCommand;

public function __construct(
\Magento\Framework\App\RequestInterface $request,
Expand Down
29 changes: 19 additions & 10 deletions Controller/Payment/Capture.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,30 @@ class Capture implements \Magento\Framework\App\Action\HttpGetActionInterface
const CHECKOUT_STATUS_CANCELLED = 'CANCELLED';
const CHECKOUT_STATUS_SUCCESS = 'SUCCESS';

private \Magento\Framework\App\RequestInterface $request;
private \Magento\Checkout\Model\Session $session;
private \Magento\Framework\Controller\Result\RedirectFactory $redirectFactory;
private \Magento\Framework\Message\ManagerInterface $messageManager;
private \Afterpay\Afterpay\Model\Payment\Capture\PlaceOrderProcessor $placeOrderProcessor;
private \Magento\Payment\Gateway\CommandInterface $validateCheckoutDataCommand;
private $request;
private $session;
private $redirectFactory;
private $messageManager;
private $placeOrderProcessor;
private $validateCheckoutDataCommand;
private $storeManager;

public function __construct(
\Magento\Framework\App\RequestInterface $request,
\Magento\Checkout\Model\Session $session,
\Magento\Framework\Controller\Result\RedirectFactory $redirectFactory,
\Magento\Framework\Message\ManagerInterface $messageManager,
\Afterpay\Afterpay\Model\Payment\Capture\PlaceOrderProcessor $placeOrderProcessor,
\Magento\Payment\Gateway\CommandInterface $validateCheckoutDataCommand
\Magento\Payment\Gateway\CommandInterface $validateCheckoutDataCommand,
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
$this->request = $request;
$this->session = $session;
$this->redirectFactory = $redirectFactory;
$this->messageManager = $messageManager;
$this->placeOrderProcessor = $placeOrderProcessor;
$this->validateCheckoutDataCommand = $validateCheckoutDataCommand;
$this->storeManager = $storeManager;
}

public function execute()
Expand All @@ -36,13 +39,17 @@ public function execute()
$this->messageManager->addErrorMessage(
(string)__('You have cancelled your Afterpay payment. Please select an alternative payment method.')
);
return $this->redirectFactory->create()->setPath('checkout/cart');
return $this->redirectFactory->create()->setPath('checkout/cart', [
'_scope' => $this->storeManager->getStore()
]);
}
if ($this->request->getParam('status') != self::CHECKOUT_STATUS_SUCCESS) {
$this->messageManager->addErrorMessage(
(string)__('Afterpay payment is failed. Please select an alternative payment method.')
);
return $this->redirectFactory->create()->setPath('checkout/cart');
return $this->redirectFactory->create()->setPath('checkout/cart', [
'_scope' => $this->storeManager->getStore()
]);
}

try {
Expand All @@ -54,7 +61,9 @@ public function execute()
? $e->getMessage()
: (string)__('Payment is failed');
$this->messageManager->addErrorMessage($errorMessage);
return $this->redirectFactory->create()->setPath('checkout/cart');
return $this->redirectFactory->create()->setPath('checkout/cart', [
'_scope' => $this->storeManager->getStore()
]);
}

$this->messageManager->addSuccessMessage((string)__('Afterpay Transaction Completed'));
Expand Down
10 changes: 5 additions & 5 deletions Cron/MerchantConfigurationUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

class MerchantConfigurationUpdater
{
private \Magento\Payment\Gateway\CommandInterface $merchantConfigurationCommand;
private \Magento\Store\Model\StoreManagerInterface $storeManager;
private \Afterpay\Afterpay\Model\Config $config;
private \Psr\Log\LoggerInterface $logger;
private \Magento\Framework\App\Cache\TypeListInterface $typeList;
private $merchantConfigurationCommand;
private $storeManager;
private $config;
private $logger;
private $typeList;

public function __construct(
\Magento\Payment\Gateway\CommandInterface $merchantConfigurationCommand,
Expand Down
2 changes: 1 addition & 1 deletion Cron/OfflineCreditMemo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class OfflineCreditMemo
{
private \Afterpay\Afterpay\Model\Order\CreditMemo\StatusChanger $statusChanger;
private $statusChanger;

public function __construct(
\Afterpay\Afterpay\Model\Order\CreditMemo\StatusChanger $statusChanger
Expand Down
8 changes: 4 additions & 4 deletions Gateway/Command/CommandPoolProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

class CommandPoolProxy implements \Magento\Payment\Gateway\Command\CommandPoolInterface
{
protected ?\Magento\Payment\Gateway\Command\CommandPoolInterface $commandPool = null;
protected $commandPool = null;

private \Magento\Payment\Gateway\Command\CommandPoolFactory $commandPoolFactory;
private \Afterpay\Afterpay\Model\Config $config;
private array $commands;
private $commandPoolFactory;
private $config;
private $commands;

public function __construct(
\Magento\Payment\Gateway\Command\CommandPoolFactory $commandPoolFactory,
Expand Down
10 changes: 5 additions & 5 deletions Gateway/Command/GetMerchantConfigurationCommandWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class GetMerchantConfigurationCommandWrapper implements \Magento\Payment\Gateway
{
const DEFAULT_WEBSITE_ID = 0;

private \Magento\Payment\Gateway\CommandInterface $merchantConfigurationCommand;
private \Afterpay\Afterpay\Model\Config $afterpayConfig;
private \Magento\Framework\App\Config\ReinitableConfigInterface $appConfig;
private \Afterpay\Afterpay\Model\Log\Method\Logger $debugLogger;
private \Psr\Log\LoggerInterface $logger;
private $merchantConfigurationCommand;
private $afterpayConfig;
private $appConfig;
private $debugLogger;
private $logger;

public function __construct(
\Magento\Payment\Gateway\CommandInterface $merchantConfigurationCommand,
Expand Down
6 changes: 3 additions & 3 deletions Gateway/Command/RefundAndVoidCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

class RefundAndVoidCommand implements \Magento\Payment\Gateway\CommandInterface
{
private \Magento\Payment\Gateway\CommandInterface $refundCommand;
private \Magento\Payment\Gateway\CommandInterface $voidCommand;
private \Afterpay\Afterpay\Model\Payment\AmountProcessor\CreditMemo $creditMemoAmountProcessor;
private $refundCommand;
private $voidCommand;
private $creditMemoAmountProcessor;

public function __construct(
\Magento\Payment\Gateway\CommandInterface $refundCommand,
Expand Down
10 changes: 5 additions & 5 deletions Gateway/Http/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

class Client implements \Magento\Payment\Gateway\Http\ClientInterface
{
protected \Magento\Framework\HTTP\ClientInterface $client;
protected \Magento\Framework\Serialize\SerializerInterface $serializer;
private \Psr\Log\LoggerInterface $logger;
private \Magento\Payment\Model\Method\Logger $debugLogger;
private \Magento\Framework\App\RequestInterface $request;
protected $client;
protected $serializer;
private $logger;
private $debugLogger;
private $request;

public function __construct(
\Magento\Framework\HTTP\ClientInterface $client,
Expand Down
14 changes: 7 additions & 7 deletions Gateway/Http/TransferFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class TransferFactory implements \Magento\Payment\Gateway\Http\TransferFactoryIn
'afterpayToken'
];

private \Magento\Payment\Gateway\Http\TransferBuilder $transferBuilder;
private \Afterpay\Afterpay\Model\Config $config;
private \Magento\Store\Model\StoreManagerInterface $storeManager;
private TransferFactory\UserAgentProvider $userAgentProvider;
private UrlBuilder $urlBuilder;
private string $uriPath;
private string $method;
private $transferBuilder;
private $config;
private $storeManager;
private $userAgentProvider;
private $urlBuilder;
private $uriPath;
private $method;

public function __construct(
\Magento\Payment\Gateway\Http\TransferBuilder $transferBuilder,
Expand Down
10 changes: 5 additions & 5 deletions Gateway/Http/TransferFactory/UserAgentProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

class UserAgentProvider
{
private \Magento\Framework\Module\ModuleListInterface $moduleList;
private \Magento\Framework\App\ProductMetadataInterface $productMetadata;
private \Magento\Framework\Util $util;
private \Afterpay\Afterpay\Model\Config $config;
private \Magento\Store\Model\Store $store;
private $moduleList;
private $productMetadata;
private $util;
private $config;
private $store;

public function __construct(
\Magento\Framework\Module\ModuleListInterface $moduleList,
Expand Down
18 changes: 12 additions & 6 deletions Gateway/Request/Checkout/CheckoutDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class CheckoutDataBuilder implements \Magento\Payment\Gateway\Request\BuilderInt
{
use \Magento\Payment\Helper\Formatter;

private \Magento\Framework\UrlInterface $url;
private \Magento\Catalog\Api\ProductRepositoryInterface $productRepository;
private \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder;
private $url;
private $productRepository;
private $searchCriteriaBuilder;

public function __construct(
\Magento\Framework\UrlInterface $url,
Expand Down Expand Up @@ -114,7 +114,10 @@ protected function getQuoteItemCategoriesNames(\Magento\Quote\Model\Quote\Item $
/** @var \Magento\Catalog\Model\ResourceModel\AbstractCollection $categoryCollection */
$categoryCollection = $item->getProduct()->getCategoryCollection();
$itemCategories = $categoryCollection->addAttributeToSelect('name')->getItems();
return array_map(static fn ($cat) => $cat->getData('name'), $itemCategories);
return array_map(
function ($cat) {return $cat->getData('name');},
$itemCategories
);
}

/**
Expand All @@ -125,8 +128,11 @@ protected function getItemsImages(array $items): array
{
$itemsImages = [];
$searchCriteria = $this->searchCriteriaBuilder
->addFilter('entity_id', array_map(static fn ($item) => $item->getProduct()->getId(), $items), 'in')
->create();
->addFilter(
'entity_id',
array_map(function ($item) {return $item->getProduct()->getId();}, $items),
'in'
)->create();
$products = $this->productRepository->getList($searchCriteria)->getItems();

foreach ($items as $item) {
Expand Down
8 changes: 4 additions & 4 deletions Gateway/Response/CaptureVirtualProductsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

class CaptureVirtualProductsHandler implements \Magento\Payment\Gateway\Response\HandlerInterface
{
private \Magento\Payment\Gateway\CommandInterface $authCaptureCommand;
private \Magento\Payment\Gateway\Data\PaymentDataObjectFactoryInterface $paymentDataObjectFactory;
private \Afterpay\Afterpay\Model\Payment\AmountProcessor\Order $orderAmountProcessor;
private $authCaptureCommand;
private $paymentDataObjectFactory;
private $orderAmountProcessor;

public function __construct(
\Magento\Payment\Gateway\CommandInterface $authCaptureCommand,
Expand All @@ -31,7 +31,7 @@ public function handle(array $handlingSubject, array $response)

$itemsToCapture = array_filter(
$payment->getOrder()->getAllItems(),
static fn ($item) => !$item->getParentItem() && $item->getIsVirtual()
function ($item) {return !$item->getParentItem() && $item->getIsVirtual();}
);

if (count($itemsToCapture)) {
Expand Down
6 changes: 3 additions & 3 deletions Gateway/Response/Checkout/CheckoutDataToQuoteHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

class CheckoutDataToQuoteHandler implements \Magento\Payment\Gateway\Response\HandlerInterface
{
private \Magento\Checkout\Api\ShippingInformationManagementInterface $shippingInformationManagement;
private \Magento\Checkout\Api\Data\ShippingInformationInterfaceFactory $shippingInformationFactory;
private \Magento\Quote\Api\Data\AddressInterfaceFactory $addressInterfaceFactory;
private $shippingInformationManagement;
private $shippingInformationFactory;
private $addressInterfaceFactory;

public function __construct(
\Magento\Checkout\Api\ShippingInformationManagementInterface $shippingInformationManagement,
Expand Down
Loading

0 comments on commit 0be8af7

Please sign in to comment.