Changeset 3382634
- Timestamp:
- 10/22/2025 01:16:29 PM (4 months ago)
- Location:
- vindi-pagamentos/trunk
- Files:
-
- 13 edited
-
app/Core/Config.php (modified) (1 diff)
-
app/Services/WooCommerce/Blocks/BlockCheckoutFieldManager.php (modified) (5 diffs)
-
app/Services/WooCommerce/Checkout/PaymentProcessor.php (modified) (3 diffs)
-
app/Services/WooCommerce/Core.php (modified) (1 diff)
-
assets/blocks/components/PersonTypeFallback/block.json (modified) (1 diff)
-
composer.json (modified) (1 diff)
-
package.json (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
vendor/autoload.php (modified) (1 diff)
-
vendor/composer/autoload_real.php (modified) (2 diffs)
-
vendor/composer/autoload_static.php (modified) (2 diffs)
-
vendor/composer/installed.php (modified) (2 diffs)
-
vindi-pagamentos.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vindi-pagamentos/trunk/app/Core/Config.php
r3371384 r3382634 73 73 public function pluginVersion(): string 74 74 { 75 return '1.0. 7';75 return '1.0.8'; 76 76 } 77 77 } -
vindi-pagamentos/trunk/app/Services/WooCommerce/Blocks/BlockCheckoutFieldManager.php
r3364036 r3382634 3 3 namespace VindiPagamentos\Services\WooCommerce\Blocks; 4 4 5 use Automattic\WooCommerce\Blocks\Package; 6 use Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFields; 5 7 use VindiPagamentos\Exceptions\MissingDocumentException; 6 8 … … 13 15 public function __construct() 14 16 { 17 add_action('woocommerce_init', [$this, 'init'], 20); 18 } 19 20 public function init() 21 { 22 if ($this->fieldsAlreadyExist()) { 23 return; 24 } 25 15 26 if ($this->shouldUseNativeFields()) { 16 27 $this->initializeNativeFields(); … … 25 36 private function shouldUseNativeFields(): bool 26 37 { 27 if (!function_exists('woocommerce_register_additional_checkout_field')) { 28 return false; 29 } 30 31 if ($this->fieldsAlreadyExist()) { 32 return false; 33 } 34 35 return true; 38 return function_exists('woocommerce_register_additional_checkout_field'); 36 39 } 37 40 … … 41 44 private function fieldsAlreadyExist(): bool 42 45 { 43 $existing_fields = [ 44 'billing_cpf', 45 'billing_cnpj', 46 'billing_persontype', 47 '_billing_cpf', 48 '_billing_cnpj', 49 '_billing_persontype' 50 ]; 51 52 foreach ($existing_fields as $field) { 46 try { 53 47 if ( 54 has_filter('woocommerce_checkout_fields', $field) ||55 has_action('woocommerce_checkout_process', $field)48 !class_exists('Automattic\WooCommerce\Blocks\Package') || 49 !class_exists('Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFields') 56 50 ) { 57 51 return true; 58 52 } 59 } 60 61 return false; 53 54 $checkout_fields = Package::container()->get(CheckoutFields::class); 55 $additional_fields = $checkout_fields->get_additional_fields(); 56 57 if (empty($additional_fields)) { 58 return false; 59 } 60 61 foreach ($additional_fields as $field) { 62 $field_id = strtolower($field['id'] ?? ''); 63 64 if (strpos($field_id, 'vindi-pagamentos/') === 0) { 65 continue; 66 } 67 68 if ( 69 strpos($field_id, 'billing_cpf') !== false || 70 strpos($field_id, 'billing_cnpj') !== false || 71 strpos($field_id, 'billing_persontype') !== false 72 ) { 73 return true; 74 } 75 } 76 77 return false; 78 } catch (\Exception $e) { 79 return false; 80 } 62 81 } 63 82 … … 74 93 75 94 /** 76 * Inicializa implementação customizada (fallback) 95 * Inicializa implementação customizada (fallback), para quando a versão do WooCommerce não suporta campos nativos 77 96 */ 78 97 private function initializeCustomFields(): void -
vindi-pagamentos/trunk/app/Services/WooCommerce/Checkout/PaymentProcessor.php
r3371384 r3382634 1273 1273 } 1274 1274 1275 /** 1276 * Busca um meta_key do pedido de forma flexível 1277 * Procura por qualquer meta_key que CONTENHA o termo buscado 1278 * 1279 * @param string $search_term Termo a buscar (ex: 'billing_cpf') 1280 * @return string Valor encontrado ou string vazia 1281 */ 1282 private function getOrderMetaFlexible(string $search_term): string 1283 { 1284 $all_meta = $this->order->get_meta_data(); 1285 1286 foreach ($all_meta as $meta) { 1287 $meta_key = $meta->key ?? ''; 1288 1289 if (strpos($meta_key, $search_term) !== false) { 1290 $value = $meta->value ?? ''; 1291 if (!empty($value)) { 1292 return $value; 1293 } 1294 } 1295 } 1296 1297 return ''; 1298 } 1299 1300 private function setCnpjData(array &$data): void 1301 { 1302 $data['cnpj'] = $this->getOrderMetaFlexible('billing_cnpj'); 1303 1304 if (!$data['cnpj']) { 1305 throw new MissingDocumentException('CNPJ'); 1306 } 1307 1308 $data['trade_name'] = "{$this->order->get_billing_first_name()} {$this->order->get_billing_last_name()}"; 1309 $data['company_name'] = $this->order->get_billing_company(); 1310 1311 $gatewayDocument = $this->getCustomerDocument(); 1312 if ($gatewayDocument) { 1313 $data['cpf'] = $gatewayDocument; 1314 } 1315 } 1316 1317 private function setCpfData(array &$data): void 1318 { 1319 $data['cpf'] = $this->getOrderMetaFlexible('billing_cpf'); 1320 1321 if (!$data['cpf']) { 1322 throw new MissingDocumentException(__('CPF', 'vindi-pagamentos')); 1323 } 1324 } 1325 1275 1326 private function setDocumentFields(array &$data): void 1276 1327 { 1277 $personType = $this-> order->get_meta('_billing_persontype');1328 $personType = $this->getOrderMetaFlexible('billing_persontype'); 1278 1329 1279 1330 if (empty($personType)) { 1280 $personType = $this->order->get_meta('billing_persontype'); 1281 } 1282 1283 if (empty($personType)) { 1284 $cpf = $this->order->get_meta('_billing_cpf'); 1285 $cnpj = $this->order->get_meta('_billing_cnpj'); 1331 $cnpj = $this->getOrderMetaFlexible('billing_cnpj'); 1332 $cpf = $this->getOrderMetaFlexible('billing_cpf'); 1286 1333 1287 1334 if (!empty($cnpj)) { … … 1291 1338 } 1292 1339 } 1340 1293 1341 switch ($personType) { 1294 1342 case '2': … … 1299 1347 break; 1300 1348 default: 1301 $cpf = $this->order->get_meta('_billing_cpf'); 1302 $cnpj = $this->order->get_meta('_billing_cnpj'); 1303 1304 if (!empty($cnpj)) { 1305 $this->setCnpjData($data); 1306 } elseif (!empty($cpf)) { 1307 $this->setCpfData($data); 1308 } else { 1309 throw new MissingDocumentException(__('Tipo de Pessoa ou documento (CPF/CNPJ)', 'vindi-pagamentos')); 1310 } 1349 throw new MissingDocumentException(__('Tipo de Pessoa ou documento (CPF/CNPJ)', 'vindi-pagamentos')); 1311 1350 break; 1312 }1313 }1314 1315 private function setCnpjData(array &$data): void1316 {1317 $data['cnpj'] = $this->order->get_meta('_billing_cnpj');1318 1319 if (!$data['cnpj']) {1320 throw new MissingDocumentException('CNPJ');1321 }1322 1323 $data['trade_name'] = "{$this->order->get_billing_first_name()} {$this->order->get_billing_last_name()}";1324 $data['company_name'] = $this->order->get_billing_company();1325 1326 $gatewayDocument = $this->getCustomerDocument();1327 if ($gatewayDocument) {1328 $data['cpf'] = $gatewayDocument;1329 }1330 }1331 1332 private function setCpfData(array &$data): void1333 {1334 $data['cpf'] = $this->order->get_meta('_billing_cpf');1335 if (!$data['cpf']) {1336 throw new MissingDocumentException('CPF');1337 1351 } 1338 1352 } -
vindi-pagamentos/trunk/app/Services/WooCommerce/Core.php
r3371384 r3382634 155 155 'woocommerce_store_api_checkout_update_order_from_request', 156 156 [PersonTypeFallback::class, 'updateBlockOrderMeta'], 157 10,157 20, 158 158 2 159 159 ); -
vindi-pagamentos/trunk/assets/blocks/components/PersonTypeFallback/block.json
r3371384 r3382634 4 4 "name": "vindi-pagamentos/person-type-fallback", 5 5 "icon": "flag", 6 "version": "1.0. 7",6 "version": "1.0.8", 7 7 "title": "Woo - Tipo de Pessoa (Fallback)", 8 8 "description": "Definição de tipo de pessoa no checkout - versão fallback para WooCommerce antigo", -
vindi-pagamentos/trunk/composer.json
r3371384 r3382634 1 1 { 2 2 "name": "vindi/vindi-pagamentos", 3 "version": "1.0. 7",3 "version": "1.0.8", 4 4 "description": "WooCommerce payment plugin using Vindi gateways", 5 5 "type": "wordpress-plugin", -
vindi-pagamentos/trunk/package.json
r3371384 r3382634 1 1 { 2 2 "name": "vindi-pagamentos", 3 "version": "1.0. 7",3 "version": "1.0.8", 4 4 "description": "WooCommerce payment plugin using Vindi gateways", 5 5 "repository": "https://github.com/vindi/vindi-pagamentos", -
vindi-pagamentos/trunk/readme.txt
r3371384 r3382634 4 4 Requires at least: 6.0 5 5 Tested up to: 6.8 6 Stable tag: 1.0. 76 Stable tag: 1.0.8 7 7 Requires PHP: 7.4 8 8 License: GPLv3 … … 56 56 57 57 == Changelog == 58 =1.0.8 = 06-10-2025 59 * Melhoria: Detecção automática de campos de checkout (CPF/CNPJ/PersonType) 60 * Melhoria: Busca flexível de meta_keys do pedido para compatibilidade com múltiplos plugins de campos 61 58 62 =1.0.7 = 30-09-2025 59 63 * Adição: Opção para habilitar/desabilitar salvamento de cartões de crédito nas configurações -
vindi-pagamentos/trunk/vendor/autoload.php
r3371384 r3382634 23 23 require_once __DIR__ . '/composer/autoload_real.php'; 24 24 25 return ComposerAutoloaderInit 9a679a4f6fec3baaddc32c3f8e39b400::getLoader();25 return ComposerAutoloaderInitbbf5ba13b74aaf6238592a8e3cb2bc1f::getLoader(); -
vindi-pagamentos/trunk/vendor/composer/autoload_real.php
r3371384 r3382634 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 9a679a4f6fec3baaddc32c3f8e39b4005 class ComposerAutoloaderInitbbf5ba13b74aaf6238592a8e3cb2bc1f 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit 9a679a4f6fec3baaddc32c3f8e39b400', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInitbbf5ba13b74aaf6238592a8e3cb2bc1f', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 27 spl_autoload_unregister(array('ComposerAutoloaderInit 9a679a4f6fec3baaddc32c3f8e39b400', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInitbbf5ba13b74aaf6238592a8e3cb2bc1f', 'loadClassLoader')); 28 28 29 29 require __DIR__ . '/autoload_static.php'; 30 call_user_func(\Composer\Autoload\ComposerStaticInit 9a679a4f6fec3baaddc32c3f8e39b400::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInitbbf5ba13b74aaf6238592a8e3cb2bc1f::getInitializer($loader)); 31 31 32 32 $loader->register(true); 33 33 34 $filesToLoad = \Composer\Autoload\ComposerStaticInit 9a679a4f6fec3baaddc32c3f8e39b400::$files;34 $filesToLoad = \Composer\Autoload\ComposerStaticInitbbf5ba13b74aaf6238592a8e3cb2bc1f::$files; 35 35 $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { 36 36 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
vindi-pagamentos/trunk/vendor/composer/autoload_static.php
r3371384 r3382634 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 9a679a4f6fec3baaddc32c3f8e39b4007 class ComposerStaticInitbbf5ba13b74aaf6238592a8e3cb2bc1f 8 8 { 9 9 public static $files = array ( … … 32 32 { 33 33 return \Closure::bind(function () use ($loader) { 34 $loader->prefixLengthsPsr4 = ComposerStaticInit 9a679a4f6fec3baaddc32c3f8e39b400::$prefixLengthsPsr4;35 $loader->prefixDirsPsr4 = ComposerStaticInit 9a679a4f6fec3baaddc32c3f8e39b400::$prefixDirsPsr4;36 $loader->classMap = ComposerStaticInit 9a679a4f6fec3baaddc32c3f8e39b400::$classMap;34 $loader->prefixLengthsPsr4 = ComposerStaticInitbbf5ba13b74aaf6238592a8e3cb2bc1f::$prefixLengthsPsr4; 35 $loader->prefixDirsPsr4 = ComposerStaticInitbbf5ba13b74aaf6238592a8e3cb2bc1f::$prefixDirsPsr4; 36 $loader->classMap = ComposerStaticInitbbf5ba13b74aaf6238592a8e3cb2bc1f::$classMap; 37 37 38 38 }, null, ClassLoader::class); -
vindi-pagamentos/trunk/vendor/composer/installed.php
r3371384 r3382634 2 2 'root' => array( 3 3 'name' => 'vindi/vindi-pagamentos', 4 'pretty_version' => '1.0. 7',5 'version' => '1.0. 7.0',4 'pretty_version' => '1.0.8', 5 'version' => '1.0.8.0', 6 6 'reference' => NULL, 7 7 'type' => 'wordpress-plugin', … … 12 12 'versions' => array( 13 13 'vindi/vindi-pagamentos' => array( 14 'pretty_version' => '1.0. 7',15 'version' => '1.0. 7.0',14 'pretty_version' => '1.0.8', 15 'version' => '1.0.8.0', 16 16 'reference' => NULL, 17 17 'type' => 'wordpress-plugin', -
vindi-pagamentos/trunk/vindi-pagamentos.php
r3371384 r3382634 7 7 * Author: Apiki WordPress 8 8 * Author URI: https://github.com/vindi/ 9 * Version: 1.0. 79 * Version: 1.0.8 10 10 * Requires PHP: 7.4 11 11 * Requires at least: 6.0 … … 15 15 * 16 16 * @link https://vindi.com.br/ 17 * @since 1.0. 717 * @since 1.0.8 18 18 * @package VindiPagamentos 19 19 */
Note: See TracChangeset
for help on using the changeset viewer.