Skip to content

Commit

Permalink
Merge pull request #334 from mollie/1.20.0
Browse files Browse the repository at this point in the history
1.20.0
  • Loading branch information
Marvin-Magmodules committed Dec 14, 2020
2 parents 9e063fa + 95ad413 commit d2f9bd1
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 21 deletions.
26 changes: 22 additions & 4 deletions Model/Client/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Mollie\Payment\Model\Client;

use Magento\Catalog\Model\Product\Type as ProductType;
use Magento\Framework\Event\ManagerInterface as EventManager;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Message\ManagerInterface;
Expand All @@ -24,6 +25,7 @@
use Magento\Checkout\Model\Session as CheckoutSession;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\MollieApiClient;
use Mollie\Api\Resources\Order as MollieOrder;
use Mollie\Api\Types\OrderStatus;
use Mollie\Payment\Config;
use Mollie\Payment\Helper\General as MollieHelper;
Expand Down Expand Up @@ -139,6 +141,11 @@ class Orders extends AbstractModel
*/
private $transactionProcessor;

/**
* @var EventManager
*/
private $eventManager;

/**
* Orders constructor.
*
Expand All @@ -164,6 +171,7 @@ class Orders extends AbstractModel
* @param Config $config
* @param DashboardUrl $dashboardUrl
* @param TransactionProcessor $transactionProcessor
* @param EventManager $eventManager
*/
public function __construct(
OrderLines $orderLines,
Expand All @@ -187,7 +195,8 @@ public function __construct(
BuildTransaction $buildTransaction,
Config $config,
DashboardUrl $dashboardUrl,
TransactionProcessor $transactionProcessor
TransactionProcessor $transactionProcessor,
EventManager $eventManager
) {
$this->orderLines = $orderLines;
$this->orderSender = $orderSender;
Expand All @@ -211,6 +220,7 @@ public function __construct(
$this->config = $config;
$this->dashboardUrl = $dashboardUrl;
$this->transactionProcessor = $transactionProcessor;
$this->eventManager = $eventManager;
}

/**
Expand Down Expand Up @@ -300,12 +310,20 @@ public function getAddressLine($address)

/**
* @param Order $order
* @param $mollieOrder
* @param MollieOrder $mollieOrder
*
* @throws LocalizedException
*/
public function processResponse(Order $order, $mollieOrder)
{
$eventData = [
'order' => $order,
'mollie_order' => $mollieOrder,
];

$this->eventManager->dispatch('mollie_process_response', $eventData);
$this->eventManager->dispatch('mollie_process_response_orders_api', $eventData);

$this->mollieHelper->addTolog('response', $mollieOrder);
$order->getPayment()->setAdditionalInformation('checkout_url', $mollieOrder->getCheckoutUrl());
$order->getPayment()->setAdditionalInformation('checkout_type', self::CHECKOUT_TYPE);
Expand Down Expand Up @@ -923,11 +941,11 @@ public function createOrderRefund(Order\Creditmemo $creditmemo, Order $order)
* an exception and the user is unable to create an order. This code checks if the selected lines are already
* marked as shipped. If that's the case a warning will be shown, but the order is still created.
*
* @param \Mollie\Api\Resources\Order $mollieOrder
* @param MollieOrder $mollieOrder
* @param $orderLines
* @return bool
*/
private function itemsAreShippable(\Mollie\Api\Resources\Order $mollieOrder, $orderLines)
private function itemsAreShippable(MollieOrder $mollieOrder, $orderLines)
{
$lines = [];
foreach ($orderLines['lines'] as $line) {
Expand Down
22 changes: 20 additions & 2 deletions Model/Client/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Mollie\Payment\Model\Client;

use Magento\Framework\Event\ManagerInterface as EventManager;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Exception\LocalizedException;
use Magento\Sales\Api\Data\OrderInterface;
Expand All @@ -15,6 +16,7 @@
use Magento\Sales\Model\OrderRepository;
use Magento\Checkout\Model\Session as CheckoutSession;
use Mollie\Api\MollieApiClient;
use Mollie\Api\Resources\Payment as MolliePayment;
use Mollie\Api\Types\PaymentStatus;
use Mollie\Payment\Config;
use Mollie\Payment\Helper\General as MollieHelper;
Expand Down Expand Up @@ -79,6 +81,11 @@ class Payments extends AbstractModel
*/
private $transactionProcessor;

/**
* @var EventManager
*/
private $eventManager;

/**
* Payments constructor.
*
Expand All @@ -93,6 +100,7 @@ class Payments extends AbstractModel
* @param DashboardUrl $dashboardUrl
* @param Transaction $transaction
* @param TransactionProcessor $transactionProcessor
* @param EventManager $eventManager
*/
public function __construct(
OrderSender $orderSender,
Expand All @@ -105,7 +113,8 @@ public function __construct(
Config $config,
DashboardUrl $dashboardUrl,
Transaction $transaction,
TransactionProcessor $transactionProcessor
TransactionProcessor $transactionProcessor,
EventManager $eventManager
) {
$this->orderSender = $orderSender;
$this->invoiceSender = $invoiceSender;
Expand All @@ -118,6 +127,7 @@ public function __construct(
$this->dashboardUrl = $dashboardUrl;
$this->transaction = $transaction;
$this->transactionProcessor = $transactionProcessor;
$this->eventManager = $eventManager;
}

/**
Expand Down Expand Up @@ -197,10 +207,18 @@ public function getAddressLine($address)

/**
* @param Order $order
* @param $payment
* @param MolliePayment $payment
*/
public function processResponse(Order $order, $payment)
{
$eventData = [
'order' => $order,
'mollie_payment' => $payment,
];

$this->eventManager->dispatch('mollie_process_response', $eventData);
$this->eventManager->dispatch('mollie_process_response_payments_api', $eventData);

$this->mollieHelper->addTolog('response', $payment);
$order->getPayment()->setAdditionalInformation('checkout_url', $payment->getCheckoutUrl());
$order->getPayment()->setAdditionalInformation('checkout_type', self::CHECKOUT_TYPE);
Expand Down
5 changes: 4 additions & 1 deletion Model/Mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,10 @@ public function getIssuers($mollieApi, $method, $issuerListType)
'resource' => 'issuer',
'id' => '',
'name' => __('QR Code'),
'image' => ['size2x' => $this->assetRepository->getUrl("Mollie_Payment::images/qr-select.svg")]
'image' => [
'size2x' => $this->assetRepository->getUrl('Mollie_Payment::images/qr-select.svg'),
'svg' => $this->assetRepository->getUrl('Mollie_Payment::images/qr-select.svg'),
]
];
}

Expand Down
2 changes: 1 addition & 1 deletion Plugin/Config/LoadCorrectGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class LoadCorrectGroup
{
public function beforeGetConfigByPath(Loader $subject, $path, $scope, $scopeId, $full)
public function beforeGetConfigByPath(Loader $subject, $path, $scope, $scopeId, $full = true)
{
$groups = ['mollie_second_chance_email', 'mollie_advanced', 'mollie_payment_methods', 'mollie_general'];
if (in_array($path, $groups)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function add(View $view)
}

$state = $view->getOrder()->getState();
if (!in_array($state, [Order::STATE_NEW, Order::STATE_PENDING_PAYMENT])) {
if (!in_array($state, [Order::STATE_NEW, Order::STATE_PENDING_PAYMENT, Order::STATE_CANCELED])) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mollie/magento2",
"description": "Mollie Payment Module for Magento 2",
"version": "1.19.0",
"version": "1.20.0",
"keywords": [
"mollie",
"payment",
Expand Down
17 changes: 17 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,23 @@
<config_path>payment/mollie_general/loading_screen</config_path>
<comment><![CDATA[Use loading screen before redirect. This will enable mobile users to use the back button.]]></comment>
</field>
<field id="use_webhooks" translate="label" type="select" sortOrder="220" showInDefault="1"
showInWebsite="0" showInStore="1">
<label>Use webhooks</label>
<source_model>Mollie\Payment\Model\Adminhtml\Source\WebhookUrlOptions</source_model>
<config_path>payment/mollie_general/use_webhooks</config_path>
<comment><![CDATA[
<strong>Note:</strong> This setting has only effect when the store deploy mode is in <u>development</u>. When the store deploy mode is in production, this setting is ignored and the webhooks are always <u>enabled</u>.
]]></comment>
</field>
<field id="custom_webhook_url" translate="label" type="text" sortOrder="230" showInDefault="1"
showInWebsite="0" showInStore="1">
<label>Custom webhook url</label>
<config_path>payment/mollie_general/custom_webhook_url</config_path>
<depends>
<field id="use_webhooks">custom_url</field>
</depends>
</field>
</group>

<group id="pwa_storefront_integration" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1"
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<default>
<payment>
<mollie_general>
<version>v1.19.0</version>
<version>v1.20.0</version>
<active>0</active>
<enabled>0</enabled>
<type>test</type>
Expand Down
6 changes: 5 additions & 1 deletion i18n/de_DE.csv
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,8 @@
"Increment ID","Inkrementierungs-ID"
"Firstname","Vorname"
"Lastname","Nachname"
"E-mail","E-Mail-Adresse"
"E-mail","E-Mail-Adresse"
"Card Holder","Kartenhalter"
"Card Number","Kartennummer"
"Expiry Date","Verfallsdatum"
"Verification Code", "Verifizierungs-Schlüssel"
6 changes: 5 additions & 1 deletion i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,8 @@
"Increment ID","Increment ID"
"Firstname","Firstname"
"Lastname","Lastname"
"E-mail","E-mail"
"E-mail","E-mail"
"Card Holder","Card Holder"
"Card Number","Card Number"
"Expiry Date","Expiry Date"
"Verification Code", "Verification Code"
6 changes: 5 additions & 1 deletion i18n/fr_FR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,8 @@
"Increment ID","Numéro d'incrément"
"Firstname","Prénom"
"Lastname","Nom"
"E-mail","E-mail"
"E-mail","E-mail"
"Card Holder","Titulaire de la carte"
"Card Number","Numéro de carte"
"Expiry Date","Date d'expiration"
"Verification Code", "Code de vérification"
6 changes: 5 additions & 1 deletion i18n/nl_NL.csv
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,8 @@
"Increment ID","ID Verhogen"
"Firstname","Voornaam"
"Lastname","Achternaam"
"E-mail","E-mail"
"E-mail","E-mail"
"Card Holder","Kaarthouder"
"Card Number","Kaartnummer"
"Expiry Date","Vervaldatum"
"Verification Code", "Verificatie code"
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"/>
<label data-bind="attr: {'for': getCode()}" class="label">
<!-- ko if: getMethodImage() -->
<img data-bind="attr: {src: getMethodImage()}" class="mollie-payment-icon"/>
<img data-bind="attr: {src: getMethodImage()}" class="mollie-payment-icon"/>
<!--/ko-->
<span data-bind="text: getTitle()"></span>
<span data-bind="text: getTitle()"></span>
</label>

</div>
Expand All @@ -18,19 +18,19 @@
<!--/ko-->

<div class="card-container">
<label for="card-holder">Card Holder</label>
<label for="card-holder" data-bind="i18n: 'Card Holder'"></label>
<div id="card-holder"></div>
<div id="card-holder-error" class="component-error"></div>

<label for="card-number">Card Number</label>
<label for="card-number" data-bind="i18n: 'Card Number'"></label></label>
<div id="card-number"></div>
<div id="card-number-error" class="component-error"></div>

<label for="expiry-date">Expiry Date</label>
<label for="expiry-date" data-bind="i18n: 'Expiry Date'"></label>
<div id="expiry-date"></div>
<div id="expiry-date-error" class="component-error"></div>

<label for="verification-code">Verification Code</label>
<label for="verification-code" data-bind="i18n: 'Verification Code'"></label>
<div id="verification-code"></div>
<div id="verification-code-error" class="component-error"></div>
</div>
Expand Down

0 comments on commit d2f9bd1

Please sign in to comment.