Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #747

Merged
merged 21 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1ae77ca
Bugfix: Only show partial capture warning when manual capture is enabled
michielgerritsen Feb 1, 2024
b6d1ad7
Improvement: Shipping discount name
michielgerritsen Feb 5, 2024
e012115
Feature: Allow to process orders in the background
michielgerritsen Feb 5, 2024
9e71e90
Feature: Paymentlink PWA for REST #732
michielgerritsen Feb 8, 2024
7ebcc7c
Improvement: Add Hyvä version string
michielgerritsen Feb 12, 2024
543942e
Feature: Allow to process orders in the background
michielgerritsen Feb 5, 2024
2397c05
Improvement: Prevent opening the success page multiple times #701
michielgerritsen Feb 12, 2024
d4ee528
Improvement: Keep the selected payment methods when switching shippin…
michielgerritsen Feb 12, 2024
4764a47
Bugfix: Calculate the correct totals for discounted items #739
michielgerritsen Feb 8, 2024
99a031e
Feature: Retrieve the Profile ID from Mollie
michielgerritsen Feb 15, 2024
55b4289
Feature: Add attribute to retrieve available POS terminals
michielgerritsen Feb 19, 2024
8854a16
Merge branch 'bugfix/only-show-warning-when-enabled' into release-wee…
michielgerritsen Feb 19, 2024
e29be16
Merge branch 'feature/background-transaction-processing' into release…
michielgerritsen Feb 19, 2024
ee90591
Merge branch 'improvement/shipping-discount-name' into release-week-07
michielgerritsen Feb 19, 2024
cad3431
Merge branch 'bugfix/shipping-discounted-items' into release-week-07
michielgerritsen Feb 19, 2024
5ecf6e0
Merge branch 'feature/paymentlink-pwa-for-rest' into release-week-07
michielgerritsen Feb 19, 2024
55b4ee2
Merge branch 'improvement/hyva-user-agent' into release-week-07
michielgerritsen Feb 19, 2024
a61588c
Merge branch 'improvement/prevent-opening-succes-page-multiple-times'…
michielgerritsen Feb 19, 2024
1e5cf64
Merge branch 'improvement/paymentlink-methods-switch' into release-we…
michielgerritsen Feb 19, 2024
53e773d
Merge branch 'feature/automatic-profile-id' into release-week-07
michielgerritsen Feb 19, 2024
a7ec1c1
Merge branch 'feature/terminals-in-graphql' into release-week-07
michielgerritsen Feb 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading