Skip to content

Commit

Permalink
Merge pull request #731 from mollie/release/2.33.0
Browse files Browse the repository at this point in the history
Release/2.33.0
  • Loading branch information
Marvin-Magmodules authored Jan 22, 2024
2 parents 4543d53 + 6eebfdf commit 0f727ba
Show file tree
Hide file tree
Showing 89 changed files with 1,762 additions and 270 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/end-2-end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ jobs:
- name: Activate the extension
run: |
docker exec magento-project-community-edition php /data/merge-config.php
docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment"
docker exec magento-project-community-edition ./retry "php bin/magento setup:upgrade"
docker exec magento-project-community-edition ./retry "php bin/magento setup:upgrade --no-interaction"
docker exec magento-project-community-edition /bin/bash /data/configure-mollie.sh
docker exec magento-project-community-edition ./retry "bin/magento config:set payment/mollie_general/use_webhooks custom_url"
docker exec magento-project-community-edition ./retry "bin/magento config:set payment/mollie_general/custom_webhook_url ${{ env.magento_url }}/mollie/checkout/webhook"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/templates/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
volumes:
- ../../../magento-logs:/data/var/log
- ./magento/configure-mollie.sh:/data/configure-mollie.sh
- ./magento/merge-config.php.stub:/data/merge-config.php
depends_on:
- ngrok

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/templates/e2e/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM cypress/included:12.1.0
FROM cypress/included:13.6.2

WORKDIR /e2e

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/templates/magento/configure-mollie.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ 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 &
bin/magento config:set payment/mollie_methods_twint/active 1 &

# Enable Components
bin/magento config:set payment/mollie_methods_creditcard/use_components 1 &
Expand All @@ -38,6 +39,11 @@ 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/default CHF --scope=ch &
bin/magento config:set payment/mollie_general/currency 0 --scope=ch &

wait

if grep -q Magento_TwoFactorAuth "app/etc/config.php"; then
Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/templates/magento/merge-config.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

# Merge the config.php file generated by Magento with our own scopes to create multiple store views.

$magentoConfig = require('app/etc/config.php');
$magentoConfig['scopes'] = [
'websites' => [
'admin' => [
'website_id' => '0',
'code' => 'admin',
'name' => 'Admin',
'sort_order' => '0',
'default_group_id' => '0',
'is_default' => '0'
],
'base' => [
'website_id' => '1',
'code' => 'base',
'name' => 'Main Website',
'sort_order' => '0',
'default_group_id' => '1',
'is_default' => '1'
]
],
'groups' => [
[
'group_id' => '0',
'website_id' => '0',
'name' => 'Default',
'root_category_id' => '0',
'default_store_id' => '0',
'code' => 'default'
],
[
'group_id' => '1',
'website_id' => '1',
'name' => 'Main Website Store',
'root_category_id' => '2',
'default_store_id' => '1',
'code' => 'main_website_store'
]
],
'stores' => [
'admin' => [
'store_id' => '0',
'code' => 'admin',
'website_id' => '0',
'group_id' => '0',
'name' => 'Admin',
'sort_order' => '0',
'is_active' => '1'
],
'default' => [
'store_id' => '1',
'code' => 'default',
'website_id' => '1',
'group_id' => '1',
'name' => 'Default Store View',
'sort_order' => '0',
'is_active' => '1'
],
'ch' => [
'store_id' => '2',
'code' => 'ch',
'website_id' => '1',
'group_id' => '1',
'name' => 'Swiss',
'sort_order' => '0',
'is_active' => '1'
]
]
];

file_put_contents(
'app/etc/config.php',
'<?php return ' . var_export($magentoConfig, true) . ';' . PHP_EOL
);
45 changes: 45 additions & 0 deletions Api/Data/IssuerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Api\Data;

interface IssuerInterface
{
/**
* @return string
*/
public function getId(): string;

/**
* @return string
*/
public function getName(): string;

/**
* @return string
*/
public function getImage(): string;

/**
* @return array
*/
public function getImages(): array;

/**
* @return string
*/
public function getImage1x(): string;

/**
* @return string
*/
public function getImage2x(): string;

/**
* @return string
*/
public function getImageSvg(): string;
}
27 changes: 27 additions & 0 deletions Api/Data/MethodMetaInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Mollie\Payment\Api\Data;

interface MethodMetaInterface
{
/**
* @return string
*/
public function getCode(): string;

/**
* @return \Mollie\Payment\Api\Data\IssuerInterface[]
*/
public function getIssuers(): array;

/**
* @return \Mollie\Payment\Api\Data\TerminalInterface[]
*/
public function getTerminals(): array;
}
35 changes: 35 additions & 0 deletions Api/Data/TerminalInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Api\Data;

interface TerminalInterface
{
/**
* @return string
*/
public function getId(): string;

/**
* @return string
*/
public function getBrand(): string;

/**
* @return string
*/
public function getModel(): string;

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

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

namespace Mollie\Payment\Api\Webapi;

interface PaymentInformationMetaInterface
{
/**
* @return \Mollie\Payment\Api\Data\MethodMetaInterface[]
*/
public function getPaymentMethodsMeta(): array;
}
50 changes: 35 additions & 15 deletions Block/Info/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@

namespace Mollie\Payment\Block\Info;

use Magento\Framework\Encryption\EncryptorInterface;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\Registry;
use Magento\Framework\UrlInterface;
use Magento\Payment\Block\Info;
use Magento\Framework\View\Element\Template\Context;
use Magento\Framework\Stdlib\DateTime;
use Magento\Sales\Api\Data\OrderInterface;
use Mollie\Payment\Config;
use Mollie\Payment\Helper\General as MollieHelper;
use Mollie\Payment\Model\Methods\Billie;
use Mollie\Payment\Model\Methods\Klarna;
Expand All @@ -21,7 +24,6 @@

class Base extends Info
{

/**
* @var string
*/
Expand All @@ -42,26 +44,36 @@ class Base extends Info
* @var PriceCurrencyInterface
*/
private $price;

/**
* Base constructor.
*
* @param Context $context
* @param MollieHelper $mollieHelper
* @param Registry $registry
* @param PriceCurrencyInterface $price
* @var EncryptorInterface
*/
private $encryptor;
/**
* @var Config
*/
private $config;
/**
* @var UrlInterface
*/
private $urlBuilder;

public function __construct(
Context $context,
Config $config,
MollieHelper $mollieHelper,
Registry $registry,
PriceCurrencyInterface $price
PriceCurrencyInterface $price,
EncryptorInterface $encryptor,
UrlInterface $urlBuilder
) {
parent::__construct($context);
$this->mollieHelper = $mollieHelper;
$this->timezone = $context->getLocaleDate();
$this->registry = $registry;
$this->price = $price;
$this->encryptor = $encryptor;
$this->config = $config;
$this->urlBuilder = $urlBuilder;
}

public function getCheckoutType(): ?string
Expand All @@ -87,16 +99,24 @@ public function getExpiresAt(): ?string
return null;
}

/**
* @param mixed $storeId
*/
public function getPaymentLink($storeId = null): ?string
{
if ($checkoutUrl = $this->getCheckoutUrl()) {
return $this->mollieHelper->getPaymentLinkMessage($checkoutUrl, $storeId);
if (!$this->config->addPaymentLinkMessage($storeId)) {
return null;
}

return null;
return str_replace(
'%link%',
$this->getPaymentLinkUrl(),
$this->config->paymentLinkMessage($storeId)
);
}

public function getPaymentLinkUrl(): string
{
return $this->urlBuilder->getUrl('mollie/checkout/paymentlink', [
'order' => base64_encode($this->encryptor->encrypt($this->getInfo()->getParentId())),
]);
}

public function getCheckoutUrl(): ?string
Expand Down
18 changes: 18 additions & 0 deletions Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ 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_PAYMENTLINK_ADD_MESSAGE = 'payment/mollie_methods_paymentlink/add_message';
const PAYMENT_PAYMENTLINK_MESSAGE = 'payment/mollie_methods_paymentlink/message';
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';
Expand Down Expand Up @@ -495,6 +497,22 @@ public function statusNewPaymentLink($storeId = null)
);
}

public function addPaymentLinkMessage($storeId = null): string
{
return (string)$this->getPath(
static::PAYMENT_PAYMENTLINK_ADD_MESSAGE,
$storeId
);
}

public function paymentLinkMessage($storeId = null): string
{
return (string)$this->getPath(
static::PAYMENT_PAYMENTLINK_MESSAGE,
$storeId
);
}

/**
* @param string $method
* @param int|null $storeId
Expand Down
Loading

0 comments on commit 0f727ba

Please sign in to comment.