Skip to content

Commit bfcd8b6

Browse files
author
magnussolution
committed
buycredit on mobile
1 parent 82ee245 commit bfcd8b6

17 files changed

+1599
-1148
lines changed

build/MagnusBilling-current.tar.gz

10.7 KB
Binary file not shown.

classic/src/view/buycredit/Module.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Ext.define('MBilling.view.buycredit.Module', {
1313
header: false,
1414
initComponent: function() {
1515
var me = this;
16+
if (window.isTablet == true) {
17+
window.open('index.php/buyCredit/method/?mobile=true', "_self");
18+
}
1619
me.items = [{
1720
xtype: 'form',
1821
reference: 'buycreditPanel',

classic/src/view/did/List.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Ext.define('MBilling.view.did.List', {
103103
renderer: Helper.Util.formatsecondsToTime,
104104
dataIndex: 'secondusedreal',
105105
hidden: !App.user.isAdmin,
106+
hideable: App.user.isAdmin,
106107
flex: 3
107108
}, {
108109
header: t('Country'),

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta content="IE=edge" http-equiv="X-UA-Compatible"/>
55
<meta charset="utf-8"/>
6-
<meta content="width=device-width, initial-scale=1, maximum-scale=10, user-scalable=yes" name="viewport"/>
6+
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
77
<link href="resources/images/logo.ico" id="favicon" rel="shortcut icon" type="image/x-icon"/>
88
<title>
99
MagnusBilling

protected/controllers/BuyCreditController.php

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,56 @@ public function actionMethod()
3131

3232
}
3333

34+
$modelUser = User::model()->findByPk((int) Yii::app()->session['id_user']);
35+
$modelPlan = Plan::model()->findByPk(Yii::app()->session['id_plan']);
36+
37+
if (isset($_GET['mobile'])) {
38+
39+
if (isset($_POST['pay_amount2']) && $_POST['pay_amount2'] > 0) {
40+
$_POST['pay_amount'] = $_POST['pay_amount2'];
41+
}
42+
43+
if (isset($_POST['pay_amount']) && $_POST['pay_amount'] > 0 && isset($_POST['payment_method']) && $_POST['payment_method'] > 0) {
44+
$_GET['amount'] = $_POST['pay_amount'];
45+
$_GET['id_method'] = $_POST['payment_method'];
46+
//continue to the payment method
47+
} else {
48+
49+
if (isset($_POST['id_method']) && $_POST['id_method'] > 0) {
50+
$modelMethodPay = Methodpay::model()->findByPK((int) $_POST['id_method']);
51+
52+
} else {
53+
$modelMethodPay = Methodpay::model()->findAll('active = 1');
54+
}
55+
56+
$this->render('mobile', array(
57+
'modelMethodPay' => $modelMethodPay,
58+
'modelUser' => $modelUser,
59+
'reference' => date('YmdHis') . '-' . $modelUser->username . '-' . $modelUser->id,
60+
));
61+
exit;
62+
}
63+
64+
}
65+
3466
$modelMethodPay = Methodpay::model()->findByPK((int) $_GET['id_method']);
3567

36-
if ($modelMethodPay->max > 0 && $_GET['amount'] > $modelMethodPay->max) {
37-
exit(Yii::t('zii', 'The maximum amount to') . ' ' . $modelMethodPay->show_name . ' ' . Yii::t('zii', 'is') . ' ' . Yii::app()->session['currency'] . ' ' . $modelMethodPay->max);
38-
} elseif ($modelMethodPay->min > 0 && $_GET['amount'] < $modelMethodPay->min) {
39-
exit(Yii::t('zii', 'The minimum amount to') . ' ' . $modelMethodPay->show_name . ' ' . Yii::t('zii', 'is') . ' ' . Yii::app()->session['currency'] . ' ' . $modelMethodPay->min);
68+
$plan_parts = explode(' ', $modelPlan->name);
69+
if (is_numeric(end($plan_parts))) {
70+
$modelMethodPay->min = end($plan_parts);
4071
}
4172

42-
$modelUser = User::model()->findByPk((int) Yii::app()->session['id_user']);
73+
if ($modelMethodPay->max > 0 && $_GET['amount'] > $modelMethodPay->max || $modelMethodPay->min > 0 && $_GET['amount'] < $modelMethodPay->min) {
74+
$error = Yii::t('zii', 'The minimum amount is') . ' ' . Yii::app()->session['currency'] . ' ' . $modelMethodPay->min;
75+
$error .= ' ' . Yii::t('zii', 'and') . ' ' . Yii::t('zii', 'The maximum amount is') . ' ' . Yii::app()->session['currency'] . ' ' . $modelMethodPay->max;
76+
}
77+
78+
if (isset($error)) {
79+
echo '<center><br><br>';
80+
echo '<font color=red>' . $error . '</font>';
81+
echo '</center><br><br>';
82+
exit;
83+
}
4384

4485
if ($modelMethodPay->active == 0 || (isset(Yii::app()->session['id_agent']) && $modelMethodPay->id_user != Yii::app()->session['id_agent'])) {
4586
exit('invalid option');

protected/controllers/DidController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function extraFilterCustomClient($filter)
8484
{
8585

8686
//for agents add filter for show only numbers free
87-
$filter .= ' AND (reserved = 0 OR id_user = ' . Yii::app()->session['id_user'] . ')';
87+
$filter .= ' AND (activated = 1 AND reserved = 0 OR id_user = ' . Yii::app()->session['id_user'] . ')';
8888
return $filter;
8989
}
9090

protected/controllers/PagHiperController.php

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ class PagHiperController extends Controller
2525
public function actionIndex()
2626
{
2727
Yii::log(print_r($_POST, true), 'error');
28-
$filter = "payment_method = 'paghiper'";
28+
29+
if (isset($_POST['transaction_id'])) {
30+
$filter = "payment_method = 'paghiperpix'";
31+
} else {
32+
$filter = "payment_method = 'paghiper'";
33+
}
2934
$params = array();
3035

3136
if (isset($_GET['id_agent'])) {
@@ -48,10 +53,58 @@ public function actionIndex()
4853
$idUser = $modelMethodpay->idUser->id_user;
4954
$token = $modelMethodpay->pagseguro_TOKEN;
5055

56+
$apiKey = $modelMethodpay->client_id;
57+
5158
if (count($_POST) > 0) {
5259
// POST recebido, indica que é a requisição do NPI.
5360

54-
$transacaoID = isset($_POST['idTransacao']) ? $_POST['idTransacao'] : '';
61+
if (isset($_POST['transaction_id'])) {
62+
63+
$ch = curl_init();
64+
curl_setopt($ch, CURLOPT_URL, "https://pix.paghiper.com/invoice/notification/");
65+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
66+
curl_setopt($ch, CURLOPT_HEADER, false);
67+
curl_setopt($ch, CURLOPT_POST, true);
68+
69+
$requestBody = json_encode([
70+
"apiKey" => $apiKey,
71+
"transaction_id" => $_POST['transaction_id'],
72+
"notification_id" => $_POST['notification_id'],
73+
"token" => $token,
74+
]);
75+
76+
Yii::log(print_r($requestBody, true), 'error');
77+
78+
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);
79+
curl_setopt($ch, CURLOPT_HTTPHEADER, [
80+
"Content-Type: application/json",
81+
"Accept: application/json",
82+
]);
83+
84+
$result = curl_exec($ch);
85+
86+
$result = json_decode($result);
87+
Yii::log(print_r($result, true), 'error');
88+
if (isset($result->status_request->status) && $result->status_request->status == 'paid') {
89+
// code...
90+
91+
$modelRefill = Refill::model()->find('description LIKE :key AND payment = 0', [':key' => '%' . $_POST['transaction_id'] . '%']);
92+
if (isset($modelRefill->id)) {
93+
$modelRefill->payment = 1;
94+
$modelRefill->description = preg_replace('/pendente/', 'confirmado', $modelRefill->description);
95+
$modelRefill->save();
96+
97+
UserCreditManager::releaseUserCredit($modelRefill->id_user, $modelRefill->credit, 'PIX', 2, $_POST['transaction_id']);
98+
header("HTTP/1.1 200 OK");
99+
exit;
100+
}
101+
} else {
102+
exit;
103+
}
104+
}
105+
106+
$transacaoID = isset($_POST['idTransacao']) ? $_POST['idTransacao'] : '';
107+
55108
$status = $_POST['status'];
56109
$codRetorno = $_POST['codRetorno'];
57110
$valorOriginal = $_POST['valorOriginal'];
@@ -110,11 +163,13 @@ public function actionIndex()
110163
UserCreditManager::releaseUserCredit($modelUser->id, $monto, $description, 1, $transacaoID);
111164
}
112165
}
166+
header("HTTP/1.1 200 OK");
113167
} else {
114168
echo 'error';
115169
}
116170
} else {
117171
echo '<h3>Obrigado por efetuar a compra.</h3>';
172+
header("HTTP/1.1 200 OK");
118173
}
119174
}
120175
}

protected/models/RateAgent.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ public function relations()
7272
public function createAgentRates($model, $id_plan)
7373
{
7474
$sql = 'INSERT INTO pkg_rate_agent (id_plan , id_prefix, rateinitial , initblock , billingblock)
75-
SELECT ' . $model->id . ', id_prefix, rateinitial, initblock, billingblock FROM pkg_rate WHERE id_plan = :id_plan';
75+
SELECT ' . $model->id . ', id_prefix, rateinitial, initblock, billingblock FROM pkg_rate WHERE id_plan = ' . $id_plan . '';
7676
$command = Yii::app()->db->createCommand($sql);
77-
$command->bindValue(":id_plan", $id_plan, PDO::PARAM_INT);
7877
$command->execute();
7978
}
8079
}

0 commit comments

Comments
 (0)