Skip to content
Merged

up #2

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7e90759
SUB-439: Rename
Feb 21, 2018
f59ed4c
SUB-439: Fix with phpcbf
Feb 21, 2018
edb08fe
SUB-439: Fix
Feb 21, 2018
6ea64d2
SUB-439:
Feb 22, 2018
96cc598
SUB-439:
Feb 26, 2018
2e64ffc
SUB-439:
Feb 27, 2018
694e072
SUB-439:
Feb 28, 2018
798355b
SUB-439:
Feb 28, 2018
984cdcd
SUB-439:
Feb 28, 2018
a65a32b
SUB-439: As a merchant I would like to use Stripe to process my payments
Mar 2, 2018
0a686eb
SUB-439: As a merchant I would like to use Stripe to process my payments
Mar 5, 2018
5ffb35c
SUB-439: As a merchant I would like to use Stripe to process my payments
Mar 6, 2018
db739a0
SUB-439
Mar 14, 2018
4cefdf1
SUB-439
Mar 15, 2018
3f9dd07
SUB-439
Mar 15, 2018
c1076dc
SUB-460
Mar 16, 2018
348e025
SUB-439:
kenboy Mar 20, 2018
6262bb2
SUB-439:
kenboy Mar 21, 2018
ccff634
SUB-439:
kenboy Mar 22, 2018
954ac9b
SUB-439:
kenboy Mar 23, 2018
bc4b601
SUB-478: Error after the module installation
kenboy Mar 30, 2018
ba60e13
SUB-478
kenboy Apr 2, 2018
7c86248
SUB-478: Error after the module installation
kenboy Apr 2, 2018
8804762
SUB-439: As a merchant I would like to use Stripe to process my payments
kenboy Apr 5, 2018
9292630
SUB-439: As a merchant I would like to use Stripe to process my payments
kenboy Apr 5, 2018
add7170
SUB-439: As a merchant I would like to use Stripe to process my payments
kenboy Apr 5, 2018
17d3e53
modman
eermolaev May 24, 2018
47fadb4
SUB-439: As a merchant I would like to use Stripe to process my payments
kenboy May 29, 2018
2f793b3
SUB-439: As a merchant I would like to use Stripe to process my payments
kenboy May 30, 2018
7a18100
SUB-439: As a merchant I would like to use Stripe to process my payments
kenboy May 30, 2018
e59a2e0
SUB-439: As a merchant I would like to use Stripe to process my payments
kenboy May 30, 2018
6a8de6d
SUB-439: As a merchant I would like to use Stripe to process my payments
kenboy Jun 4, 2018
eba977c
Merge pull request #1 from PowerSync/SUB-439
eermolaev Jun 8, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

63 changes: 0 additions & 63 deletions .travis/before_script.sh

This file was deleted.

58 changes: 58 additions & 0 deletions Block/Adminhtml/Form/Field/CcTypes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace TNW\Stripe\Block\Adminhtml\Form\Field;

use TNW\Stripe\Helper\CcType;
use Magento\Framework\View\Element\Context;
use Magento\Framework\View\Element\Html\Select;

/**
* Class CcTypes
*/
class CcTypes extends Select
{
/**
* @var CcType
*/
private $ccTypeHelper;

/**
* Constructor
*
* @param Context $context
* @param CcType $ccTypeHelper
* @param array $data
*/
public function __construct(
Context $context,
CcType $ccTypeHelper,
array $data = []
) {
$this->ccTypeHelper = $ccTypeHelper;

parent::__construct($context, $data);
}

/**
* @inheritdoc
*/
protected function _construct()
{
parent::_construct();

$this->setOptions($this->ccTypeHelper->getCcTypes())
->setClass('cc-type-select')
->setData('extra_params', 'multiple="multiple"');
}

/**
* Sets name for input element
*
* @param string $value
* @return $this
*/
public function setInputName($value)
{
return $this->setData('name', $value . '[]');
}
}
56 changes: 56 additions & 0 deletions Block/Adminhtml/Form/Field/Countries.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace TNW\Stripe\Block\Adminhtml\Form\Field;

use TNW\Stripe\Helper\Country;
use Magento\Framework\View\Element\Context;
use Magento\Framework\View\Element\Html\Select;

/**
* Class Countries
*/
class Countries extends Select
{
/**
* @var Country
*/
private $countryHelper;

/**
* Constructor
*
* @param Context $context
* @param Country $countryHelper
* @param array $data
*/
public function __construct(
Context $context,
Country $countryHelper,
array $data = []
) {
$this->countryHelper = $countryHelper;

parent::__construct($context, $data);
}

/**
* @inheritdoc
*/
protected function _construct()
{
parent::_construct();

$this->setOptions($this->countryHelper->getCountries());
}

/**
* Sets name for input element
*
* @param string $value
* @return $this
*/
public function setInputName($value)
{
return $this->setData('name', $value);
}
}
107 changes: 107 additions & 0 deletions Block/Adminhtml/Form/Field/CountryCreditCard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php

namespace TNW\Stripe\Block\Adminhtml\Form\Field;

use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;
use Magento\Framework\DataObject;

/**
* Class CountryCreditCard
*/
class CountryCreditCard extends AbstractFieldArray
{
/**
* @var Countries
*/
private $countryRenderer = null;

/**
* @var CcTypes
*/
private $ccTypesRenderer = null;

/**
* Returns renderer for country element
*
* @return Countries
* @throws \Magento\Framework\Exception\LocalizedException
*/
private function getCountryRenderer()
{
if (!$this->countryRenderer) {
$this->countryRenderer = $this->getLayout()->createBlock(
Countries::class,
'',
['data' => ['is_render_to_js_template' => true]]
);
}

return $this->countryRenderer;
}

/**
* Returns renderer for country element
*
* @return CcTypes
* @throws \Magento\Framework\Exception\LocalizedException
*/
private function getCcTypesRenderer()
{
if (!$this->ccTypesRenderer) {
$this->ccTypesRenderer = $this->getLayout()->createBlock(
CcTypes::class,
'',
['data' => ['is_render_to_js_template' => true]]
);
}

return $this->ccTypesRenderer;
}

/**
* Prepare to render
* @return void
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _prepareToRender()
{
$this->addColumn('country_id', [
'label' => __('Country'),
'renderer' => $this->getCountryRenderer(),
]);

$this->addColumn('cc_types', [
'label' => __('Allowed Credit Card Types'),
'renderer' => $this->getCcTypesRenderer(),
]);

$this->_addAfter = false;
$this->_addButtonLabel = __('Add Rule');
}

/**
* Prepare existing row data object
*
* @param DataObject $row
* @return void
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _prepareArrayRow(DataObject $row)
{
$options = [];

$country = $row->getData('country_id');
if ($country) {
$options['option_' . $this->getCountryRenderer()->calcOptionHash($country)]
= 'selected="selected"';

$ccTypes = $row->getData('cc_types');
foreach ($ccTypes as $cardType) {
$options['option_' . $this->getCcTypesRenderer()->calcOptionHash($cardType)]
= 'selected="selected"';
}
}

$row->setData('option_extra_attrs', $options);
}
}
34 changes: 34 additions & 0 deletions Block/Adminhtml/System/Config/Fieldset/Hint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* See LICENSE.txt for license details.
*/
namespace TNW\Stripe\Block\Adminhtml\System\Config\Fieldset;

use Magento\Backend\Block\Template;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Data\Form\Element\Renderer\RendererInterface;

/**
* Class Hint adds "Configuration Details" link to payment configuration.
* `<comment>` node must be defined in `<group>` node and contain some link.
*/
class Hint extends Template implements RendererInterface
{
/**
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
if (!$element->getData('comment')) {
return '';
}

return sprintf(
'<tr id="row_%s"><td colspan="1"><p class="note"><span><a href="%s" target="_blank">%s</a></span></p></td></tr>',
$element->getHtmlId(),
$element->getData('comment'),
__('Configuration Details')
);
}
}
Loading