Skip to content

Commit

Permalink
fix Paghiper payment method
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Apr 1, 2021
1 parent d26b1a0 commit bf71e20
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
Empty file modified build/MagnusBilling-current.tar.gz
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions protected/components/ValidaCPFCNPJ.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected function calc_digitos_posicoes($digitos, $posicoes = 10, $soma_digitos
* @param string $cpf O CPF com ou sem pontos e traço
* @return bool True para CPF correto - False para CPF incorreto
*/
protected function valida_cpf()
public function valida_cpf()
{
// Captura os 9 primeiros dígitos do CPF
// Ex.: 02546288423 = 025462884
Expand Down Expand Up @@ -147,7 +147,7 @@ protected function valida_cpf()
* @param string $cnpj
* @return bool true para CNPJ correto
*/
protected function valida_cnpj()
public function valida_cnpj()
{
// O valor original
$cnpj_original = $this->valor;
Expand Down
2 changes: 1 addition & 1 deletion protected/controllers/BuyCreditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function actionMethod()
exit(Yii::t('zii', 'The minimum amount to') . ' ' . $modelMethodPay->show_name . ' ' . Yii::t('zii', 'is') . ' ' . Yii::app()->session['currency'] . ' ' . $modelMethodPay->min);
}

$modelUser = User::model()->findByPk((int) Yii::app()->session['id_user']);
$modelUser = User::model()->findByPk((int) $modelSip->id_user);

if ($modelMethodPay->active == 0 || $modelMethodPay->id_user != Yii::app()->session['id_agent']) {
exit('invalid option');
Expand Down
20 changes: 16 additions & 4 deletions protected/views/buyCredit/paghiper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ function httpPost($url, $params)

$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://';

$modelUser->doc = preg_replace('/-|\.|\//', '', $modelUser->doc);

$cpf_cnpj = new ValidaCPFCNPJ($modelUser->doc);

$params = array(
"email_loja" => $modelMethodPay->username,
"urlRetorno" => $protocol . $_SERVER['HTTP_HOST'] . '/mbilling/index.php/pagHiper' . $agent,
Expand All @@ -41,13 +45,21 @@ function httpPost($url, $params)
"produto_qtde_1" => "1",
"email" => $modelUser->email,
"nome" => $modelUser->firstname . ' ' . $modelUser->lastname,
"cpf" => $modelUser->doc,
"telefone" => $modelUser->phone,
"endereco" => $modelUser->doc,
"cidade" => $modelUser->doc,
"endereco" => $modelUser->address,
"cidade" => $modelUser->city,
"estado" => $modelUser->doc,
"cep" => $modelUser->doc,
"cep" => $modelUser->zipcode,
"pagamento" => "pagamento",
);

if ($cpf_cnpj->valida_cnpj() == 1) {

$params['cnpj'] = $modelUser->doc;
$params['razao_social'] = $modelUser->company_name;

} else {
$params['cpf'] = $modelUser->doc;
}

echo httpPost("https://www.paghiper.com/checkout/", $params);

0 comments on commit bf71e20

Please sign in to comment.