Skip to content

Commit

Permalink
Merge pull request #529 from mollie/release/2.12.0
Browse files Browse the repository at this point in the history
Release/2.12.0
  • Loading branch information
Marvin-Magmodules authored Jun 7, 2022
2 parents f99a2da + 8643c13 commit e3b8413
Show file tree
Hide file tree
Showing 40 changed files with 371 additions and 82 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,23 @@ jobs:
MAGENTO_VERSION: 2.4.2
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.3-with-replacements
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.4
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Start Docker
run: PHP_VERSION=${{ matrix.PHP_VERSION }} MAGENTO_VERSION=magento${{ matrix.MAGENTO_VERSION }} docker-compose -f .github/workflows/templates/docker-compose.yml up -d
run: docker run --detach --name magento-project-community-edition michielgerritsen/magento-project-community-edition:${{ matrix.PHP_VERSION }}-magento${{ matrix.MAGENTO_VERSION }}

- name: Create branch for Composer and remove version from composer.json
run: git checkout -b continuous-integration-test-branch && sed -i '/version/d' ./composer.json

- name: Upload the code into the docker container
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ && docker exec magento-project-community-edition composer require mollie/magento2:dev-continuous-integration-test-branch

- name: Enable developer mode
run: docker exec magento-project-community-edition php bin/magento deploy:mode:set developer
- name: Activate the extension
run: docker exec magento-project-community-edition bash -c "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade"

- name: Run tests
run: docker exec magento-project-community-edition bash -c "cd /data/dev/tests/integration/ && /data/vendor/bin/phpunit -c /data/dev/tests/integration/phpunit.xml"
26 changes: 16 additions & 10 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ on: [push, pull_request]
jobs:
build:
strategy:
matrix:
include:
- PHP_VERSION: php72-fpm
MAGENTO_VERSION: 2.3.3
- PHP_VERSION: php73-fpm
MAGENTO_VERSION: 2.3.6-p1
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.2
matrix:
include:
- PHP_VERSION: php72-fpm
MAGENTO_VERSION: 2.3.4
- PHP_VERSION: php73-fpm
MAGENTO_VERSION: 2.3.7
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.0
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.4

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Expand All @@ -26,7 +29,10 @@ jobs:
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/

- name: Install the extensions in Magento
run: docker exec magento-project-community-edition composer require mollie/magento2:dev-continuous-integration-test-branch fooman/phpstan-magento2-magic-methods:^0.7 phpstan/phpstan:0.*
run: docker exec magento-project-community-edition composer require mollie/magento2:dev-continuous-integration-test-branch

- name: Activate the extension
run: docker exec magento-project-community-edition bash -c "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade && php bin/magento setup:di:compile"

- name: Run PHPStan
run: docker exec magento-project-community-edition /bin/bash -c "./vendor/bin/phpstan analyse -c /data/extensions/*/phpstan.neon /data/extensions"
run: docker exec magento-project-community-edition /bin/bash -c "./vendor/bin/phpstan analyse --no-progress -c /data/extensions/*/phpstan.neon /data/extensions"
9 changes: 7 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ jobs:
- PHP_VERSION: php71-fpm
MAGENTO_VERSION: 2.3.3
- PHP_VERSION: php73-fpm
MAGENTO_VERSION: 2.3.6-p1
MAGENTO_VERSION: 2.3.7
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.2
MAGENTO_VERSION: 2.4.0
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.3-with-replacements
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.4
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Expand All @@ -27,5 +29,8 @@ jobs:
- name: Upload the code into the docker container
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ && docker exec magento-project-community-edition composer require mollie/magento2:dev-continuous-integration-test-branch

- name: Activate the extension
run: docker exec magento-project-community-edition bash -c "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade && php bin/magento setup:di:compile"

- name: Run tests
run: docker exec magento-project-community-edition bash -c "vendor/bin/phpunit extensions/*/Test/Unit"
2 changes: 1 addition & 1 deletion Block/Loading.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* Class Loading
*
* @package Mollie\Payment\Block
* @method string getMollieRedirect()
*/
class Loading extends Template
{

/**
* @var Session
*/
Expand Down
1 change: 1 addition & 0 deletions Helper/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ public function getAllActiveMethods($storeId)
'mollie_methods_giftcard',
'mollie_methods_giropay',
'mollie_methods_ideal',
'mollie_methods_in3',
'mollie_methods_kbc',
'mollie_methods_klarnapaylater',
'mollie_methods_klarnapaynow',
Expand Down
4 changes: 2 additions & 2 deletions Helper/Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public function __construct(
}

/**
* @param null $testKey
* @param null $liveKey
* @param string|null $testKey
* @param string|null $liveKey
*
* @return array
*/
Expand Down
1 change: 0 additions & 1 deletion Model/Client/Orders/OrderProcessors.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public function process(
ProcessTransactionResponse $response
): ?ProcessTransactionResponse {
if (!isset($this->processors[$event])) {
$response = $response ?? $this->returnResponse($mollieOrder, $magentoOrder, $type);
$this->config->addToLog('success', $response->toArray());
return $response;
}
Expand Down
1 change: 0 additions & 1 deletion Model/Client/Payments/PaymentProcessors.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public function process(
ProcessTransactionResponse $response
): ?ProcessTransactionResponse {
if (!isset($this->processors[$event])) {
$response = $response ?? $this->returnResponse($molliePayment, $magentoOrder, $type);
$this->config->addToLog('success', $response->toArray());
return $response;
}
Expand Down
24 changes: 24 additions & 0 deletions Model/Methods/In3.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 In3
*
* @package Mollie\Payment\Model\Methods
*/
class In3 extends Mollie
{
/**
* Payment method code
*
* @var string
*/
const CODE = 'mollie_methods_in3';
}
11 changes: 3 additions & 8 deletions Model/Mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private function startTransactionUsingTheOrdersApi(Order $order, MollieApiClient
}

$methodCode = $this->mollieHelper->getMethodCode($order);
if (in_array($methodCode, ['klarnapaylater', 'klarnapaynow', 'klarnasliceit', 'voucher'])) {
if (in_array($methodCode, ['klarnapaylater', 'klarnapaynow', 'klarnasliceit', 'voucher', 'in3'])) {
throw new LocalizedException(__($exception->getMessage()));
}

Expand Down Expand Up @@ -308,11 +308,6 @@ public function processTransaction($orderId, $type = 'webhook', $paymentToken =
/** @var \Magento\Sales\Model\Order $order */
$order = $this->orderRepository->get($orderId);
$this->eventManager->dispatch('mollie_process_transaction_start', ['order' => $order]);
if (empty($order)) {
$msg = ['error' => true, 'msg' => __('Order not found')];
$this->mollieHelper->addTolog('error', $msg);
return $msg;
}

$transactionId = $order->getMollieTransactionId();
if (empty($transactionId)) {
Expand Down Expand Up @@ -556,13 +551,13 @@ public function getOrderIdsByTransactionId(string $transactionId): array
/**
* Get list of Issuers from API
*
* @param MollieApiClient $mollieApi
* @param MollieApiClient|null $mollieApi
* @param $method
* @param $issuerListType
*
* @return array|null
*/
public function getIssuers($mollieApi, $method, $issuerListType): ?array
public function getIssuers(MollieApiClient $mollieApi = null, $method, $issuerListType): ?array
{
$issuers = [];
if (empty($mollieApi) || $issuerListType == 'none') {
Expand Down
19 changes: 10 additions & 9 deletions Model/MollieConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,27 @@ class MollieConfigProvider implements ConfigProviderInterface
* @var array
*/
private $methodCodes = [
'mollie_methods_applepay',
'mollie_methods_bancontact',
'mollie_methods_banktransfer',
'mollie_methods_belfius',
'mollie_methods_creditcard',
'mollie_methods_directdebit',
'mollie_methods_eps',
'mollie_methods_giftcard',
'mollie_methods_giropay',
'mollie_methods_ideal',
'mollie_methods_in3',
'mollie_methods_kbc',
'mollie_methods_voucher',
'mollie_methods_paypal',
'mollie_methods_paysafecard',
'mollie_methods_sofort',
'mollie_methods_giropay',
'mollie_methods_eps',
'mollie_methods_klarnapaylater',
'mollie_methods_klarnapaynow',
'mollie_methods_klarnasliceit',
'mollie_methods_giftcard',
'mollie_methods_przelewy24',
'mollie_methods_applepay',
'mollie_methods_mybank',
'mollie_methods_paypal',
'mollie_methods_paysafecard',
'mollie_methods_przelewy24',
'mollie_methods_sofort',
'mollie_methods_voucher',
];
/**
* @var array
Expand Down
4 changes: 4 additions & 0 deletions Model/PaymentFee/Order/Pdf/Total/PaymentFee.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory;

/**
* @method getSource();
* @method int|null getFontSize();
*/
class PaymentFee extends DefaultTotal
{
/**
Expand Down
6 changes: 3 additions & 3 deletions Service/Mollie/DashboardUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(
$this->config = $config;
}

public function forOrdersApi($storeId, $id)
public function forOrdersApi($storeId, string $id): string
{
return str_replace(
'{id}',
Expand All @@ -30,12 +30,12 @@ public function forOrdersApi($storeId, $id)
);
}

public function forPaymentsApi($storeId, $id)
public function forPaymentsApi($storeId, string $id): string
{
return str_replace(
'{id}',
$id,
$this->config->getDashboardUrlForPaymentsApi($storeId)
);
}
}
}
1 change: 1 addition & 0 deletions Service/Mollie/PaymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function __construct(
'mollie_methods_directdebit',
'mollie_methods_eps',
'mollie_methods_ideal',
'mollie_methods_in3',
'mollie_methods_giropay',
'mollie_methods_giftcard',
'mollie_methods_kbc',
Expand Down
6 changes: 3 additions & 3 deletions Service/Order/Lines/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ private function getOrderLine(OrderItemInterface $item, $zeroPriceLine = false)
$orderLine = [
'item_id' => $item->getId(),
'type' => $item->getProductType() != 'downloadable' ? 'physical' : 'digital',
'name' => preg_replace("/[^A-Za-z0-9 -]/", "", $item->getName()),
'name' => preg_replace('/[^A-Za-z0-9 -]/', '', $item->getName() ?? ''),
'quantity' => round($item->getQtyOrdered()),
'unitPrice' => $this->mollieHelper->getAmountArray($this->currency, $unitPrice),
'totalAmount' => $this->mollieHelper->getAmountArray($this->currency, $totalAmount),
'vatRate' => sprintf("%.2f", $item->getTaxPercent()),
'vatAmount' => $this->mollieHelper->getAmountArray($this->currency, $vatAmount),
'sku' => substr($item->getSku(), 0, 64),
'sku' => substr($item->getSku() ?? '', 0, 64),
'productUrl' => $this->getProductUrl($item),
];

Expand Down Expand Up @@ -212,7 +212,7 @@ protected function getShippingOrderLine(OrderInterface $order)
*/
$vatAmount = round($totalAmount * ($vatRate / (100 + $vatRate)), 2);

$name = preg_replace("/[^A-Za-z0-9 -]/", "", $order->getShippingDescription());
$name = preg_replace('/[^A-Za-z0-9 -]/', '', $order->getShippingDescription() ?? '');
if (!$name) {
$name = $order->getShippingMethod();
}
Expand Down
1 change: 1 addition & 0 deletions Service/Order/PartialInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function createFromShipment(ShipmentInterface $shipment)
'mollie_methods_klarnapaylater',
'mollie_methods_klarnapaynow',
'mollie_methods_klarnasliceit',
'mollie_methods_in3',
]
) ||
$this->mollieHelper->getInvoiceMoment($order->getStoreId()) != InvoiceMoment::ON_SHIPMENT
Expand Down
1 change: 1 addition & 0 deletions Test/Integration/Etc/Config/MethodsConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function methods()
['mollie_methods_giftcard'],
['mollie_methods_giropay'],
['mollie_methods_ideal'],
['mollie_methods_in3'],
['mollie_methods_kbc'],
['mollie_methods_klarnapaylater'],
['mollie_methods_klarnapaynow'],
Expand Down
1 change: 1 addition & 0 deletions Test/Integration/Helper/GeneralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public function getMethodCodeDataProvider()
'giftcard' => ['mollie_methods_giftcard', 'giftcard'],
'giropay' => ['mollie_methods_giropay', 'giropay'],
'ideal' => ['mollie_methods_ideal', 'ideal'],
'in3' => ['mollie_methods_in3', 'in3'],
'kbc' => ['mollie_methods_kbc', 'kbc'],
'klarnapaylater' => ['mollie_methods_klarnapaylater', 'klarnapaylater'],
'klarnapaynow' => ['mollie_methods_klarnapaynow', 'klarnapaynow'],
Expand Down
2 changes: 2 additions & 0 deletions Test/Integration/Model/Client/OrdersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function testRemovesEmptySpaceFromThePrefix()
$address = $this->objectManager->get(OrderAddressInterface::class);

$address->setPrefix(' ');
$address->setStreet('');

$result = $instance->getAddressLine($address);

Expand All @@ -75,6 +76,7 @@ public function testProcessTransactionHandlesAStackOfPaymentsCorrectly()
$this->loadFakeEncryptor()->addReturnValue('', 'test_dummyapikeythatisvalidandislongenough');

$mollieOrderMock = $this->mollieOrderMock('N/A', 'EUR');
$mollieOrderMock->id = 'trx_test_123';
$mollieOrderMock->lines = [];
$mollieOrderMock->status = OrderStatus::STATUS_PAID;
$mollieOrderMock->_embedded->payments = [];
Expand Down
1 change: 1 addition & 0 deletions Test/Integration/Model/Client/PaymentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public function testProcessTransaction($currency, $mollieOrderStatus, $orderComm
protected function getMolliePayment($status, $currency)
{
$payment = new \Mollie\Api\Resources\Payment($this->createMock(MollieApiClient::class));
$payment->id = 'tr_test_transaction';
$payment->status = $status;
$payment->settlementAmount = new \stdClass;
$payment->settlementAmount->value = 50;
Expand Down
1 change: 1 addition & 0 deletions Test/Integration/Model/Client/ProcessTransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public function testCallsTheCorrectProcessor(string $state, string $event)
protected function mollieClientMock(string $status, string $currency): MockObject
{
$mollieOrder = new \Mollie\Api\Resources\Order($this->createMock(MollieApiClient::class));
$mollieOrder->id = 'tr_test_transaction';
$mollieOrder->lines = [];
$mollieOrder->status = $status;
$mollieOrder->amountCaptured = new \stdClass();
Expand Down
16 changes: 16 additions & 0 deletions Test/Integration/Model/Methods/In3Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Test\Integration\Model\Methods;

use Mollie\Payment\Model\Methods\In3;

class In3Test extends AbstractMethodTest
{
protected $instance = In3::class;

protected $code = 'in3';
}
1 change: 1 addition & 0 deletions Test/Integration/Model/MollieConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function testGetConfig()
$this->assertArrayHasKey('mollie_methods_giftcard', $result['payment']['image']);
$this->assertArrayHasKey('mollie_methods_giropay', $result['payment']['image']);
$this->assertArrayHasKey('mollie_methods_ideal', $result['payment']['image']);
$this->assertArrayHasKey('mollie_methods_in3', $result['payment']['image']);
$this->assertArrayHasKey('mollie_methods_kbc', $result['payment']['image']);
$this->assertArrayHasKey('mollie_methods_klarnapaylater', $result['payment']['image']);
$this->assertArrayHasKey('mollie_methods_klarnapaynow', $result['payment']['image']);
Expand Down
Loading

0 comments on commit e3b8413

Please sign in to comment.