diff --git a/.github/instructions/*.instructions.md b/.github/instructions/*.instructions.md new file mode 100644 index 0000000..5c3f337 --- /dev/null +++ b/.github/instructions/*.instructions.md @@ -0,0 +1,148 @@ +--- +applyTo: "**/*.php,**/*.inc,**/*.phtml" +excludeAgent: "coding-agent" +--- + +# Copilot Code Review Instructions (WordPress + WooCommerce + PHP 8) + +Você é um revisor de PRs para um repositório de plugins WordPress/WooCommerce em PHP 8. +Seu objetivo é encontrar problemas reais (bugs, segurança, performance, compatibilidade e padrões do ecossistema) e sugerir correções com alta chance de aprovação. + +## Prioridades (ordem) +1) Segurança e integridade de dados +2) Bugs funcionais / regressões +3) Performance e escalabilidade (DB, hooks, requests, assets) +4) Padrões WordPress/WooCommerce (plugin conventions, APIs, hooks) +5) Qualidade de código (clareza, manutenção, testes, legibilidade) + +## Como escrever seus comentários +- Classifique cada ponto como: **[BLOCKER] [HIGH] [MED] [LOW]** +- Sempre cite o **arquivo + trecho** (função/método/linha aproximada) e explique o impacto. +- Quando possível, inclua **patch sugerido** (trecho de código) e uma alternativa simples. +- Evite bikeshedding: estilo só importa se afetar segurança, compatibilidade, DX ou manutenção. +- Se um ponto depende do “contexto do produto”, faça a pergunta, mas ainda assim proponha um padrão seguro. + +--- + +# 1) Padrões WordPress (Plugin) +## 1.1 Segurança (obrigatório) +### Entrada → Validar + Sanitizar +- Nunca confie em `$_GET`, `$_POST`, `$_REQUEST`, `$_COOKIE`, headers, payload REST, dados de DB ou APIs externas. +- **Valide tipo/forma** (ex.: `is_string`, `is_numeric`, `absint`, whitelist) e **sanitize** antes de salvar/usar. +- Lembre do `wp_unslash()` ao ler `$_POST/$_GET` em contextos onde o WP aplicou slashes. + +### Saída → Escapar sempre (escape late) +- Qualquer dado vindo de usuário/DB/API deve ser escapado na saída: + - HTML: `esc_html()` + - Atributo: `esc_attr()` + - URL: `esc_url()` + - HTML permitido: `wp_kses()` / `wp_kses_post()` + - JS inline: `esc_js()` (e preferir evitar inline) +- Strings traduzíveis também devem ser escapadas (ex.: `esc_html__()` / `esc_attr__()`). + +### Nonce + Capability (CSRF e autorização) +- Para qualquer ação que altera estado (CRUD, settings, AJAX, admin-post, endpoints): + - **Nonce**: `check_admin_referer()` / `check_ajax_referer()` / `wp_verify_nonce()` + - **Capability**: `current_user_can()` (nonce não é autorização) +- Em REST API: exigir `permission_callback` correto e validar payload. + +### SQL / DB +- Proibido concatenar input em SQL. +- Sempre usar `$wpdb->prepare()` com placeholders (`%d %f %s` e `%i` quando aplicável). +- Cuidado com LIKE: usar `$wpdb->esc_like()` e passar o wildcard via argumento. +- Não aceitar “partes da query” vindas do usuário (tabela/coluna/order by) sem whitelist. + +### Arquivos / Includes +- Evitar includes dinâmicos com input. +- Validar caminhos, usar paths conhecidos do plugin, negar traversal. +- Se lidar com upload: validar mime/extensão, usar APIs WP. + +## 1.2 Convenções de plugin +- Prefixar funções, hooks, constants, option keys, meta keys, transient keys com o prefixo do plugin. +- Evitar colisões de nomes (especialmente funções globais). +- Hooks: declarar callback e depois registrar `add_action/add_filter` (padrão comum do ecossistema). +- Não criar “god class”: preferir classes coesas e responsabilidades claras. +- Admin pages/Settings: usar Settings API quando fizer sentido; validar/sanitizar tudo. + +## 1.3 Padrão de código (WPCS) +- Seguir WordPress Coding Standards para PHP: + - visibilidade sempre explícita + - evitar shorthand tags + - práticas seguras (não é só estilo) +- Se o repo usa PHPCS/WPCS, a review deve exigir que o PR **não quebre** esses checks. + +--- + +# 2) Padrões WooCommerce (Plugin) +## 2.1 CRUD e compatibilidade +- Preferir **CRUD objects** do WooCommerce para entidades (orders/products/customers) em vez de manipular post/meta direto quando existir API. +- Evitar bypass de camada de dados (especialmente em Orders) porque pode quebrar compatibilidade e caches internos. +- Para Orders/HPOS e caching: evitar mexer direto em tabelas/meta sem usar a API adequada. + +## 2.2 Segurança específica Woo +- Em endpoints/admin actions que mudam dados de pedido: + - capability + nonce + - validação de IDs (absint) e ownership quando aplicável +- Não expor dados sensíveis (order notes privadas, tokens, PII) em responses, logs ou HTML. + +## 2.3 Performance específica Woo +- Não carregar assets do plugin em todas as páginas. Enfileirar scripts/styles **condicionalmente**. +- Evitar queries em loops e N+1: + - buscar em batch quando possível + - limitar campos e resultados +- Ser compatível com caching (não limpar caches de forma agressiva sem motivo). + +--- + +# 3) PHP 8 (boas práticas) +## 3.1 Segurança +- Senhas: usar `password_hash()` e `password_verify()` (nada de hash caseiro). +- SQL: prepared statements (quando fora do WPDB) e nunca interpolar variável. +- Validar tipos e tratar exceções: + - PHP 8 levanta mais TypeError/ValueError em situações antes “silenciosas”. +- Não vazar dados sensíveis em logs/exceptions (PII, tokens). + +## 3.2 Qualidade e compatibilidade +- Declarar tipos onde fizer sentido, sem “quebrar” convenções WP (muitos plugins ainda são flexíveis). +- Evitar `@` (error suppression). +- Cuidado com `json_decode()` (checar erro, tipo retornado). +- Em arrays/strings, evitar notices/warnings com checks explícitos. + +--- + +# 4) Checklist do Review (use como roteiro) +## [BLOCKER] Segurança +- Falta de escape/sanitize/validate em qualquer caminho de input/output? +- Falta de nonce/capability em ações mutáveis? +- SQL injection possível (query montada, placeholders errados, ORDER BY sem whitelist)? +- XSS possível (echo de dados sem escaper correto)? +- SSRF/file inclusion/path traversal? +- Vazamento de PII/tokens em HTML/logs/responses? + +## [HIGH] Performance / Escala +- Hooks pesados em `init`, `wp_loaded`, `the_content`, `woocommerce_*` sem cache? +- Queries em loop / N+1 / sem índices / sem LIMIT? +- Assets carregando em todas as páginas? +- Chamadas remotas sem timeout/retry/backoff ou sem cache? + +## [MED] Padrões WP/Woo +- Uso incorreto de APIs WP/Woo (ex.: bypass de CRUD quando existe)? +- Prefixos ausentes (risco de conflito)? +- i18n: strings sem text domain / sem funções de tradução? + +## [LOW] Manutenibilidade +- Código confuso, nomes ruins, duplicação, responsabilidades misturadas. +- Falta de testes onde o repo exige. +- Comentários desnecessários ou “clever code”. + +--- + +# 5) Regras de ouro para sugestões +- Sugira sempre o caminho mais “WordPress way”: + - sanitize/escape com funções WP + - nonces e capabilities + - `$wpdb->prepare()` + - APIs Woo (CRUD) quando aplicável +- Se você não tiver certeza, **assuma o mais seguro** e peça ajuste do autor do PR. + +Fim. diff --git a/README.md b/README.md index 7c0cdfd..67dff7e 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ _Funcionalidades_ - Checkout Card View - Authorize Only - Authorize and Capture -- Authentication 3DS 2.0 +- Authentication 3DS 2.2 (Exceto cartões Elo e Amex) - Anti Fraud - Credit Card Token @@ -122,7 +122,7 @@ _Funcionalidades_ _Funcionalidades_ -- Authenticate 3DS 2.0 +- Authenticate 3DS 2.2 (Exceto cartões Elo e Amex) - Checkout Card View #### Boleto diff --git a/assets/js/braspag.js b/assets/js/braspag.js index 3e0b7eb..f1ca0d4 100644 --- a/assets/js/braspag.js +++ b/assets/js/braspag.js @@ -6,7 +6,7 @@ var braspagDefaultCardRegexFormat = /(\d{1,4})/g; var braspagCards = [ { type: 'naranja-nevada', - typeTitle: 'Naranja e Nevada', + typeName: 'Naranja e Nevada', patterns: [5895], regex_include: '^(589562)', regex_exclude: '', @@ -16,9 +16,9 @@ var braspagCards = [ luhn: true }, { type: 'elo', - typeTitle: 'Elo', - patterns: [6363, 4389, 5041, 4514, 6362, 5067, 4576, 4011], - regex_include: '', + typeName: 'Elo', + patterns: [6363, 4389, 5041, 4514, 6362, 5067, 4576], + regex_include: '^(40117[89]|431274|438935|451416|457393|45763[12]|504175|506(699|7[0-6][0-9]|77[0-8])|509[0-9]{3}|636297|636368|6500(31|33|3[5-9]|4[0-9]|5[01])|6504(0[5-9]|[1-3][0-9])|650(48[5-9]|49[0-9]|5[0-2][0-9]|53[0-8])|650(54[1-9]|5[5-8][0-9]|59[0-8])|650(70[0-9]|71[0-8])|65072[0-7]|650(90[1-9]|91[0-9]|920)|651(65[2-9]|6[6-7][0-9])|6550[01][0-9]|655(02[1-9]|0[3-4][0-9]|05[0-8]))', regex_exclude: '', format: braspagDefaultCardRegexFormat, length: [16], @@ -98,8 +98,8 @@ var braspagCards = [ type: 'discover', typeName: 'Discover', patterns: [6011, 622, 64, 65], - regex_include: '', - regex_exclude: '', + regex_include: '^(6011|65|64[4-9]|622)', + regex_exclude: '^(6500(31|33|3[5-9]|4[0-9]|5[01])|6504(0[5-9]|[1-3][0-9])|650(48[5-9]|49[0-9]|5[0-2][0-9]|53[0-8])|650(54[1-9]|5[5-8][0-9]|59[0-8])|650(70[0-9]|71[0-8])|65072[0-7]|650(90[1-9]|91[0-9]|920)|651(65[2-9]|6[6-7][0-9])|6550[01][0-9]|655(02[1-9]|0[3-4][0-9]|05[0-8]))', format: braspagDefaultCardRegexFormat, length: [16], cvcLength: [3], diff --git a/changelog.txt b/changelog.txt index a11cd73..2913e6b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -118,3 +118,13 @@ = 2.3.5.40 - 2026-01-28 = * Hotfix when send hostname to 3DS in WP new version + += 2.3.5.41 - 2026-01-28 = +* Added default case for unhandled failure types. +* We changed the condition for providers other than Cielo. +* Added early return when appendMpi +* Updated the 3DS authentication version from 2.0 to 2.2 +* Add into documentation indicating that Elo and Amex cards are not supported. +* Fixed a critical bug where the quantity of items in the cart was accessed as an object property instead of an array element. +* Enabled the execution of anti-fraud analysis simultaneously with 3DS authentication. +* Validation logic with handling of 3DS failure and error cases. diff --git a/includes/admin/braspag-creditcard-settings.php b/includes/admin/braspag-creditcard-settings.php index 3bf71de..a2bd738 100644 --- a/includes/admin/braspag-creditcard-settings.php +++ b/includes/admin/braspag-creditcard-settings.php @@ -106,7 +106,7 @@ 'options' => wc_get_order_statuses() ), 'auth3ds20' => array( - 'title' => "
" . __('Authentication 3DS 2.0 for Credit Card', 'woocommerce-braspag'), + 'title' => "
" . __('Authentication 3DS 2.2 for Credit Card', 'woocommerce-braspag'), 'type' => 'title', 'description' => '', ), @@ -114,7 +114,7 @@ 'title' => __('Enable', 'woocommerce-braspag'), 'label' => __('Enable', 'woocommerce-braspag'), 'type' => 'checkbox', - 'description' => 'Choose whether you wish to enable Authentication 3ds 2.0 for Credit Card.', + 'description' => 'Choose whether you wish to enable Authentication 3ds 2.2 for Credit Card.', 'default' => 'no', 'desc_tip' => true, ), @@ -122,7 +122,7 @@ 'title' => __('MasterCard Notify Only', 'woocommerce-braspag'), 'label' => __('Enable', 'woocommerce-braspag'), 'type' => 'checkbox', - 'description' => 'Choose whether you wish to enable Authentication 3ds 2.0 MasterCard Notify Only for Credit Card.', + 'description' => 'Choose whether you wish to enable Authentication 3ds 2.2 MasterCard Notify Only for Credit Card.', 'default' => 'no', 'desc_tip' => true, ), @@ -130,7 +130,7 @@ 'title' => __('Authorization On Error', 'woocommerce-braspag'), 'label' => __('Enable', 'woocommerce-braspag'), 'type' => 'checkbox', - 'description' => 'Choose whether you wish to enable Authentication 3ds 2.0 Authorization On Error for Credit Card.', + 'description' => 'Choose whether you wish to enable Authentication 3ds 2.2 Authorization On Error for Credit Card.', 'default' => 'no', 'desc_tip' => true, ), @@ -138,7 +138,7 @@ 'title' => __('Authorization On Failure', 'woocommerce-braspag'), 'label' => __('Enable', 'woocommerce-braspag'), 'type' => 'checkbox', - 'description' => 'Choose whether you wish to enable Authentication 3ds 2.0 Authorization On Failure for Credit Card.', + 'description' => 'Choose whether you wish to enable Authentication 3ds 2.2 Authorization On Failure for Credit Card.', 'default' => 'no', 'desc_tip' => true, ), @@ -146,7 +146,7 @@ 'title' => __('Authorization On Unenrolled', 'woocommerce-braspag'), 'label' => __('Enable', 'woocommerce-braspag'), 'type' => 'checkbox', - 'description' => 'Choose whether you wish to enable Authentication 3ds 2.0 Authorization On Unenrolled for Credit Card.', + 'description' => 'Choose whether you wish to enable Authentication 3ds 2.2 Authorization On Unenrolled for Credit Card.', 'default' => 'no', 'desc_tip' => true, ), @@ -154,7 +154,7 @@ 'title' => __('Authorization On Unsupported Brand', 'woocommerce-braspag'), 'label' => __('Enable', 'woocommerce-braspag'), 'type' => 'checkbox', - 'description' => 'Choose whether you wish to enable Authentication 3ds 2.0 Authorization On Unsupported Brand for Credit Card.', + 'description' => 'Choose whether you wish to enable Authentication 3ds 2.2 Authorization On Unsupported Brand for Credit Card.', 'default' => 'no', 'desc_tip' => true, ) diff --git a/includes/admin/braspag-debitcard-settings.php b/includes/admin/braspag-debitcard-settings.php index 4d215e9..5f6c0cf 100644 --- a/includes/admin/braspag-debitcard-settings.php +++ b/includes/admin/braspag-debitcard-settings.php @@ -70,7 +70,7 @@ 'desc_tip' => false, ), 'auth3ds20' => array( - 'title' => "
" . __('Authentication 3DS 2.0 for Debit Card', 'woocommerce-braspag'), + 'title' => "
" . __('Authentication 3DS 2.2 for Debit Card', 'woocommerce-braspag'), 'type' => 'title', 'description' => '', ), @@ -78,7 +78,7 @@ 'title' => __('Enable', 'woocommerce-braspag'), 'label' => __('Enable', 'woocommerce-braspag'), 'type' => 'checkbox', - 'description' => 'Choose whether you wish to enable Authentication 3ds 2.0 for Debit Card.', + 'description' => 'Choose whether you wish to enable Authentication 3ds 2.2 for Debit Card.', 'default' => 'no', 'desc_tip' => true, ), @@ -86,7 +86,7 @@ 'title' => __('MasterCard Notify Only', 'woocommerce-braspag'), 'label' => __('Enable', 'woocommerce-braspag'), 'type' => 'checkbox', - 'description' => 'Choose whether you wish to enable Authentication 3ds 2.0 MasterCard Notify Only for Debit Card.', + 'description' => 'Choose whether you wish to enable Authentication 3ds 2.2 MasterCard Notify Only for Debit Card.', 'default' => 'no', 'desc_tip' => true, ), @@ -94,7 +94,7 @@ 'title' => __('Authorization On Error', 'woocommerce-braspag'), 'label' => __('Enable', 'woocommerce-braspag'), 'type' => 'checkbox', - 'description' => 'Choose whether you wish to enable Authentication 3ds 2.0 Authorization On Error for Debit Card.', + 'description' => 'Choose whether you wish to enable Authentication 3ds 2.2 Authorization On Error for Debit Card.', 'default' => 'no', 'desc_tip' => true, ), @@ -102,7 +102,7 @@ 'title' => __('Authorization On Failure', 'woocommerce-braspag'), 'label' => __('Enable', 'woocommerce-braspag'), 'type' => 'checkbox', - 'description' => 'Choose whether you wish to enable Authentication 3ds 2.0 Authorization On Failure for Debit Card.', + 'description' => 'Choose whether you wish to enable Authentication 3ds 2.2 Authorization On Failure for Debit Card.', 'default' => 'no', 'desc_tip' => true, ), @@ -110,7 +110,7 @@ 'title' => __('Authorization On Unenrolled', 'woocommerce-braspag'), 'label' => __('Enable', 'woocommerce-braspag'), 'type' => 'checkbox', - 'description' => 'Choose whether you wish to enable Authentication 3ds 2.0 Authorization On Unenrolled for Debit Card.', + 'description' => 'Choose whether you wish to enable Authentication 3ds 2.2 Authorization On Unenrolled for Debit Card.', 'default' => 'no', 'desc_tip' => true, ), @@ -118,7 +118,7 @@ 'title' => __('Authorization On Unsupported Brand', 'woocommerce-braspag'), 'label' => __('Enable', 'woocommerce-braspag'), 'type' => 'checkbox', - 'description' => 'Choose whether you wish to enable Authentication 3ds 2.0 Authorization On Unsupported Brand for Debit Card.', + 'description' => 'Choose whether you wish to enable Authentication 3ds 2.2 Authorization On Unsupported Brand for Debit Card.', 'default' => 'no', 'desc_tip' => true, ) diff --git a/includes/admin/braspag-settings.php b/includes/admin/braspag-settings.php index 7e66918..4df3523 100644 --- a/includes/admin/braspag-settings.php +++ b/includes/admin/braspag-settings.php @@ -300,21 +300,21 @@ 'desc_tip' => true, ), 'auth3ds20' => array( - 'title' => "
" . __('Authentication 3DS 2.0', 'woocommerce-braspag'), + 'title' => "
" . __('Authentication 3DS 2.2', 'woocommerce-braspag'), 'type' => 'title', 'description' => '', ), 'auth3ds20_oauth_authentication_client_id' => array( 'title' => __('Client ID', 'woocommerce-braspag'), 'type' => 'text', - 'description' => __('Get your Authentication 3DS 2.0 OAuth Client ID from Braspag Support.', 'woocommerce-braspag'), + 'description' => __('Get your Authentication 3DS 2.2 OAuth Client ID from Braspag Support.', 'woocommerce-braspag'), 'default' => '', 'desc_tip' => true, ), 'auth3ds20_oauth_authentication_client_secret' => array( 'title' => __('Client Secret', 'woocommerce-braspag'), 'type' => 'text', - 'description' => __('Get your Authentication 3DS 2.0 Client Secret from Braspag Support.', 'woocommerce-braspag'), + 'description' => __('Get your Authentication 3DS 2.2 Client Secret from Braspag Support.', 'woocommerce-braspag'), 'default' => '', 'desc_tip' => true, ) diff --git a/includes/class-wc-gateway-braspag.php b/includes/class-wc-gateway-braspag.php index 8effd6a..4ae374f 100644 --- a/includes/class-wc-gateway-braspag.php +++ b/includes/class-wc-gateway-braspag.php @@ -163,7 +163,7 @@ public function get_braspag_auth3ds20_elements($fields) - +
diff --git a/includes/payment-methods/class-wc-gateway-braspag-creditcard.php b/includes/payment-methods/class-wc-gateway-braspag-creditcard.php index 0d637be..cdcc6e3 100644 --- a/includes/payment-methods/class-wc-gateway-braspag-creditcard.php +++ b/includes/payment-methods/class-wc-gateway-braspag-creditcard.php @@ -290,22 +290,22 @@ public function elements_form() $fields = wp_parse_args($fields, apply_filters('woocommerce_credit_card_form_fields', $default_fields, $this->id)); ?> - - -
- id); ?> - - id); ?> -
-
- - id); + + +
+ id); ?> + + id); ?> +
+
+ + id); } /** @@ -383,7 +383,6 @@ public function process_payment($order_id, $retry = true, $previous_error = fals } if (!empty($response->errors)) { - if ($this->is_retryable_error($response)) { return $this->retry_after_error($response, $order, $retry, $previous_error, $use_order_source); } @@ -462,8 +461,8 @@ public function process_payment_validation() $failureType = (string) $checkout->get_value('bpmpi_auth_failure_type'); if ($failureType === '' || $failureType === '0') { - return; - } + return; + } $message = __('Credit Card Payment Failure.', 'woocommerce-braspag'); $appendMpi = false; @@ -481,15 +480,23 @@ public function process_payment_validation() case '5': $appendMpi = ($this->auth3ds20_mpi_authorize_on_unsupported_brand === 'no'); break; + default: + $appendMpi = true; + break; } $cardType = (string) $checkout->get_value('braspag_creditcard-card-type'); $provider = (string) $this->get_braspag_payment_provider($cardType, $this->test_mode); + $isCielo = (bool) preg_match('#cielo#i', $provider); - if (!$appendMpi && !$this->test_mode && $failureType !== '3' && !preg_match('#cielo#i', $provider)) { + if (!$this->test_mode && $failureType !== '3' && !$isCielo) { $appendMpi = true; } + if (!$appendMpi) { + return; + } + $message .= " #MPI{$failureType}"; throw new WC_Braspag_Exception( @@ -580,8 +587,6 @@ public function braspag_pagador_creditcard_payment_request_builder($payment_data $customer_wants_to_save_card = $checkout->get_value('wc-braspag_creditcard-new-payment-method') == 'true'; $brandCard = $checkout->get_value('braspag_creditcard-card-type'); - WC_Braspag_Logger::log('SOP: ' . $this->sop_enabled . 'saved card: ' . $this->save_card); - $card_data = [ "Holder" => $checkout->get_value('braspag_creditcard-card-holder'), "ExpirationDate" => $card_expiration_date, @@ -593,13 +598,11 @@ public function braspag_pagador_creditcard_payment_request_builder($payment_data if ($this->sop_enabled === 'yes') { if ($this->save_card == 'yes' && $customer_wants_to_save_card && $this->sop_tokenize === 'yes') { $returnData = $checkout->get_value('braspag_creditcard-card-cardtoken'); - WC_Braspag_Logger::log('Card Token: ' . print_r($returnData, true)); $cardnumber = [ "CardToken" => $returnData ]; } else { $returnData = $checkout->get_value('braspag_creditcard-card-paymenttoken'); - WC_Braspag_Logger::log('Payment Token: ' . print_r($returnData, true)); $cardnumber = [ "PaymentToken" => $returnData ]; @@ -716,8 +719,6 @@ public function braspag_antifraud_request_builder($cart, $order, $braspag_pagado ]; } - WC_Braspag_Logger::log('card_expiration_date: ' . print_r($braspag_pagador_request['Payment']['Card']['ExpirationDate'], true)); - $return_data = [ "MerchantOrderId" => $braspag_pagador_request['MerchantOrderId'], "TotalOrderAmount" => intval($order->get_total() * 100), @@ -821,7 +822,7 @@ public function braspag_pagador_creditcard_payment_request_antifraud_builder($pa if ( 'yes' !== $this->antifraud_enabled || 'yes' !== $this->antifraud_send_with_pagador_transaction - || 'yes' === $this->auth3ds20_mpi_is_active + // || 'yes' === $this->auth3ds20_mpi_is_active || 'yes' === $this->sop_enabled ) { return $payment_data; @@ -831,7 +832,6 @@ public function braspag_pagador_creditcard_payment_request_antifraud_builder($pa $fraudAnalysCartItems = []; foreach ($cart->get_cart_contents() as $cart_content) { - $fraudAnalysCartItems[] = [ "GiftCategory" => "Undefined", "HostHedge" => "Off", @@ -839,7 +839,7 @@ public function braspag_pagador_creditcard_payment_request_antifraud_builder($pa "ObscenitiesHedge" => "Off", "PhoneHedge" => "Off", "Name" => $cart_content['data']->get_name(), - "Quantity" => $cart_content->quantity, + "Quantity" => $cart_content['quantity'], "Sku" => $cart_content['data']->get_sku(), "UnitPrice" => intval($cart_content['data']->get_price() * 100), ]; @@ -932,6 +932,31 @@ public function braspag_pagador_creditcard_payment_request_auth3ds20_builder($pa return $payment_data; } + $failureType = (string) $checkout->get_value('bpmpi_auth_failure_type'); + + if ($failureType !== '' && $failureType !== '0') { + $block = true; + + switch ($failureType) { + case '4': + $block = ($this->auth3ds20_mpi_authorize_on_error === 'no'); + break; + case '1': + $block = ($this->auth3ds20_mpi_authorize_on_failure === 'no'); + break; + case '2': + $block = ($this->auth3ds20_mpi_authorize_on_unenrolled === 'no'); + break; + case '5': + $block = ($this->auth3ds20_mpi_authorize_on_unsupported_brand === 'no'); + break; + } + + if ($block === false) { + return $payment_data; + } + } + $payment_data_auth3ds20_data = [ "Cavv" => $checkout->get_value('bpmpi_auth_cavv'), "Xid" => $checkout->get_value('bpmpi_auth_xid'), @@ -1058,19 +1083,19 @@ public function display_order_creditcard_data($order) ?> - - - - - - - -
: - get_meta('_braspag_creditcard_installments'); ?>x -
- + + + : + + get_meta('_braspag_creditcard_installments'); ?>x + + + + +