Skip to content

Commit

Permalink
Merge pull request #577 from ebanx/staging/v1.21.0
Browse files Browse the repository at this point in the history
Staging/v1.21.0
  • Loading branch information
gpressutto5 authored Oct 9, 2017
2 parents b03192a + 4289479 commit 8a6c44e
Show file tree
Hide file tree
Showing 29 changed files with 374 additions and 32 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# CHANGELOG

# 1.21.0
* Feature - Added new Argentina payment method Efectivo [#576](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/576)
* Feature - Showing instalments on local currency [#571](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/571)
* Fix - Saving customer document when creating account on checkout [#566](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/566)
* Fix - Show one click button only if customer has document [#567](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/567)
* Fix - Removed ::class from same file that checks if php version is supported [#568](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/568)
* Fix - Added fake birthdate to payment data to prevent error on unconfigured merchants [#569](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/569)
* Fix - Overwriting libjs invalid expiry date error [#572](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/572)
* Fix - Saving document on redirect payment methods [#574](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/574)
* Fix - Fixed iframe resizer [#575](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/575)

# 1.20.0
* Feature - Dashboard lead links update to Dashboard v2 [#564](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/564)

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions woocommerce-gateway-ebanx/assets/js/checkout-fields.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
jQuery (function ($) {
EBANX.errors.summary.pt_BR['BP-DR-57'] = 'A data do cartão de crédito deve estar no formato MM/AA';
EBANX.errors.summary.es['BP-DR-57'] = 'Por favor, escribe la fecha en el formato MM/AA';
// Custom select fields
if ('select2' in $.fn) {
$('select.ebanx-select-field').select2();
Expand Down
2 changes: 1 addition & 1 deletion woocommerce-gateway-ebanx/assets/js/order-received.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jQuery(document).ready(function ($) {

if (iframe) {
var resizeIframe = function resizeIframe(iframe) {
iframe.style.height = iframe.contentWindow.document.body.parentElement.scrollHeight + 'px';
iframe.style.height = iframe.contentWindow.document.body.scrollHeight + 'px';
}

$(window).on('load', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,7 @@ private function get_integration_key() {
* @return void
*/
public function order_received($hash, $payment_type) {
$is_sandbox = $this->config->get_setting_or_default('sandbox_mode_enabled', 'yes') === 'yes';

$subdomain = $is_sandbox ? 'sandbox' : 'print';
$url = "https://{$subdomain}.ebanx.com/";

if ($payment_type !== 'cip') {
$url .= 'print/';
}

if ($payment_type !== null && $payment_type !== 'boleto') {
$url .= "{$payment_type}/";
}

$url .= "?hash={$hash}";

if ($payment_type !== 'baloto') {
$url .= '&format=basic#';
}
$url = $this->get_url($hash, $payment_type);

if (!in_array('curl', get_loaded_extensions())) {
echo file_get_contents($url);
Expand All @@ -124,4 +107,31 @@ public function order_received($hash, $payment_type) {
private function is_sandbox() {
return $this->config->settings['sandbox_mode_enabled'] === 'yes';
}

private function get_url($hash, $payment_type) {
$is_sandbox = $this->config->get_setting_or_default('sandbox_mode_enabled', 'yes') === 'yes';

$subdomain = $is_sandbox ? 'sandbox' : 'print';
$url = "https://{$subdomain}.ebanx.com/";

if ($payment_type !== 'cip') {
$url .= 'print/';
}

if ($payment_type === 'efectivo') {
$url .= 'voucher/';
}

if ($payment_type !== null && $payment_type !== 'boleto' && $payment_type !== 'efectivo') {
$url .= "{$payment_type}/";
}

$url .= "?hash={$hash}";

if ($payment_type !== 'baloto') {
$url .= '&format=basic#';
}

return $url;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function __construct()
{
$this->id = 'ebanx-credit-card-br';
$this->method_title = __('EBANX - Credit Card Brazil', 'woocommerce-gateway-ebanx');
$this->currency_code = WC_EBANX_Constants::CURRENCY_CODE_BRL;

$this->title = 'Cartão de Crédito';
$this->description = 'Pague com cartão de crédito.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function __construct()
{
$this->id = 'ebanx-credit-card-co';
$this->method_title = __('EBANX - Credit Card Colombia', 'woocommerce-gateway-ebanx');
$this->currency_code = WC_EBANX_Constants::CURRENCY_CODE_COP;

$this->title = 'Tarjeta de Crédito';
$this->description = 'Pay with credit card.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ public function payment_fields() {
'currency' => $currency,
'country' => $country,
'instalments_terms' => $instalments_terms,
'currency' => $this->currency_code,
'currency_rate' => round(floatval($this->get_local_currency_rate_for_site($this->currency_code)), 2),
'cards' => (array) $cards,
'cart_total' => $cart_total,
'place_order_enabled' => $save_card,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function __construct()
{
$this->id = 'ebanx-credit-card-mx';
$this->method_title = __('EBANX - Credit Card Mexico', 'woocommerce-gateway-ebanx');
$this->currency_code = WC_EBANX_Constants::CURRENCY_CODE_MXN;

$this->title = 'Tarjeta de Crédito';
$this->description = 'Pay with credit card.';
Expand Down
134 changes: 134 additions & 0 deletions woocommerce-gateway-ebanx/gateways/class-wc-ebanx-efectivo-gateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?php

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

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

$this->api_name = 'efectivo';
$this->title = 'Efectivo';
$this->description = 'Paga con Efectivo.';

parent::__construct();

$this->enabled = is_array($this->configs->settings['argentina_payment_methods']) ? in_array($this->id, $this->configs->settings['argentina_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_Constants::COUNTRY_ARGENTINA;
}

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

/**
* 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(
'efectivo/payment-form.php',
array(
'id' => $this->id
),
'woocommerce/ebanx/',
WC_EBANX::get_templates_path()
);

parent::checkout_rate_conversion(WC_EBANX_Constants::CURRENCY_CODE_ARS);
}

/**
* 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, '_efectivo_url', $request->payment->voucher_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)
{
$efectivo_url = get_post_meta($order->id, '_efectivo_url', true);
$efectivo_basic = $efectivo_url . "&format=basic";
$efectivo_pdf = $efectivo_url . "&format=pdf";
$efectivo_print = $efectivo_url . "&format=print";
$customer_email = get_post_meta($order->id, '_ebanx_payment_customer_email', true);
$efectivo_hash = get_post_meta($order->id, '_ebanx_payment_hash', true);

$data = array(
'data' => array(
'url_basic' => $efectivo_basic,
'url_pdf' => $efectivo_pdf,
'url_print' => $efectivo_print,
'url_iframe' => get_site_url() . '/?ebanx=order-received&hash=' . $efectivo_hash . '&payment_type=efectivo',
'customer_email' => $customer_email
),
'order_status' => $order->get_status(),
'method' => 'efectivo'
);

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
* @throws Exception
*/
protected function request_data($order)
{
if ( ! WC_EBANX_Request::has('efectivo')
|| ! in_array(WC_EBANX_Request::read('efectivo'), WC_EBANX_Constants::$VOUCHERS_EFECTIVO_ALLOWED)) {
throw new Exception('MISSING-VOUCHER');
}

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

$data['payment']['payment_type_code'] = WC_EBANX_Request::read('efectivo');

return $data;
}
}
9 changes: 9 additions & 0 deletions woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ protected function get_data()
'ebanx_billing_brazil_cnpj' => WC_EBANX_Request::read($this->names['ebanx_billing_brazil_cnpj'], null),
'ebanx_billing_chile_document' => WC_EBANX_Request::read($this->names['ebanx_billing_chile_document'], null),
'ebanx_billing_colombia_document' => WC_EBANX_Request::read($this->names['ebanx_billing_colombia_document'], null),
'ebanx_billing_brazil_birth_date' => '31/12/1969',
'ebanx_billing_chile_birth_date' => '31/12/1969',
'billing_postcode' => WC_EBANX_Request::read('billing_postcode', null),
'billing_address_1' => WC_EBANX_Request::read('billing_address_1', null),
'billing_address_2' => WC_EBANX_Request::read('billing_address_2', null),
Expand Down Expand Up @@ -755,6 +757,7 @@ private static function get_error_message($exception, $country)
$code = $exception->getCode() ?: $exception->getMessage();

$languages = array(
'ar' => 'es',
'mx' => 'es',
'cl' => 'es',
'pe' => 'es',
Expand Down Expand Up @@ -846,6 +849,10 @@ protected function save_order_meta_fields($order, $request)
*/
protected function save_user_meta_fields($order)
{
if (!$this->userId) {
$this->userId = get_current_user_id();
}

if ($this->userId) {
$document = false;

Expand Down Expand Up @@ -1193,6 +1200,7 @@ public function get_checkout_message($amount, $currency, $country) {
$price = wc_price($amount, array('currency' => $currency));

$languages = array(
'ar' => 'es',
'mx' => 'es',
'cl' => 'es',
'pe' => 'es',
Expand All @@ -1212,6 +1220,7 @@ public function get_checkout_message($amount, $currency, $country) {
WC_EBANX_Constants::CURRENCY_CODE_CLP => 'Peso chileno',
WC_EBANX_Constants::CURRENCY_CODE_PEN => 'Sol peruano',
WC_EBANX_Constants::CURRENCY_CODE_COP => 'Peso colombiano',
WC_EBANX_Constants::CURRENCY_CODE_ARS => 'Peso argentino',
WC_EBANX_Constants::CURRENCY_CODE_BRL => 'Real brasileño'
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ final class WC_EBANX_Global_Gateway extends WC_Payment_Gateway
'ebanx-safetypay',
'ebanx-pagoefectivo',
),
'argentina_payment_methods' => array(
'ebanx-efectivo',
),
'save_card_data' => 'yes',
'one_click' => 'yes',
'capture_enabled' => 'yes',
Expand All @@ -68,7 +71,7 @@ public function __construct()

$this->id = 'ebanx-global';
$this->method_title = __('EBANX', 'woocommerce-gateway-ebanx');
$this->method_description = __('EBANX easy-to-setup checkout allows your business to accept local payments in Brazil, Mexico, Colombia, Chile & Peru.', 'woocommerce-gateway-ebanx');
$this->method_description = __('EBANX easy-to-setup checkout allows your business to accept local payments in Brazil, Mexico, Argentina, Colombia, Chile & Peru.', 'woocommerce-gateway-ebanx');

$this->merchant_currency = strtoupper(get_woocommerce_currency());

Expand Down Expand Up @@ -229,6 +232,17 @@ public function init_form_fields() {
'ebanx-pagoefectivo',
),
),
'argentina_payment_methods' => array(
'title' => __('Argentina', 'woocommerce-gateway-ebanx'),
'type' => 'multiselect',
'class' => 'wc-enhanced-select',
'options' => array(
'ebanx-efectivo' => 'Efectivo',
),
'default' => array(
'ebanx-efectivo'
),
),
'payments_options_title' => array(
'title' => __('Payment Options', 'woocommerce-gateway-ebanx'),
'type' => 'title'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ protected function process_response($request, $order)
}
$redirect = $request->payment->redirect_url;

parent::process_response($request, $order);

update_post_meta($order->id, '_ebanx_payment_hash', $request->payment->hash);

$this->redirect_url = $redirect;
Expand Down
19 changes: 16 additions & 3 deletions woocommerce-gateway-ebanx/readme.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
=== EBANX Payment Gateway for WooCommerce ===
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
Tags: credit card, boleto, ebanx, woocommerce, approval rate, conversion rate, brazil, mexico, argentina, 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.20.0
Stable tag: 1.21.0
License: Apache v2.0
License URI: http://www.apache.org/licenses/LICENSE-2.0

Expand All @@ -19,7 +19,7 @@ Ready to accept local payments but don’t have an account yet? Finish our [simp

**Plugin Description**

The WooCommerce EBANX Payment Gateway plugin allows you to accept local & international payment methods directly on your ecommerce store. Using the EBANX plugin you can process relevant cash, online debit, and credit card payments in Brazil, Mexico, Chile, Colombia & Peru, and access over 20M EBANX Wallet users. **No technical knowledge is needed for installation. Installation is simple, the way it should be.**
The WooCommerce EBANX Payment Gateway plugin allows you to accept local & international payment methods directly on your ecommerce store. Using the EBANX plugin you can process relevant cash, online debit, and credit card payments in Brazil, Mexico, Argentina, Chile, Colombia & Peru, and access over 20M EBANX Wallet users. **No technical knowledge is needed for installation. Installation is simple, the way it should be.**

**EBANX Advantages**

Expand Down Expand Up @@ -105,6 +105,8 @@ The [Developer’s Academy](https://www.ebanx.com/business/en/developers/integra
* OXXO, Cash Payment
* Debit & Credit Cards
* EBANX Wallet, Debit Transfer
* Argentina
* Efectivo
* Chile
* Sencillito, Cash Payment
* Servipag, Online Debit Transfer
Expand Down Expand Up @@ -136,6 +138,17 @@ Yes, you can.

== Changelog ==

= 1.21.0 =
* Feature - Added new Argentina payment method Efectivo [#576](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/576)
* Feature - Showing instalments on local currency [#571](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/571)
* Fix - Saving customer document when creating account on checkout [#566](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/566)
* Fix - Show one click button only if customer has document [#567](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/567)
* Fix - Removed ::class from same file that checks if php version is supported [#568](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/568)
* Fix - Added fake birthdate to payment data to prevent error on unconfigured merchants [#569](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/569)
* Fix - Overwriting libjs invalid expiry date error [#572](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/572)
* Fix - Saving document on redirect payment methods [#574](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/574)
* Fix - Fixed iframe resizer [#575](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/575)

= 1.20.0 =
* Feature - Dashboard lead links update to Dashboard v2 [#564](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/564)

Expand Down
Loading

0 comments on commit 8a6c44e

Please sign in to comment.