diff --git a/FE/Currency.php b/FE/Currency.php
new file mode 100644
index 0000000..1203e92
--- /dev/null
+++ b/FE/Currency.php
@@ -0,0 +1,92 @@
+getComment()) {
+ * $html .= '
' . $element->getComment() . '
';
+ * }
+ * @return string|null
+ */
+ function getComment() {return !$this->hasKey() || $this->s()->isMerchantInUS() ?
+ ""
+ : (!$this->disabled() ? null :
+ __("The %1 Stripe accounts can only charge in %2.",
+ dftr($this->country(), ['BR' => __('Brazilian'), 'MX' => __('Mexican')])
+ ,df_currency_name($this->currency()
+ ))
+ )
+ ;}
+
+ /**
+ * 2017-10-15
+ * @override
+ * @see \Df\Directory\FE\Currency::getValue()
+ * @used-by \Df\Framework\Form\Element\Select2::setRenderer()
+ * @return string|null
+ */
+ function getValue() {return $this->disabled() ? $this->currency() : parent::getValue();}
+
+ /**
+ * 2017-10-15
+ * @override
+ * @see \Df\Framework\Form\Element\Select2::enabled()
+ * @used-by getValue()
+ * @used-by \Df\Framework\Form\Element\Select2::setRenderer()
+ * @return bool
+ */
+ final protected function disabled() {return in_array($this->country(), ['BR', 'MX']);}
+
+ /**
+ * 2017-10-15
+ * @used-by currency()
+ * @used-by disabled()
+ * @used-by getComment()
+ * @return string
+ */
+ private function country() {return dfc($this, function() {return !$this->hasKey() ? null :
+ $this->s()->merchantCountry()
+ ;});}
+
+ /**
+ * 2017-10-15
+ * @used-by getComment()
+ * @used-by getValue()
+ * @return string
+ */
+ private function currency() {return df_currency_by_country_c($this->country());}
+
+ /**
+ * 2017-10-15
+ * @used-by country()
+ * @used-by getComment()
+ * @return bool
+ */
+ private function hasKey() {return dfc($this, function() {return $this->s()->privateKey(null, false);});}
+
+ /**
+ * 2017-10-15
+ * @used-by country()
+ * @used-by getComment()
+ * @used-by hasKey()
+ * @return S $s
+ */
+ private function s() {return dfc($this, function() {return dfps($this);});}
+}
\ No newline at end of file
diff --git a/Method.php b/Method.php
index ee4a64f..8124c06 100644
--- a/Method.php
+++ b/Method.php
@@ -24,8 +24,7 @@ function canCapturePartial() {return true;}
* @used-by \Dfe\Stripe\Currency::_iso3()
* @return string|null
*/
- function cardType() {return dfc($this, function() {
- /** @var string $r */
+ function cardType() {return dfc($this, function() {/** @var string $r */
if (!($r = $this->iia(self::$II_CARD_TYPE))) {
/**
* 2017-10-12
diff --git a/Settings.php b/Settings.php
index bb63d85..989e197 100644
--- a/Settings.php
+++ b/Settings.php
@@ -18,7 +18,15 @@ function init() {\Stripe\Stripe::setApiKey($this->privateKey());}
* @used-by \Dfe\Stripe\Method::minimumAmount()
* @return bool
*/
- function isMerchantInUS() {return 'US' === $this->account()->{'country'};}
+ function isMerchantInUS() {return 'US' === $this->merchantCountry();}
+
+ /**
+ * 2017-10-15
+ * @used-by isMerchantInUS()
+ * @used-by \Dfe\Stripe\FE\Currency::country()
+ * @return string
+ */
+ function merchantCountry() {return $this->account()->{'country'};}
/**
* 2016-03-08 https://stripe.com/docs/api/php#retrieve_account
diff --git a/composer.json b/composer.json
index 0369a39..4aaf3ea 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
"name": "mage2pro/stripe"
- ,"version": "2.0.0"
+ ,"version": "2.1.0"
,"description": "The «Stripe» payment extension for Magento 2."
,"type": "magento2-module"
,"homepage": "https://mage2.pro/c/extensions/stripe"
@@ -11,7 +11,7 @@
"homepage": "https://mage2.pro/users/dmitry_fedyuk",
"role": "Developer"
}]
- ,"require": {"mage2pro/core": ">=3.2.0", "stripe/stripe-php": "3.*"}
+ ,"require": {"mage2pro/core": ">=3.2.2", "stripe/stripe-php": "3.*"}
,"autoload": {"files": ["registration.php"], "psr-4": {"Dfe\\Stripe\\": ""}}
,"keywords": [
"API"
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index c4021aa..20772a0 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -145,10 +145,8 @@
showInDefault='1' showInStore='1' showInWebsite='1'
sortOrder='10'
translate='label'
- type='Df\Directory\FormElement\Currency'
+ type='Dfe\Stripe\FE\Currency'
>
- The JCB, Discover, and Diners Club bank cards are always charged in USD (Stripe does not support other currencies for them).
-]]>
1