Skip to content

Commit

Permalink
Merge pull request #386 from ebanx/release/v1.8.0
Browse files Browse the repository at this point in the history
Release/v1.8.0
  • Loading branch information
Cezar Luiz authored Mar 24, 2017
2 parents 52320dd + b1642c0 commit aceb879
Show file tree
Hide file tree
Showing 17 changed files with 382 additions and 27 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

# 1.8.0
* Feature - Hide irrelevant fields and group fields by country on EBANX Settings page [#373](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/373)
* Feature - Added new payment gateway Baloto (Colombia) [#371](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/371)
* Feature - Hide the payment gateways on checkout page when sandbox mode is enabled for non admin users and not logged users [#380](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/380)
* Feature - A warning was added when sandbox mode is enabled [#378](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/378)
* Feature - Added asterisk to required compliance fields on checkout page [#370](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/370)

## 1.7.1
* Fix - Fixed Oxxo and Pagoefectivo iframe not showing [#382](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/382)

Expand All @@ -10,7 +17,7 @@
* Fix - Fixed the low resolution of the EBANX badge on non-retina displays [#354](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/354)
* Fix - Prevent fatal error when the plugin is activated without WooCommerce plugin [#360](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/360)
* Fix - Avoid SSL warning from EBANX PHP libray when the plugin make a request to URLs with a bad SSL certificate [#362](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/362)
* Fix - Fix - Resolves fatal error when the plugin can't get some informations [#365](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/365)
* Fix - Resolves fatal error when the plugin can't get some informations [#365](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/365)

## 1.6.1
* Fix - Address splitting function to avoid mistakes during checkout [#352](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/352)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 38 additions & 4 deletions woocommerce-gateway-ebanx/assets/js/advanced-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
var modesField = $('#woocommerce_ebanx-global_brazil_taxes_options');
var fields = $('.ebanx-checkout-manager-field');
var fieldsToggler = $('#woocommerce_ebanx-global_checkout_manager_enabled');
var fieldBrazilTaxes = $('.brazil-taxes');
var countryPayments = {
brazil: $('#woocommerce_ebanx-global_brazil_payment_methods'),
chile: $('#woocommerce_ebanx-global_chile_payment_methods'),
colombia: $('#woocommerce_ebanx-global_colombia_payment_methods')
};


var disableFields = function(jqElementList){
jqElementList.closest('tr').hide();
Expand All @@ -38,15 +45,36 @@

var updateFields = function(){
var modes = modesField.val();
var brazilVal = countryPayments.brazil.val();
var chileVal = countryPayments.chile.val();
var colombiaVal = countryPayments.colombia.val();
disableFields(fields);
disableFields(fieldBrazilTaxes);

if (brazilVal != null && brazilVal.length > 0) {
enableFields(fieldBrazilTaxes);
}

if (fieldsToggler[0].checked) {

enableFields(fields.filter('.always-visible'));
for (var i in modes) {
enableFields(fields.filter('.' + modes[i]));
if (brazilVal != null && brazilVal.length > 0 && modes != null) {
for (var i in modes) {
enableFields(fields.filter('.' + modes[i]));
}

if (modes.length == 2) {
enableFields(fields.filter('.cpf_cnpj'));
}
}
if (modes.length == 2) {
enableFields(fields.filter('.cpf_cnpj'));

if (chileVal != null && chileVal.length > 0) {
enableFields(fields.filter('.ebanx-chile-document'));
enableFields(fields.filter('.ebanx-chile-bdate'));
}

if (colombiaVal != null && colombiaVal.length > 0) {
enableFields(fields.filter('.ebanx-colombia-document'));
}
}
};
Expand All @@ -60,6 +88,12 @@
updateFields();
});

for (var i in countryPayments) {
countryPayments[i].change(function(){
updateFields();
});
}

// Advanced options toggler
var optionsToggler = $('#woocommerce_ebanx-global_advanced_options_title');

Expand Down
130 changes: 130 additions & 0 deletions woocommerce-gateway-ebanx/includes/class-wc-ebanx-baloto-gateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?php

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

class WC_EBANX_Baloto_Gateway extends WC_EBANX_Gateway
{
/**
* Constructor
*/
public function __construct()
{
$this->id = 'ebanx-baloto';
$this->method_title = __('EBANX - Baloto', 'woocommerce-gateway-ebanx');

$this->api_name = 'baloto';
$this->title = __('Baloto', 'woocommerce-gateway-ebanx');
$this->description = __('Paga con Baloto.', 'woocommerce-gateway-ebanx');

parent::__construct();

$this->enabled = is_array($this->configs->settings['colombia_payment_methods']) ? in_array($this->id, $this->configs->settings['colombia_payment_methods']) ? 'yes' : false : false;
}

/**
* This method always will return false, it doesn't need to show to the customers
*
* @return boolean Always return false
*/
public function is_available()
{
return parent::is_available() && $this->getTransactionAddress('country') == WC_EBANX_Gateway_Utils::COUNTRY_COLOMBIA;
}

/**
* Check if the currency is processed by EBANX
*
* @param string $currency Possible currencies: COP
* @return boolean Return true if EBANX process the currency
*/
public function ebanx_process_merchant_currency($currency) {
return $currency === WC_EBANX_Gateway_Utils::CURRENCY_CODE_COP;
}

/**
* The HTML structure on checkout page
*/
public function payment_fields()
{
if ($description = $this->get_description()) {
echo wp_kses_post(wpautop(wptexturize($description)));
}

wc_get_template(
'baloto/payment-form.php',
array(
'language' => $this->language,
),
'woocommerce/ebanx/',
WC_EBANX::get_templates_path()
);
}

/**
* Save order's meta fields for future use
*
* @param WC_Order $order The order created
* @param Object $request The request from EBANX success response
* @return void
*/
protected function save_order_meta_fields($order, $request)
{
parent::save_order_meta_fields($order, $request);

update_post_meta($order->id, '_baloto_url', $request->payment->baloto_url);
}

/**
* The page of order received, we call them as "Thank you pages"
*
* @param WC_Order $order The order created
* @return void
*/
public static function thankyou_page($order)
{
$baloto_url = get_post_meta($order->id, '_baloto_url', true);
$baloto_basic = $baloto_url . "&format=basic";
$baloto_pdf = $baloto_url . "&format=pdf";
$baloto_print = $baloto_url . "&format=print";
$customer_email = get_post_meta($order->id, '_ebanx_payment_customer_email', true);
$baloto_hash = get_post_meta($order->id, '_ebanx_payment_hash', true);

$data = array(
'data' => array(
'url_basic' => $baloto_basic,
'url_pdf' => $baloto_pdf,
'url_print' => $baloto_print,
'url_iframe' => get_site_url() . '/?ebanx=order-received&hash=' . $baloto_hash . '&payment_type=baloto',
'customer_email' => $customer_email
),
'order_status' => $order->get_status(),
'method' => 'baloto'
);

parent::thankyou_page($data);

wp_enqueue_script('woocommerce_ebanx_clipboard', plugins_url('assets/js/vendor/clipboard.min.js', WC_EBANX::DIR, false, true));
wp_enqueue_script('woocommerce_ebanx_order_received', plugins_url('assets/js/order-received.js', WC_EBANX::DIR, false, true));
}

/**
* Mount the data to send to EBANX API
*
* @param WC_Order $order
* @return array
*/
protected function request_data($order)
{
/*TODO: ? if (empty($_POST['ebanx_baloto_rfc'])) {
throw new Exception("Missing rfc.");
}*/

$data = parent::request_data($order);

$data['payment']['payment_type_code'] = $this->api_name;

return $data;
}
}
27 changes: 27 additions & 0 deletions woocommerce-gateway-ebanx/includes/class-wc-ebanx-checker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

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

class WC_EBANX_Checker {

/**
* Checks if sandbox mode is enabled and warns the user if it is.
*
* @return void
*/
public static function check_sandbox_mode($context) {

if (!$context->is_sandbox_mode) {
return;
}

$warning_message = __('EBANX Gateway - The Sandbox Mode option is enabled, in this mode, none of your transactions will be processed.', 'woocommerce-gateway-ebanx');
$context->notices
->with_message($warning_message)
->with_type('warning')
->persistent()
->display();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public function checkout_assets()
if (is_checkout()) {
wp_enqueue_script('wc-credit-card-form');
// Using // to avoid conflicts between http and https protocols
wp_enqueue_script('ebanx_fingerprint', '//js.ebanx.com/device-fingerprint-1.4.min.js', '', null, true);
wp_enqueue_script('ebanx', '//js.ebanx.com/ebanx-1.4.min.js', '', null, true);
wp_enqueue_script('ebanx', '//js.ebanx.com/ebanx-1.5.min.js', '', null, true);
wp_enqueue_script('woocommerce_ebanx_jquery_mask', plugins_url('assets/js/jquery-mask.js', WC_EBANX::DIR), array('jquery'), WC_EBANX::VERSION, true);
wp_enqueue_script('woocommerce_ebanx', plugins_url('assets/js/credit-card.js', WC_EBANX::DIR), array('jquery-payment', 'ebanx'), WC_EBANX::VERSION, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ abstract class WC_EBANX_Gateway_Utils
'oxxo' => 'America/Mexico_City',
'pagoefectivo' => 'America/Lima',
'sencillito' => 'America/Santiago',
'safetypay-cash' => 'America/Lima'
'safetypay-cash' => 'America/Lima',
'baloto' => 'America/Bogota',
);

/**
Expand Down
Loading

0 comments on commit aceb879

Please sign in to comment.