-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`Melhorias implementadas` * Checagem e validação de CPF/CNPJ no checkout, na página de invoice e na tela de boleto/PIX * Exibição das tags de boleto/PIX no editor de templates de e-mail * Suporte a campo de razão social (opcional) * Melhor lógica de reaproveitamento de boletos * Mais informações nos logs * Melhor manipulação de CPF/CNPJ para criação de faturas * Tela de erro, caso o o valor com desconto por pagto. antecipado seja menor que R$ 3 * Tela de erro genérica (evita tela branca, caso uma transação não possa ser gerada) `Bugs resolvidos` * Boletos vencidos eram ignorados, ainda que dentro do período de tolerância * Erro ao cancelar boletos nos logs * Bloco de inserção de boleto/PIX PDF era executado apenas na primeira fatura da CRON (mod_lsapi) * Melhor cálculo de desconto para pagto. antecipado * Maior dinstinção entre as mensagens (evita confusão no front-end) * Melhor convenção de naming de funções (evita conflitos com outros módulos/gateways) * Warning de operador ternário removido
- Loading branch information
Showing
11 changed files
with
522 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** | ||
* Mostra campos da Paghiper na lista de campos disponíveis para uso nos templates | ||
* | ||
* @package PagHiper e Boleto para WHMCS | ||
* @version 2.2 | ||
* @author Equipe PagHiper https://github.com/paghiper/whmcs | ||
* @author Henrique Cruz | ||
* @license BSD License (3-clause) | ||
* @copyright (c) 2017-2021, PagHiper | ||
* @link https://www.paghiper.com/ | ||
*/ | ||
|
||
if (!defined("WHMCS")) die("This file cannot be accessed directly"); | ||
function show_paghiper_tpl_fields($vars) { | ||
$merge_fields = []; | ||
$merge_fields['codigo_pix'] = "Mostra o código PIX Paghiper e informações de pagamento"; | ||
$merge_fields['linha_digitavel'] = "Mostra a linha digitável e código de barras do boleto PagHiper"; | ||
return $merge_fields; | ||
} | ||
add_hook('EmailTplMergeFields', 1, 'show_paghiper_tpl_fields'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
/** | ||
* Valida informações de faturamento do cliente no check-out | ||
* | ||
* @package PagHiper e Boleto para WHMCS | ||
* @version 2.2 | ||
* @author Equipe PagHiper https://github.com/paghiper/whmcs | ||
* @author Henrique Cruz | ||
* @license BSD License (3-clause) | ||
* @copyright (c) 2017-2021, PagHiper | ||
* @link https://www.paghiper.com/ | ||
*/ | ||
|
||
require_once(dirname(__FILE__) . '/../../modules/gateways/paghiper/inc/helpers/gateway_functions.php'); | ||
|
||
function paghiper_clientValidateTaxId($vars){ | ||
|
||
if(array_key_exists('paymentmethod', $vars) && strpos($vars['paymentmethod'], "paghiper") !== false) { | ||
$gatewayConfig = getGatewayVariables($vars['paymentmethod']); | ||
} else { | ||
return; | ||
} | ||
|
||
// Checamos o CPF/CNPJ novamente, para evitar problemas no checkout | ||
$taxIdFields = explode("|", $gatewayConfig['cpf_cnpj']); | ||
$clientCustomFields = []; | ||
$clientTaxIds = []; | ||
|
||
if(array_key_exists('custtype', $vars) && $vars['custtype'] == 'existing') { | ||
|
||
$gateway_admin = $gatewayConfig['admin']; | ||
$backup_admin = array_shift(mysql_fetch_array(mysql_query("SELECT username FROM tbladmins LIMIT 1"))); | ||
|
||
// Se o usuário admin estiver vazio nas configurações, usamos o padrão | ||
$whmcsAdmin = ( | ||
(empty(trim($gateway_admin))) ? | ||
|
||
// Caso não tenha um valor para usarmos, pegamos o primeiro admin disponível na tabela | ||
$backup_admin : | ||
|
||
// Caso tenha, usamos o preenchido | ||
( | ||
empty(array_shift(mysql_fetch_array(mysql_query("SELECT username FROM tbladmins WHERE username = '$gateway_admin' LIMIT 1"))))) ? | ||
$backup_admin : | ||
trim($GATEWAY['admin'] | ||
) | ||
|
||
); | ||
|
||
$query_params = array( | ||
'clientid' => $vars['userid'], | ||
'stats' => false | ||
); | ||
|
||
$client_details = localAPI('getClientsDetails', $query_params, $whmcsAdmin); | ||
|
||
foreach($client_details["customfields"] as $key => $value){ | ||
$clientCustomFields[$value['id']] = $value['value']; | ||
} | ||
|
||
} else { | ||
|
||
foreach($vars["customfield"] as $key => $value){ | ||
$clientCustomFields[$key] = $value; | ||
} | ||
|
||
} | ||
|
||
if(count($taxIdFields) > 1) { | ||
$clientTaxIds[] = $clientCustomFields[$taxIdFields[0]]; | ||
$clientTaxIds[] = $clientCustomFields[$taxIdFields[1]]; | ||
} else { | ||
$clientTaxIds[] = $clientCustomFields[$taxIdFields[0]]; | ||
} | ||
|
||
$isValidTaxId = false; | ||
foreach($clientTaxIds as $clientTaxId) { | ||
if(paghiper_is_tax_id_valid($clientTaxId)) { | ||
$isValidTaxId = true; | ||
break 1; | ||
} | ||
} | ||
|
||
if(!$isValidTaxId) { | ||
|
||
if(array_key_exists('custtype', $vars) && $vars['custtype'] == 'existing') { | ||
return array('CPF/CNPJ inválido! Cheque seu cadastro.'); | ||
} else { | ||
return array('CPF/CNPJ inválido!'); | ||
} | ||
} | ||
} | ||
|
||
//add_hook("ClientDetailsValidation", 1, "paghiper_clientValidateTaxId"); | ||
add_hook("ShoppingCartValidateCheckout", 1, "paghiper_clientValidateTaxId"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.