Skip to content

Commit

Permalink
Merge pull request #94 from mollie/1.4.2
Browse files Browse the repository at this point in the history
1.4.2
  • Loading branch information
Marvin-Magmodules authored Nov 20, 2018
2 parents 55ec239 + a99d478 commit 965ea85
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 7 deletions.
12 changes: 12 additions & 0 deletions Helper/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class General extends AbstractHelper
const XML_PATH_USE_BASE_CURRENCY = 'payment/mollie_general/currency';
const XML_PATH_SHOW_TRANSACTION_DETAILS = 'payment/mollie_general/transaction_details';
const XML_PATH_IDEAL_ISSUER_LIST_TYPE = 'payment/mollie_methods_ideal/issuer_list_type';
const XML_PATH_ADD_QR = 'payment/mollie_methods_ideal/add_qr';
const XML_PATH_GIFTCARD_ISSUER_LIST_TYPE = 'payment/mollie_methods_giftcard/issuer_list_type';
const XML_PATH_PAYMENTLINK_ADD_MESSAGE = 'payment/mollie_methods_paymentlink/add_message';
const XML_PATH_PAYMENTLINK_MESSAGE = 'payment/mollie_methods_paymentlink/message';
Expand Down Expand Up @@ -319,6 +320,17 @@ public function getIssuerListType($method)
}
}

/**
* @param null $storeId
*
* @return mixed
*/
public function addQrOption($storeId = null)
{
return $this->getStoreConfig(self::XML_PATH_ADD_QR, $storeId);

}

/**
* Disable extension function.
* Used when Mollie API is not installed
Expand Down
30 changes: 25 additions & 5 deletions Model/Mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Mollie\Payment\Model\Client\Orders as OrdersApi;
use Mollie\Payment\Model\Client\Payments as PaymentsApi;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\View\Asset\Repository as AssetRepository;

/**
* Class Mollie
Expand Down Expand Up @@ -101,6 +102,10 @@ class Mollie extends AbstractMethod
* @var PaymentsApi
*/
private $paymentsApi;
/**
* @var AssetRepository
*/
private $assetRepository;

/**
* Mollie constructor.
Expand All @@ -119,6 +124,7 @@ class Mollie extends AbstractMethod
* @param MollieHelper $mollieHelper
* @param CheckoutSession $checkoutSession
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param AssetRepository $assetRepository
* @param AbstractResource|null $resource
* @param AbstractDb|null $resourceCollection
* @param array $data
Expand All @@ -138,6 +144,7 @@ public function __construct(
MollieHelper $mollieHelper,
CheckoutSession $checkoutSession,
SearchCriteriaBuilder $searchCriteriaBuilder,
AssetRepository $assetRepository,
AbstractResource $resource = null,
AbstractDb $resourceCollection = null,
array $data = []
Expand All @@ -162,6 +169,7 @@ public function __construct(
$this->orderRepository = $orderRepository;
$this->orderFactory = $orderFactory;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->assetRepository = $assetRepository;
}

/**
Expand Down Expand Up @@ -401,13 +409,16 @@ public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount)

try {
$mollieApi = $this->loadMollieApi($apiKey);
$mollieOrder = $mollieApi->orders->get($transactionId);
$mollieOrder->refundAll(['Testing Refund Order xx']);
$payment = $mollieApi->payments->get($transactionId);
$payment->refund([
"amount" => [
"currency" => $order->getOrderCurrencyCode(),
"value" => $this->mollieHelper->formatCurrencyValue($amount, $order->getOrderCurrencyCode())
]
]);
} catch (\Exception $e) {
$this->mollieHelper->addTolog('error', $e->getMessage());
throw new LocalizedException(
__('Mollie: %1', $e->getMessage())
);
throw new LocalizedException(__('Error: not possible to create an online refund: %1', $e->getMessage()));
}

return $this;
Expand Down Expand Up @@ -471,6 +482,15 @@ public function getIssuers($mollieApi, $method, $issuerListType)
]);
}

if ($this->mollieHelper->addQrOption()) {
$issuers[] = [
'resource' => 'issuer',
'id' => '',
'name' => __('QR Code'),
'image' => ['size2x' => $this->assetRepository->getUrl("Mollie_Payment::images/qr-select.png")]
];
}

return $issuers;
}

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.4.0",
"version": "1.4.2",
"require": {
"mollie/mollie-api-php": "^2.1",
"magento/framework": ">=100.1.0",
Expand Down
6 changes: 6 additions & 0 deletions etc/adminhtml/methods/ideal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
<field id="active">1</field>
</depends>
</field>
<field id="add_qr" translate="label" type="select" sortOrder="5" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Add QR-Code option in Issuer List</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/mollie_methods_ideal/add_qr</config_path>
</field>
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="96" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Payment from Applicable Countries</label>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Mollie_Payment" setup_version="1.4.0" />
<module name="Mollie_Payment" setup_version="1.4.2" />
</config>
Binary file added view/frontend/web/images/qr-select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 965ea85

Please sign in to comment.