Skip to content

Commit

Permalink
Merge pull request #33 from OnTap/master
Browse files Browse the repository at this point in the history
Version 3.2.0
  • Loading branch information
ellenchristine authored Mar 18, 2022
2 parents 09ed766 + de0a6e1 commit 5594815
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 109 deletions.
59 changes: 59 additions & 0 deletions Block/Adminhtml/ColorPicker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* Copyright (c) 2022 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 Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;

class ColorPicker extends Field
{
/**
* @param AbstractElement $element
*
* @return string
*/
protected function _getElementHtml(AbstractElement $element)
{
$html = $element->getElementHtml();
$value = $element->getData('value');
$elementId = $element->getHtmlId();
$html .= '<script type="text/javascript">
require(["jquery", "tinycolor"], function($) {
$(document).ready(function(e) {
$("#' . $elementId . '").css("color", "#ffffff");
$("#' . $elementId . '").css("background-color", "' . $value . '");
$("#' . $elementId . '").colpick({
layout: "hex",
submit: 0,
color: "' . $value . '",
onChange: function(hsb, hex, rgb, el, bySetColor) {
$(el).css("background-color", "#" + hex);
if (!bySetColor) {
$(el).val("#" + hex);
}
}
}).keyup(function() {
$(this).colpickSetColor(this.value);
});
});
});
</script>';

return $html;
}
}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog
All notable changes to this project will be documented in this file.

## [3.2.0] - 2022-03-11
### Changed
- Installation instructions in the README.md file were updated
- Color selector for Pay Button on the module Configuration page


## [3.1.1] - 2022-01-04
### Fixed
- Installation instructions in the README.md file were updated
Expand Down
29 changes: 16 additions & 13 deletions Ui/ConfigProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013-2021 Mastercard
* Copyright (c) 2013-2022 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 @@ -35,6 +35,7 @@ class ConfigProvider implements ConfigProviderInterface
const IS_MODAL = 'is_modal';
const REDIRECT_URL = 'redirect_url';
const VAULT_CODE = 'vault_code';
const BUTTON_COLOR = 'button_color';

/**
* @var ConfigInterface
Expand All @@ -53,6 +54,7 @@ class ConfigProvider implements ConfigProviderInterface

/**
* ConfigProvider constructor.
*
* @param ConfigInterface $config
* @param UrlInterface $urlBuilder
* @param ConfigInterface $embeddedConfig
Expand All @@ -62,8 +64,8 @@ public function __construct(
UrlInterface $urlBuilder,
ConfigInterface $embeddedConfig
) {
$this->config = $config;
$this->urlBuilder = $urlBuilder;
$this->config = $config;
$this->urlBuilder = $urlBuilder;
$this->embeddedConfig = $embeddedConfig;
}

Expand All @@ -73,7 +75,7 @@ public function __construct(
protected function getPlaceOrderUrl()
{
return $this->urlBuilder->getUrl('mastercard/simplify/placeOrder', [
'_secure' => 1
'_secure' => 1,
]);
}

Expand All @@ -86,21 +88,22 @@ public function getConfig()
{
return [
'payment' => [
self::CODE => [
self::CODE => [
self::JS_COMPONENT => $this->config->getValue(self::JS_COMPONENT),
self::PUBLIC_KEY => $this->config->getValue(self::PUBLIC_KEY),
self::IS_MODAL => $this->config->getValue(self::PAYMENT_FORM_TYPE) == FormType::MODAL,
self::PUBLIC_KEY => $this->config->getValue(self::PUBLIC_KEY),
self::IS_MODAL => $this->config->getValue(self::PAYMENT_FORM_TYPE) == FormType::MODAL,
self::REDIRECT_URL => $this->getPlaceOrderUrl(),
self::VAULT_CODE => self::VAULT_PAYMENT_CODE,
self::VAULT_CODE => self::VAULT_PAYMENT_CODE,
],
self::EMBEDDED_CODE => [
self::JS_COMPONENT => $this->embeddedConfig->getValue(self::JS_COMPONENT),
self::PUBLIC_KEY => $this->embeddedConfig->getValue(self::PUBLIC_KEY),
self::IS_MODAL => $this->embeddedConfig->getValue(self::PAYMENT_FORM_TYPE) == FormType::MODAL,
self::PUBLIC_KEY => $this->embeddedConfig->getValue(self::PUBLIC_KEY),
self::IS_MODAL => $this->embeddedConfig->getValue(self::PAYMENT_FORM_TYPE) == FormType::MODAL,
self::REDIRECT_URL => $this->getPlaceOrderUrl(),
self::VAULT_CODE => self::VAULT_EMBEDDED_PAYMENT_CODE,
]
]
self::VAULT_CODE => self::VAULT_EMBEDDED_PAYMENT_CODE,
self::BUTTON_COLOR => $this->embeddedConfig->getValue(self::BUTTON_COLOR),
],
],
];
}
}
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "mastercard/module-simplifycommerce",
"version": "3.1.1",
"description": "Mastercard Simplify Commerce",
"license": "proprietary",
"version": "3.2.0",
"description": "Mastercard Payment Gateway Services - Simplify",
"license": "Apache-2.0",
"authors": [
{
"name": "Tomasz Waraksa",
Expand All @@ -14,7 +14,7 @@
}
],
"require": {
"magento/framework": "^101.0.0|^102.0.0|^103.0.0|^104.0.0"
"magento/framework": "^101.0.0|^102.0.0|^103.0.0"
},
"type": "magento2-module",
"autoload": {
Expand Down
5 changes: 5 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/simplifycommerce_embedded_vault/active</config_path>
</field>
<field id="button_color" translate="label" type="text" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Hosted Payments Button Color</label>
<config_path>payment/simplifycommerce_embedded/button_color</config_path>
<frontend_model>MasterCard\SimplifyCommerce\Block\Adminhtml\ColorPicker</frontend_model>
</field>
</group>
</group>
</section>
Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<can_use_internal>0</can_use_internal>
<privateInfoKeys />
<paymentInfoKeys>last4,type,expMonth,expYear,source,paymentStatus</paymentInfoKeys>
<button_color>#1979c3</button_color>
</simplifycommerce_embedded>
<simplifycommerce_vault>
<model>SimplifyVaultFacade</model>
Expand Down
2 changes: 1 addition & 1 deletion lib/SimplifyAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct($publicKey, $privateKey)

Simplify::$publicKey = $publicKey;
Simplify::$privateKey = $privateKey;
Simplify::$userAgent = 'Magento-3.1.1';
Simplify::$userAgent = 'Magento-3.2.0';
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2020 Mastercard
* Copyright (c) 2013-2022 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2021 Mastercard
* Copyright (c) 2013-2022 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 @@ -194,5 +194,17 @@ define([
isVaultEnabled: function () {
return this.vaultEnabler.isVaultEnabled();
},

/**
* @returns {String}
*/
getButtonColor: function () {
var config, buttonColor;

config = window.checkoutConfig["payment"][this.getCode()] || {};
buttonColor = config["button_color"] || null;

return buttonColor;
}
});
});
Loading

0 comments on commit 5594815

Please sign in to comment.