Skip to content

Commit

Permalink
Merge pull request #496 from ebanx/hotfix/1.12.1
Browse files Browse the repository at this point in the history
[HOTFIX] Fixed credit-card saving and one-click payments
  • Loading branch information
SparK-Cruz authored Apr 26, 2017
2 parents 5797868 + d609644 commit 6eb105e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 24 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

# 1.12.1
* Fix - Credit-card saving for new customers [#496](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/496)
* Fix - One-click payments button in product details [#496](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/496)

# 1.12.0
* Feature - Using interest rate on minimum instalment value [#490](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/490)
* Feature - Refactor EBANX query router [#487](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/487)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function capture_payment_action() {
* @return stdClass
*/
public function check_capture_errors($response) {
if ($response->status !== 'ERROR') {
if ( $response->status !== 'ERROR' ) {
return null;
}

Expand Down Expand Up @@ -183,7 +183,7 @@ public function checkout_assets()
*/
protected function request_data($order)
{

if (empty(WC_EBANX_Request::read('ebanx_token', null))
|| empty(WC_EBANX_Request::read('ebanx_masked_card_number', null))
|| empty(WC_EBANX_Request::read('ebanx_brand', null))
Expand Down Expand Up @@ -262,9 +262,9 @@ protected function save_user_meta_fields($order)
{
parent::save_user_meta_fields($order);

if ($this->userId
if ( ! $this->userId
|| $this->get_setting_or_default('save_card_data', 'no') !== 'yes'
|| ! WC_EBANX_Request::has(['ebanx-save-credit-card'])
|| ! WC_EBANX_Request::has('ebanx-save-credit-card')
|| WC_EBANX_Request::read('ebanx-save-credit-card') !== 'yes') {
return;
}
Expand Down
10 changes: 5 additions & 5 deletions woocommerce-gateway-ebanx/gateways/class-wc-ebanx-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ protected function request_data($order)
$person_type = 'business';
}
if (in_array('cpf', $fields_options) && in_array('cnpj', $fields_options)) {
$person_type = WC_EBANX_Request::read($this->names['ebanx_billing_brazil_person_type']) == 'cnpj' ? 'business' : 'personal';
$person_type = WC_EBANX_Request::read($this->names['ebanx_billing_brazil_person_type'], 'cpf') == 'cnpj' ? 'business' : 'personal';
}


Expand Down Expand Up @@ -624,10 +624,10 @@ protected function request_data($order)
*/
public function getTransactionAddress($attr = '')
{
if (
!isset(WC()->customer)
|| is_admin()
|| empty(WC_EBANX_Request::read('billing_country', null))
if (
!isset(WC()->customer)
|| is_admin()
|| empty(WC_EBANX_Request::read('billing_country', null))
&& empty(WC()->customer->get_country())
) {
return false;
Expand Down
14 changes: 9 additions & 5 deletions 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.12.0
Stable tag: 1.12.1
License: MIT
License URI: https://opensource.org/licenses/MIT

Expand Down Expand Up @@ -136,7 +136,11 @@ Yes, you can.

== Changelog ==

== 1.12.0 ==
= 1.12.1 =
* Fix - Credit-card saving for new customers [#496](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/496)
* Fix - One-click payments button in product details [#496](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/496)

= 1.12.0 =
* Feature - Using interest rate on minimum instalment value [#490](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/490)
* Feature - Refactor EBANX query router [#487](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/487)
* Feature - Added a minimal value setting on settings [#477](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/477)
Expand All @@ -149,14 +153,14 @@ Yes, you can.
* Fix - Using absolute path to spinner gif [#485](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/485)
* Improvement - Updated notification notices and notes [#468](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/468)

== 1.11.4 ==
= 1.11.4 =
* Fix - Fixed float values not being accepted in interest rates [#480](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/480)
* Fix - Added '/' to Notification URL to prevent Response Code 301 [#480](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/480)

== 1.11.3 ==
= 1.11.3 =
* Fix - Fixed a problem that it was incrementing a value by instalment [#463](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/463)

== 1.11.2 ==
= 1.11.2 =
* Fix - Fixed translation paths [#462](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/462)
* Fix - Fixed converted value message when instalments is changed [#462](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/462)
* Fix - Fixed problems with newer version of WooCommerce [#462](https://github.com/ebanx/woocommerce-gateway-ebanx/pull/462)
Expand Down
14 changes: 7 additions & 7 deletions woocommerce-gateway-ebanx/services/class-wc-ebanx-one-click.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
}

class WC_EBANX_One_Click {
const CREATE_ORDER_ACTION = 'ebanx_create_order';

private $cards;
private $userId;
private $gateway;
private $orderAction = 'ebanx_create_order';

protected $instalment_rates = array();

Expand Down Expand Up @@ -71,13 +72,12 @@ public function one_click_handler() {
ob_start();

if ( is_admin()
|| ! WC_EBANX_Request::has('product')
|| ! WC_EBANX_Request::has('ebanx-action')
|| WC_EBANX_Request::read('ebanx-action') !== $this->orderAction
|| ! WC_EBANX_Request::has('ebanx-nonce')
|| ! wp_verify_nonce( WC_EBANX_Request::read('ebanx-nonce'), $this->orderAction )
|| ! WC_EBANX_Request::has('ebanx-cart-total')
|| ! WC_EBANX_Request::has('ebanx-product-id')
|| ! WC_EBANX_Request::has('ebanx-cart-total')
|| WC_EBANX_Request::read('ebanx-action') !== self::CREATE_ORDER_ACTION
|| ! wp_verify_nonce( WC_EBANX_Request::read('ebanx-nonce'), self::CREATE_ORDER_ACTION )
|| ! $this->customer_can()
|| ! $this->customer_has_ebanx_required_data()
) {
Expand Down Expand Up @@ -153,7 +153,7 @@ public function one_click_handler() {
exit;
}
catch (Exception $e) {
// TODO: Make a caucght exception
// TODO: Make a caught exception
}

$this->restore_cart();
Expand Down Expand Up @@ -332,7 +332,7 @@ public function print_button() {
'label' => __( 'Pay with one click', 'woocommerce-gateway-ebanx' ),
'instalments' => $messages['instalments'],
'instalments_terms' => $instalments_terms,
'nonce' => wp_create_nonce( $this->orderAction ),
'nonce' => wp_create_nonce( self::CREATE_ORDER_ACTION ),
'action' => $this->orderAction,
'permalink' => get_permalink($product->id),
'country' => $country,
Expand Down
6 changes: 3 additions & 3 deletions woocommerce-gateway-ebanx/woocommerce-gateway-ebanx.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
* 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.12.0
* Version: 1.12.1
* License: MIT
* Text Domain: woocommerce-gateway-ebanx
* Domain Path: /languages
*
* @package WooCommerce_EBANX
*/

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

Expand All @@ -31,7 +31,7 @@
define('WC_EBANX_ASSETS_DIR', __DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR);
define('WC_EBANX_CONTROLLERS_DIR', __DIR__ . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR);

if (!class_exists('WC_EBANX')) {
if ( ! class_exists('WC_EBANX') ) {
/**
* Hooks
*/
Expand Down

0 comments on commit 6eb105e

Please sign in to comment.