Skip to content
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.

Commit

Permalink
Release of 1.14.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper-MultiSafepay committed Nov 13, 2020
2 parents 2b3dd8a + 347942d commit 9a4af77
Show file tree
Hide file tree
Showing 27 changed files with 420 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -12,7 +12,7 @@ jobs:
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: magento
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,15 @@
## 1.14.1
Release date: Nov 13th, 2020

### Fixed
+ Fixed order item ids missing if an order was placed through adminhtml, graphql, restapi or soapapi - by Hexmage
+ Added translatable labels to config source models - by vmalyk

### Changed
+ DAVAMS-309: Rebrand Klarna to Klarna - buy now, pay later

***

## 1.14.0
Release date: Sep 11th, 2020

Expand Down
2 changes: 1 addition & 1 deletion Helper/Data.php
Expand Up @@ -81,7 +81,7 @@ class Data
'ing' => ['code' => 'INGHOME', 'name' => 'ING Home\'Pay', 'type' => 'gateways'],
'cbc' => ['code' => 'CBC', 'name' => 'CBC', 'type' => 'gateways'],
'kbc' => ['code' => 'KBC', 'name' => 'KBC', 'type' => 'gateways'],
'klarnainvoice' => ['code' => 'KLARNA', 'name' => 'Klarna', 'type' => 'gateways'],
'klarnainvoice' => ['code' => 'KLARNA', 'name' => 'Klarna - buy now, pay later', 'type' => 'gateways'],
'maestro' => ['code' => 'MAESTRO', 'name' => 'Maestro', 'type' => 'gateways'],
'mastercard' => ['code' => 'MASTERCARD', 'name' => 'Mastercard', 'type' => 'gateways'],
'mspbanktransfer' => ['code' => 'BANKTRANS', 'name' => 'Bank transfer', 'type' => 'gateways'],
Expand Down
6 changes: 3 additions & 3 deletions Model/Config/Source/Customfields.php
Expand Up @@ -45,15 +45,15 @@ public function toOptionArray()
return [
[
"value" => 0,
"label" => 'Disabled'
"label" => __('Disabled')
],
[
"value" => 1,
"label" => 'Mandatory'
"label" => __('Mandatory')
],
[
"value" => 2,
"label" => 'Optional'
"label" => __('Optional')
]
];
}
Expand Down
6 changes: 3 additions & 3 deletions Model/Config/Source/Email.php
Expand Up @@ -45,15 +45,15 @@ public function toOptionArray()
return [
[
"value" => "place_order",
"label" => "When placing the order"
"label" => __('When placing the order')
],
[
"value" => "after_transaction",
"label" => "After transaction"
"label" => __('After transaction')
],
[
"value" => "after_transaction_paid",
"label" => "After paid transaction"
"label" => __('After paid transaction')
],
];
}
Expand Down
4 changes: 2 additions & 2 deletions Model/Config/Source/Environment.php
Expand Up @@ -48,11 +48,11 @@ public function toOptionArray()
return [
[
"value" => self::TEST_MODE,
"label" => "Test account"
"label" => __('Test account')
],
[
"value" => self::LIVE_MODE,
"label" => "Live account"
"label" => __('Live account')
],
];
}
Expand Down
39 changes: 38 additions & 1 deletion Model/Connect.php
Expand Up @@ -535,6 +535,12 @@ public function transactionRequest($order, $resetGateway = false)
$type = 'redirect';
}

$payload = null;
if ($this->_gatewayCode == "CREDITCARD" && !empty($params['payload'])) {
$type = 'direct';
$payload = $params['payload'];
}

/** @var \Magento\Framework\Locale\Resolver $resolver */
$resolver =$this->_localeResolver;

Expand Down Expand Up @@ -646,14 +652,17 @@ public function transactionRequest($order, $resetGateway = false)
"plugin" => [
"shop" => $magentoInfo->getName() . ' ' . $magentoInfo->getVersion() . ' ' . $magentoInfo->getEdition(),
"shop_version" => $magentoInfo->getVersion(),
"plugin_version" => ' - Plugin 1.14.0',
"plugin_version" => ' - Plugin 1.14.1',
"partner" => "MultiSafepay",
],
"gateway_info" => [
"issuer_id" => !empty($this->issuer_id) ? $this->issuer_id : null,
],
"shopping_cart" => $shoppingCart,
"checkout_options" => $checkoutData,
'payment_data' => [
'payload' => $payload,
],
];

$mspOrderDataObject = $this->dataObjectFactory->create();
Expand Down Expand Up @@ -730,6 +739,34 @@ public function getIssuers()
return $issuers;
}

public function getApiToken()
{
$environment = $this->getMainConfigData('msp_env');

$api_key = null;

if ($environment == true) {
$this->_client->setApiKey($this->getMainConfigData('test_api_key'));
$api_key = $this->getMainConfigData('test_api_key');
$this->_client->setApiUrl('https://testapi.multisafepay.com/v1/connect/');
} else {
$this->_client->setApiKey($this->getMainConfigData('live_api_key'));
$api_key = $this->getMainConfigData('live_api_key');
$this->_client->setApiUrl('https://api.multisafepay.com/v1/connect/');
}

if (empty($api_key)) {
return false;
}

try {
$apiToken = $this->_client->processAPIRequest('GET', 'auth/api_token');
} catch (\Magento\Framework\Exception\LocalizedException $e) {
return false;
}
return $apiToken;
}

public function shipOrder($order)
{
$payment = $order->getPayment();
Expand Down
38 changes: 37 additions & 1 deletion Model/ConnectConfigProvider.php
Expand Up @@ -73,7 +73,11 @@ public function getConfig()
'creditcards' => $this->getCreditcards(),
'years' => $this->getYears(),
'active_method' => $this->getActiveMethod(),
'images' => $this->getImageURLs()
'images' => $this->getImageURLs(),
'useCreditcardComponent' => $this->isCreditcardComponentsEnabled(),
'apitoken' => $this->getApiToken(),
'environment' => $this->getEnvironment(),
'locale' => $this->localeResolver->getLocale(),
],
],
]
Expand Down Expand Up @@ -211,4 +215,36 @@ public function hasRecurrings($gateway, $array = null)
}
return false;
}

/**
* @return bool
*/
public function isCreditcardComponentsEnabled()
{
return (bool)$this->_scopeConfig->getValue(
'gateways/creditcard/creditcard_components_enabled',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}

public function getApiToken()
{
if ($this->isCreditcardComponentsEnabled()) {
return json_decode($this->_connect->getApiToken())->api_token;
}
return false;
}

public function getEnvironment()
{
$mspEnv = $this->_scopeConfig->getValue(
'multisafepay/connect/msp_env',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);

if ($mspEnv) {
return 'TEST';
}
return 'LIVE';
}
}
2 changes: 1 addition & 1 deletion Model/Fastcheckout.php
Expand Up @@ -412,7 +412,7 @@ public function transactionRequest($session, $resetGateway = false)
"plugin" => [
"shop" => $magentoInfo->getName() . ' ' . $magentoInfo->getVersion() . ' ' . $magentoInfo->getEdition(),
"shop_version" => $magentoInfo->getVersion(),
"plugin_version" => ' - Plugin 1.14.0',
"plugin_version" => ' - Plugin 1.14.1',
"partner" => "MultiSafepay",
],
"shopping_cart" => $shoppingCart,
Expand Down
26 changes: 21 additions & 5 deletions Model/Observers/Order.php
Expand Up @@ -31,21 +31,32 @@

namespace MultiSafepay\Connect\Model\Observers;

use Magento\Backend\App\Area\FrontNameResolver;
use Magento\Catalog\Model\Product;
use Magento\Framework\App\Area;
use Magento\Framework\App\State;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Message\ManagerInterface;
use Magento\Sales\Model\OrderRepository;
use MultiSafepay\Connect\Helper\Data;
use MultiSafepay\Connect\Model\Connect;

class Order implements ObserverInterface
{
/**
* @var Connect
*/
protected $_mspConnect;
/**
* @var State
*/
protected $_state;
/**
* @var Data
*/
protected $_mspData;
/**
* @var OrderRepository
*/
protected $_orderRepository;

/*
* @var \PHPUnit_Framework_MockObject_MockObject
Expand All @@ -57,17 +68,20 @@ class Order implements ObserverInterface
* @param State $state
* @param Connect $connect
* @param Data $data
* @param OrderRepository $orderRepository
*/
public function __construct(
ManagerInterface $messageManager,
State $state,
Connect $connect,
Data $data
Data $data,
OrderRepository $orderRepository
) {
$this->_messageManager = $messageManager;
$this->_mspConnect = $connect;
$this->_mspData = $data;
$this->_state = $state;
$this->_orderRepository = $orderRepository;
}

/**
Expand All @@ -78,7 +92,7 @@ public function execute(Observer $observer)
{
$paymentMethod = $this->_mspConnect;

/** @var $order Mage_Sales_Model_Order */
/** @var \Magento\Sales\Model\Order $order */
$order = $observer->getEvent()->getOrder();

$paymentMethod->_isAdmin = true;
Expand All @@ -101,6 +115,8 @@ public function execute(Observer $observer)

$paymentMethod->_manualGateway = $payment->_gatewayCode;

$this->_orderRepository->save($order);

$transactionObject = $paymentMethod->transactionRequest($order, $resetGateway);

if (!empty($transactionObject->result->error_code)) {
Expand Down
10 changes: 10 additions & 0 deletions Setup/UpgradeData.php
Expand Up @@ -116,13 +116,23 @@ public function upgrade(
}
// Rebrand Direct Bank Transfer to Request to Pay
if (version_compare($context->getVersion(), '1.14.0', '<')) {
// Rebrand Direct Bank Transfer to Request to Pay
$currentTitle = $this->scopeConfig->getValue(
'gateways/directbanktransfer/title',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
if ($currentTitle === 'Direct Bank Transfer') {
$this->configWriter->save('gateways/directbanktransfer/title', 'Request to Pay');
}

// Rebrand Klarna
$currentTitle = $this->scopeConfig->getValue(
'gateways/klarnainvoice/title',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
if ($currentTitle === 'Klarna') {
$this->configWriter->save('gateways/klarnainvoice/title', 'Klarna - buy now, pay later');
}
}
}
}
2 changes: 1 addition & 1 deletion Test/Unit/Helper/DataTest.php
Expand Up @@ -276,7 +276,7 @@ public function testGetAllMethods()
'ing' => 'ING Home\'Pay',
'cbc' => 'CBC',
'kbc' => 'KBC',
'klarnainvoice' => 'Klarna',
'klarnainvoice' => 'Klarna - buy now, pay later',
'maestro' => 'Maestro',
'mastercard' => 'Mastercard',
'mspbanktransfer' => 'Bank transfer',
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -2,7 +2,7 @@
"name": "multisafepay/magento2msp",
"description": "MultiSafepay module for Magento2",
"type": "magento2-module",
"version": "1.14.0",
"version": "1.14.1",
"license": [
"OSL-3.0"
],
Expand Down
6 changes: 3 additions & 3 deletions etc/adminhtml/system.xml
Expand Up @@ -2,7 +2,7 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="multisafepay" translate="label" sortOrder="400">
<label>MultiSafepay (1.14.0)</label>
<label>MultiSafepay (1.14.1)</label>
</tab>
<section id="multisafepay" translate="label" type="text" sortOrder="400" showInDefault="1" showInWebsite="1" showInStore="1">
<class>separator-top</class>
Expand Down Expand Up @@ -1088,9 +1088,9 @@
</field>
</group>

<!--Start Klarna -->
<!--Start Klarna - buy now, pay later -->
<group id="klarnainvoice" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Klarna</label>
<label>Klarna - buy now, pay later</label>
<field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
Expand Down
9 changes: 5 additions & 4 deletions etc/config.xml
Expand Up @@ -228,10 +228,10 @@
<group>multisafepay_connect</group>
</einvoice>

<!-- Start Klarna -->
<!-- Start Klarna - buy now, pay later -->
<klarnainvoice>
<active>0</active>
<title>Klarna</title>
<title>Klarna - buy now, pay later</title>
<instructions></instructions>
<allowed_currency>EUR</allowed_currency>
<allowed_groups>0,1,2,3</allowed_groups>
Expand Down Expand Up @@ -673,6 +673,7 @@
<!-- Start Credit Card -->
<creditcard>
<active>0</active>
<creditcard_components_enabled>false</creditcard_components_enabled>
<title>Credit Card</title>
<instructions>Credit Card</instructions>
<allowed_currency>EUR</allowed_currency>
Expand Down Expand Up @@ -840,10 +841,10 @@
<group>multisafepay_connect</group>
</einvoice>

<!-- Start Klarna -->
<!-- Start Klarna - buy now, pay later -->
<klarnainvoice>
<active>0</active>
<title>Klarna</title>
<title>Klarna - buy now, pay later</title>
<instructions></instructions>
<allowed_currency>EUR</allowed_currency>
<allowed_groups>0,1,2,3</allowed_groups>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
@@ -1,6 +1,6 @@
<?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="MultiSafepay_Connect" setup_version="1.14.0">
<module name="MultiSafepay_Connect" setup_version="1.14.1">
<sequence>
<module name="Magento_Sales" />
</sequence>
Expand Down

0 comments on commit 9a4af77

Please sign in to comment.