Skip to content

Commit

Permalink
Merge pull request #748 from mollie/release/2.35.0
Browse files Browse the repository at this point in the history
Release/2.35.0
  • Loading branch information
Marvin-Magmodules authored Feb 22, 2024
2 parents ac30d84 + a722cc9 commit fa60d53
Show file tree
Hide file tree
Showing 63 changed files with 1,683 additions and 213 deletions.
20 changes: 20 additions & 0 deletions Api/Data/PaymentLinkRedirectResultInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Api\Data;

interface PaymentLinkRedirectResultInterface
{
/**
* @return bool
*/
public function isAlreadyPaid(): bool;

/**
* @return string|null
*/
public function getRedirectUrl(): ?string;
}
14 changes: 13 additions & 1 deletion Api/Data/TransactionToOrderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface TransactionToOrderInterface extends ExtensibleDataInterface
public const TRANSACTION_ID = 'transaction_id';
public const ORDER_ID = 'order_id';
public const SKIPPED = 'skipped';
public const REDIRECTED = 'redirected';
public const CREATED_AT = 'created_at';

/**
Expand Down Expand Up @@ -47,7 +48,7 @@ public function getCreatedAt(): ?string;
public function setCreatedAt(string $created_at): \Mollie\Payment\Api\Data\TransactionToOrderInterface;

/**
* @return string|null
* @return int|null
*/
public function getSkipped(): ?int;

Expand All @@ -57,6 +58,17 @@ public function getSkipped(): ?int;
*/
public function setSkipped(int $skipped): \Mollie\Payment\Api\Data\TransactionToOrderInterface;

/**
* @return int|null
*/
public function getRedirected(): ?int;

/**
* @param int $redirected
* @return \Mollie\Payment\Api\Data\TransactionToOrderInterface
*/
public function setRedirected(int $redirected): \Mollie\Payment\Api\Data\TransactionToOrderInterface;

/**
* @return \Mollie\Payment\Api\Data\TransactionToOrderExtensionInterface|null
*/
Expand Down
32 changes: 32 additions & 0 deletions Api/Data/TransactionToProcessInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Api\Data;

interface TransactionToProcessInterface
{
/**
* @param string $id
* @return \Mollie\Payment\Api\Data\TransactionToProcessInterface
*/
public function setTransactionId(string $id): TransactionToProcessInterface;

/**
* @return string
*/
public function getTransactionId(): ?string;

/**
* @param int $id
* @return \Mollie\Payment\Api\Data\TransactionToProcessInterface
*/
public function setOrderId(int $id): TransactionToProcessInterface;

/**
* @return int|null
*/
public function getOrderId(): ?int;
}
18 changes: 18 additions & 0 deletions Api/Webapi/GetPaymentLinkRedirectInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Api\Webapi;

use Mollie\Payment\Api\Data\PaymentLinkRedirectResultInterface;

interface GetPaymentLinkRedirectInterface
{
/**
* @param string $hash
* @return \Mollie\Payment\Api\Data\PaymentLinkRedirectResultInterface
*/
public function byHash(string $hash): PaymentLinkRedirectResultInterface;
}
24 changes: 24 additions & 0 deletions Block/Adminhtml/System/Config/Form/DisabledInput.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.
*/

declare(strict_types=1);

namespace Mollie\Payment\Block\Adminhtml\System\Config\Form;

use Magento\Config\Block\System\Config\Form\Field;

class DisabledInput extends Field
{
/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$element->setReadonly(true, true);
return parent::_getElementHtml($element);
}
}
44 changes: 9 additions & 35 deletions Block/Form/Pointofsale.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

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

/**
* Class Pointofsale
Expand All @@ -20,22 +18,23 @@
class Pointofsale extends Form
{
/**
* @var string
* @var AvailableTerminals
*/
protected $_template = 'Mollie_Payment::form/pointofsale.phtml';
private $availableTerminals;

/**
* @var MollieApiClient
* @var string
*/
private $mollieApiClient;
protected $_template = 'Mollie_Payment::form/pointofsale.phtml';

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

$this->mollieApiClient = $mollieApiClient;
$this->availableTerminals = $availableTerminals;
}

/**
Expand All @@ -46,36 +45,11 @@ public function __construct(
* serialNumber: string|null,
* description: string
* }
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function getTerminals(): array
{
$storeId = $this->_storeManager->getStore()->getId();

try {
$mollieApiClient = $this->mollieApiClient->loadByStore((int)$storeId);
$terminals = $mollieApiClient->terminals->page();
} catch (ApiException $exception) {
return [];
}

$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;
return $this->availableTerminals->execute((int)$storeId);
}
}
40 changes: 30 additions & 10 deletions Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Config
const GENERAL_DASHBOARD_URL_PAYMENTS_API = 'payment/mollie_general/dashboard_url_payments_api';
const GENERAL_ENABLE_MAGENTO_VAULT = 'payment/mollie_general/enable_magento_vault';
const GENERAL_ENABLE_SECOND_CHANCE_EMAIL = 'payment/mollie_general/enable_second_chance_email';
const GENERAL_PROCESS_TRANSACTION_IN_THE_QUEUE = 'payment/mollie_general/process_transactions_in_the_queue';
const GENERAL_ENCRYPT_PAYMENT_DETAILS = 'payment/mollie_general/encrypt_payment_details';
const GENERAL_INCLUDE_SHIPPING_IN_SURCHARGE = 'payment/mollie_general/include_shipping_in_surcharge';
const GENERAL_INVOICE_NOTIFY = 'payment/mollie_general/invoice_notify';
Expand Down Expand Up @@ -209,20 +210,35 @@ public function getApiKey($storeId = null)
}

if (!$this->isProductionMode($storeId)) {
$apiKey = trim($this->getPath(static::GENERAL_APIKEY_TEST, $storeId) ?? '');
if (empty($apiKey)) {
$this->addToLog('error', 'Mollie API key not set (test modus)');
}

if (!preg_match('/^test_\w+$/', $apiKey)) {
$this->addToLog('error', 'Mollie set to test modus, but API key does not start with "test_"');
}
$apiKey = $this->getTestApiKey($storeId === null ? null : (int)$storeId);

$keys[$storeId] = $apiKey;
return $apiKey;
}

$apiKey = trim($this->getPath(static::GENERAL_APIKEY_LIVE, $storeId) ?? '');
$apiKey = $this->getLiveApiKey($storeId === null ? null : (int)$storeId);

$keys[$storeId] = $apiKey;
return $apiKey;
}

public function getTestApiKey(int $storeId = null): string
{
$apiKey = trim((string)$this->getPath(static::GENERAL_APIKEY_TEST, $storeId) ?? '');
if (empty($apiKey)) {
$this->addToLog('error', 'Mollie API key not set (test modus)');
}

if (!preg_match('/^test_\w+$/', $apiKey)) {
$this->addToLog('error', 'Mollie set to test modus, but API key does not start with "test_"');
}

return $apiKey;
}

public function getLiveApiKey(int $storeId = null): string
{
$apiKey = trim((string)$this->getPath(static::GENERAL_APIKEY_LIVE, $storeId) ?? '');
if (empty($apiKey)) {
$this->addToLog('error', 'Mollie API key not set (live modus)');
}
Expand All @@ -231,7 +247,6 @@ public function getApiKey($storeId = null)
$this->addToLog('error', 'Mollie set to live modus, but API key does not start with "live_"');
}

$keys[$storeId] = $apiKey;
return $apiKey;
}

Expand Down Expand Up @@ -756,6 +771,11 @@ public function isMultishippingEnabled(): bool
return $this->moduleManager->isEnabled('Mollie_Multishipping');
}

public function processTransactionsInTheQueue(int $storeId = null): bool
{
return $this->isSetFlag(static::GENERAL_PROCESS_TRANSACTION_IN_THE_QUEUE, $storeId);
}

public function encryptPaymentDetails($storeId = null): bool
{
return $this->isSetFlag(static::GENERAL_ENCRYPT_PAYMENT_DETAILS, $storeId);
Expand Down
Loading

0 comments on commit fa60d53

Please sign in to comment.