Skip to content

Commit

Permalink
release: 3.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiano-mallmann authored Feb 10, 2025
2 parents 239ab9f + d24af39 commit f268f38
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 83 deletions.
6 changes: 4 additions & 2 deletions assets/javascripts/front/checkout/model/payment/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ let pagarmeCard = {
valueTarget: 'input[data-pagarme-element="order-value"]',
installmentsTarget: '[data-pagarme-component="installments"]',
installmentsInfoTarget: '[data-pagarme-component="installments-info"]',
maskTargets: 'input[class*="pagarme-card-form"][data-mask]',
mundiCdn: 'https://cdn.mundipagg.com/assets/images/logos/brands/png/',
tokenElement: '[data-pagarme-element="token"]',
fieldsetCardElements: 'fieldset[data-pagarmecheckout="card"]',
Expand Down Expand Up @@ -475,6 +476,7 @@ let pagarmeCard = {
addEventListener: function () {
jQuery(document.body).on('updated_checkout', function () {
pagarmeCard.renewEventListener();
jQuery.applyDataMask(pagarmeCard.maskTargets);
let creditCardField = jQuery(pagarmeCard.cardNumberTarget);
creditCardField.each(function () {
if (jQuery(this)?.val() && pagarmeCard.isVisible(jQuery(this)[0])) {
Expand All @@ -500,7 +502,7 @@ let pagarmeCard = {
pagarmeCard.preventSpecialCharacter(this);
});

jQuery(this.cardNumberTarget).on('input', function (event) {
jQuery(this.cardNumberTarget).on('change', function (event) {
pagarmeCard.keyEventHandlerCard(event);
});

Expand All @@ -509,7 +511,7 @@ let pagarmeCard = {
});
},
renewEventListener: function () {
jQuery(this.cardNumberTarget).on('input', function (event) {
jQuery(this.cardNumberTarget).on('change', function (event) {
pagarmeCard.keyEventHandlerCard(event);
});
jQuery(`${this.fieldsetCardElements} input`).on('change', function () {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pagarme/woocommerce-pagarme-payments",
"description": "Pagar.me module for Woocommerce",
"type": "wordpress-plugin",
"version": "3.4.4",
"version": "3.5.0",
"license": "GPL",
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function wc_pagarme_define($name, $value)

wc_pagarme_define('WCMP_SLUG', 'woo-pagarme-payments');
wc_pagarme_define('WCMP_PREFIX', 'pagarme');
wc_pagarme_define('WCMP_VERSION', '3.4.4');
wc_pagarme_define('WCMP_VERSION', '3.5.0');
wc_pagarme_define('WCMP_ROOT_PATH', dirname(__FILE__) . '/');
wc_pagarme_define('WCMP_ROOT_SRC', WCMP_ROOT_PATH . 'src/');
wc_pagarme_define('WCMP_ROOT_FILE', WCMP_ROOT_PATH . WCMP_SLUG . '.php');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "woo-pagarme-payments",
"version": "3.4.4",
"version": "3.5.0",
"description": "Pagar.me module for Woocommerce",
"main": "woo-pagarme-payments.php",
"devDependencies": {
Expand Down
20 changes: 9 additions & 11 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: payment, pagarme, ecommerce, brasil, woocommerce
Requires at least: 4.1
Tested up to: 6.5.5
Requires PHP: 7.1
Stable tag: 3.4.4
Stable tag: 3.5.0
License: MIT
License URI: https://github.com/pagarme/woocommerce/blob/master/LICENSE

Expand All @@ -25,6 +25,14 @@ Nosso processo de instalação é simples e bem detalhado:
== Changelog ==
Lançamos versões regularmente com melhorias, correções e atualizações.

= 3.5.0 (10/02/2025) =
Você pode conferir essas atualizações aqui: [Github](https://github.com/pagarme/woocommerce/releases/tag/3.5.0)

* **Correções:**
* Corrige excesso de requisições para buscar bandeira de cartão no Checkout normal;
* Corrige URL de webhooks quando o site possui Paths;
* Corrige a reaplicação de máscara no checkout.

= 3.4.4 (15/01/2025) =
Você pode conferir essas atualizações aqui: [Github](https://github.com/pagarme/woocommerce/releases/tag/3.4.4)

Expand All @@ -37,15 +45,5 @@ Você pode conferir essas atualizações aqui: [Github](https://github.com/pagar
* **Melhorias:**
* Adicionando link para o pedido na Dashboard Pagar.me.

= 3.4.3 (21/11/2024) =
Você pode conferir essas atualizações aqui: [Github](https://github.com/pagarme/woocommerce/releases/tag/3.4.3)

* **Correções:**
* Problema na tela de Produtos;
* Problema com versões antigas e Checkout Blocks;
* Aceitar S/N (Não numeral) no campo de Número do endereço;
* Problema com transação deslogado e assinatura.


== Upgrade Notice ==
Agora é possível transacionar com Ticket
8 changes: 4 additions & 4 deletions src/Controller/Hub.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Hub
public function __construct()
{
$this->settings = new Config();
add_action('woocommerce_api_' . Core::get_hub_name(), array($this, 'handle_requests'));
add_action('woocommerce_api_' . Core::getHubName(), array($this, 'handle_requests'));
}

public function handle_requests()
Expand All @@ -31,8 +31,8 @@ public function handle_requests()
$hubIntegrationService->endHubIntegration(
$params['install_token'],
$params['authorization_code'],
Core::get_hub_command_url(),
Core::get_webhook_url()
Core::getHubCommandUrl(),
Core::getWebhookUrl()
);
$this->updateConfig();
} catch (\Throwable $error) {
Expand Down Expand Up @@ -72,7 +72,7 @@ public function updateConfig()
);

$this->settings->setAccountId($moduleConfig->getAccountId()->getValue());

$this->settings->setData('sandbox_secret_key', null);
$this->settings->setData('sandbox_public_key', null);
$this->settings->setData('environment', null);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/HubCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class HubCommand
public function __construct()
{
$this->settings = new Config;
add_action('woocommerce_api_' . Core::get_hub_command_name(), array($this, 'handle_requests'));
add_action('woocommerce_api_' . Core::getHubCommandName(), array($this, 'handle_requests'));
}

public function handle_requests()
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Webhooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Webhooks
public function __construct()
{
$this->config = new Config();
add_action('woocommerce_api_' . Core::get_webhook_name(), array($this, 'handle_requests'));
add_action('woocommerce_api_' . Core::getWebhookName(), array($this, 'handle_requests'));
}

public function handle_requests()
Expand Down
57 changes: 32 additions & 25 deletions src/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
exit(0);
}

use WooCommerce;
use Woocommerce\Pagarme\Helper\Utils;
use Woocommerce\Pagarme\Action\ActionsRunner;

Expand Down Expand Up @@ -222,48 +223,54 @@ public static function instance()
endif;
}

public static function get_webhook_url($custom_url = false)
/**
* @param $custom_url
*
* @return string
*/
public static function getWebhookUrl()
{
$url = !$custom_url ? Utils::get_site_url() : $custom_url;
if ( !$custom_url ) {
$parsedUrl = parse_url($url);
$url = $parsedUrl['scheme'] . '://' . $parsedUrl['host'];
}

return sprintf('%s/wc-api/%s/', $url, self::get_webhook_name());
return (new WooCommerce())->api_request_url(self::getWebhookName());
}

public static function get_webhook_name()
/**
* @return string
*/
public static function getWebhookName()
{
return Utils::add_prefix('-webhook');
}

public static function get_hub_command_url($custom_url = false)
/**
* @param $custom_url
*
* @return string
*/
public static function getHubCommandUrl()
{
$url = !$custom_url ? Utils::get_site_url() : $custom_url;

return sprintf(
'%s/wc-api/%s/',
$url,
self::get_hub_command_name()
);
return (new WooCommerce())->api_request_url(self::getHubCommandName());
}

public static function get_hub_command_name()
/**
* @return string
*/
public static function getHubCommandName()
{
return Utils::add_prefix('-hubcommand');
}

public static function get_hub_url()
/**
* @return string
*/
public static function getHubUrl()
{
return sprintf(
'%s/wc-api/%s/',
Utils::get_site_url(),
self::get_hub_name()
);
return (new WooCommerce())->api_request_url(self::getHubName());
}

public static function get_hub_name()
/**
* @return string
*/
public static function getHubName()
{
return Utils::add_prefix('-hub');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private function getHubParamsUrl()
{
return sprintf(
'?redirect=%s?install_token=%s',
Core::get_hub_url(),
Core::getHubUrl(),
$this->getHubInstallToken()
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private function get_hub_integrate_url()

$params = sprintf(
'?redirect=%s?install_token=%s',
Core::get_hub_url(),
Core::getHubUrl(),
$this->get_hub_install_token()
);

Expand Down
61 changes: 28 additions & 33 deletions tests/Model/CoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Woocommerce\Pagarme\Tests\Model;

use PHPUnit\Framework\TestCase;
use Woocommerce\Pagarme\Core;
use Brain;
use Mockery;
use PHPUnit\Framework\TestCase;
use Woocommerce\Pagarme\Core;

class CoreTest extends TestCase
{
Expand All @@ -21,45 +21,40 @@ public function tearDown(): void
Mockery::close();
Brain\Monkey\tearDown();
}
public function testGetWebhookWithoutCustomUrlAndWithPath()

public function testGetWebhookUrlWithoutCustomUrlWithoutSubfolder()
{
$domain = "https://mycustomdomain.test";
$webhookLink = $domain . "/wc-api/pagarme-webhook/";

$wpHomeAddress = "https://domain.test/";
$apiPath = "wc-api/";
$webhookName = "pagarme-webhook";
$webhookLink = $wpHomeAddress . $apiPath . $webhookName;

$utils = Mockery::mock("alias:Woocommerce\Pagarme\Helper\Utils");
$utils->shouldReceive('get_site_url')->andReturn($domain);
$utils->shouldReceive('add_prefix')->andReturn('pagarme-webhook');

$getUrl = Core::get_webhook_url();
$utils->shouldReceive('add_prefix')->with('-webhook')->andReturn($webhookName);

$this->assertEquals($webhookLink, $getUrl);
}
$wooCommerce = Mockery::mock("overload:WooCommerce");
$wooCommerce->shouldReceive('api_request_url')->with($webhookName)->andReturn($webhookLink);

public function testGetWebhookWithoutCustomUrlWithPath()
{
$domain = "https://mycustomdomain.test";
$domainWithPath = "https://mycustomdomain.test/app/customPath";
$webhookLink = $domain . "/wc-api/pagarme-webhook/";

$utils = Mockery::mock("alias:Woocommerce\Pagarme\Helper\Utils");
$utils->shouldReceive('get_site_url')->andReturn($domainWithPath);
$utils->shouldReceive('add_prefix')->andReturn('pagarme-webhook');

$getUrl = Core::get_webhook_url();
$getWebhookUrl = Core::getWebhookUrl();

$this->assertEquals($webhookLink, $getUrl);
$this->assertEquals($webhookLink, $getWebhookUrl);
}
public function testGetWebhookWithoutCustomUrl()

public function testGetWebhookUrlWithoutCustomUrlWithSubfolder()
{
$customDomain = "https://mycustomdomain.test";
$webhookLink = $customDomain . "/wc-api/pagarme-webhook/";

$wpHomeAddress = "https://domain.test/subfolder/";
$apiPath = "wc-api/";
$webhookName = "pagarme-webhook";
$webhookLink = $wpHomeAddress . $apiPath . $webhookName;

$utils = Mockery::mock("alias:Woocommerce\Pagarme\Helper\Utils");
$utils->shouldReceive('get_site_url')->andReturn($customDomain);
$utils->shouldReceive('add_prefix')->andReturn('pagarme-webhook');

$getUrl = Core::get_webhook_url($customDomain);
$utils->shouldReceive('add_prefix')->with('-webhook')->andReturn($webhookName);

$wooCommerce = Mockery::mock("overload:WooCommerce");
$wooCommerce->shouldReceive('api_request_url')->with($webhookName)->andReturn($webhookLink);

$getWebhookUrl = Core::getWebhookUrl();

$this->assertEquals($webhookLink, $getUrl);
$this->assertEquals($webhookLink, $getWebhookUrl);
}
}
2 changes: 1 addition & 1 deletion woo-pagarme-payments.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
* Plugin Name: Pagar.me for WooCommerce
* Version: 3.4.4
* Version: 3.5.0
* Author: Pagar.me
* Author URI: https://pagar.me
* License: GPL2
Expand Down

0 comments on commit f268f38

Please sign in to comment.