Skip to content

Commit

Permalink
Merge pull request #522 from ebanx/release/v1.14.0
Browse files Browse the repository at this point in the history
Release/v1.14.0
  • Loading branch information
Cezar Luiz authored Jun 12, 2017
2 parents 5f93525 + e800849 commit e054e26
Show file tree
Hide file tree
Showing 6 changed files with 961 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

# 1.14.0
* Feature - Added EURO conversion [#520](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/520)
* Feature - Support for pt_PT translations [#521](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/521)

# 1.13.2
* Fix - Replaced wp_die to exit to avoid error 500 [#515](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/515)
* Fix - Updating order when it receives a payment status notification [#516](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/516)
Expand Down
27 changes: 13 additions & 14 deletions woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,16 +417,18 @@ public function process_refund($order_id, $amount = null, $reason = '')
* @return double
*/
public function get_local_currency_rate_for_site($local_currency_code) {
$site_currency = get_woocommerce_currency();

if ($site_currency === $local_currency_code) {
if ($this->merchant_currency === strtoupper($local_currency_code)) {
return 1;
}

$usd_to_site_rate = 1;
$converted_currencies = array(
WC_EBANX_Constants::CURRENCY_CODE_USD,
WC_EBANX_Constants::CURRENCY_CODE_EUR
);

if ($site_currency !== WC_EBANX_Constants::CURRENCY_CODE_USD) {
$usd_to_site_rate = $this->get_currency_rate($site_currency);
if ( ! in_array($this->merchant_currency, $converted_currencies) ) {
$usd_to_site_rate = $this->get_currency_rate($this->merchant_currency);
}

return $this->get_currency_rate($local_currency_code) / $usd_to_site_rate;
Expand All @@ -449,18 +451,18 @@ public function get_currency_rate($local_currency_code) {
$cached = get_option($cache_key);
if ($cached !== false) {
list($rate, $time) = explode('|', $cached);
if ($time == $cache_time) {
if ($time === $cache_time) {
return $rate;
}
}

$usd_to_local = \Ebanx\Ebanx::getExchange( array(
'currency_code' => WC_EBANX_Constants::CURRENCY_CODE_USD,
'currency_base_code' => $local_currency_code
) );
'currency_code' => $this->merchant_currency,
'currency_base_code' => $local_currency_code
) );

if (!isset($usd_to_local)
|| strtoupper(trim($usd_to_local->status)) !== "SUCCESS") {
|| strtoupper(trim($usd_to_local->status)) !== 'SUCCESS') {

return 1;
}
Expand Down Expand Up @@ -1035,10 +1037,7 @@ final public function process_refund_hook($order, $data) {
* @return void
*/
public function checkout_rate_conversion($currency, $template = true, $country = null, $instalments = null) {
if ( ! in_array($this->merchant_currency, array(
WC_EBANX_Constants::CURRENCY_CODE_USD,
WC_EBANX_Constants::CURRENCY_CODE_EUR,
WC_EBANX_Constants::CURRENCY_CODE_BRL) ) ){
if ( ! in_array($this->merchant_currency, WC_EBANX_Constants::$CURRENCIES_CODES_ALLOWED ) ) {
return;
}

Expand Down
Binary file not shown.
Loading

0 comments on commit e054e26

Please sign in to comment.