Skip to content

Commit

Permalink
Merge pull request #14 from mollie/development
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
Magmodules authored Mar 12, 2017
2 parents 2993c08 + 6fcfc2e commit 55cc5f2
Show file tree
Hide file tree
Showing 84 changed files with 695 additions and 151 deletions.
43 changes: 43 additions & 0 deletions Block/Adminhtml/Render/Header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* Copyright © 2017 Mollie.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Block\Adminhtml\Render;

use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Mollie\Payment\Helper\General as GeneralHelper;
use Magento\Backend\Block\Template\Context;

class Header extends Field
{

protected $general;
protected $_template = 'Mollie_Payment::system/config/fieldset/header.phtml';

/**
* Header constructor.
* @param Context $context
* @param GeneralHelper $general
*/
public function __construct(
Context $context,
GeneralHelper $general
) {
$this->general = $general;
parent::__construct($context);
}

/**
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
$element->addClass('Mollie');

return $this->toHtml();
}
}
2 changes: 1 addition & 1 deletion Block/Adminhtml/Render/Heading.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2016 Magmodules.eu. All rights reserved.
* Copyright © 2017 Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/Render/Version.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2016 Magmodules.eu. All rights reserved.
* Copyright © 2017 Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2016 Magmodules.eu. All rights reserved.
* Copyright © 2017 Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2016 Magmodules.eu. All rights reserved.
* Copyright © 2017 Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
57 changes: 57 additions & 0 deletions Block/Loading.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* Copyright © 2017 Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Block;

use Magento\Checkout\Model\Session;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\View\Element\Template;

class Loading extends Template
{
protected $checkoutSession;

/**
* Loading constructor.
*
* @param Context $context
* @param Session $checkoutSession
* @param array $data
*/
public function __construct(
Context $context,
Session $checkoutSession,
array $data = []
) {
$this->checkoutSession = $checkoutSession;
parent::__construct($context, $data);
}

/**
* Disable caching of block.
*
* @return null
*/
public function getCacheLifetime()
{
return null;
}

/**
* @return string
*/
public function getRedirectUrl()
{
$orderId = $this->checkoutSession->getLastRealOrder()->getId();
if ($this->checkoutSession->getMollieRedirect() == $orderId) {
$this->checkoutSession->restoreQuote();
return $this->getUrl('checkout/') . '#payment';
} else {
$this->checkoutSession->setMollieRedirect($orderId);
return $this->getMollieRedirect();
}
}
}
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Action/Compatibility.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2016 Magmodules.eu. All rights reserved.
* Copyright © 2017 Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
19 changes: 16 additions & 3 deletions Controller/Checkout/Redirect.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2016 Magmodules.eu. All rights reserved.
* Copyright © 2017 Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand All @@ -11,12 +11,13 @@
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Checkout\Model\Session;
use Magento\Framework\View\Result\PageFactory;

class Redirect extends Action
{

protected $checkoutSession;
protected $logger;
protected $resultPageFactory;
protected $paymentHelper;
protected $mollieHelper;

Expand All @@ -25,16 +26,19 @@ class Redirect extends Action
*
* @param Context $context
* @param Session $checkoutSession
* @param PageFactory $resultPageFactory
* @param PaymentHelper $paymentHelper
* @param MollieHelper $mollieHelper
*/
public function __construct(
Context $context,
Session $checkoutSession,
PageFactory $resultPageFactory,
PaymentHelper $paymentHelper,
MollieHelper $mollieHelper
) {
$this->checkoutSession = $checkoutSession;
$this->resultPageFactory = $resultPageFactory;
$this->paymentHelper = $paymentHelper;
$this->mollieHelper = $mollieHelper;
parent::__construct($context);
Expand All @@ -50,9 +54,18 @@ public function execute()
$method = $order->getPayment()->getMethod();
$methodInstance = $this->paymentHelper->getMethodInstance($method);
if ($methodInstance instanceof \Mollie\Payment\Model\Mollie) {
$storeId = $order->getStoreId();
$issuer = $this->getRequest()->getParam('issuer');
$redirectUrl = $methodInstance->startTransaction($order, $issuer);
$this->getResponse()->setRedirect($redirectUrl);
$this->mollieHelper->addTolog('request', $redirectUrl);
if ($this->mollieHelper->useLoadingScreen($storeId)) {
$resultPage = $this->resultPageFactory->create();
$resultPage->getLayout()->initMessages();
$resultPage->getLayout()->getBlock('mollie_loading')->setMollieRedirect($redirectUrl);
return $resultPage;
} else {
$this->getResponse()->setRedirect($redirectUrl);
}
} else {
$msg = __('Paymentmethod not found.');
$this->messageManager->addError($msg);
Expand Down
3 changes: 1 addition & 2 deletions Controller/Checkout/Success.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2016 Magmodules.eu. All rights reserved.
* Copyright © 2017 Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand All @@ -17,7 +17,6 @@ class Success extends Action
{

protected $checkoutSession;
protected $logger;
protected $paymentHelper;
protected $mollieModel;
protected $mollieHelper;
Expand Down
2 changes: 1 addition & 1 deletion Controller/Checkout/Webhook.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2016 Magmodules.eu. All rights reserved.
* Copyright © 2017 Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
61 changes: 52 additions & 9 deletions Helper/General.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2016 Magmodules.eu. All rights reserved.
* Copyright © 2017 Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand All @@ -11,6 +11,7 @@
use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\Module\ModuleListInterface;
use Magento\Config\Model\ResourceModel\Config;
use Magento\Framework\App\ProductMetadataInterface;
use Mollie\Payment\Logger\MollieLogger;

class General extends AbstractHelper
Expand All @@ -22,29 +23,41 @@ class General extends AbstractHelper
const XML_PATH_LIVE_APIKEY = 'payment/mollie_general/apikey_live';
const XML_PATH_TEST_APIKEY = 'payment/mollie_general/apikey_test';
const XML_PATH_DEBUG = 'payment/mollie_general/debug';
const XML_PATH_LOADING_SCREEN = 'payment/mollie_general/loading_screen';
const XML_PATH_STATUS_PROCESSING = 'payment/mollie_general/order_status_processing';
const XML_PATH_STATUS_PENDING = 'payment/mollie_general/order_status_pending';
const XML_PATH_STATUS_PENDING_BANKTRANSFER = 'payment/mollie_methods_banktransfer/order_status_pending';
const XML_PATH_INVOICE_NOTIFY = 'payment/mollie_general/invoice_notify';

protected $metadata;
protected $storeManager;
protected $resourceConfig;
protected $moduleList;
protected $logger;

/**
* General constructor
* General constructor.
*
* @param Context $context
* @param StoreManagerInterface $storeManager
* @param ModuleListInterface $moduleList
* @param MollieLogger $logger
* @param Context $context
* @param StoreManagerInterface $storeManager
* @param Config $resourceConfig
* @param ModuleListInterface $moduleList
* @param ProductMetadataInterface $metadata
* @param MollieLogger $logger
*/
public function __construct(
Context $context,
StoreManagerInterface $storeManager,
Config $resourceConfig,
ModuleListInterface $moduleList,
ProductMetadataInterface $metadata,
MollieLogger $logger
) {
$this->storeManager = $storeManager;
$this->resourceConfig = $resourceConfig;
$this->urlBuilder = $context->getUrlBuilder();
$this->moduleList = $moduleList;
$this->metadata = $metadata;
$this->logger = $logger;
parent::__construct($context);
}
Expand Down Expand Up @@ -104,8 +117,6 @@ public function getApiKey($storeId)
} else {
return $this->getStoreConfig(self::XML_PATH_LIVE_APIKEY, $storeId);
}

return false;
}

/**
Expand All @@ -118,6 +129,16 @@ public function getModus($storeId)
return $this->getStoreConfig(self::XML_PATH_API_MODUS, $storeId);
}

/**
* @param $storeId
*
* @return mixed
*/
public function useLoadingScreen($storeId)
{
return $this->getStoreConfig(self::XML_PATH_LOADING_SCREEN, $storeId);
}

/**
* Write to log
*
Expand Down Expand Up @@ -146,7 +167,7 @@ public function disableExtension()
}

/**
* Currecny check
* Currency check
*
* @param $currency
*
Expand Down Expand Up @@ -229,6 +250,18 @@ public function getStatusPending($storeId = 0)
return $this->getStoreConfig(self::XML_PATH_STATUS_PENDING, $storeId);
}

/**
* Selected pending (payment) status for banktransfer
*
* @param int $storeId
*
* @return mixed
*/
public function getStatusPendingBanktransfer($storeId = 0)
{
return $this->getStoreConfig(self::XML_PATH_STATUS_PENDING_BANKTRANSFER, $storeId);
}

/**
* Send invoice
*
Expand Down Expand Up @@ -294,6 +327,16 @@ public function getExtensionVersion()
return $moduleInfo['setup_version'];
}

/**
* Returns current version of Magento
*
* @return string
*/
public function getMagentoVersion()
{
return $this->metadata->getVersion();
}

/**
* Check is class extists, used for Mollie API check
*
Expand Down
2 changes: 1 addition & 1 deletion Logger/MollieHandler.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2016 Magmodules.eu. All rights reserved.
* Copyright © 2017 Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Logger/MollieLogger.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2016 Magmodules.eu. All rights reserved.
* Copyright © 2017 Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Model/Adminhtml/Source/ApiKey.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2016 Magmodules.eu. All rights reserved.
* Copyright © 2017 Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
2 changes: 1 addition & 1 deletion Model/Adminhtml/Source/Pending.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright © 2016 Magmodules.eu. All rights reserved.
* Copyright © 2017 Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

Expand Down
Loading

0 comments on commit 55cc5f2

Please sign in to comment.