diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d8df192..05eceafd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +# 1.18.0 +* Feature - Filter to change amount per gateway [#555](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/555) +* Feature - Added "Cancel Order" button on "My Account" page [#556](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/556) +* Fix - Removed autocomplete from cvv field on on-click payment [#557](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/557) +* Fix - Correctly saves Credit Card when creating account [#558](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/558) + # 1.17.1 * Fix - Removed unused include [#554](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/554) diff --git a/woocommerce-gateway-ebanx/controllers/class-wc-ebanx-api-controller.php b/woocommerce-gateway-ebanx/controllers/class-wc-ebanx-api-controller.php index 219747fe..482281a7 100644 --- a/woocommerce-gateway-ebanx/controllers/class-wc-ebanx-api-controller.php +++ b/woocommerce-gateway-ebanx/controllers/class-wc-ebanx-api-controller.php @@ -28,6 +28,52 @@ public function dashboard_check() { )); } + /** + * Cancels an open cash payment order with "On hold" status + * + * @return void + */ + public function cancel_order($order_id, $user_id) { + $order = new WC_Order( $order_id ); + if ($user_id != get_current_user_id() + || $order->get_status() !== 'on-hold' + || !in_array($order->get_payment_method(), WC_EBANX_Constants::$CASH_PAYMENTS_GATEWAYS_CODE) + ) { + wp_redirect( get_site_url() ); + return; + } + + $data = array( + 'hash' => get_post_meta($order_id, '_ebanx_payment_hash', true) + ); + + \Ebanx\Config::set(array( + 'integrationKey' => $this->get_integration_key(), + 'testMode' => $this->is_sandbox(), + )); + + try { + $request = \Ebanx\EBANX::doCancel($data); + + if ($request->status === 'SUCCESS') { + $order->update_status('cancelled', __('EBANX: Cancelled by customer', 'woocommerce-gateway-ebanx')); + } + + wp_redirect($order->get_view_order_url()); + + } catch (Exception $e) { + $message = $e->getMessage(); + WC_EBANX::log("EBANX Error: $message"); + + wc_add_notice($message, 'error'); + wp_redirect( get_site_url() ); + } + } + + private function get_integration_key() { + return $this->is_sandbox() ? $this->config->settings['sandbox_private_key'] : $this->config->settings['live_private_key']; + } + /** * Gets the banking ticket HTML by cUrl with url fopen fallback * @@ -69,4 +115,13 @@ public function order_received($hash, $payment_type) { curl_close($curl); echo $html; } + + /** + * @param $configs + * + * @return bool + */ + private function is_sandbox() { + return $this->config->settings['sandbox_mode_enabled'] === 'yes'; + } } diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-gateway.php index 8945ba5c..7eaeed03 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-gateway.php @@ -264,6 +264,10 @@ protected function save_user_meta_fields($order) { parent::save_user_meta_fields($order); + if ( ! $this->userId ) { + $this->userId = $order->user_id; + } + if ( ! $this->userId || $this->get_setting_or_default('save_card_data', 'no') !== 'yes' || ! WC_EBANX_Request::has('ebanx-save-credit-card') diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php index c757a115..f03cf35d 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php @@ -1148,6 +1148,8 @@ public function checkout_rate_conversion($currency, $template = true, $country = $amount = WC()->cart->total; + $amount = apply_filters('ebanx_get_custom_total_amount', $amount, $instalments); + $order_id = null; if (!empty(get_query_var('order-pay'))) { diff --git a/woocommerce-gateway-ebanx/languages/woocommerce-gateway-ebanx-pt_BR.mo b/woocommerce-gateway-ebanx/languages/woocommerce-gateway-ebanx-pt_BR.mo index 1398f3de..1b0ba669 100644 Binary files a/woocommerce-gateway-ebanx/languages/woocommerce-gateway-ebanx-pt_BR.mo and b/woocommerce-gateway-ebanx/languages/woocommerce-gateway-ebanx-pt_BR.mo differ diff --git a/woocommerce-gateway-ebanx/languages/woocommerce-gateway-ebanx-pt_BR.po b/woocommerce-gateway-ebanx/languages/woocommerce-gateway-ebanx-pt_BR.po index 26e53411..c0993a9b 100644 --- a/woocommerce-gateway-ebanx/languages/woocommerce-gateway-ebanx-pt_BR.po +++ b/woocommerce-gateway-ebanx/languages/woocommerce-gateway-ebanx-pt_BR.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: \n" -"POT-Creation-Date: 2017-08-04 13:17-0300\n" -"PO-Revision-Date: 2017-08-04 16:29-0300\n" +"POT-Creation-Date: 2017-08-08 18:51-0300\n" +"PO-Revision-Date: 2017-08-08 18:52-0300\n" "Last-Translator: \n" "Language-Team: EBANX\n" "Language: pt_BR\n" @@ -557,6 +557,10 @@ msgstr "" "caixa não irá refletir para seu cliente. Contate seu Administrador de Conta " "do EBANX ou Business Development Expert." +#: services/class-wc-ebanx-cancel-order.php:15 +msgid "Cancel" +msgstr "Cancelar" + #: services/class-wc-ebanx-checker.php:20 msgid "" "EBANX - The Sandbox Mode option is enabled, in this mode, none of your " @@ -655,7 +659,7 @@ msgstr "" msgid "View Banking Ticket" msgstr "Ver Boleto" -#: services/class-wc-ebanx-one-click.php:143 +#: services/class-wc-ebanx-one-click.php:142 msgid "EBANX: Unable to create the payment via one click." msgstr "EBANX: Incapaz de criar o pagamento via um clique." @@ -757,9 +761,10 @@ msgstr "Endereço" msgid "Town / City" msgstr "Cidade" -#: templates/compliance-fields-br.php:32 templates/compliance-fields-cl.php:32 +#: templates/compliance-fields-br.php:65 templates/compliance-fields-cl.php:32 #: templates/compliance-fields-co.php:27 templates/compliance-fields-mx.php:22 -#: templates/compliance-fields-pe.php:22 +#: templates/compliance-fields-mx.php:58 templates/compliance-fields-pe.php:22 +#: templates/compliance-fields-pe.php:58 msgid "State / County" msgstr "Estado" @@ -841,7 +846,7 @@ msgstr "Processando..." msgid "Pay Now" msgstr "Pagar" -#: templates/payment-by-link-action.php:6 woocommerce-gateway-ebanx.php:645 +#: templates/payment-by-link-action.php:6 woocommerce-gateway-ebanx.php:649 msgid "Create EBANX Payment Link" msgstr "Criar Link de Pagamento EBANX" @@ -870,7 +875,7 @@ msgstr "Pagamento realizado com sucesso usando Servipag.." msgid "Currency %s is not supported. Works only with Brazilian Real." msgstr "A moeda %s não é suportada. Funciona apenas como Real Brasileiro." -#: woocommerce-gateway-ebanx.php:578 +#: woocommerce-gateway-ebanx.php:582 msgid "Settings" msgstr "Configurações" diff --git a/woocommerce-gateway-ebanx/readme.txt b/woocommerce-gateway-ebanx/readme.txt index 885bdbd3..3aed61da 100644 --- a/woocommerce-gateway-ebanx/readme.txt +++ b/woocommerce-gateway-ebanx/readme.txt @@ -3,7 +3,7 @@ Contributors: ebanxwp Tags: credit card, boleto, ebanx, woocommerce, approval rate, conversion rate, brazil, mexico, peru, colombia, chile, oxxo, baloto, cash payment, local payment one-click payment, installments, alternative payments, accept more payments Requires at least: 4.0 Tested up to: 4.7 -Stable tag: 1.17.1 +Stable tag: 1.18.0 License: Apache v2.0 License URI: http://www.apache.org/licenses/LICENSE-2.0 @@ -136,8 +136,14 @@ Yes, you can. == Changelog == += 1.18.0 = +* Feature - Filter to change amount per gateway [#555](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/555) +* Feature - Added "Cancel Order" button on "My Account" page [#556](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/556) +* Fix - Removed autocomplete from cvv field on on-click payment [#557](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/557) +* Fix - Correctly saves Credit Card when creating account [#558](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/558) + = 1.17.1 = -* Fix - Removed unused include [554](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/554) +* Fix - Removed unused include [#554](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/554) = 1.17.0 = * Feature - New Thank You pages for Credit Card and Boleto [#544](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/544) diff --git a/woocommerce-gateway-ebanx/services/class-wc-ebanx-cancel-order.php b/woocommerce-gateway-ebanx/services/class-wc-ebanx-cancel-order.php new file mode 100644 index 00000000..369cb6b9 --- /dev/null +++ b/woocommerce-gateway-ebanx/services/class-wc-ebanx-cancel-order.php @@ -0,0 +1,23 @@ +get_status() !== 'on-hold' || !in_array($order->get_payment_method(), WC_EBANX_Constants::$CASH_PAYMENTS_GATEWAYS_CODE)) { + return $actions; + } + + $actions['cancel'] = array( + 'url' => self::get_cancel_button_url($order), + 'name' => __('Cancel', 'woocommerce-gateway-ebanx'), + ); + return $actions; + } + + private static function get_cancel_button_url($order) { + return get_site_url() . '?ebanx=cancel-order&user_id=' . $order->get_user_id() . '&order_id=' . $order->get_id(); + } +} diff --git a/woocommerce-gateway-ebanx/services/class-wc-ebanx-constants.php b/woocommerce-gateway-ebanx/services/class-wc-ebanx-constants.php index b3712301..03aada4b 100644 --- a/woocommerce-gateway-ebanx/services/class-wc-ebanx-constants.php +++ b/woocommerce-gateway-ebanx/services/class-wc-ebanx-constants.php @@ -138,6 +138,20 @@ abstract class WC_EBANX_Constants 'baloto' => 'America/Bogota', ); + /** + * The cash payments processed by EBANX + * + * @var array + */ + public static $CASH_PAYMENTS_GATEWAYS_CODE = array( + 'ebanx-banking-ticket', + 'ebanx-oxxo', + 'ebanx-pagoefectivo', + 'ebanx-sencillito', + 'ebanx-safetypay-cash', + 'ebanx-baloto', + ); + /** * The banks that EBANX process in Brazil * diff --git a/woocommerce-gateway-ebanx/templates/one-click/one-click.php b/woocommerce-gateway-ebanx/templates/one-click/one-click.php index 99c3bf0e..8da4e4fe 100644 --- a/woocommerce-gateway-ebanx/templates/one-click/one-click.php +++ b/woocommerce-gateway-ebanx/templates/one-click/one-click.php @@ -37,7 +37,7 @@