From 73367cd19ab9c686a90405da7e1e60e95212959d Mon Sep 17 00:00:00 2001 From: Cezar Luiz Date: Wed, 24 May 2017 17:22:19 -0300 Subject: [PATCH 1/8] Fix for volumes --- docker-compose.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1557e55a..493c8e91 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,7 @@ services: ports: - 3306:3306 volumes: - - ./.data:/var/lib/mysql + - ./.data/db:/var/lib/mysql woo_plugin: image: ebanx/ebanx-woocommerce @@ -29,6 +29,7 @@ services: ports: - 80:80 volumes: + - /var/www/html - ./woocommerce-gateway-ebanx/:/var/www/html/wp-content/plugins/woocommerce-gateway-ebanx/ links: - woo_mysql:mysql \ No newline at end of file From 2bf6bd7fa54b69a331aa0433b82aa89cc75189e8 Mon Sep 17 00:00:00 2001 From: Cezar Luiz Date: Wed, 24 May 2017 18:49:46 -0300 Subject: [PATCH 2/8] Intercepted payment status notification to return nothing and avoid EBANX payment notification issues --- .../gateways/class-wc-ebanx-gateway.php | 9 +++++++++ .../services/class-wc-ebanx-hooks.php | 6 ++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php index 5bee5941..ad5fca52 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php @@ -970,6 +970,15 @@ final public function process_hook(array $codes, $notificationType) update_post_meta($order->id, "_ebanx_payment_refunds", $refunds); break; case 'UPDATE': + $status = array( + 'CO' => 'Confirmed', + 'CA' => 'Canceled', + 'PE' => 'Pending', + 'OP' => 'Opened' + ); + + $order->add_order_note(sprintf(__('EBANX: The payment has been updated to: %s.', 'woocommerce-gateway-ebanx'), $status[$data->payment->status])); + switch (strtoupper($data->payment->status)) { case 'CO': $order->update_status('processing'); diff --git a/woocommerce-gateway-ebanx/services/class-wc-ebanx-hooks.php b/woocommerce-gateway-ebanx/services/class-wc-ebanx-hooks.php index 3979aa68..e6602c4f 100644 --- a/woocommerce-gateway-ebanx/services/class-wc-ebanx-hooks.php +++ b/woocommerce-gateway-ebanx/services/class-wc-ebanx-hooks.php @@ -35,9 +35,6 @@ private static function is_url_response() { public static function payment_status_hook_action() { ob_start(); - // $myfile = fopen("/var/www/checkout-woocommerce/test.txt", "a") or die("Unable to open file!"); - // fwrite($myfile, json_encode(array('get' => $_GET, 'post' => $_REQUEST, 'request' => $_REQUEST))); - if ( ( WC_EBANX_Request::has('operation') && WC_EBANX_Request::read('operation') == 'payment_status_change' && WC_EBANX_Request::has('notification_type') @@ -68,8 +65,9 @@ public static function payment_status_hook_action() { if ( self::is_url_response() ) { wp_redirect( $order->get_checkout_order_received_url() ); - exit; } + + exit; } ob_end_clean(); From 4ca5b0eb7400967fe80df3fe42c4dc5b830e1386 Mon Sep 17 00:00:00 2001 From: Cezar Luiz Date: Thu, 25 May 2017 12:18:31 -0300 Subject: [PATCH 3/8] Separeted the methods --- .../gateways/class-wc-ebanx-gateway.php | 115 +++++++++++------- 1 file changed, 68 insertions(+), 47 deletions(-) diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php index ad5fca52..ef8c99bd 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php @@ -941,58 +941,14 @@ final public function process_hook(array $codes, $notificationType) $order = new WC_Order($order_id); - // TODO: if (empty($order)) {} - // TODO: if ($data->status != "SUCCESS") - switch (strtoupper($notificationType)) { case 'REFUND': - $refunds = current(get_post_meta($order->id, "_ebanx_payment_refunds")); - - foreach ($refunds as $k => $ref) { - foreach ($data->payment->refunds as $refund) { - if ($ref->id == $refund->id) { - if ($refund->status == 'CO' && $refunds[$k]->status != 'CO') { - $order->add_order_note(sprintf(__('EBANX: Your Refund was confirmed to EBANX - Refund ID: %s', 'woocommerce-gateway-ebanx'), $refund->id)); - } - if ($refund->status == 'CA' && $refunds[$k]->status != 'CA') { - $order->add_order_note(sprintf(__('EBANX: Your Refund was canceled to EBANX - Refund ID: %s', 'woocommerce-gateway-ebanx'), $refund->id)); - } - - $refunds[$k]->status = $refund->status; // status == co save note - $refunds[$k]->cancel_date = $refund->cancel_date; - $refunds[$k]->request_date = $refund->request_date; - $refunds[$k]->pending_date = $refund->pending_date; - $refunds[$k]->confirm_date = $refund->confirm_date; - } - } - } + $this->process_refund_hook($order, $data); - update_post_meta($order->id, "_ebanx_payment_refunds", $refunds); break; case 'UPDATE': - $status = array( - 'CO' => 'Confirmed', - 'CA' => 'Canceled', - 'PE' => 'Pending', - 'OP' => 'Opened' - ); - - $order->add_order_note(sprintf(__('EBANX: The payment has been updated to: %s.', 'woocommerce-gateway-ebanx'), $status[$data->payment->status])); + $this->update_payment($order, $data); - switch (strtoupper($data->payment->status)) { - case 'CO': - $order->update_status('processing'); - break; - case 'CA': - $order->update_status('failed'); - break; - case 'PE': - $order->update_status('on-hold'); - break; - case 'OP': - $order->update_status('pending'); - break; - } break; }; @@ -1002,7 +958,72 @@ final public function process_hook(array $codes, $notificationType) } /** - * Create the conveter amount on checkout page + * Updates the payment when receive a notification from EBANX + * + * @param WC_Order $order + * @param EBANX_Request $data + * @return void + */ + final public function update_payment($order, $data) { + $status = array( + 'CO' => 'Confirmed', + 'CA' => 'Canceled', + 'PE' => 'Pending', + 'OP' => 'Opened' + ); + + $order->add_order_note(sprintf(__('EBANX: The payment has been updated to: %s.', 'woocommerce-gateway-ebanx'), $status[$data->payment->status])); + + switch (strtoupper($data->payment->status)) { + case 'CO': + $order->update_status('processing'); + break; + case 'CA': + $order->update_status('failed'); + break; + case 'PE': + $order->update_status('on-hold'); + break; + case 'OP': + $order->update_status('pending'); + break; + } + } + + /** + * Updates the refunds when receivers a EBANX refund notification + * + * @param WC_Order $order + * @param EBANX_Request $data + * @return void + */ + final public function process_refund_hook($order, $data) { + $refunds = current(get_post_meta($order->id, "_ebanx_payment_refunds")); + + foreach ($refunds as $k => $ref) { + foreach ($data->payment->refunds as $refund) { + if ($ref->id == $refund->id) { + if ($refund->status == 'CO' && $refunds[$k]->status != 'CO') { + $order->add_order_note(sprintf(__('EBANX: Your Refund was confirmed to EBANX - Refund ID: %s', 'woocommerce-gateway-ebanx'), $refund->id)); + } + if ($refund->status == 'CA' && $refunds[$k]->status != 'CA') { + $order->add_order_note(sprintf(__('EBANX: Your Refund was canceled to EBANX - Refund ID: %s', 'woocommerce-gateway-ebanx'), $refund->id)); + } + + $refunds[$k]->status = $refund->status; // status == co save note + $refunds[$k]->cancel_date = $refund->cancel_date; + $refunds[$k]->request_date = $refund->request_date; + $refunds[$k]->pending_date = $refund->pending_date; + $refunds[$k]->confirm_date = $refund->confirm_date; + } + } + } + + update_post_meta($order->id, "_ebanx_payment_refunds", $refunds); + } + + /** + * Create the converter amount on checkout page * * @param string $currency Possible currencies: BRL, USD, EUR, PEN, CLP, COP, MXN * @return void From 1ef4210c8ab302f8aa5c64d350fd42ee272ccea9 Mon Sep 17 00:00:00 2001 From: Cezar Luiz Date: Thu, 25 May 2017 12:32:36 -0300 Subject: [PATCH 4/8] Avoid updating payment many times --- .../gateways/class-wc-ebanx-gateway.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php index ef8c99bd..1907b659 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php @@ -965,6 +965,8 @@ final public function process_hook(array $codes, $notificationType) * @return void */ final public function update_payment($order, $data) { + $requestStatus = strtoupper($data->payment->status); + $status = array( 'CO' => 'Confirmed', 'CA' => 'Canceled', @@ -972,9 +974,17 @@ final public function update_payment($order, $data) { 'OP' => 'Opened' ); - $order->add_order_note(sprintf(__('EBANX: The payment has been updated to: %s.', 'woocommerce-gateway-ebanx'), $status[$data->payment->status])); + $paymentStatus = $status[$data->payment->status]; + + // Avoid updating payment many times + if ( + in_array($order->status, array('processing', 'completed')) + && $requestStatus !== 'CA' + ) return; + + $order->add_order_note(sprintf(__('EBANX: The payment has been updated to: %s.', 'woocommerce-gateway-ebanx'), $paymentStatus)); - switch (strtoupper($data->payment->status)) { + switch ($requestStatus) { case 'CO': $order->update_status('processing'); break; From 93abd81b0caae4b06c5f7cf86e41c8c73a115088 Mon Sep 17 00:00:00 2001 From: Cezar Luiz Date: Fri, 26 May 2017 10:07:29 -0300 Subject: [PATCH 5/8] New code to avoid all cases of payment duplications --- .../gateways/class-wc-ebanx-gateway.php | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php index 1907b659..dbd90431 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php @@ -971,33 +971,28 @@ final public function update_payment($order, $data) { 'CO' => 'Confirmed', 'CA' => 'Canceled', 'PE' => 'Pending', - 'OP' => 'Opened' + 'OP' => 'Opened' ); - - $paymentStatus = $status[$data->payment->status]; - - // Avoid updating payment many times - if ( - in_array($order->status, array('processing', 'completed')) - && $requestStatus !== 'CA' - ) return; - - $order->add_order_note(sprintf(__('EBANX: The payment has been updated to: %s.', 'woocommerce-gateway-ebanx'), $paymentStatus)); - + $new_status = null; switch ($requestStatus) { case 'CO': - $order->update_status('processing'); + $new_status = 'processing'; break; case 'CA': - $order->update_status('failed'); + $new_status = 'failed'; break; case 'PE': - $order->update_status('on-hold'); + $new_status = 'on-hold'; break; case 'OP': - $order->update_status('pending'); + $new_status = 'pending'; break; } + + if ($new_status !== $order->status) { + $paymentStatus = $status[$data->payment->status]; + $order->add_order_note(sprintf(__('EBANX: The payment has been updated to: %s.', 'woocommerce-gateway-ebanx'), $paymentStatus)); + } } /** From 47b1737c42e1ebce3d871f055326f20f52440b4e Mon Sep 17 00:00:00 2001 From: Cezar Luiz Date: Fri, 26 May 2017 16:15:37 -0300 Subject: [PATCH 6/8] Removed 4px white space between elements --- woocommerce-gateway-ebanx/templates/baloto/payment-on-hold.php | 3 +-- .../templates/banking-ticket/payment-on-hold.php | 3 +-- woocommerce-gateway-ebanx/templates/oxxo/payment-on-hold.php | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/woocommerce-gateway-ebanx/templates/baloto/payment-on-hold.php b/woocommerce-gateway-ebanx/templates/baloto/payment-on-hold.php index 4430bd44..0c79a837 100644 --- a/woocommerce-gateway-ebanx/templates/baloto/payment-on-hold.php +++ b/woocommerce-gateway-ebanx/templates/baloto/payment-on-hold.php @@ -22,8 +22,7 @@

diff --git a/woocommerce-gateway-ebanx/templates/banking-ticket/payment-on-hold.php b/woocommerce-gateway-ebanx/templates/banking-ticket/payment-on-hold.php index d6a34a12..7087f335 100644 --- a/woocommerce-gateway-ebanx/templates/banking-ticket/payment-on-hold.php +++ b/woocommerce-gateway-ebanx/templates/banking-ticket/payment-on-hold.php @@ -37,8 +37,7 @@ diff --git a/woocommerce-gateway-ebanx/templates/oxxo/payment-on-hold.php b/woocommerce-gateway-ebanx/templates/oxxo/payment-on-hold.php index 3cbbef01..4ed06fd8 100644 --- a/woocommerce-gateway-ebanx/templates/oxxo/payment-on-hold.php +++ b/woocommerce-gateway-ebanx/templates/oxxo/payment-on-hold.php @@ -24,8 +24,7 @@

From 13f8dc69a03517523f39dafc0a70f4afc1f60019 Mon Sep 17 00:00:00 2001 From: Cezar Luiz Date: Fri, 26 May 2017 17:53:12 -0300 Subject: [PATCH 7/8] Change CSS to avoid breakpoints on Boleto Thankyou Page --- .../assets/css/paying-via-ebanx.css | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/woocommerce-gateway-ebanx/assets/css/paying-via-ebanx.css b/woocommerce-gateway-ebanx/assets/css/paying-via-ebanx.css index ae209467..2944a0e6 100644 --- a/woocommerce-gateway-ebanx/assets/css/paying-via-ebanx.css +++ b/woocommerce-gateway-ebanx/assets/css/paying-via-ebanx.css @@ -363,31 +363,21 @@ li[class*="ebanx"] .payment_box .ebanx-credit-card-label > .ebanx-credit-card-bi margin: 20px 0; } -.woocommerce .ebanx-button--group-two > a, -.woocommerce .ebanx-button--group-two > button, -.woocommerce .ebanx-button--group-two > .button { - width: 49%; - float: left; -} - -.woocommerce .ebanx-button--group-two > a:not(:first-child), -.woocommerce .ebanx-button--group-two > button:not(:first-child), -.woocommerce .ebanx-button--group-two > .button:not(:first-child) { - float: right; +.button.banking-ticket__action { + width: calc(50% - 10px); + display: inline-block; + margin: 0; } -.woocommerce .ebanx-button--group::before, -.woocommerce .ebanx-button--group::after { - content: " "; - display: table; +.button.banking-ticket__action:last-child { + margin-left: 20px; } .woocommerce .ebanx-button--group::after {clear: both;} .woocommerce .ebanx-button--copy { position: relative; - margin-bottom: 0 !important; - + margin: 0 !important; transition: all .3s; } @@ -465,14 +455,15 @@ li[class*="ebanx"] .payment_box .ebanx-credit-card-label > .ebanx-credit-card-bi .banking-ticket__barcode::after {clear: both;} .banking-ticket__barcode-code { - display: inline-block; + display: block; letter-spacing: .32px; - vertical-align: middle; + text-align: center; } .banking-ticket__barcode-copy { - display: inline-block; - margin-left: 32px; + display: block; + text-align: center; + margin-top: 20px; } .ebanx-form-row .select2.select2-container { From daa24481051c80ddb2a6ec23055d388310c99ebd Mon Sep 17 00:00:00 2001 From: Cezar Luiz Date: Mon, 29 May 2017 12:14:15 -0300 Subject: [PATCH 8/8] Bump version for 1.13.1 --- CHANGELOG.md | 5 +++++ woocommerce-gateway-ebanx/readme.txt | 7 ++++++- woocommerce-gateway-ebanx/woocommerce-gateway-ebanx.php | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 890c8f5d..33a51e53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +# 1.13.1 +* Fix - Avoid duplication payment notifications [#509](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/509) +* Fix - Changed PSE thank you page HTML [#512](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/512) +* Fix - Changed Boleto thank you page HTML [#513](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/513) + # 1.13.0 * Fix - Fix for debug log when is enabled before record a log [#507](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/507) * Fix - Fix issue to avoid some issues on refund transactions [#506](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/506) diff --git a/woocommerce-gateway-ebanx/readme.txt b/woocommerce-gateway-ebanx/readme.txt index 51753cbe..fcca91af 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.13.0 +Stable tag: 1.13.1 License: MIT License URI: https://opensource.org/licenses/MIT @@ -136,6 +136,11 @@ Yes, you can. == Changelog == += 1.13.1 = +* Fix - Avoid duplication payment notifications [#509](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/509) +* Fix - Changed PSE thank you page HTML [#512](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/512) +* Fix - Changed Boleto thank you page HTML [#513](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/513) + = 1.13.0 = * Fix - Fix for debug log when is enabled before record a log [#507](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/507) * Fix - Fix issue to avoid some issues on refund transactions [#506](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/506) diff --git a/woocommerce-gateway-ebanx/woocommerce-gateway-ebanx.php b/woocommerce-gateway-ebanx/woocommerce-gateway-ebanx.php index 6ba30bbc..3e0af6b2 100644 --- a/woocommerce-gateway-ebanx/woocommerce-gateway-ebanx.php +++ b/woocommerce-gateway-ebanx/woocommerce-gateway-ebanx.php @@ -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.13.0 + * Version: 1.13.1 * License: MIT * Text Domain: woocommerce-gateway-ebanx * Domain Path: /languages