-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #423 from omise/release-v3.0.0
Release v3.0.0
- Loading branch information
Showing
39 changed files
with
1,531 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
name: Magento Coding Standard | ||
on: | ||
pull_request: | ||
branches: [ master ] | ||
push: | ||
|
||
jobs: | ||
static: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name: Deploy to Staging | ||
on: | ||
push: | ||
branches: [ 'master' ] | ||
branches: [ 'develop' ] | ||
|
||
jobs: | ||
static: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
Block/Adminhtml/System/Config/CardFormCustomization/FormModal.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<?php | ||
|
||
namespace Omise\Payment\Block\Adminhtml\System\Config\CardFormCustomization; | ||
|
||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Config\Block\System\Config\Form\Field; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
use Magento\Framework\App\Request\Http; | ||
use Magento\Framework\Filesystem\Driver\File; | ||
|
||
class FormModal extends Field | ||
{ | ||
public $request; | ||
public $storeManager; | ||
public $localFileSystem; | ||
public $theme; | ||
|
||
/** | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Store\Model\StoreManagerInterface $storeManager | ||
* @param \Magento\Framework\App\Request\Http $http | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
StoreManagerInterface $storeManager, | ||
Http $request, | ||
array $data = [] | ||
) { | ||
$this->storeManager = $storeManager; | ||
$this->request = $request; | ||
$this->localFileSystem = new File(); | ||
$this->theme = new Theme(); | ||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* get css | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @return string | ||
*/ | ||
public function getCss(AbstractElement $element) | ||
{ | ||
return $this->localFileSystem->fileGetContents(__DIR__ . '/css/style.css'); | ||
} | ||
|
||
/** | ||
* get javascript | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @return string | ||
*/ | ||
public function getScript(AbstractElement $element) | ||
{ | ||
$script = $this->addGlobalJsVariables([ | ||
'OMISE_CC_INPUT_ID' => $element->getId(), | ||
'OMISE_CC_DESIGN' => $element->getData('value'), | ||
'OMISE_CC_LIGHT_THEME' => json_encode($this->theme->getLightTheme()), | ||
'OMISE_CC_DARK_THEME' => json_encode($this->theme->getDarkTheme()), | ||
'OMISE_CC_INPUT_INHERIT_VALUE' => $element->getInherit(), | ||
'OMISE_CC_INPUT_INHERIT_LABEL' => $this->_getInheritCheckboxLabel($element), | ||
'OMISE_CC_INPUT_INHERIT_SHOULD_SHOW' => $this->_isInheritCheckboxRequired($element), | ||
]); | ||
|
||
$script .= $this->localFileSystem->fileGetContents(__DIR__ . '/js/script.js'); | ||
return $script; | ||
} | ||
|
||
/** | ||
* add global javascript variables | ||
* | ||
* @param Array | ||
*/ | ||
private function addGlobalJsVariables($array) | ||
{ | ||
$script = ''; | ||
foreach ($array as $key => $value) { | ||
$script .= sprintf('window.%s = `%s`;', $key, $value); | ||
} | ||
return $script; | ||
} | ||
|
||
/** | ||
* get inherit input name (use website checkbox) | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
*/ | ||
protected function getInheritCheckboxName($element) | ||
{ | ||
$namePrefix = preg_replace('#\[value\](\[\])?$#', '', $element->getName()); | ||
return $namePrefix . '[inherit]'; | ||
} | ||
|
||
/** | ||
* get HTML | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @return string | ||
*/ | ||
public function getHtml(AbstractElement $element) | ||
{ | ||
$isCheckboxRequired = $this->_isInheritCheckboxRequired($element); | ||
$value = $element->getData('value'); | ||
$id = $element->getId(); | ||
$name = $element->getName(); | ||
$html = sprintf( | ||
"<input id='%s' name='%s' value='%s' type='hidden'>", | ||
$id, | ||
$name, | ||
$value | ||
); | ||
if ($isCheckboxRequired) { | ||
$html .= sprintf( | ||
"<input id='%s' name='%s' value='%s' type='hidden'>", | ||
$id . '_inherit', | ||
$this->getInheritCheckboxName($element), | ||
$element->getInherit() | ||
); | ||
} | ||
$html .= $this->localFileSystem->fileGetContents(__DIR__ . '/form-modal.html'); | ||
return $html; | ||
} | ||
|
||
/** | ||
* render HTML markup for given element | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @return string | ||
*/ | ||
public function render(AbstractElement $element) | ||
{ | ||
$html = '<style>' . $this->getCss($element) . '</style>'; | ||
$html .= $this->getHtml($element); | ||
$html .= '<script>' . $this->getScript($element) . '</script>'; | ||
return $html; | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
Block/Adminhtml/System/Config/CardFormCustomization/SecureFormBannerMessage.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
namespace Omise\Payment\Block\Adminhtml\System\Config\CardFormCustomization; | ||
|
||
use Magento\Framework\Notification\MessageInterface; | ||
use Omise\Payment\Model\Config\Cc as OmiseCcConfig; | ||
|
||
class SecureFormBannerMessage implements MessageInterface | ||
{ | ||
|
||
/** | ||
* @var \Omise\Payment\Model\Config\Cc | ||
*/ | ||
protected $omiseCcConfig; | ||
|
||
/** | ||
* @var Omise\Payment\Model\Customer | ||
*/ | ||
protected $customer; | ||
|
||
public function __construct( | ||
OmiseCcConfig $omiseCcConfig | ||
) { | ||
$this->omiseCcConfig = $omiseCcConfig; | ||
} | ||
|
||
/** | ||
* Retrieve unique system message identity | ||
* | ||
* @return string | ||
*/ | ||
public function getIdentity() | ||
{ | ||
return 'opn_payments_secure_form_message'; | ||
} | ||
|
||
/** | ||
* Whether the system message should be shown | ||
* | ||
* @return bool | ||
*/ | ||
public function isDisplayed() | ||
{ | ||
$secureForm = $this->omiseCcConfig->getSecureForm(); | ||
return $secureForm == 'yes' ? false : true; | ||
} | ||
|
||
/** | ||
* Retrieve system message text | ||
* | ||
* @return \Magento\Framework\Phrase | ||
*/ | ||
public function getText() | ||
{ | ||
$defaultMessage = "<b>Opn Payments</b> : Update your plugin to the latest version to enable | ||
Secure Form and maximize the security of your customers’ information. | ||
You will need to re-customize the credit card checkout form after the upgrade. | ||
<a target='blank' href='https://www.omise.co/magento-plugin'> | ||
Learn how to enable Secure Form.</a>"; | ||
|
||
return $this->localize('secure_form_banner_message', $defaultMessage); | ||
} | ||
|
||
/** | ||
* Retrieve system message severity | ||
* | ||
* @return int | ||
*/ | ||
public function getSeverity() | ||
{ | ||
return self::SEVERITY_CRITICAL; | ||
} | ||
|
||
/** | ||
* localize using translation key | ||
* | ||
* @param string $key | ||
* @param string $default | ||
* @return string | ||
*/ | ||
public function localize($key, $default) | ||
{ | ||
$result = __($key); | ||
return $result == $key ? $default : $result; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
Block/Adminhtml/System/Config/CardFormCustomization/Theme.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace Omise\Payment\Block\Adminhtml\System\Config\CardFormCustomization; | ||
|
||
class Theme | ||
{ | ||
public function getFormDesign($theme, $customDesign) | ||
{ | ||
if (!empty($customDesign)) { | ||
$result = json_decode($customDesign, true); | ||
if (!$result) { | ||
return $this->getDefaultFormDesign($theme); | ||
} | ||
return $result; | ||
} | ||
return $this->getDefaultFormDesign($theme); | ||
} | ||
|
||
public function getDefaultFormDesign($theme) | ||
{ | ||
return (empty($theme) || $theme == 'light') | ||
? $this->getLightTheme() | ||
: $this->getDarkTheme(); | ||
} | ||
|
||
public function getLightTheme() | ||
{ | ||
return [ | ||
'font' => [ | ||
'name' => 'Poppins', | ||
'size' => 16, | ||
], | ||
'input' => [ | ||
'height' => '44px', | ||
'border_radius' => '4px', | ||
'border_color' => '#ced3de', | ||
'active_border_color' => '#1451cc', | ||
'background_color' => '#ffffff', | ||
'label_color' => '#212121', | ||
'text_color' => '#212121', | ||
'placeholder_color' => '#98a1b2', | ||
], | ||
'checkbox' => [ | ||
'text_color' => '#1c2433', | ||
'theme_color' => '#1451cc', | ||
] | ||
]; | ||
} | ||
|
||
public function getDarkTheme() | ||
{ | ||
return [ | ||
'font' => [ | ||
'name' => 'Poppins', | ||
'size' => 16, | ||
], | ||
'input' => [ | ||
'height' => '44px', | ||
'border_radius' => '4px', | ||
'border_color' => '#475266', | ||
'active_border_color' => '#475266', | ||
'background_color' => '#131926', | ||
'label_color' => '#E6EAF2', | ||
'text_color' => '#ffffff', | ||
'placeholder_color' => '#DBDBDB', | ||
], | ||
'checkbox' => [ | ||
'text_color' => '#E6EAF2', | ||
'theme_color' => '#1451CC', | ||
] | ||
]; | ||
} | ||
} |
Oops, something went wrong.