--- a/openpix-for-woocommerce/includes/class-wc-openpix-pix.php
+++ b/openpix-for-woocommerce/includes/class-wc-openpix-pix.php
@@ -83,7 +83,8 @@
$this->order_button_text = $this->get_option('order_button_text');
$this->appID = $this->get_option('appID');
- $this->environment = $this->get_option('environment') ?? EnvironmentEnum::PRODUCTION;
+ $this->environment =
+ $this->get_option('environment') ?? EnvironmentEnum::PRODUCTION;
OpenPixConfig::initialize($this->environment);
@@ -254,17 +255,20 @@
WC_OpenPix::debug('process_admin_options');
if ($saved) {
$new_environment = $this->get_option('environment');
-
+
// Always update the environment option to ensure consistency
if ($old_environment !== $new_environment) {
WC_OpenPix::debug(
- 'Environment changed from ' . $old_environment . ' to ' . $new_environment
+ 'Environment changed from ' .
+ $old_environment .
+ ' to ' .
+ $new_environment
);
$this->update_option('environment', $new_environment);
OpenPixConfig::initialize($new_environment);
}
}
-
+
return $saved;
}
@@ -444,7 +448,7 @@
{
$this->update_option('appID', $data['appID']);
$this->update_option('webhook_status', 'Configured');
-
+
// Update environment if provided in the webhook data
// I don't know if it makes sense to keep this
// @todo: remove this after testing
@@ -767,11 +771,14 @@
'environment' => [
'title' => __('Ambiente', 'woocommerce-openpix'),
'type' => 'select',
- 'description' => __('Selecione o ambiente de integração', 'woocommerce-openpix'),
+ 'description' => __(
+ 'Selecione o ambiente de integração',
+ 'woocommerce-openpix'
+ ),
'default' => 'prod',
'options' => [
'sandbox-prod' => 'Sandbox',
- 'prod' => 'Production'
+ 'prod' => 'Production',
],
],
'oneclick_section' => [
@@ -927,44 +934,7 @@
public function formatPhone($phone)
{
- if (!class_exists('libphonenumberPhoneNumberUtil')) {
- require_once __DIR__ . '/../vendor/autoload.php';
- }
-
- $phoneUtil = libphonenumberPhoneNumberUtil::getInstance();
-
- // Remove all non-numeric characters
- $cleanNumber = preg_replace('/D+/', '', $phone);
-
- // Try first validation with original number
- try {
- $numberProto = $phoneUtil->parse($cleanNumber, 'BR');
- if ($phoneUtil->isValidNumber($numberProto)) {
- $formattedNumber = $phoneUtil->format($numberProto, libphonenumberPhoneNumberFormat::E164);
- return ltrim($formattedNumber, '+');
- }
- } catch (libphonenumberNumberParseException $e) {
- // Continue to try alternative format if this fails
- }
-
- // If the first validation fails and number starts with 5555,
- // try removing one instance of 55 and validate again
- if (strpos($cleanNumber, '5555') === 0) {
- $alternativeNumber = '55' . substr($cleanNumber, 4);
-
- try {
- $numberProto = $phoneUtil->parse($alternativeNumber, 'BR');
- if ($phoneUtil->isValidNumber($numberProto)) {
- $formattedNumber = $phoneUtil->format($numberProto, libphonenumberPhoneNumberFormat::E164);
- return ltrim($formattedNumber, '+');
- }
- } catch (libphonenumberNumberParseException $e) {
- // If both attempts fail, return false
- return false;
- }
- }
-
- return false;
+ return preg_replace('/D+/', '', $phone);
}
public function getHasCustomer($order)
--- a/openpix-for-woocommerce/includes/customer/class-wc-openpix-customer.php
+++ b/openpix-for-woocommerce/includes/customer/class-wc-openpix-customer.php
@@ -6,27 +6,39 @@
class WC_OpenPix_Customer
{
- public function getCustomerAddress($order) {
- $order_billing_address_1 = $order->get_billing_address_1();
- $order_billing_address_2 = $order->get_billing_address_2();
- $order_billing_city = $order->get_billing_city();
- $order_billing_state = $order->get_billing_state();
- $order_billing_postcode = $order->get_billing_postcode();
- $order_billing_country = $order->get_billing_country();
- $order_billing_neighborhood = $order->get_meta('_billing_neighborhood');
- $order_billing_number = $order->get_meta('_billing_number');
+ public function getCustomerAddress($order)
+ {
+ $order_billing_address_1 = $order->get_billing_address_1();
+ $order_billing_address_2 = $order->get_billing_address_2();
+ $order_billing_city = $order->get_billing_city();
+ $order_billing_state = $order->get_billing_state();
+ $order_billing_postcode = $order->get_billing_postcode();
+ $order_billing_country = $order->get_billing_country();
+ $order_billing_neighborhood = $order->get_meta('_billing_neighborhood');
+ if (empty($order_billing_neighborhood)) {
+ $order_billing_neighborhood = $order->get_billing_address_2();
+ }
+
+ if (empty($order_billing_neighborhood)) {
+ $order_billing_neighborhood = 'Bairro';
+ }
+
+ $order_billing_number = $order->get_meta('_billing_number');
+ if (empty($order_billing_number)) {
+ $order_billing_number = 'S/N';
+ }
$address = [
'zipcode' => $order_billing_postcode,
'street' => $order_billing_address_1,
'number' => $order_billing_number,
'neighborhood' => $order_billing_neighborhood,
- 'city' => $order_billing_city,
+ 'city' => $order_billing_city,
'state' => $order_billing_state,
'complement' => $order_billing_address_2,
- 'country' => $order_billing_country
+ 'country' => $order_billing_country,
];
return $address;
}
-}
No newline at end of file
+}
--- a/openpix-for-woocommerce/vendor/composer/installed.php
+++ b/openpix-for-woocommerce/vendor/composer/installed.php
@@ -3,7 +3,7 @@
'name' => 'openpix/woocommerce-openpix',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
- 'reference' => '180d5569a542914f5cfcf180b19c07c8d56272f9',
+ 'reference' => 'bfb1f6965e493a2bc238c7df58d653c76384e5df',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -37,7 +37,7 @@
'openpix/woocommerce-openpix' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
- 'reference' => '180d5569a542914f5cfcf180b19c07c8d56272f9',
+ 'reference' => 'bfb1f6965e493a2bc238c7df58d653c76384e5df',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
--- a/openpix-for-woocommerce/woocommerce-openpix.php
+++ b/openpix-for-woocommerce/woocommerce-openpix.php
@@ -5,7 +5,7 @@
* Description: Aceite pagamentos Pix em com atualização em tempo real, checkout transparente e atualização automática de status do pedido.
* Author: OpenPix
* Author URI: https://openpix.com.br/
- * Version: 2.13.3
+ * Version: 2.13.4
* Text Domain: woocommerce-openpix
* WC tested up to: 8.2.2
* Requires Plugins: woocommerce
@@ -55,7 +55,7 @@
class WC_OpenPix
{
- const VERSION = '2.13.3';
+ const VERSION = '2.13.4';
protected static $instance = null;
@@ -101,6 +101,8 @@
'/includes/class-wc-openpix-pix-parcelado.php';
include_once dirname(__FILE__) .
'/includes/class-wc-openpix-pix-crediary.php';
+ include_once dirname(__FILE__) .
+ '/includes/class-wc-openpix-boleto.php';
}
/**
@@ -147,6 +149,17 @@
'</a>';
$plugin_links[] =
+ '<a href="' .
+ esc_url(
+ admin_url(
+ 'admin.php?page=wc-settings&tab=checkout§ion=woocommerce_openpix_boleto'
+ )
+ ) .
+ '">' .
+ __('Settings Boleto', 'woocommerce-openpix') .
+ '</a>';
+
+ $plugin_links[] =
'<a target="_blank" href="https://developers.openpix.com.br/docs/ecommerce/woocommerce/woocommerce-plugin">' .
__('Documentation', 'woocommerce-openpix') .
'</a>';
@@ -166,6 +179,7 @@
// $methods[] = 'WC_OpenPix_Pix_Gateway';
$methods[] = WC_OpenPix_Pix_Parcelado_Gateway::instance();
$methods[] = WC_OpenPix_Pix_Crediary_Gateway::instance();
+ $methods[] = WC_OpenPix_Boleto_Gateway::instance();
return $methods;
}
@@ -182,6 +196,8 @@
include_once dirname(__FILE__) .
'/includes/class-wc-openpix-pix-block.php';
+ include_once dirname(__FILE__) .
+ '/includes/class-wc-openpix-boleto-block.php';
add_action(
'woocommerce_blocks_payment_method_type_registration',
@@ -189,6 +205,9 @@
AutomatticWooCommerceBlocksPaymentsPaymentMethodRegistry $payment_method_registry
) {
$payment_method_registry->register(new WC_OpenPix_Pix_Block());
+ $payment_method_registry->register(
+ new WC_OpenPix_Boleto_Block()
+ );
}
);
}
@@ -288,7 +307,9 @@
return is_plugin_active($pluginId) &&
class_exists('AutomatticWooCommerceBlocksPackage') &&
file_exists(
- __DIR__ . '/assets/' . WC_OpenPix_Pix_Block::PIX_BLOCK_SCRIPT_FILENAME
+ __DIR__ .
+ '/assets/' .
+ WC_OpenPix_Pix_Block::PIX_BLOCK_SCRIPT_FILENAME
);
}