Skip to content

Commit

Permalink
Merge pull request #677 from mollie/release/2.30.0
Browse files Browse the repository at this point in the history
Release/2.30.0
  • Loading branch information
Marvin-Magmodules authored Aug 8, 2023
2 parents 5636a71 + 5f25cad commit f2fd09a
Show file tree
Hide file tree
Showing 72 changed files with 1,401 additions and 83 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/end-2-end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ jobs:
env:
MOLLIE_API_KEY_TEST: ${{ secrets.MOLLIE_API_KEY_TEST }}
if: "${{ env.MOLLIE_API_KEY_TEST != '' }}"
# Disabled for now. Change to =true to re-enable.
run: echo "is_mollie_api_key_test_set=false" >> $GITHUB_OUTPUT
run: echo "is_mollie_api_key_test_set=true" >> $GITHUB_OUTPUT

# Remove flag used to trigger the e2e tests
remove_flag:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/templates/magento/configure-mollie.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ bin/magento config:set payment/mollie_methods_klarnapaylater/active 1 &
bin/magento config:set payment/mollie_methods_billie/active 1 &
bin/magento config:set payment/mollie_methods_paymentlink/active 1 &
bin/magento config:set payment/mollie_methods_paysafecard/active 1 &
bin/magento config:set payment/mollie_methods_pointofsale/active 1 &
bin/magento config:set payment/mollie_methods_sofort/active 1 &

# Enable Components
Expand Down
77 changes: 77 additions & 0 deletions Block/Form/Pointofsale.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Block\Form;

use Magento\Framework\View\Element\Template\Context;
use Magento\Payment\Block\Form;
use Mollie\Api\Resources\Terminal;
use Mollie\Payment\Service\Mollie\MollieApiClient;

/**
* Class Pointofsale
*
* @package Mollie\Payment\Block\Form
*/
class Pointofsale extends Form
{
/**
* @var string
*/
protected $_template = 'Mollie_Payment::form/pointofsale.phtml';
/**
* @var MollieApiClient
*/
private $mollieApiClient;

public function __construct(
Context $context,
MollieApiClient $mollieApiClient,
array $data = []
) {
parent::__construct($context, $data);

$this->mollieApiClient = $mollieApiClient;
}

/**
* @return array{
* id: string,
* brand: string,
* model: string,
* serialNumber: string|null,
* description: string
* }
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function getTerminals(): array
{
$storeId = $this->_storeManager->getStore()->getId();

$mollieApiClient = $this->mollieApiClient->loadByStore((int)$storeId);
$terminals = $mollieApiClient->terminals->page();

$output = [];
/** @var Terminal $terminal */
foreach ($terminals as $terminal) {
if (!$terminal->isActive()) {
continue;
}

$output[] = [
'id' => $terminal->id,
'brand' => $terminal->brand,
'model' => $terminal->model,
'serialNumber' => $terminal->serialNumber,
'description' => $terminal->description,
];
}

return $output;
}
}
9 changes: 9 additions & 0 deletions Block/Info/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ public function getDashboardUrl()
}
}

public function getChangePaymentStatusUrl(): string
{
try {
return (string)$this->getInfo()->getAdditionalInformation('mollie_change_payment_state_url');
} catch (\Exception $exception) {
return '';
}
}

/**
* @return bool|string
*/
Expand Down
10 changes: 10 additions & 0 deletions Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Config
const PAYMENT_METHOD_PAYMENT_TITLE = 'payment/mollie_methods_%s/title';
const PAYMENT_PAYMENTLINK_ALLOW_MARK_AS_PAID = 'payment/mollie_methods_paymentlink/allow_mark_as_paid';
const PAYMENT_PAYMENTLINK_NEW_STATUS = 'payment/mollie_methods_paymentlink/order_status_new';
const PAYMENT_POINTOFSALE_ALLOWED_CUSTOMER_GROUPS = 'payment/mollie_methods_pointofsale/allowed_customer_groups';
const PAYMENT_VOUCHER_CATEGORY = 'payment/mollie_methods_voucher/category';
const PAYMENT_VOUCHER_CUSTOM_ATTRIBUTE = 'payment/mollie_methods_voucher/custom_attribute';
const CURRENCY_OPTIONS_DEFAULT = 'currency/options/default';
Expand Down Expand Up @@ -571,6 +572,15 @@ public function paymentlinkAllowMarkAsPaid($storeId = null)
return $this->isSetFlag(static::PAYMENT_PAYMENTLINK_ALLOW_MARK_AS_PAID, $storeId);
}

/**
* @param int|null $storeId
* @return string
*/
public function pointofsaleAllowedCustomerGroups(int $storeId = null)
{
return (string)$this->getPath(static::PAYMENT_POINTOFSALE_ALLOWED_CUSTOMER_GROUPS, $storeId);
}

/**
* @param $method
* @param null|int|string $storeId
Expand Down
7 changes: 6 additions & 1 deletion Controller/Adminhtml/Action/MarkAsPaid.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\Backend\App\Action;
use Magento\Backend\Model\Session\Quote;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Sales\Model\Order;
use Mollie\Payment\Service\Order\Reorder;

class MarkAsPaid extends Action
Expand Down Expand Up @@ -56,7 +57,11 @@ public function execute()

$resultRedirect = $this->resultRedirectFactory->create();
try {
$order = $this->reorder->createAndInvoice($originalOrder);
$order = $this->reorder->createAndInvoice(
$originalOrder,
Order::STATE_PROCESSING,
Order::STATE_PROCESSING
);

$this->messageManager->addSuccessMessage(
__(
Expand Down
53 changes: 53 additions & 0 deletions Controller/Checkout/Pointofsale.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

declare(strict_types=1);

namespace Mollie\Payment\Controller\Checkout;

use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Exception\AuthorizationException;
use Magento\Framework\View\Result\PageFactory;
use Magento\Store\Model\StoreManagerInterface;

class Pointofsale implements HttpGetActionInterface
{
/**
* @var PageFactory
*/
private $resultPageFactory;
/**
* @var RequestInterface
*/
private $request;
/**
* @var StoreManagerInterface
*/
private $storeManager;

public function __construct(
PageFactory $resultPageFactory,
RequestInterface $request,
StoreManagerInterface $storeManager
) {
$this->resultPageFactory = $resultPageFactory;
$this->request = $request;
$this->storeManager = $storeManager;
}

public function execute()
{
$token = $this->request->getParam('token');
if (!$token) {
throw new AuthorizationException(__('Invalid token'));
}

$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->set(__('Please finish the payment on the terminal.'));
$block = $resultPage->getLayout()->getBlock('mollie.pointofsale.wait');
$block->setData('token', $token);
$block->setData('storeCode', $this->storeManager->getStore()->getCode());

return $resultPage;
}
}
5 changes: 3 additions & 2 deletions GraphQL/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ class DataProvider implements AdditionalDataProviderInterface
public function getData(array $data): array
{
return [
'selected_issuer' => $data['mollie_selected_issuer'] ?? null,
'card_token' => $data['mollie_card_token'] ?? null,
'applepay_payment_token' => $data['mollie_applepay_payment_token'] ?? null,
'card_token' => $data['mollie_card_token'] ?? null,
'selected_issuer' => $data['mollie_selected_issuer'] ?? null,
'selected_terminal' => $data['mollie_selected_terminal'] ?? null,
];
}
}
5 changes: 3 additions & 2 deletions Helper/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,11 @@ public function getMethodCode($order): string
}

/***
* @param \Magento\Sales\Model\Order $order
* @param OrderInterface $order
*
* @return mixed
*/
public function getApiMethod($order)
public function getApiMethod(OrderInterface $order)
{
$method = $order->getPayment()->getMethodInstance()->getCode();
$method = str_replace('_vault', '', $method);
Expand Down Expand Up @@ -693,6 +693,7 @@ public function getAllActiveMethods($storeId)
'mollie_methods_mybank',
'mollie_methods_paypal',
'mollie_methods_paysafecard',
'mollie_methods_pointofsale',
'mollie_methods_przelewy24',
'mollie_methods_sofort',
];
Expand Down
37 changes: 37 additions & 0 deletions Model/Adminhtml/Source/CustomerGroup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace Mollie\Payment\Model\Adminhtml\Source;

use Magento\Customer\Api\GroupManagementInterface;
use Magento\Framework\Data\OptionSourceInterface;

class CustomerGroup implements OptionSourceInterface
{
/**
* @var GroupManagementInterface
*/
private $groupManagement;

public function __construct(
GroupManagementInterface $groupManagement
) {
$this->groupManagement = $groupManagement;
}

public function toOptionArray(): array
{
$groups = $this->groupManagement->getLoggedInGroups();

$output = [];
foreach ($groups as $group) {
$output[] = [
'label' => $group->getCode(),
'value' => $group->getId(),
];
}

return $output;
}
}
11 changes: 9 additions & 2 deletions Model/Client/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,14 @@ public function __construct(
}

/**
* @param Order $order
* @param OrderInterface $order
* @param MollieApiClient $mollieApi
*
* @return string
* @throws LocalizedException
* @throws ApiException
*/
public function startTransaction(Order $order, $mollieApi)
public function startTransaction(OrderInterface $order, $mollieApi)
{
$storeId = $order->getStoreId();
$orderId = $order->getEntityId();
Expand Down Expand Up @@ -352,6 +352,13 @@ public function processResponse(Order $order, $mollieOrder)
$order->getPayment()->setAdditionalInformation('expires_at', $mollieOrder->expiresAt);
}

if (isset($mollieOrder->_links->changePaymentState->href)) {
$order->getPayment()->setAdditionalInformation(
'mollie_change_payment_state_url',
$mollieOrder->_links->changePaymentState->href
);
}

$this->orderLines->linkOrderLines($mollieOrder->lines, $order);

$status = $this->mollieHelper->getPendingPaymentStatus($order);
Expand Down
11 changes: 9 additions & 2 deletions Model/Client/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ public function __construct(
}

/**
* @param Order $order
* @param OrderInterface $order
* @param \Mollie\Api\MollieApiClient $mollieApi
*
* @return string
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function startTransaction(Order $order, $mollieApi)
public function startTransaction(OrderInterface $order, $mollieApi)
{
$storeId = $order->getStoreId();
$orderId = $order->getEntityId();
Expand Down Expand Up @@ -309,6 +309,13 @@ public function processResponse(OrderInterface $order, $payment)
$order->getPayment()->setAdditionalInformation('expires_at', $payment->expiresAt);
}

if (isset($payment->_links->changePaymentState->href)) {
$order->getPayment()->setAdditionalInformation(
'mollie_change_payment_state_url',
$payment->_links->changePaymentState->href
);
}

$status = $this->mollieHelper->getPendingPaymentStatus($order);

$order->setState(Order::STATE_PENDING_PAYMENT);
Expand Down
24 changes: 24 additions & 0 deletions Model/Methods/Pointofsale.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Model\Methods;

use Mollie\Payment\Model\Mollie;

/**
* Class Pointofsale
*
* @package Mollie\Payment\Model\Methods
*/
class Pointofsale extends Mollie
{
/**
* Payment method code
*
* @var string
*/
const CODE = 'mollie_methods_pointofsale';
}
4 changes: 2 additions & 2 deletions Model/Methods/Przelewy24.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2018 Magmodules.eu. All rights reserved.
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
Loading

0 comments on commit f2fd09a

Please sign in to comment.