Skip to content

Commit

Permalink
Merge pull request #150 from henriqueccruz/master
Browse files Browse the repository at this point in the history
v2.5.1
  • Loading branch information
henriqueccruz authored Mar 18, 2024
2 parents 6980a2e + f4746ce commit 228f23c
Show file tree
Hide file tree
Showing 12 changed files with 414 additions and 175 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Boletos registrados conforme especificação da FEBRABAN. Baixa de pagamentos au

Seu boleto sai direto no PDF anexo a fatura (funcionalidade exclusiva).

* **Versão mais Recente:** 2.4.2
* **Versão mais Recente:** 2.5.1
* **Requer WHMCS** versão mínima 5.0
* **Requisitos:** PHP >= 5.2.0, cURL e JSON ativado.
* **Requisitos:** PHP >= 5.6.0, cURL e JSON ativado.
* **Compatibilidade:** WHMCS 8.X, PHP 7.x. Mod_rewrite opcional


Expand All @@ -33,7 +33,16 @@ Na aba “All Payment Gateways” ou "Todos os Portais de Pagamento" e procure p

8. Adicione o texto abaixo no arquivo invoicepdf.tpl do seu tema, para anexar boletos e códigos PIX ao PDF das faturas (opcional)

```<?php include dirname(__FILE__).'/../../modules/gateways/paghiper/inc/helpers/attach_pdf_slip.php'; ?>```
```<?php // Paghiper PHP template integration
// PHP 5.x compatibility
if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
$basedir = (function_exists('dirname')) ? dirname(__DIR__, 2) : realpath(__DIR__ . '/../..');
} else {
$basedir = (function_exists('dirname') && function_exists('dirname_with_levels')) ? dirname_with_levels(__DIR__, 2) : realpath(__DIR__ . '/../..');
}
include $basedir . '/modules/gateways/paghiper/inc/helpers/attach_pdf_slip.php'; ?>```

9. Para inserir código PIX e linha digitável de boletos, edite seu template de e-mail em Opções (Setup) > Modelos de e-mail (E-mail templates). Você pode usar dois campos de mesclagens, um para boleto e outro para PIX, respectivamente: {$linha_digitavel} e {$codigo_pix}. Basta inserí-los nos templates de comunicação de e-mail nos locais desejados.

Expand Down
13 changes: 10 additions & 3 deletions includes/hooks/cancel_paghiper_slip.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
* Cancela boletos bancários não-pagos, atrelados a uma fatura cancelada ou paga.
*
* @package PagHiper para WHMCS
* @version 2.5
* @version 2.5.1
* @author Equipe PagHiper https://github.com/paghiper/whmcs
* @author Henrique Cruz
* @license BSD License (3-clause)
* @copyright (c) 2017-2023, PagHiper
* @copyright (c) 2017-2024, PagHiper
* @link https://www.paghiper.com/
*/

if (!defined("WHMCS")) die("This file cannot be accessed directly");

function paghiper_cancel_paghiper_slips($vars) {

// PHP 5.x compatibility
if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
$basedir = (function_exists('dirname')) ? dirname(__DIR__, 2) : realpath(__DIR__ . '/../..');
} else {
$basedir = (function_exists('dirname') && function_exists('dirname_with_levels')) ? dirname_with_levels(__DIR__, 2) : realpath(__DIR__ . '/../..');
}

//require_once ("../init.php");
require_once(dirname(__FILE__) . '/../../modules/gateways/paghiper/inc/helpers/gateway_functions.php');
require_once($basedir . '/modules/gateways/paghiper/inc/helpers/gateway_functions.php');
$invoice_id = $vars['invoiceid'];

// Initialise gateway configuration
Expand Down
37 changes: 23 additions & 14 deletions includes/hooks/create_paghiper_pix.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,49 @@
* Adiciona QR code do PIX nos templates do WHMCS
*
* @package PagHiper para WHMCS
* @version 2.5
* @version 2.5.1
* @author Equipe PagHiper https://github.com/paghiper/whmcs
* @author Henrique Cruz
* @license BSD License (3-clause)
* @copyright (c) 2017-2023, PagHiper
* @copyright (c) 2017-2024, PagHiper
* @link https://www.paghiper.com/
*/

if (!defined("WHMCS")) die("This file cannot be accessed directly");

function paghiper_display_pix_qr_code($vars) {

// PHP 5.x compatibility
if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
$basedir = (function_exists('dirname')) ? dirname(__DIR__, 2) : realpath(__DIR__ . '/../..');
} else {
$basedir = (function_exists('dirname') && function_exists('dirname_with_levels')) ? dirname_with_levels(__DIR__, 2) : realpath(__DIR__ . '/../..');
}

$merge_fields = [];
$email_template = $vars['messagename'];
$invoice_id = $vars['relid'];

$target_templates = array('Invoice Created', 'Invoice Payment Reminder', 'First Invoice Overdue Notice', 'Second Invoice Overdue Notice', 'Third Invoice Overdue Notice');

if(in_array($email_template, $target_templates)) {
// Todo:
$invoice = mysql_fetch_array(mysql_query("SELECT tblinvoices.*,tblclients.id as client_id, tblclients.email FROM tblinvoices INNER JOIN tblclients ON tblclients.id=tblinvoices.userid WHERE tblinvoices.id='$invoice_id'"));

require_once(dirname(__FILE__) . '/../../modules/gateways/paghiper/classes/PaghiperTransaction.php');
require_once($basedir . '/modules/gateways/paghiper/classes/PaghiperTransaction.php');
$paghiperTransaction = new PaghiperTransaction(['invoiceID' => $invoice_id, 'format' => 'array']);
$invoiceTransaction = $paghiperTransaction->process();

if($invoiceTransaction) {

$digitable_line = $invoiceTransaction['emv'];
$qrcode_image_url = $invoiceTransaction['qrcode_image_url'];

if($digitable_line) {
$merge_fields['codigo_pix'] = "<div style='text-align: center;' class='qr-code-container'><img class='qr-code' width='320' height='320' src='{$qrcode_image_url}'><br>";
$merge_fields['codigo_pix'] .= '<h2 style="font-size: 16px; color: #000000">Use a opção QR Code no seu app de internet banking<br><span style="font-size: 14px; font-weight: normal;">Ou, se preferir, copie o texto abaixo para fazer o pagamento</span></h2>';
$merge_fields['codigo_pix'] .= '<span>Seu código PIX: <br><span style="font-size: 16px; color: #000000"><strong>';
$merge_fields['codigo_pix'] .= $digitable_line;
$merge_fields['codigo_pix'] .= '</strong></span></span></div>';
$digitable_line = $invoiceTransaction['emv'];
$qrcode_image_url = $invoiceTransaction['qrcode_image_url'];

if($digitable_line) {
$merge_fields['codigo_pix'] = "<div style='text-align: center;' class='qr-code-container'><img class='qr-code' width='320' height='320' src='{$qrcode_image_url}'><br>";
$merge_fields['codigo_pix'] .= '<h2 style="font-size: 16px; color: #000000">Use a opção QR Code no seu app de internet banking<br><span style="font-size: 14px; font-weight: normal;">Ou, se preferir, copie o texto abaixo para fazer o pagamento</span></h2>';
$merge_fields['codigo_pix'] .= '<span>Seu código PIX: <br><span style="font-size: 16px; color: #000000"><strong>';
$merge_fields['codigo_pix'] .= $digitable_line;
$merge_fields['codigo_pix'] .= '</strong></span></span></div>';
}
}


Expand Down
36 changes: 22 additions & 14 deletions includes/hooks/create_paghiper_slip.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,52 @@
* Adiciona boleto bancário e link direto para boleto no WHMCS
*
* @package PagHiper para WHMCS
* @version 2.5
* @version 2.5.1
* @author Equipe PagHiper https://github.com/paghiper/whmcs
* @author Henrique Cruz
* @license BSD License (3-clause)
* @copyright (c) 2017-2023, PagHiper
* @copyright (c) 2017-2024, PagHiper
* @link https://www.paghiper.com/
*/

if (!defined("WHMCS")) die("This file cannot be accessed directly");

function paghiper_display_digitable_line($vars) {

// PHP 5.x compatibility
if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
$basedir = (function_exists('dirname')) ? dirname(__DIR__, 2) : realpath(__DIR__ . '/../..');
} else {
$basedir = (function_exists('dirname') && function_exists('dirname_with_levels')) ? dirname_with_levels(__DIR__, 2) : realpath(__DIR__ . '/../..');
}

$merge_fields = [];
$email_template = $vars['messagename'];
$invoice_id = $vars['relid'];

$target_templates = array('Invoice Created', 'Invoice Payment Reminder', 'First Invoice Overdue Notice', 'Second Invoice Overdue Notice', 'Third Invoice Overdue Notice');

if(in_array($email_template, $target_templates)) {
// Todo:
$invoice = mysql_fetch_array(mysql_query("SELECT tblinvoices.*,tblclients.id as client_id, tblclients.email FROM tblinvoices INNER JOIN tblclients ON tblclients.id=tblinvoices.userid WHERE tblinvoices.id='$invoice_id'"));

$whmcs_url = rtrim(\App::getSystemUrl(),"/");

require_once(dirname(__FILE__) . '/../../modules/gateways/paghiper/classes/PaghiperTransaction.php');
require_once($basedir . '/modules/gateways/paghiper/classes/PaghiperTransaction.php');
$paghiperTransaction = new PaghiperTransaction(['invoiceID' => $invoice_id, 'format' => 'array']);
$invoiceTransaction = $paghiperTransaction->process();

$digitable_line = $invoiceTransaction['digitable_line'];
$bar_code_number_to_image = $invoiceTransaction['bar_code_number_to_image'];

if($digitable_line) {
$merge_fields['linha_digitavel'] = '<div style="text-align: center;" class="billet-barcode-container"><span>Linha digitável: <br><span style="font-size: 16px; color: #000000"><strong>';
$merge_fields['linha_digitavel'] .= "<img class='billet-barcode' style='max-width: 100%;' height='50' src='{$whmcs_url}/modules/gateways/paghiper/assets/php/barcode.php?codigo={$bar_code_number_to_image}'><br>";
$merge_fields['linha_digitavel'] .= $digitable_line;
$merge_fields['linha_digitavel'] .= '</strong></span></span></div>';
if($invoiceTransaction) {

$digitable_line = $invoiceTransaction['digitable_line'];
$bar_code_number_to_image = $invoiceTransaction['bar_code_number_to_image'];

if($digitable_line) {
$merge_fields['linha_digitavel'] = '<div style="text-align: center;" class="billet-barcode-container"><span>Linha digitável: <br><span style="font-size: 16px; color: #000000"><strong>';
$merge_fields['linha_digitavel'] .= "<img class='billet-barcode' style='max-width: 100%;' height='50' src='{$whmcs_url}/modules/gateways/paghiper/assets/php/barcode.php?codigo={$bar_code_number_to_image}'><br>";
$merge_fields['linha_digitavel'] .= $digitable_line;
$merge_fields['linha_digitavel'] .= '</strong></span></span></div>';
}
}


}
return $merge_fields;
}
Expand Down
4 changes: 2 additions & 2 deletions includes/hooks/show_paghiper_mergefields.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Mostra campos da Paghiper na lista de campos disponíveis para uso nos templates
*
* @package PagHiper e Boleto para WHMCS
* @version 2.5
* @version 2.5.1
* @author Equipe PagHiper https://github.com/paghiper/whmcs
* @author Henrique Cruz
* @license BSD License (3-clause)
* @copyright (c) 2017-2023, PagHiper
* @copyright (c) 2017-2024, PagHiper
* @link https://www.paghiper.com/
*/

Expand Down
13 changes: 10 additions & 3 deletions includes/hooks/validate_paghiper_taxid.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@
* Valida informações de faturamento do cliente no check-out
*
* @package PagHiper e Boleto para WHMCS
* @version 2.5
* @version 2.5.1
* @author Equipe PagHiper https://github.com/paghiper/whmcs
* @author Henrique Cruz
* @license BSD License (3-clause)
* @copyright (c) 2017-2023, PagHiper
* @copyright (c) 2017-2024, PagHiper
* @link https://www.paghiper.com/
*/

require_once(dirname(__FILE__) . '/../../modules/gateways/paghiper/inc/helpers/gateway_functions.php');
// PHP 5.x compatibility
if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
$basedir = (function_exists('dirname')) ? dirname(__DIR__, 2) : realpath(__DIR__ . '/../..');
} else {
$basedir = (function_exists('dirname') && function_exists('dirname_with_levels')) ? dirname_with_levels(__DIR__, 2) : realpath(__DIR__ . '/../..');
}

require_once($basedir . '/modules/gateways/paghiper/inc/helpers/gateway_functions.php');

function paghiper_getClientDetails($vars, $gateway_config) {

Expand Down
6 changes: 3 additions & 3 deletions modules/gateways/paghiper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* PagHiper - Módulo oficial para integração com WHMCS
*
* @package PagHiper para WHMCS
* @version 2.5
* @version 2.5.1
* @author Equipe PagHiper https://github.com/paghiper/whmcs
* @author Desenvolvido e mantido Henrique Cruz - https://henriquecruz.com.br/
* @license BSD License (3-clause)
* @copyright (c) 2017-2023, PagHiper
* @copyright (c) 2017-2024, PagHiper
* @link https://www.paghiper.com/
*/

Expand All @@ -30,7 +30,7 @@ function paghiper_config($params = NULL) {
<tbody>
<tr>
<td width='60%'><img src='https://s3.amazonaws.com/logopaghiper/whmcs/badge.oficial.png' style='max-width: 100%;'></td>
<td>Versão <h2 style='font-weight: bold; margin-top: 0px; font-size: 300%;'>2.5</h2></td>
<td>Versão <h2 style='font-weight: bold; margin-top: 0px; font-size: 300%;'>2.5.1</h2></td>
</tr>
</tbody>
</table>
Expand Down
Loading

0 comments on commit 228f23c

Please sign in to comment.