diff --git a/CHANGELOG.md b/CHANGELOG.md index b9d993d9..3a48d587 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/woocommerce-gateway-ebanx/assets/images/ebanx-cupon.png b/woocommerce-gateway-ebanx/assets/images/ebanx-cupon.png new file mode 100644 index 00000000..5f57125d Binary files /dev/null and b/woocommerce-gateway-ebanx/assets/images/ebanx-cupon.png differ diff --git a/woocommerce-gateway-ebanx/assets/images/ebanx-efectivo.png b/woocommerce-gateway-ebanx/assets/images/ebanx-efectivo.png new file mode 100644 index 00000000..e7e17972 Binary files /dev/null and b/woocommerce-gateway-ebanx/assets/images/ebanx-efectivo.png differ diff --git a/woocommerce-gateway-ebanx/assets/images/ebanx-pagofacil.png b/woocommerce-gateway-ebanx/assets/images/ebanx-pagofacil.png new file mode 100644 index 00000000..9cd96921 Binary files /dev/null and b/woocommerce-gateway-ebanx/assets/images/ebanx-pagofacil.png differ diff --git a/woocommerce-gateway-ebanx/assets/images/ebanx-rapipago.png b/woocommerce-gateway-ebanx/assets/images/ebanx-rapipago.png new file mode 100644 index 00000000..61b66ef1 Binary files /dev/null and b/woocommerce-gateway-ebanx/assets/images/ebanx-rapipago.png differ diff --git a/woocommerce-gateway-ebanx/assets/js/checkout-fields.js b/woocommerce-gateway-ebanx/assets/js/checkout-fields.js index 957a8c42..68f780bd 100644 --- a/woocommerce-gateway-ebanx/assets/js/checkout-fields.js +++ b/woocommerce-gateway-ebanx/assets/js/checkout-fields.js @@ -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(); diff --git a/woocommerce-gateway-ebanx/assets/js/order-received.js b/woocommerce-gateway-ebanx/assets/js/order-received.js index 891658ac..f01aca62 100644 --- a/woocommerce-gateway-ebanx/assets/js/order-received.js +++ b/woocommerce-gateway-ebanx/assets/js/order-received.js @@ -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 () { 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 482281a7..ba8f41a9 100644 --- a/woocommerce-gateway-ebanx/controllers/class-wc-ebanx-api-controller.php +++ b/woocommerce-gateway-ebanx/controllers/class-wc-ebanx-api-controller.php @@ -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); @@ -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; + } } diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-br-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-br-gateway.php index 774774f8..28e96717 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-br-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-br-gateway.php @@ -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.'; diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-co-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-co-gateway.php index f85cdf4d..62b37fa3 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-co-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-co-gateway.php @@ -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.'; 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 7eaeed03..0977e719 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 @@ -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, diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-mx-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-mx-gateway.php index 11bde1f0..8ffb12d5 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-mx-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-mx-gateway.php @@ -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.'; diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-efectivo-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-efectivo-gateway.php new file mode 100644 index 00000000..f852a787 --- /dev/null +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-efectivo-gateway.php @@ -0,0 +1,134 @@ +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; + } +} diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php index 44d721b3..1806fb1e 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php @@ -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), @@ -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', @@ -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; @@ -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', @@ -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' ), ); diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-global-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-global-gateway.php index f5629f72..810ad2a7 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-global-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-global-gateway.php @@ -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', @@ -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()); @@ -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' diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-redirect-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-redirect-gateway.php index e1f2b4c1..f1bce18a 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-redirect-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-redirect-gateway.php @@ -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; diff --git a/woocommerce-gateway-ebanx/readme.txt b/woocommerce-gateway-ebanx/readme.txt index a8dbdda2..6a5a3805 100644 --- a/woocommerce-gateway-ebanx/readme.txt +++ b/woocommerce-gateway-ebanx/readme.txt @@ -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 @@ -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** @@ -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 @@ -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) diff --git a/woocommerce-gateway-ebanx/services/class-wc-ebanx-constants.php b/woocommerce-gateway-ebanx/services/class-wc-ebanx-constants.php index 03aada4b..f42acc4d 100644 --- a/woocommerce-gateway-ebanx/services/class-wc-ebanx-constants.php +++ b/woocommerce-gateway-ebanx/services/class-wc-ebanx-constants.php @@ -14,10 +14,12 @@ abstract class WC_EBANX_Constants const COUNTRY_BRAZIL = 'br'; const COUNTRY_MEXICO = 'mx'; const COUNTRY_COLOMBIA = 'co'; + const COUNTRY_ARGENTINA = 'ar'; /** * The full name of countries that EBANX processes */ + const COUNTRY_ARGENTINA_NAME = 'Argentina'; const COUNTRY_BRAZIL_NAME = 'Brazil'; const COUNTRY_CHILE_NAME = 'Chile'; const COUNTRY_COLOMBIA_NAME = 'Colombia'; @@ -39,6 +41,7 @@ abstract class WC_EBANX_Constants const CURRENCY_CODE_MXN = 'MXN'; // Mexico const CURRENCY_CODE_COP = 'COP'; // Colombia const CURRENCY_CODE_CLP = 'CLP'; // Chile + const CURRENCY_CODE_ARS = 'ARS'; // Argentina /** * Only the currencies allowed and processed by EBANX @@ -52,7 +55,8 @@ abstract class WC_EBANX_Constants self::CURRENCY_CODE_PEN, self::CURRENCY_CODE_MXN, self::CURRENCY_CODE_COP, - self::CURRENCY_CODE_CLP + self::CURRENCY_CODE_CLP, + self::CURRENCY_CODE_ARS, ); /** @@ -63,7 +67,8 @@ abstract class WC_EBANX_Constants self::COUNTRY_CHILE => self::CURRENCY_CODE_CLP, self::COUNTRY_COLOMBIA => self::CURRENCY_CODE_COP, self::COUNTRY_MEXICO => self::CURRENCY_CODE_MXN, - self::COUNTRY_PERU => self::CURRENCY_CODE_PEN + self::COUNTRY_PERU => self::CURRENCY_CODE_PEN, + self::COUNTRY_ARGENTINA => self::CURRENCY_CODE_ARS, ); /** @@ -98,6 +103,7 @@ abstract class WC_EBANX_Constants self::COUNTRY_MEXICO, self::COUNTRY_PERU, self::COUNTRY_CHILE, + self::COUNTRY_ARGENTINA, ); /** @@ -136,6 +142,10 @@ abstract class WC_EBANX_Constants 'sencillito' => 'America/Santiago', 'safetypay-cash' => 'America/Lima', 'baloto' => 'America/Bogota', + 'efectivo' => 'America/Argentina/Buenos_Aires', + 'rapipago' => 'America/Argentina/Buenos_Aires', + 'pagofacil' => 'America/Argentina/Buenos_Aires', + 'cupon' => 'America/Argentina/Buenos_Aires', ); /** @@ -150,6 +160,7 @@ abstract class WC_EBANX_Constants 'ebanx-sencillito', 'ebanx-safetypay-cash', 'ebanx-baloto', + 'ebanx-efectivo', ); /** @@ -190,6 +201,12 @@ abstract class WC_EBANX_Constants ) ); + public static $VOUCHERS_EFECTIVO_ALLOWED = array( + 'rapipago', + 'pagofacil', + 'cupon', + ); + /** * Payment type API codes for each plugin payment gateway * @@ -249,7 +266,10 @@ abstract class WC_EBANX_Constants 'ebanx-credit-card-mx', 'ebanx-debit-card', 'ebanx-oxxo' - ) + ), + self::COUNTRY_ARGENTINA => array( + 'ebanx-efectivo' + ), ); /** diff --git a/woocommerce-gateway-ebanx/services/class-wc-ebanx-errors.php b/woocommerce-gateway-ebanx/services/class-wc-ebanx-errors.php index 0016e19b..56655cb7 100644 --- a/woocommerce-gateway-ebanx/services/class-wc-ebanx-errors.php +++ b/woocommerce-gateway-ebanx/services/class-wc-ebanx-errors.php @@ -54,6 +54,7 @@ public static function get_errors() { 'MISSING-CVV' => 'Por favor digite o CVV do seu cartão de crédito.', 'MISSING-INSTALMENTS' => 'Por favor escolha em quantas parcelas você quer pagar.', 'MISSING-BANK-NAME' => 'Escolha um banco que deseja efetuar a sua compra.', + 'MISSING-VOUCHER' => 'Escolha o tipo de voucher que deseja para efetuar a sua compra.', 'INVALID-SAFETYPAY-TYPE' => 'Escolha uma opção para o método de pagamento SafetyPay.', 'INVALID-FIELDS' => 'Alguns campos não foram preenchidos corretamente. Por favor, verifique e tente novamente.', 'INVALID-BILLING-COUNTRY' => 'Por favor, escolha um país.', @@ -107,6 +108,7 @@ public static function get_errors() { 'MISSING-CVV' => 'Por favor, introduce el CVV de tu tarjeta de crédito.', 'MISSING-INSTALMENTS' => 'Por favor, escoge en cuántos meses sin intereses deseas pagar.', 'MISSING-BANK-NAME' => 'Por favor, escoge el banco para finalizar la compra.', + 'MISSING-VOUCHER' => 'Por favor, escoge el tipo de voucher que desea para finalizar la compra.', 'INVALID-SAFETYPAY-TYPE' => 'Por favor, escoge una opción para el método de pago SafetyPay.', 'INVALID-FIELDS' => 'Algunos campos no fueron llenados correctamente. Por favor verifica e inténtalo de nuevo.', 'INVALID-BILLING-COUNTRY' => 'Por favor, escoge un país.', diff --git a/woocommerce-gateway-ebanx/services/class-wc-ebanx-my-account.php b/woocommerce-gateway-ebanx/services/class-wc-ebanx-my-account.php index ab746311..c456d736 100644 --- a/woocommerce-gateway-ebanx/services/class-wc-ebanx-my-account.php +++ b/woocommerce-gateway-ebanx/services/class-wc-ebanx-my-account.php @@ -124,6 +124,9 @@ public static function order_details($order) case 'ebanx-baloto': WC_EBANX_Baloto_Gateway::thankyou_page($order); break; + case 'ebanx-efectivo': + WC_EBANX_Efectivo_Gateway::thankyou_page($order); + break; } } } diff --git a/woocommerce-gateway-ebanx/services/class-wc-ebanx-one-click.php b/woocommerce-gateway-ebanx/services/class-wc-ebanx-one-click.php index 8339fee9..17642f72 100644 --- a/woocommerce-gateway-ebanx/services/class-wc-ebanx-one-click.php +++ b/woocommerce-gateway-ebanx/services/class-wc-ebanx-one-click.php @@ -278,6 +278,13 @@ public function customer_can() { return !is_user_logged_in() || !get_user_meta( $this->userId, '_billing_email', true ) && !empty( $this->cards ); } + public function should_show_button() { + return $this->cards + && (! empty(get_user_meta( $this->userId, '_ebanx_billing_brazil_document', true )) + || ! empty(get_user_meta( $this->userId, '_ebanx_billing_colombia_document', true )) + || $this->userCountry === WC_EBANX_Constants::COUNTRY_MEXICO); + } + /** * Render the button "One-Click Purchase" using a template * @@ -322,12 +329,15 @@ public function print_button() { $instalments_terms = $this->gateway->get_payment_terms($cart_total, $max_instalments, $tax); $currency = WC_EBANX_Constants::$LOCAL_CURRENCIES[$country]; + $ebanx = new WC_EBANX_Gateway(); $args = apply_filters( 'ebanx_template_args', array( 'cards' => $this->cards, 'cart_total' => $cart_total, 'product_id' => $product->id, 'installment_taxes' => $this->instalment_rates, + 'currency' => $currency, + 'currency_rate' => round(floatval($ebanx->get_local_currency_rate_for_site($currency)), 2), 'label' => __( 'Pay with one click', 'woocommerce-gateway-ebanx' ), 'instalments' => $messages['instalments'], 'instalments_terms' => $instalments_terms, @@ -335,7 +345,7 @@ public function print_button() { 'action' => self::CREATE_ORDER_ACTION, 'permalink' => get_permalink($product->id), 'country' => $country, - 'currency' => $currency + 'should_show_button' => $this->should_show_button(), ) ); wc_get_template( 'one-click.php', $args, '', WC_EBANX::get_templates_path() . 'one-click/' ); diff --git a/woocommerce-gateway-ebanx/templates/efectivo/payment-completed.php b/woocommerce-gateway-ebanx/templates/efectivo/payment-completed.php new file mode 100644 index 00000000..4244bcd6 --- /dev/null +++ b/woocommerce-gateway-ebanx/templates/efectivo/payment-completed.php @@ -0,0 +1 @@ + + +
Su Voucher fue generado con éxito.
+Una copia de la voucher fue enviada al correo electrónico =$customer_email ?>.
+Si tienes dudas, por favor escribe a soporte@ebanx.com.
+