Skip to content

Commit

Permalink
Merge pull request #41 from mollie/1.1.3
Browse files Browse the repository at this point in the history
1.1.3
  • Loading branch information
Magmodules authored Nov 28, 2017
2 parents 370a2ed + 1c95297 commit ab72fb6
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 27 deletions.
61 changes: 50 additions & 11 deletions Controller/Adminhtml/Action/Apikey.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,21 @@
class Apikey extends Action
{

/**
* @var \Magento\Framework\App\RequestInterface
*/
protected $request;
/**
* @var JsonFactory
*/
protected $resultJsonFactory;
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $objectManager;
/**
* @var MollieHelper
*/
protected $mollieHelper;

/**
Expand All @@ -39,7 +51,7 @@ public function __construct(
}

/**
* @return $this
* @return \Magento\Framework\Controller\Result\Json
*/
public function execute()
{
Expand All @@ -58,33 +70,60 @@ public function execute()
$results = [];

if (empty($testKey)) {
$results[] = '<span class="mollie-error">' . __('Test Key: Empty value') . '</span>';
$results[] = '<span class="mollie-error">' . __('Test API-key: Empty value') . '</span>';
} else {
if (!preg_match('/^test_\w+$/', $testKey)) {
$results[] = '<span class="mollie-error">' . __('Test Key: Should start with "test_"') . '</span>';
$results[] = '<span class="mollie-error">' . __('Test API-key: Should start with "test_"') . '</span>';
} else {
try {
$availableMethods = [];
$mollieApi = $this->loadApi($testKey);
$mollieApi->issuers->all();
$results[] = '<span class="mollie-success">' . __('Test Key: Success!') . '</span>';
$methods = $mollieApi->methods->all();

foreach ($methods as $apiMethod) {
$availableMethods[] = ucfirst($apiMethod->id);
}

if (empty($availableMethods)) {
$msg = __('Enabled Methods: None, Please enable the payment methods in your Mollie dashboard.');
$methodsMsg = '<span class="enabled-methods-error">' . $msg . '</span>';
} else {
$msg = __('Enabled Methods') . ': ' . implode(', ', $availableMethods);
$methodsMsg = '<span class="enabled-methods">' . $msg . '</span>';
}

$results[] = '<span class="mollie-success">' . __('Test API-key: Success!') . $methodsMsg . '</span>';
} catch (\Exception $e) {
$results[] = '<span class="mollie-error">' . __('Test Key: %1', $e->getMessage()) . '</span>';
$results[] = '<span class="mollie-error">' . __('Test API-key: %1', $e->getMessage()) . '</span>';
}
}
}

if (empty($liveKey)) {
$results[] = '<span class="mollie-error">' . __('Live Key: Empty value') . '</span>';
$results[] = '<span class="mollie-error">' . __('Live API-key: Empty value') . '</span>';
} else {
if (!preg_match('/^live_\w+$/', $liveKey)) {
$results[] = '<span class="mollie-error">' . __('Live Key: Should start with "live_"') . '</span>';
$results[] = '<span class="mollie-error">' . __('Live API-key: Should start with "live_"') . '</span>';
} else {
try {
$availableMethods = [];
$mollieApi = $this->loadApi($liveKey);
$mollieApi->issuers->all();
$results[] = '<span class="mollie-success">' . __('Live Key: Success!') . '</span>';
$methods = $mollieApi->methods->all();
foreach ($methods as $apiMethod) {
$availableMethods[] = ucfirst($apiMethod->id);
}

if (empty($availableMethods)) {
$msg = __('Enabled Methods: None, Please enable the payment methods in your Mollie dashboard.');
$methodsMsg = '<span class="enabled-methods-error">' . $msg . '</span>';
} else {
$msg = __('Enabled Methods') . ': ' . implode(', ', $availableMethods);
$methodsMsg = '<span class="enabled-methods">' . $msg . '</span>';
}

$results[] = '<span class="mollie-success">' . __('Live API-key: Success!') . $methodsMsg . '</span>';
} catch (\Exception $e) {
$results[] = '<span class="mollie-error">' . __('Live Key: %1', $e->getMessage()) . '</span>';
$results[] = '<span class="mollie-error">' . __('Live API-key: %1', $e->getMessage()) . '</span>';
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion Controller/Adminhtml/Action/Compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,21 @@
class Compatibility extends Action
{

/**
* @var \Magento\Framework\App\RequestInterface
*/
protected $request;
/**
* @var JsonFactory
*/
protected $resultJsonFactory;
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $objectManager;
/**
* @var MollieHelper
*/
protected $mollieHelper;

/**
Expand Down Expand Up @@ -44,7 +56,7 @@ public function __construct(
* - Check if Mollie php API is installed
* - Check for minimum system requirements of API
*
* @return $this
* @return \Magento\Framework\Controller\Result\Json
*/
public function execute()
{
Expand Down
7 changes: 7 additions & 0 deletions Controller/Checkout/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ public function execute()
{
try {
$order = $this->checkoutSession->getLastRealOrder();

if (!$order) {
$msg = __('Order not found.');
$this->mollieHelper->addTolog('error', $msg);
$this->_redirect('checkout/cart');
}

$method = $order->getPayment()->getMethod();
$methodInstance = $this->paymentHelper->getMethodInstance($method);
if ($methodInstance instanceof \Mollie\Payment\Model\Mollie) {
Expand Down
12 changes: 8 additions & 4 deletions Model/Mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Mollie extends AbstractMethod
* @param Data $paymentData
* @param ScopeConfigInterface $scopeConfig
* @param Logger $logger
* @param ObjectManagerInterface $objectManager
* @param MollieHelper $mollieHelper
* @param CheckoutSession $checkoutSession
* @param StoreManagerInterface $storeManager
Expand Down Expand Up @@ -143,15 +144,19 @@ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
/**
* @param string $paymentAction
* @param object $stateObject
*
* @return $this
*/
public function initialize($paymentAction, $stateObject)
{
/** @var \Magento\Sales\Model\Order\Payment $payment */
$payment = $this->getInfoInstance();

/** @var \Magento\Sales\Model\Order $order */
$order = $payment->getOrder();
$order->setCanSendNewEmailFlag(false);
$order->setIsNotified(false);

$status = $this->mollieHelper->getStatusPending($order->getId());
$status = $this->mollieHelper->getStatusPending($order->getStoreId());
$stateObject->setState(\Magento\Sales\Model\Order::STATE_NEW);
$stateObject->setStatus($status);
$stateObject->setIsNotified(false);
Expand Down Expand Up @@ -181,8 +186,7 @@ public function startTransaction(Order $order)
$transactionId = $order->getMollieTransactionId();
if (!empty($transactionId)) {
$paymentData = $mollieApi->payments->get($transactionId);
$paymentUrl = $paymentData->links->paymentUrl;
if (!empty($paymentUrl)) {
if (!empty($paymentData->links->paymentUrl)) {
return $this->mollieHelper->getRedirectUrl($orderId);
}
}
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.1.2",
"version": "1.1.3",
"require": {
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6|~7.1.0",
"mollie/mollie-api-php": "^1.9.3"
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?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.1.2">
<module name="Mollie_Payment" setup_version="1.1.3">
</module>
</config>
69 changes: 60 additions & 9 deletions view/adminhtml/web/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
padding: 10px 0px;
font-size: 12px;
}

.mollie-success {
display: block;
line-height: 30px;
}

.mollie-success:before {
font-family: 'Admin Icons';
font-size: 12px;
Expand All @@ -15,11 +17,44 @@
color: #79A22E;
content: '\e62d';
}

.mollie-success .enabled-methods-error {
display: block;
line-height: 30px;
}

.mollie-success .enabled-methods-error:before {
font-family: 'Admin Icons';
font-size: 12px;
font-style: normal;
font-weight: 400;
padding: 10px;
color: #EB5103;
content: '\e610';
}

.mollie-success .enabled-methods {
display: block;
line-height: 30px;
margin-top: 15px;
}

.mollie-success .enabled-methods:before {
font-family: 'Admin Icons';
font-size: 12px;
font-style: normal;
font-weight: 400;
padding: 11px;
color: #78A230;
content: '\e610';
}

.mollie-error {
display: block;
background-color: white;
line-height: 30px;
}

.mollie-error:before {
color: #EB5202;
content: '\e623';
Expand All @@ -29,88 +64,104 @@
font-weight: 400;
padding: 10px;
}

.mm-heading-mollie {
color: #666;
text-align: left;
border: 1px solid rgba(229, 229, 229, 0.27);
border-left: 2px solid #ea4c00;
border-left: 2px solid #EA4C00;
font-size: 14px;
margin: 20px 0 0;
padding: 5px 5px 5px 10px;
background: #f8f8f8;
background: #F8F8F8;
}

.mm-block-mollie {
background: #f8f8f8 no-repeat 8px;
border: 1px solid #e5e5e5;
border-left: 2px solid #ea4c00;
background: #F8F8F8 no-repeat 8px;
border: 1px solid #E5E5E5;
border-left: 2px solid #EA4C00;
font-size: 12px;
color: #303030;
margin-bottom: 0;
padding: 1.5rem 1.5rem 1.5rem 1.5rem;
background-size: 55px;
}

.mm-block-mollie table {
width: 520px!important;
width: 520px !important;
}

.mm-block-mollie strong {
font-weight: 600;
color: #514943;
}

.mm-block-mollie p {
font-size: 12px;
padding: 0 0 0.3em;
}

.mm-block-mollie tr a {
color: #6d6761;
color: #6D6761;
margin-top: 3px;
display: block;
}

.mm-block-mollie tr td {
padding: 5px 0px 0 0!important;
padding: 5px 0px 0 0 !important;
}

.mm-block-mollie .accordion .form-inline .config td {
padding: 0.8rem 1.5rem 0 0;
}

.mm-block-mollie .helpbutton {
padding: 10px 15px;
width: 100px;
height: 31px;
float: right;
background: url(../images/icons.png) no-repeat scroll 0px -175px #F8F8F8;
}

.mm-block-mollie .icon1 {
background: url(../images/icons.png) no-repeat scroll -20px -14px;
width: 45px;
height: 25px;
float: left;
}

.mm-block-mollie .icon2 {
background: url(../images/icons.png) no-repeat scroll -30px -70px;
width: 36px;
height: 25px;
float: left;
}

.mm-block-mollie .icon3 {
background: url(../images/icons.png) no-repeat scroll -20px -129px;
width: 47px;
height: 25px;
float: left;
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
.mm-block-mollie .icon1 {
background: url(../images/icons@x2.png) no-repeat scroll 0px -7px;
background-size: 55px;
}

.mm-block-mollie .icon2 {
background: url(../images/icons@x2.png) no-repeat scroll -4px -32px;
background-size: 45px;
}

.mm-block-mollie .icon3 {
background: url(../images/icons@x2.png) no-repeat scroll 0px -75px;
background-size: 52px;
}

.mm-block-mollie .helpbutton {
background: url(../images/icons@x2.png) no-repeat scroll 0px -260px #f8f8f8;
background: url(../images/icons@x2.png) no-repeat scroll 0px -260px #F8F8F8;
background-size: 130px;
}
}

0 comments on commit ab72fb6

Please sign in to comment.