Skip to content

Commit

Permalink
Merge pull request #763 from mollie/release/2.36.0
Browse files Browse the repository at this point in the history
Release/2.36.0
  • Loading branch information
Marvin-Magmodules authored Mar 25, 2024
2 parents 76719d8 + ec7be4c commit ad83c2a
Show file tree
Hide file tree
Showing 61 changed files with 712 additions and 53 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/end-2-end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ jobs:
matrix:
include:
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.3.7-p3
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.6
MAGENTO_VERSION: 2.3.7-p4
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6-p4
runs-on: ubuntu-latest
env:
PHP_VERSION: ${{ matrix.PHP_VERSION }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ jobs:
matrix:
include:
- PHP_VERSION: php73-fpm
MAGENTO_VERSION: 2.3.7-p3
MAGENTO_VERSION: 2.3.7-p4
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.0
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.3-with-replacements
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.6
MAGENTO_VERSION: 2.4.6-p4
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6
MAGENTO_VERSION: 2.4.6-p4
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ jobs:
matrix:
include:
- PHP_VERSION: php73-fpm
MAGENTO_VERSION: 2.3.7-p3
MAGENTO_VERSION: 2.3.7-p4
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.0
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.6
MAGENTO_VERSION: 2.4.6-p4
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6
MAGENTO_VERSION: 2.4.6-p4

runs-on: ubuntu-latest
steps:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/setup-di-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ jobs:
matrix:
include:
- PHP_VERSION: php73-fpm
MAGENTO_VERSION: 2.3.7-p3
MAGENTO_VERSION: 2.3.7-p4
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.0
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.3-with-replacements
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.6
MAGENTO_VERSION: 2.4.6-p4
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6
MAGENTO_VERSION: 2.4.6-p4

runs-on: ubuntu-latest
steps:
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/templates/magento/configure-mollie.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ bin/magento config:set payment/mollie_general/type test &
# Enable all payment methods
bin/magento config:set payment/mollie_methods_applepay/active 1 &
bin/magento config:set payment/mollie_methods_banktransfer/active 1 &
bin/magento config:set payment/mollie_methods_billie/active 1 &
bin/magento config:set payment/mollie_methods_blik/active 1 &
bin/magento config:set payment/mollie_methods_creditcard/active 1 &
bin/magento config:set payment/mollie_methods_giftcard/active 1 &
bin/magento config:set payment/mollie_methods_ideal/active 1 &
Expand All @@ -24,7 +26,6 @@ bin/magento config:set payment/mollie_methods_belfius/active 1 &
bin/magento config:set payment/mollie_methods_eps/active 1 &
bin/magento config:set payment/mollie_methods_giropay/active 1 &
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 &
Expand All @@ -40,10 +41,16 @@ bin/magento config:set payment/mollie_methods_ideal/add_qr 1 &
bin/magento config:set payment/mollie_general/use_webhooks disabled &

# Configure currency for the swiss store view
bin/magento config:set currency/options/allow EUR,CHF &
bin/magento config:set currency/options/allow EUR,CHF,PLN &

# Swiss scope
bin/magento config:set currency/options/default CHF --scope=ch &
bin/magento config:set payment/mollie_general/currency 0 --scope=ch &

# Polish scope
bin/magento config:set currency/options/default PLN --scope=pl &
bin/magento config:set payment/mollie_general/currency 0 --scope=pl &

wait

if grep -q Magento_TwoFactorAuth "app/etc/config.php"; then
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/templates/magento/merge-config.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,16 @@ $magentoConfig['scopes'] = [
'website_id' => '1',
'group_id' => '1',
'name' => 'Swiss',
'sort_order' => '0',
'sort_order' => '1',
'is_active' => '1'
],
'pl' => [
'store_id' => '3',
'code' => 'pl',
'website_id' => '1',
'group_id' => '1',
'name' => 'Poland',
'sort_order' => '2',
'is_active' => '1'
]
]
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ jobs:
matrix:
include:
- PHP_VERSION: php73-fpm
MAGENTO_VERSION: 2.3.7-p3
MAGENTO_VERSION: 2.3.7-p4
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.0
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.3-with-replacements
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.6
MAGENTO_VERSION: 2.4.6-p4
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6
MAGENTO_VERSION: 2.4.6-p4
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Expand Down
5 changes: 5 additions & 0 deletions Api/Data/PaymentLinkRedirectResultInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ public function isAlreadyPaid(): bool;
* @return string|null
*/
public function getRedirectUrl(): ?string;

/**
* @return bool
*/
public function isExpired(): bool;
}
11 changes: 11 additions & 0 deletions Api/Data/TransactionToProcessInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,15 @@ public function setOrderId(int $id): TransactionToProcessInterface;
* @return int|null
*/
public function getOrderId(): ?int;

/**
* @param string $type
* @return \Mollie\Payment\Api\Data\TransactionToProcessInterface
*/
public function setType(string $type): TransactionToProcessInterface;

/**
* @return string|null
*/
public function getType(): ?string;
}
6 changes: 6 additions & 0 deletions Controller/Checkout/PaymentLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public function execute()
return $this->returnStatusCode(404);
}

if ($result->isExpired()) {
$this->messageManager->addErrorMessage(__('Your payment link has expired.'));

return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setUrl('/');
}

if ($result->isAlreadyPaid()) {
$this->messageManager->addSuccessMessage(__('Your order has already been paid.'));

Expand Down
4 changes: 2 additions & 2 deletions Controller/Checkout/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ public function execute()
$result = null;
foreach ($orderIds as $orderId => $paymentToken) {
$order = $this->orderRepository->get($orderId);
$result = $this->processTransaction->execute($orderId, $order->getMollieTransactionId());
$result = $this->processTransaction->execute($orderId, $order->getMollieTransactionId(), 'success');
}
} catch (\Exception $e) {
$this->mollieHelper->addTolog('error', $e->getMessage());
$this->messageManager->addExceptionMessage($e, __('There was an error checking the transaction status.'));
return $this->_redirect($this->redirectOnError->getUrl());
}

if ($result !== null && in_array($result->getStatus(), ['paid', 'authorized'])) {
if ($result !== null && $result->shouldRedirectToSuccessPage()) {
try {
$this->successPageRedirect->execute($order, $orderIds);
return $this->getResponse();
Expand Down
1 change: 1 addition & 0 deletions GraphQL/Resolver/Checkout/PaymentLinkRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
return [
'already_paid' => $result->isAlreadyPaid(),
'redirect_url' => $result->getRedirectUrl(),
'is_expired' => $result->isExpired(),
];
}
}
2 changes: 1 addition & 1 deletion GraphQL/Resolver/Checkout/ProcessTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value

$order = $this->orderRepository->get($tokenModel->getOrderId());
$result = $this->processTransaction->execute($tokenModel->getOrderId(), $order->getMollieTransactionId());
$redirectToSuccessPage = in_array($result->getStatus(), ['pending', 'paid', 'authorized']);
$redirectToSuccessPage = $result->shouldRedirectToSuccessPage();

$cart = null;
if ($tokenModel->getCartId()) {
Expand Down
1 change: 1 addition & 0 deletions Helper/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ public function getAllActiveMethods($storeId)
'mollie_methods_banktransfer',
'mollie_methods_belfius',
'mollie_methods_billie',
'mollie_methods_blik',
'mollie_methods_creditcard',
'mollie_methods_directdebit',
'mollie_methods_eps',
Expand Down
2 changes: 1 addition & 1 deletion Model/Adminhtml/Backend/ChangeApiMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function afterSave()
{
$apiKey = $this->getApiKey($this->getValue());
if ($apiKey) {
$this->updateProfileId->execute($apiKey, $this->getScope(), $this->getScopeId());
$this->updateProfileId->execute($apiKey, $this->getScope(), (int)$this->getScopeId());
}

return parent::afterSave();
Expand Down
15 changes: 13 additions & 2 deletions Model/Client/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ public function startTransaction(OrderInterface $order, $mollieApi)

$transactionId = $order->getMollieTransactionId();
if (!empty($transactionId)) {
$mollieOrder = $mollieApi->orders->get($transactionId);
return $mollieOrder->getCheckoutUrl();
return $this->getCheckoutUrl($mollieApi, $order);
}

$paymentToken = $this->paymentTokenForOrder->execute($order);
Expand Down Expand Up @@ -900,4 +899,16 @@ private function getCaptureAmount(OrderInterface $order, InvoiceInterface $invoi

return $order->getBaseGrandTotal();
}

private function getCheckoutUrl(MollieApiClient $mollieApi, OrderInterface $order): string
{
$mollieOrder = $mollieApi->orders->get($order->getMollieTransactionId());
if ($checkoutUrl = $mollieOrder->getCheckoutUrl()) {
return $checkoutUrl;
}

// There is no checkout URL, the transaction is either canceled or expired. Create a new transaction.
$order->setMollieTransactionId(null);
return $this->startTransaction($order, $mollieApi);
}
}
3 changes: 2 additions & 1 deletion Model/Client/Orders/Processors/SuccessfulPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ private function handleWebhookCall(OrderInterface $order, MollieOrder $mollieOrd
}

if ($mollieOrder->isAuthorized() &&
$this->mollieHelper->getInvoiceMoment($order->getStoreId()) == InvoiceMoment::ON_AUTHORIZE
$this->mollieHelper->getInvoiceMoment($order->getStoreId()) == InvoiceMoment::ON_AUTHORIZE &&
$order->getInvoiceCollection()->count() === 0
) {
$payment->setIsTransactionClosed(false);
$payment->registerAuthorizationNotification($order->getBaseGrandTotal(), true);
Expand Down
24 changes: 24 additions & 0 deletions Model/Methods/Blik.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 Blik
*
* @package Mollie\Payment\Model\Methods
*/
class Blik extends Mollie
{
/**
* Payment method code
*
* @var string
*/
const CODE = 'mollie_methods_blik';
}
1 change: 1 addition & 0 deletions Model/MollieConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class MollieConfigProvider implements ConfigProviderInterface
'mollie_methods_banktransfer',
'mollie_methods_belfius',
'mollie_methods_billie',
'mollie_methods_blik',
'mollie_methods_creditcard',
'mollie_methods_directdebit',
'mollie_methods_eps',
Expand Down
17 changes: 17 additions & 0 deletions Model/Queue/TransactionToProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class TransactionToProcess implements TransactionToProcessInterface
*/
private $orderId = null;

/**
* @var null | string
*/
private $type = null;

public function setTransactionId(string $id): TransactionToProcessInterface
{
$this->transactionId = $id;
Expand All @@ -45,4 +50,16 @@ public function getOrderId(): ?int
{
return $this->orderId;
}

public function setType(string $type): TransactionToProcessInterface
{
$this->type = $type;

return $this;
}

public function getType(): ?string
{
return $this->type;
}
}
2 changes: 1 addition & 1 deletion Queue/Handler/TransactionProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function execute(TransactionToProcessInterface $data): void
$order = $this->orderRepository->get($data->getOrderId());
$order->setMollieTransactionId($data->getTransactionId());

$this->mollieModel->processTransactionForOrder($order, 'webhook');
$this->mollieModel->processTransactionForOrder($order, $data->getType());
} catch (\Throwable $throwable) {
$this->config->addToLog('error', [
'from' => 'TransactionProcessor consumer',
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Mollie requires no minimum costs, no fixed contracts, no hidden costs. At Mollie
- Bank transfer
- Belfius Pay Button
- Billie
- Blik
- Credit card (VISA, MasterCard, Maestro and American Express)
- EPS
- Gift cards (Webshop Giftcard, Podium Cadeaukaart, VVV Cadeaukaart, YourGift etc.)
Expand Down
Loading

0 comments on commit ad83c2a

Please sign in to comment.