Skip to content

Commit

Permalink
Merge pull request #559 from ebanx/staging/v1.18.0
Browse files Browse the repository at this point in the history
Staging/v1.18.0
  • Loading branch information
Anderson Campanha authored Aug 14, 2017
2 parents 3b2184f + 61b4f2d commit 03bcca1
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'))) {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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."

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down
10 changes: 8 additions & 2 deletions woocommerce-gateway-ebanx/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
23 changes: 23 additions & 0 deletions woocommerce-gateway-ebanx/services/class-wc-ebanx-cancel-order.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

if (!defined('ABSPATH')) {
exit;
}

class WC_EBANX_Cancel_Order {
public static function add_my_account_cancel_order_action( $actions, $order ) {
if ($order->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();
}
}
14 changes: 14 additions & 0 deletions woocommerce-gateway-ebanx/services/class-wc-ebanx-constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<div class="ebanx-one-click-cvv">
<label><?php _e('Card Code', 'woocommerce-gateway-ebanx') ?></label>
<input type="text" maxlength="4" minlength="3" class="ebanx-one-click-cvv-input input-text" id="ebanx-one-click-cvv-input" name="ebanx-one-click-cvv" placeholder="CVV" required>
<input type="text" maxlength="4" minlength="3" autocomplete="off" class="ebanx-one-click-cvv-input input-text" id="ebanx-one-click-cvv-input" name="ebanx-one-click-cvv" placeholder="CVV" required>
</div>

<div class="ebanx-one-click-installments">
Expand Down
5 changes: 4 additions & 1 deletion woocommerce-gateway-ebanx/woocommerce-gateway-ebanx.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Offer Latin American local payment methods & increase your conversion rates with the solution used by AliExpress, AirBnB and Spotify in Brazil.
* Author: EBANX
* Author URI: https://www.ebanx.com/business/en
* Version: 1.17.1
* Version: 1.18.0
* License: MIT
* Text Domain: woocommerce-gateway-ebanx
* Domain Path: /languages
Expand Down Expand Up @@ -137,6 +137,7 @@ private function __construct()
*/
add_filter('woocommerce_payment_gateways', array($this, 'add_gateway'));
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links'));
add_filter('woocommerce_my_account_my_orders_actions', array(WC_EBANX_Cancel_Order::class, 'add_my_account_cancel_order_action'), 10, 2);
}

/**
Expand Down Expand Up @@ -212,6 +213,7 @@ public function ebanx_router() {

$ebanx_router->map('dashboard-check', array($api_controller, 'dashboard_check'));
$ebanx_router->map('order-received', array($api_controller, 'order_received'));
$ebanx_router->map('cancel-order', array($api_controller, 'cancel_order'));

$ebanx_router->serve();
}
Expand Down Expand Up @@ -464,6 +466,7 @@ private function includes()
include_once WC_EBANX_SERVICES_DIR . 'class-wc-ebanx-assets.php';
include_once WC_EBANX_SERVICES_DIR . 'class-wc-ebanx-query-router.php';
include_once WC_EBANX_SERVICES_DIR . 'class-wc-ebanx-third-party-compability-layer.php';
include_once WC_EBANX_SERVICES_DIR . 'class-wc-ebanx-cancel-order.php';

// Gateways
include_once WC_EBANX_GATEWAYS_DIR . 'class-wc-ebanx-gateway.php';
Expand Down

0 comments on commit 03bcca1

Please sign in to comment.