Skip to content

Commit

Permalink
Merge pull request #514 from ebanx/release/v1.13.1
Browse files Browse the repository at this point in the history
Release/v1.13.1
  • Loading branch information
Cezar Luiz authored May 29, 2017
2 parents 5a8d0f7 + daa2448 commit 1a6c059
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 73 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
ports:
- 3306:3306
volumes:
- ./.data:/var/lib/mysql
- ./.data/db:/var/lib/mysql

woo_plugin:
image: ebanx/ebanx-woocommerce
Expand All @@ -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
33 changes: 12 additions & 21 deletions woocommerce-gateway-ebanx/assets/css/paying-via-ebanx.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 {
Expand Down
113 changes: 74 additions & 39 deletions woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -941,49 +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':
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;
}
$this->update_payment($order, $data);

break;
};

Expand All @@ -993,7 +958,77 @@ 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) {
$requestStatus = strtoupper($data->payment->status);

$status = array(
'CO' => 'Confirmed',
'CA' => 'Canceled',
'PE' => 'Pending',
'OP' => 'Opened'
);
$new_status = null;
switch ($requestStatus) {
case 'CO':
$new_status = 'processing';
break;
case 'CA':
$new_status = 'failed';
break;
case 'PE':
$new_status = 'on-hold';
break;
case 'OP':
$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));
}
}

/**
* 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
Expand Down
7 changes: 6 additions & 1 deletion 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.13.0
Stable tag: 1.13.1
License: MIT
License URI: https://opensource.org/licenses/MIT

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions woocommerce-gateway-ebanx/services/class-wc-ebanx-hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
<hr>
<div class="banking-ticket__actions">
<div class="ebanx-button--group ebanx-button--group-two">
<a href="<?=$url_pdf ?>" target="_blank" class="button banking-ticket__action">Guardar como PDF</a>
<a href="<?=$url_print ?>" target="_blank" class="button banking-ticket__action">Imprimir Baloto</a>
<a href="<?=$url_pdf ?>" target="_blank" class="button banking-ticket__action">Guardar como PDF</a><a href="<?=$url_print ?>" target="_blank" class="button banking-ticket__action">Imprimir Baloto</a>
</div>
</div>
<hr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@

<div class="banking-ticket__actions">
<div class="ebanx-button--group ebanx-button--group-two">
<a href="<?php echo $url_pdf ?>" target="_blank" class="button banking-ticket__action">Salvar em PDF</a>
<a href="<?php echo $url_print ?>" target="_blank" class="button banking-ticket__action">Imprimir boleto</a>
<a href="<?php echo $url_pdf ?>" target="_blank" class="button banking-ticket__action">Salvar em PDF</a><a href="<?php echo $url_print ?>" target="_blank" class="button banking-ticket__action">Imprimir boleto</a>
</div>
</div>

Expand Down
3 changes: 1 addition & 2 deletions woocommerce-gateway-ebanx/templates/oxxo/payment-on-hold.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
<hr>
<div class="banking-ticket__actions">
<div class="ebanx-button--group ebanx-button--group-two">
<a href="<?=$url_pdf ?>" target="_blank" class="button banking-ticket__action">Guardar como PDF</a>
<a href="<?=$url_print ?>" target="_blank" class="button banking-ticket__action">Imprimir OXXO</a>
<a href="<?=$url_pdf ?>" target="_blank" class="button banking-ticket__action">Guardar como PDF</a><a href="<?=$url_print ?>" target="_blank" class="button banking-ticket__action">Imprimir OXXO</a>
</div>
</div>
<hr>
Expand Down
2 changes: 1 addition & 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.13.0
* Version: 1.13.1
* License: MIT
* Text Domain: woocommerce-gateway-ebanx
* Domain Path: /languages
Expand Down

0 comments on commit 1a6c059

Please sign in to comment.