Skip to content

Commit

Permalink
Merge pull request #27 from OnTap/master
Browse files Browse the repository at this point in the history
## [3.1.0] - 2021-10-19
### Changed
- Add Embedded Payment Option
- Add configs for automated testing
- Add compatibility with Magento 2.4
- Branding Update

### Fixed
- Simplify JS is not included into csp_whitelist.xml file
- Shopping Cart is not emptied correctly after order is successfully created
- JS is broken after bundling
  • Loading branch information
JohnbConneely authored Nov 9, 2021
2 parents bd49969 + 9c9aa28 commit 1daecf0
Show file tree
Hide file tree
Showing 65 changed files with 1,665 additions and 762 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitlab-ci.yml export-ignore
Makefile export-ignore
sonar-project.properties export-ignore
* -crlf
114 changes: 114 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
stages:
- test
- deploy

variables:
COMPOSER_MIRROR_PATH_REPOS: 1
COMPOSER_ALLOW_SUPERUSER: 1
COMPOSER_MEMORY_LIMIT: -1
COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/.cache/composer"

deploy-to-uat:
image: gitlab.extensions.ontap.cloud:5050/mpgs/docker-ontap-php:7.4-2
stage: deploy
script:
- curl -v -X POST -F "token=$PIPELINE_TOKEN" -F ref=master -F "variables[EXTENSION]=$PLAYBOOK" "$TRIGGER_URL"
only:
refs:
- master

sonarqube-check:
stage: test
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner
allow_failure: true
only:
- merge_requests

.magento:build: &magento-build
before_script:
- mkdir -p _build
- ln -s /magento _build/magento
- git clone . _build/module
- (cd _build/module && git checkout -b build && sed -i '/"version"/d' composer.json && cat composer.json)
- cd _build/magento
- composer.phar config repositories.ontap composer https://packages.ontapgroup.com/
- composer.phar config repositories.modules path $CI_PROJECT_DIR/_build/module
- composer.phar config --unset repositories.0
- composer.phar config repo.packagist false
- composer.phar config minimum-stability dev
- composer.phar config prefer-stable true
- composer.phar require --no-suggest --dev --no-update ontap/ambassador:^1.2
- composer.phar require --no-suggest $MODULE_NAME:dev-build
- |
cat > $MODULE_DIR/Makefile <<- "EOF"
MOD_PATH = $(abspath ./../../ontap/ambassador)
BIN_PATH = $(abspath ./../../bin)
include $(MOD_PATH)/Makefile
EOF
magento-2.3.6:phpcs:
image: ontap/magento:2.3.6
stage: test
only:
- merge_requests
script:
- (cd $MODULE_DIR && make phpcs)
<<: *magento-build

magento-2.3.6:phpstan:
image: ontap/magento:2.3.6
stage: test
only:
- merge_requests
script:
- (cd $MODULE_DIR && make phpstan)
<<: *magento-build

magento-2.3.6:compile:
image: ontap/magento:2.3.6
stage: test
only:
- merge_requests
script:
- php bin/magento module:enable --all
- php -d memory_limit=1G bin/magento setup:di:compile --ansi --no-interaction
<<: *magento-build

magento-2.4.1:phpcs:
image: ontap/magento:2.4.1
stage: test
only:
- merge_requests
script:
- (cd $MODULE_DIR && make phpcs)
<<: *magento-build

magento-2.4.1:phpstan:
image: ontap/magento:2.4.1
stage: test
only:
- merge_requests
script:
- (cd $MODULE_DIR && make phpstan)
<<: *magento-build

magento-2.4.1:compile:
image: ontap/magento:2.4.1
stage: test
only:
- merge_requests
script:
- php bin/magento module:enable --all
- php -d memory_limit=1G bin/magento setup:di:compile --ansi --no-interaction
<<: *magento-build
114 changes: 114 additions & 0 deletions Block/Adminhtml/ModuleVersion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php
/**
* Copyright (c) 2021 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace MasterCard\SimplifyCommerce\Block\Adminhtml;

use Exception;
use Magento\Backend\Block\Context;
use Magento\Config\Block\System\Config\Form\Field\Heading;
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Component\ComponentRegistrarInterface;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Filesystem\Directory\ReadFactory;
use Zend_Json;

class ModuleVersion extends Heading
{
const CACHE_KEY = 'SIMPLIFYCOMMERCE_MODULE_VERSION';

/**
* @var ReadFactory
*/
protected $readFactory;

/**
* @var ComponentRegistrarInterface
*/
protected $componentRegistrar;

/**
* @var Context
*/
protected $context;

/**
* @param Context $context
* @param ComponentRegistrarInterface $componentRegistrar
* @param ReadFactory $readFactory
* @param array $data
*/
public function __construct(
Context $context,
ComponentRegistrarInterface $componentRegistrar,
ReadFactory $readFactory,
array $data = []
) {
parent::__construct($context, $data);
$this->context = $context;
$this->componentRegistrar = $componentRegistrar;
$this->readFactory = $readFactory;
}

/**
* @param string $moduleName
* @return string
*/
protected function getVersionInfo($moduleName): string
{
$cache = $this->context->getCache();
$version = $cache->load(self::CACHE_KEY);

if (!$version) {
$path = $this->componentRegistrar->getPath(
ComponentRegistrar::MODULE,
$moduleName
);

$dir = $this->readFactory->create($path);

try {
$jsonData = $dir->readFile('composer.json');
$data = Zend_Json::decode($jsonData);
} catch (Exception $e) {
$this->_logger->error('Module read error', [
'exception' => $e
]);
$data = [];
}

$version = $data['version'] ?? 'unknown';
$cache->save($version, self::CACHE_KEY);
}

return (string)__('Module version: %1', $version);
}

/**
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element): string
{
return sprintf(
'<tr class="system-fieldset-sub-head" id="row_%s">'
. '<td colspan="5"><div style="background-color:#fff;">%s</div></td>'
. '</tr>',
$element->getHtmlId(),
$this->getVersionInfo('MasterCard_SimplifyCommerce')
);
}
}
10 changes: 8 additions & 2 deletions Block/Customer/CardRenderer.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2020 Mastercard
* Copyright (c) 2013-2021 Mastercard
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -68,6 +68,12 @@ public function getIconWidth()
*/
public function canRender(PaymentTokenInterface $token)
{
return $token->getPaymentMethodCode() === ConfigProvider::CODE;
return in_array(
$token->getPaymentMethodCode(),
[
ConfigProvider::CODE,
ConfigProvider::EMBEDDED_CODE,
]
);
}
}
70 changes: 48 additions & 22 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,62 @@
## 3.0.4 (March 18, 2021)
Adding Magento 2.4 Support
Removed dependency from Zend_Json
Fixed CardTokenBuilder constructor php doc
Fixing crypt issue
# Changelog
All notable changes to this project will be documented in this file.

## 3.0.3 (September 10, 2020)
Changing terminology for payment actions to Authorization and Payment

Fix the loading with production mode
## [3.1.0] - 2021-10-19
### Changed
- Add Embedded Payment Option
- Add configs for automated testing
- Add compatibility with Magento 2.4
- Branding Update

## 3.0.2 (June 2, 2020)
This release has multiple bugfixes and adds some optimizations.
### Fixed
- Simplify JS is not included into csp_whitelist.xml file
- Shopping Cart is not emptied correctly after order is successfully created
- JS is broken after bundling

Optimizations:

JS component loading in checkout
## [3.0.4] - 2021-03-18
### Changed
- Adding Magento 2.4 Support
- Removed dependency from Zend_Json

Composer metadata
### Fixed
- Fixed CardTokenBuilder constructor php doc
- Fixing crypt issue

Fixes:

PHP autoloader issue when package not installed via composer (classmap missing)
## [3.0.3] - 2020-09-10
### Changed
- Changing terminology for payment actions to Authorization and Payment

Private content not correctly invalidated when checkout success page is requested
### Fixed
- Fix the loading with production mode

## 3.0.1 (November 6, 2019)
Fixing broken links in the plugin

## 3.0.0 (September 10, 2019)
This release makes the module compatible with Magento 2.2 and 2.3, we also added tokenization (Vault) support.
## [3.0.2] - 2020-06-02
### Changed
- Optimized JS component loading in checkout
- Composer metadata updates

### Fixed
- PHP autoloader issue when package not installed via composer (classmap missing)
- Private content not correctly invalidated when checkout success page is requested


## [3.0.1] - 2019-11-06
### Fixed
- Fixing broken links in the plugin


## [3.0.0] - 2019-09-10
### Changed
- This release makes the module compatible with Magento 2.2 and 2.3, we also added tokenization (Vault) support.
### Fixed


## [2.1.6] - 2017-02-23
### Changed
- Initial release of Simplify Commerce payment gateway for Magento 2

## 2.1.6 (February 23, 2017)
Initial release of Simplify Commerce payment gateway for Magento 2


Loading

0 comments on commit 1daecf0

Please sign in to comment.