Payment Gateway Tripay done
This commit is contained in:
parent
5ce70b972b
commit
4a6ea093c1
43
system/autoload/Http.php
Normal file
43
system/autoload/Http.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
||||||
|
**/
|
||||||
|
|
||||||
|
class Http
|
||||||
|
{
|
||||||
|
public static function getData($url, $headers)
|
||||||
|
{
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($ch, CURLOPT_POST, 0);
|
||||||
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
$server_output = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
return $server_output;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function postJsonData($url, $array_post, $headers = [], $basic = null)
|
||||||
|
{
|
||||||
|
$headers[] = 'Content-Type: application/json';
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
||||||
|
curl_setopt($ch, CURLOPT_VERBOSE, false);
|
||||||
|
curl_setopt($ch, CURLINFO_HEADER_OUT, false);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($array_post));
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
if (!empty($basic)) {
|
||||||
|
curl_setopt($ch, CURLOPT_USERPWD, $basic);
|
||||||
|
}
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
$server_output = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
return $server_output;
|
||||||
|
}
|
||||||
|
}
|
123
system/autoload/PGTripay.php
Normal file
123
system/autoload/PGTripay.php
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
||||||
|
*
|
||||||
|
* Payment Gateway Tripay
|
||||||
|
**/
|
||||||
|
|
||||||
|
class PGTripay
|
||||||
|
{
|
||||||
|
protected $user;
|
||||||
|
protected $trx;
|
||||||
|
|
||||||
|
public function __construct($trx, $user)
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
$this->trx = $trx;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSignature()
|
||||||
|
{
|
||||||
|
global $_c;
|
||||||
|
return hash_hmac('sha256', $_c['tripay_merchant'] . $this->trx['id'] . $this->trx['price'], $_c['tripay_secret_key']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createTransaction($channel) //$trxID, $channel, $amount, $user, $description)
|
||||||
|
{
|
||||||
|
global $_c;
|
||||||
|
$json = [
|
||||||
|
'method' => $channel,
|
||||||
|
'amount' => $this->trx['price'],
|
||||||
|
'merchant_ref' => $this->trx['id'],
|
||||||
|
'customer_name' => $this->user['fullname'],
|
||||||
|
'customer_email' => (empty($this->user['email'])) ? $this->user['username'] . '@' . $_SERVER['HTTP_HOST'] : $this->user['email'],
|
||||||
|
'customer_phone' => $this->user['phonenumber'],
|
||||||
|
'order_items' => [
|
||||||
|
[
|
||||||
|
'name' => $this->trx['plan_name'],
|
||||||
|
'price' => $this->trx['price'],
|
||||||
|
'quantity' => 1
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'return_url' => U . 'order/view/' . $this->trx['id'] . '/check',
|
||||||
|
'signature' => $this->getSignature()
|
||||||
|
];
|
||||||
|
return json_decode(Http::postJsonData($this->getServer() . 'transaction/create', $json, ['Authorization: Bearer ' . $_c['tripay_api_key']]), true);
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"message": "",
|
||||||
|
"data": {
|
||||||
|
"reference": "T0001000000000000006",
|
||||||
|
"merchant_ref": "INV345675",
|
||||||
|
"payment_selection_type": "static",
|
||||||
|
"payment_method": "BRIVA",
|
||||||
|
"payment_name": "BRI Virtual Account",
|
||||||
|
"customer_name": "Nama Pelanggan",
|
||||||
|
"customer_email": "emailpelanggan@domain.com",
|
||||||
|
"customer_phone": "081234567890",
|
||||||
|
"callback_url": "https://domainanda.com/callback",
|
||||||
|
"return_url": "https://domainanda.com/redirect",
|
||||||
|
"amount": 1000000,
|
||||||
|
"fee_merchant": 1500,
|
||||||
|
"fee_customer": 0,
|
||||||
|
"total_fee": 1500,
|
||||||
|
"amount_received": 998500,
|
||||||
|
"pay_code": "57585748548596587",
|
||||||
|
"pay_url": null,
|
||||||
|
"checkout_url": "https://tripay.co.id/checkout/T0001000000000000006",
|
||||||
|
"status": "UNPAID",
|
||||||
|
"expired_time": 1582855837,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStatus($trxID)
|
||||||
|
{
|
||||||
|
global $_c;
|
||||||
|
return json_decode(Http::getData($this->getServer() . 'transaction/detail?'.http_build_query(['reference'=>$trxID]), [
|
||||||
|
'Authorization: Bearer ' . $_c['tripay_api_key']
|
||||||
|
]), true);
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"message": "",
|
||||||
|
"data": {
|
||||||
|
"reference": "T0001000000000000006",
|
||||||
|
"merchant_ref": "INV345675",
|
||||||
|
"payment_selection_type": "static",
|
||||||
|
"payment_method": "BRIVA",
|
||||||
|
"payment_name": "BRI Virtual Account",
|
||||||
|
"customer_name": "Nama Pelanggan",
|
||||||
|
"customer_email": "emailpelanggan@domain.com",
|
||||||
|
"customer_phone": "081234567890",
|
||||||
|
"callback_url": "https://domainanda.com/callback",
|
||||||
|
"return_url": "https://domainanda.com/redirect",
|
||||||
|
"amount": 1000000,
|
||||||
|
"fee_merchant": 1500,
|
||||||
|
"fee_customer": 0,
|
||||||
|
"total_fee": 1500,
|
||||||
|
"amount_received": 998500,
|
||||||
|
"pay_code": "57585748548596587",
|
||||||
|
"pay_url": null,
|
||||||
|
"checkout_url": "https://tripay.co.id/checkout/T0001000000000000006",
|
||||||
|
"status": "PAID",
|
||||||
|
"expired_time": 1582855837,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getServer()
|
||||||
|
{
|
||||||
|
global $_app_stage;
|
||||||
|
if ($_app_stage == 'Live') {
|
||||||
|
return 'https://tripay.co.id/api/';
|
||||||
|
} else {
|
||||||
|
return 'https://tripay.co.id/api-sandbox/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
system/autoload/PGXendit.php
Normal file
93
system/autoload/PGXendit.php
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
||||||
|
*
|
||||||
|
* Payment Gateway Xendit
|
||||||
|
**/
|
||||||
|
|
||||||
|
class PGTripay {
|
||||||
|
protected $user;
|
||||||
|
protected $trx;
|
||||||
|
protected $channel;
|
||||||
|
|
||||||
|
public function __construct($trx,$user) {
|
||||||
|
$this->user = $user;
|
||||||
|
$this->trx = $trx;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createInvoice()
|
||||||
|
{
|
||||||
|
global $_c;
|
||||||
|
$json = [
|
||||||
|
'external_id' => $this->trx['id'],
|
||||||
|
'amount' => $this->trx['price'],
|
||||||
|
'description' => $this->trx['plan_name'],
|
||||||
|
'customer' => [
|
||||||
|
'mobile_number' => $this->user['phonenumber'],
|
||||||
|
],
|
||||||
|
'customer_notification_preference' => [
|
||||||
|
'invoice_created' => ['whatsapp', 'sms'],
|
||||||
|
'invoice_reminder' => ['whatsapp', 'sms'],
|
||||||
|
'invoice_paid' => ['whatsapp', 'sms'],
|
||||||
|
'invoice_expired' => ['whatsapp', 'sms']
|
||||||
|
],
|
||||||
|
'payment_methods ' => explode(',', $_c['xendit_channel']),
|
||||||
|
'success_redirect_url' => U . 'order/view/' . $this->trx['id'] . '/check',
|
||||||
|
'failure_redirect_url' => U . 'order/view/' . $this->trx['id'] . '/check'
|
||||||
|
];
|
||||||
|
|
||||||
|
return json_decode(Http::postJsonData($this->getServer() . 'invoices', $json, ['Authorization: Basic ' . base64_encode($_c['xendit_secret_key'] . ':')]), true);
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"id": "631597513897510bace2459d", #gateway_trx_id
|
||||||
|
"external_id": "test-va-success-1662359375",
|
||||||
|
"user_id": "599bd7f1ccab55b020bb1147",
|
||||||
|
"status": "PENDING",
|
||||||
|
"merchant_name": "Xendit",
|
||||||
|
"merchant_profile_picture_url": "https://xnd-companies.s3.amazonaws.com/prod/1538466380522_868.png",
|
||||||
|
"amount": 3000000,
|
||||||
|
"description": "Test - VA Successful invoice payment",
|
||||||
|
"expiry_date": "2022-09-06T06:29:37.251Z",
|
||||||
|
"invoice_url": "https://checkout-staging.xendit.co/web/631597513897510bace2459d"
|
||||||
|
"created": "2022-09-05T06:29:37.954Z",
|
||||||
|
"updated": "2022-09-05T06:29:37.954Z"
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInvoice($xendittrxID)
|
||||||
|
{
|
||||||
|
global $_c;
|
||||||
|
return json_decode(Http::getData($this->getServer() . 'invoices/' . $xendittrxID, [
|
||||||
|
'Authorization: Basic ' . base64_encode($_c['xendit_secret_key'] . ':')
|
||||||
|
]), true);
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"id": "631597513897510bace2459d", #gateway_trx_id
|
||||||
|
"external_id": "test-va-success-1662359375",
|
||||||
|
"user_id": "599bd7f1ccab55b020bb1147",
|
||||||
|
"status": "PENDING", // CHECK THIS
|
||||||
|
"merchant_name": "Xendit",
|
||||||
|
"merchant_profile_picture_url": "https://xnd-companies.s3.amazonaws.com/prod/1538466380522_868.png",
|
||||||
|
"amount": 3000000,
|
||||||
|
"description": "Test - VA Successful invoice payment",
|
||||||
|
"expiry_date": "2022-09-06T06:29:37.251Z",
|
||||||
|
"invoice_url": "https://checkout-staging.xendit.co/web/631597513897510bace2459d"
|
||||||
|
"created": "2022-09-05T06:29:37.954Z",
|
||||||
|
"updated": "2022-09-05T06:29:37.954Z"
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getServer(){
|
||||||
|
global $_app_stage;
|
||||||
|
if ($_app_stage == 'Live') {
|
||||||
|
return 'https://api.xendit.co/v2/';
|
||||||
|
} else {
|
||||||
|
return 'https://api.xendit.co/v2/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
378
system/autoload/Package.php
Normal file
378
system/autoload/Package.php
Normal file
@ -0,0 +1,378 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
use PEAR2\Net\RouterOS;
|
||||||
|
|
||||||
|
class Package
|
||||||
|
{
|
||||||
|
public static function rechargeUser($id_customer, $router_name, $plan_id, $gateway, $channel)
|
||||||
|
{
|
||||||
|
global $_c, $_L;
|
||||||
|
$date_now = date("Y-m-d H:i:s");
|
||||||
|
$date_only = date("Y-m-d");
|
||||||
|
$time = date("H:i:s");
|
||||||
|
|
||||||
|
if ($id_customer == '' or $router_name == '' or $plan_id == '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
|
||||||
|
$p = ORM::for_table('tbl_plans')->where('id', $plan_id)->where('enabled', '1')->find_one();
|
||||||
|
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->find_one();
|
||||||
|
|
||||||
|
$mikrotik = Router::_info($router_name);
|
||||||
|
if ($p['validity_unit'] == 'Months') {
|
||||||
|
$date_exp = date("Y-m-d", strtotime('+' . $p['validity'] . ' month'));
|
||||||
|
} else if ($p['validity_unit'] == 'Days') {
|
||||||
|
$date_exp = date("Y-m-d", strtotime('+' . $p['validity'] . ' day'));
|
||||||
|
} else if ($p['validity_unit'] == 'Hrs') {
|
||||||
|
$datetime = explode(' ', date("Y-m-d H:i:s", strtotime('+' . $p['validity'] . ' hour')));
|
||||||
|
$date_exp = $datetime[0];
|
||||||
|
$time = $datetime[1];
|
||||||
|
} else if ($p['validity_unit'] == 'Mins') {
|
||||||
|
$datetime = explode(' ', date("Y-m-d H:i:s", strtotime('+' . $p['validity'] . ' minute')));
|
||||||
|
$date_exp = $datetime[0];
|
||||||
|
$time = $datetime[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($p['type'] == 'Hotspot') {
|
||||||
|
if ($b) {
|
||||||
|
if (!$_c['radius_mode']) {
|
||||||
|
try {
|
||||||
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
die("Unable to connect to the router.<br>" . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
$printRequest = new RouterOS\Request(
|
||||||
|
'/ip hotspot user print .proplist=name',
|
||||||
|
RouterOS\Query::where('name', $c['username'])
|
||||||
|
);
|
||||||
|
$userName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
||||||
|
$client(
|
||||||
|
$removeRequest
|
||||||
|
->setArgument('numbers', $userName)
|
||||||
|
);
|
||||||
|
/* iBNuX Added:
|
||||||
|
* Time limit to Mikrotik
|
||||||
|
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
||||||
|
*/
|
||||||
|
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
||||||
|
if ($p['typebp'] == "Limited") {
|
||||||
|
if ($p['limit_type'] == "Time_Limit") {
|
||||||
|
if ($p['time_unit'] == 'Hrs')
|
||||||
|
$timelimit = $p['time_limit'] . ":00:00";
|
||||||
|
else
|
||||||
|
$timelimit = "00:" . $p['time_limit'] . ":00";
|
||||||
|
$client->sendSync(
|
||||||
|
$addRequest
|
||||||
|
->setArgument('name', $c['username'])
|
||||||
|
->setArgument('profile', $p['name_plan'])
|
||||||
|
->setArgument('password', $c['password'])
|
||||||
|
->setArgument('limit-uptime', $timelimit)
|
||||||
|
);
|
||||||
|
} else if ($p['limit_type'] == "Data_Limit") {
|
||||||
|
if ($p['data_unit'] == 'GB')
|
||||||
|
$datalimit = $p['data_limit'] . "000000000";
|
||||||
|
else
|
||||||
|
$datalimit = $p['data_limit'] . "000000";
|
||||||
|
$client->sendSync(
|
||||||
|
$addRequest
|
||||||
|
->setArgument('name', $c['username'])
|
||||||
|
->setArgument('profile', $p['name_plan'])
|
||||||
|
->setArgument('password', $c['password'])
|
||||||
|
->setArgument('limit-bytes-total', $datalimit)
|
||||||
|
);
|
||||||
|
} else if ($p['limit_type'] == "Both_Limit") {
|
||||||
|
if ($p['time_unit'] == 'Hrs')
|
||||||
|
$timelimit = $p['time_limit'] . ":00:00";
|
||||||
|
else
|
||||||
|
$timelimit = "00:" . $p['time_limit'] . ":00";
|
||||||
|
if ($p['data_unit'] == 'GB')
|
||||||
|
$datalimit = $p['data_limit'] . "000000000";
|
||||||
|
else
|
||||||
|
$datalimit = $p['data_limit'] . "000000";
|
||||||
|
$client->sendSync(
|
||||||
|
$addRequest
|
||||||
|
->setArgument('name', $c['username'])
|
||||||
|
->setArgument('profile', $p['name_plan'])
|
||||||
|
->setArgument('password', $c['password'])
|
||||||
|
->setArgument('limit-uptime', $timelimit)
|
||||||
|
->setArgument('limit-bytes-total', $datalimit)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$client->sendSync(
|
||||||
|
$addRequest
|
||||||
|
->setArgument('name', $c['username'])
|
||||||
|
->setArgument('profile', $p['name_plan'])
|
||||||
|
->setArgument('password', $c['password'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$b->customer_id = $id_customer;
|
||||||
|
$b->username = $c['username'];
|
||||||
|
$b->plan_id = $plan_id;
|
||||||
|
$b->namebp = $p['name_plan'];
|
||||||
|
$b->recharged_on = $date_only;
|
||||||
|
$b->expiration = $date_exp;
|
||||||
|
$b->time = $time;
|
||||||
|
$b->status = "on";
|
||||||
|
$b->method = "$gateway - $channel";
|
||||||
|
$b->routers = $router_name;
|
||||||
|
$b->type = "Hotspot";
|
||||||
|
$b->save();
|
||||||
|
|
||||||
|
// insert table transactions
|
||||||
|
$t = ORM::for_table('tbl_transactions')->create();
|
||||||
|
$t->invoice = "INV-" . _raid(5);
|
||||||
|
$t->username = $c['username'];
|
||||||
|
$t->plan_name = $p['name_plan'];
|
||||||
|
$t->price = $p['price'];
|
||||||
|
$t->recharged_on = $date_only;
|
||||||
|
$t->expiration = $date_exp;
|
||||||
|
$t->time = $time;
|
||||||
|
$t->method = "$gateway - $channel";
|
||||||
|
$t->routers = $router_name;
|
||||||
|
$t->type = "Hotspot";
|
||||||
|
$t->save();
|
||||||
|
} else {
|
||||||
|
if (!$_c['radius_mode']) {
|
||||||
|
try {
|
||||||
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
die("Unable to connect to the router.<br>" . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* iBNuX Added:
|
||||||
|
* Time limit to Mikrotik
|
||||||
|
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
||||||
|
*/
|
||||||
|
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
||||||
|
if ($p['typebp'] == "Limited") {
|
||||||
|
if ($p['limit_type'] == "Time_Limit") {
|
||||||
|
if ($p['time_unit'] == 'Hrs')
|
||||||
|
$timelimit = $p['time_limit'] . ":00:00";
|
||||||
|
else
|
||||||
|
$timelimit = "00:" . $p['time_limit'] . ":00";
|
||||||
|
$client->sendSync(
|
||||||
|
$addRequest
|
||||||
|
->setArgument('name', $c['username'])
|
||||||
|
->setArgument('profile', $p['name_plan'])
|
||||||
|
->setArgument('password', $c['password'])
|
||||||
|
->setArgument('limit-uptime', $timelimit)
|
||||||
|
);
|
||||||
|
} else if ($p['limit_type'] == "Data_Limit") {
|
||||||
|
if ($p['data_unit'] == 'GB')
|
||||||
|
$datalimit = $p['data_limit'] . "000000000";
|
||||||
|
else
|
||||||
|
$datalimit = $p['data_limit'] . "000000";
|
||||||
|
$client->sendSync(
|
||||||
|
$addRequest
|
||||||
|
->setArgument('name', $c['username'])
|
||||||
|
->setArgument('profile', $p['name_plan'])
|
||||||
|
->setArgument('password', $c['password'])
|
||||||
|
->setArgument('limit-bytes-total', $datalimit)
|
||||||
|
);
|
||||||
|
} else if ($p['limit_type'] == "Both_Limit") {
|
||||||
|
if ($p['time_unit'] == 'Hrs')
|
||||||
|
$timelimit = $p['time_limit'] . ":00:00";
|
||||||
|
else
|
||||||
|
$timelimit = "00:" . $p['time_limit'] . ":00";
|
||||||
|
if ($p['data_unit'] == 'GB')
|
||||||
|
$datalimit = $p['data_limit'] . "000000000";
|
||||||
|
else
|
||||||
|
$datalimit = $p['data_limit'] . "000000";
|
||||||
|
$client->sendSync(
|
||||||
|
$addRequest
|
||||||
|
->setArgument('name', $c['username'])
|
||||||
|
->setArgument('profile', $p['name_plan'])
|
||||||
|
->setArgument('password', $c['password'])
|
||||||
|
->setArgument('limit-uptime', $timelimit)
|
||||||
|
->setArgument('limit-bytes-total', $datalimit)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$client->sendSync(
|
||||||
|
$addRequest
|
||||||
|
->setArgument('name', $c['username'])
|
||||||
|
->setArgument('profile', $p['name_plan'])
|
||||||
|
->setArgument('password', $c['password'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$d = ORM::for_table('tbl_user_recharges')->create();
|
||||||
|
$d->customer_id = $id_customer;
|
||||||
|
$d->username = $c['username'];
|
||||||
|
$d->plan_id = $plan_id;
|
||||||
|
$d->namebp = $p['name_plan'];
|
||||||
|
$d->recharged_on = $date_only;
|
||||||
|
$d->expiration = $date_exp;
|
||||||
|
$d->time = $time;
|
||||||
|
$d->status = "on";
|
||||||
|
$d->method = "$gateway - $channel";
|
||||||
|
$d->routers = $router_name;
|
||||||
|
$d->type = "Hotspot";
|
||||||
|
$d->save();
|
||||||
|
|
||||||
|
// insert table transactions
|
||||||
|
$t = ORM::for_table('tbl_transactions')->create();
|
||||||
|
$t->invoice = "INV-" . _raid(5);
|
||||||
|
$t->username = $c['username'];
|
||||||
|
$t->plan_name = $p['name_plan'];
|
||||||
|
$t->price = $p['price'];
|
||||||
|
$t->recharged_on = $date_only;
|
||||||
|
$t->expiration = $date_exp;
|
||||||
|
$t->time = $time;
|
||||||
|
$t->method = "$gateway - $channel";
|
||||||
|
$t->routers = $router_name;
|
||||||
|
$t->type = "Hotspot";
|
||||||
|
$t->save();
|
||||||
|
}
|
||||||
|
sendTelegram("#u$c[username] #buy #Hotspot \n" . $p['name_plan'] .
|
||||||
|
"\nRouter: " . $router_name .
|
||||||
|
"\nGateway: " . $gateway .
|
||||||
|
"\nChannel: " . $channel .
|
||||||
|
"\nPrice: " . $p['price']);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if ($b) {
|
||||||
|
if (!$_c['radius_mode']) {
|
||||||
|
try {
|
||||||
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
die("Unable to connect to the router.<br>" . $e->getMessage());
|
||||||
|
}
|
||||||
|
$printRequest = new RouterOS\Request(
|
||||||
|
'/ppp secret print .proplist=name',
|
||||||
|
RouterOS\Query::where('name', $c['username'])
|
||||||
|
);
|
||||||
|
$userName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
|
||||||
|
$removeRequest = new RouterOS\Request('/ppp/secret/remove');
|
||||||
|
$client(
|
||||||
|
$removeRequest
|
||||||
|
->setArgument('numbers', $userName)
|
||||||
|
);
|
||||||
|
|
||||||
|
$addRequest = new RouterOS\Request('/ppp/secret/add');
|
||||||
|
$client->sendSync(
|
||||||
|
$addRequest
|
||||||
|
->setArgument('name', $c['username'])
|
||||||
|
->setArgument('service', 'pppoe')
|
||||||
|
->setArgument('profile', $p['name_plan'])
|
||||||
|
->setArgument('password', $c['password'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$b->customer_id = $id_customer;
|
||||||
|
$b->username = $c['username'];
|
||||||
|
$b->plan_id = $plan_id;
|
||||||
|
$b->namebp = $p['name_plan'];
|
||||||
|
$b->recharged_on = $date_only;
|
||||||
|
$b->expiration = $date_exp;
|
||||||
|
$b->time = $time;
|
||||||
|
$b->status = "on";
|
||||||
|
$b->method = "$gateway - $channel";
|
||||||
|
$b->routers = $router_name;
|
||||||
|
$b->type = "PPPOE";
|
||||||
|
$b->save();
|
||||||
|
|
||||||
|
// insert table transactions
|
||||||
|
$t = ORM::for_table('tbl_transactions')->create();
|
||||||
|
$t->invoice = "INV-" . _raid(5);
|
||||||
|
$t->username = $c['username'];
|
||||||
|
$t->plan_name = $p['name_plan'];
|
||||||
|
$t->price = $p['price'];
|
||||||
|
$t->recharged_on = $date_only;
|
||||||
|
$t->expiration = $date_exp;
|
||||||
|
$t->time = $time;
|
||||||
|
$t->method = "$gateway - $channel";
|
||||||
|
$t->routers = $router_name;
|
||||||
|
$t->type = "PPPOE";
|
||||||
|
$t->save();
|
||||||
|
} else {
|
||||||
|
if (!$_c['radius_mode']) {
|
||||||
|
try {
|
||||||
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
die("Unable to connect to the router.<br>" . $e->getMessage());
|
||||||
|
}
|
||||||
|
$addRequest = new RouterOS\Request('/ppp/secret/add');
|
||||||
|
$client->sendSync(
|
||||||
|
$addRequest
|
||||||
|
->setArgument('name', $c['username'])
|
||||||
|
->setArgument('service', 'pppoe')
|
||||||
|
->setArgument('profile', $p['name_plan'])
|
||||||
|
->setArgument('password', $c['password'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$d = ORM::for_table('tbl_user_recharges')->create();
|
||||||
|
$d->customer_id = $id_customer;
|
||||||
|
$d->username = $c['username'];
|
||||||
|
$d->plan_id = $plan_id;
|
||||||
|
$d->namebp = $p['name_plan'];
|
||||||
|
$d->recharged_on = $date_only;
|
||||||
|
$d->expiration = $date_exp;
|
||||||
|
$d->time = $time;
|
||||||
|
$d->status = "on";
|
||||||
|
$d->method = "$gateway - $channel";
|
||||||
|
$d->routers = $router_name;
|
||||||
|
$d->type = "PPPOE";
|
||||||
|
$d->save();
|
||||||
|
|
||||||
|
// insert table transactions
|
||||||
|
$t = ORM::for_table('tbl_transactions')->create();
|
||||||
|
$t->invoice = "INV-" . _raid(5);
|
||||||
|
$t->username = $c['username'];
|
||||||
|
$t->plan_name = $p['name_plan'];
|
||||||
|
$t->price = $p['price'];
|
||||||
|
$t->recharged_on = $date_only;
|
||||||
|
$t->expiration = $date_exp;
|
||||||
|
$t->time = $time;
|
||||||
|
$t->method = "$gateway - $channel";
|
||||||
|
$t->routers = $router_name;
|
||||||
|
$t->type = "PPPOE";
|
||||||
|
$t->save();
|
||||||
|
}
|
||||||
|
sendTelegram("#u$c[username] #buy #PPPOE \n" . $p['name_plan'] .
|
||||||
|
"\nRouter: " . $router_name .
|
||||||
|
"\nGateway: " . $gateway .
|
||||||
|
"\nChannel: " . $channel .
|
||||||
|
"\nPrice: " . $p['price']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one();
|
||||||
|
|
||||||
|
sendWhatsapp($c['username'], "*$_c[CompanyName]*\n" .
|
||||||
|
"$_c[address]\n" .
|
||||||
|
"$_c[phone]\n" .
|
||||||
|
"\n\n" .
|
||||||
|
"INVOICE: *$in[invoice]*\n" .
|
||||||
|
"$_L[Date] : $date_now\n" .
|
||||||
|
"$gateway $channel\n" .
|
||||||
|
"\n\n" .
|
||||||
|
"$_L[Type] : *$in[type]*\n" .
|
||||||
|
"$_L[Plan_Name] : *$in[plan_name]*\n" .
|
||||||
|
"$_L[Plan_Price] : *$_c[currency_code] " . number_format($in['price'], 2, $_c['dec_point'], $_c['thousands_sep']) . "*\n\n" .
|
||||||
|
"$_L[Username] : *$in[username]*\n" .
|
||||||
|
"$_L[Password] : **********\n\n" .
|
||||||
|
"$_L[Created_On] :\n*" . date($_c['date_format'], strtotime($in['recharged_on'])) . " $in[time]*\n" .
|
||||||
|
"$_L[Expires_On] :\n*" . date($_c['date_format'], strtotime($in['expiration'])) . " $in[time]*\n" .
|
||||||
|
"\n\n" .
|
||||||
|
"$_c[note]");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,189 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
|
||||||
**/
|
|
||||||
|
|
||||||
|
|
||||||
// Payment Gateway Server
|
|
||||||
if ($_app_stage == 'Live') {
|
|
||||||
$xendit_server = 'https://api.xendit.co/v2/';
|
|
||||||
$midtrans_server = 'https://api.midtrans.com/';
|
|
||||||
$tripay_server = 'https://tripay.co.id/api/';
|
|
||||||
} else {
|
|
||||||
$xendit_server = 'https://api.xendit.co/v2/';
|
|
||||||
$midtrans_server = 'https://api.sandbox.midtrans.com/';
|
|
||||||
$tripay_server = 'https://tripay.co.id/api-sandbox/';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function xendit_create_invoice($trxID, $amount, $phone, $description)
|
|
||||||
{
|
|
||||||
global $xendit_server, $_c;
|
|
||||||
$json = [
|
|
||||||
'external_id' => $trxID,
|
|
||||||
'amount' => $amount,
|
|
||||||
'description' => $description,
|
|
||||||
'customer' => [
|
|
||||||
'mobile_number' => $phone,
|
|
||||||
],
|
|
||||||
'customer_notification_preference' => [
|
|
||||||
'invoice_created' => ['whatsapp', 'sms'],
|
|
||||||
'invoice_reminder' => ['whatsapp', 'sms'],
|
|
||||||
'invoice_paid' => ['whatsapp', 'sms'],
|
|
||||||
'invoice_expired' => ['whatsapp', 'sms']
|
|
||||||
],
|
|
||||||
'payment_methods ' => explode(',', $_c['xendit_channel']),
|
|
||||||
'success_redirect_url' => U . 'order/view/' . $trxID . '/check',
|
|
||||||
'failure_redirect_url' => U . 'order/view/' . $trxID . '/check'
|
|
||||||
];
|
|
||||||
|
|
||||||
return json_decode(postJsonData($xendit_server . 'invoices', $json, ['Authorization: Basic ' . base64_encode($_c['xendit_secret_key'] . ':')]), true);
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
"id": "631597513897510bace2459d", #gateway_trx_id
|
|
||||||
"external_id": "test-va-success-1662359375",
|
|
||||||
"user_id": "599bd7f1ccab55b020bb1147",
|
|
||||||
"status": "PENDING",
|
|
||||||
"merchant_name": "Xendit",
|
|
||||||
"merchant_profile_picture_url": "https://xnd-companies.s3.amazonaws.com/prod/1538466380522_868.png",
|
|
||||||
"amount": 3000000,
|
|
||||||
"description": "Test - VA Successful invoice payment",
|
|
||||||
"expiry_date": "2022-09-06T06:29:37.251Z",
|
|
||||||
"invoice_url": "https://checkout-staging.xendit.co/web/631597513897510bace2459d"
|
|
||||||
"created": "2022-09-05T06:29:37.954Z",
|
|
||||||
"updated": "2022-09-05T06:29:37.954Z"
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
function xendit_get_invoice($xendittrxID)
|
|
||||||
{
|
|
||||||
global $xendit_server, $_c;
|
|
||||||
return json_decode(getData($xendit_server . 'invoices/' . $xendittrxID, [
|
|
||||||
'Authorization: Basic ' . base64_encode($_c['xendit_secret_key'] . ':')
|
|
||||||
]), true);
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
"id": "631597513897510bace2459d", #gateway_trx_id
|
|
||||||
"external_id": "test-va-success-1662359375",
|
|
||||||
"user_id": "599bd7f1ccab55b020bb1147",
|
|
||||||
"status": "PENDING", // CHECK THIS
|
|
||||||
"merchant_name": "Xendit",
|
|
||||||
"merchant_profile_picture_url": "https://xnd-companies.s3.amazonaws.com/prod/1538466380522_868.png",
|
|
||||||
"amount": 3000000,
|
|
||||||
"description": "Test - VA Successful invoice payment",
|
|
||||||
"expiry_date": "2022-09-06T06:29:37.251Z",
|
|
||||||
"invoice_url": "https://checkout-staging.xendit.co/web/631597513897510bace2459d"
|
|
||||||
"created": "2022-09-05T06:29:37.954Z",
|
|
||||||
"updated": "2022-09-05T06:29:37.954Z"
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/** MIDTRANS */
|
|
||||||
|
|
||||||
|
|
||||||
function midtrans_create_payment($trxID, $invoiceID, $amount, $description)
|
|
||||||
{
|
|
||||||
global $midtrans_server, $_c;
|
|
||||||
$json = [
|
|
||||||
'transaction_details' => [
|
|
||||||
'order_id' => $trxID,
|
|
||||||
'gross_amount' => intval($amount),
|
|
||||||
"payment_link_id" => $invoiceID
|
|
||||||
],
|
|
||||||
"item_details" => [
|
|
||||||
[
|
|
||||||
"name" => $description,
|
|
||||||
"price" => intval($amount),
|
|
||||||
"quantity" => 1
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'enabled_payments' => explode(',', $_c['midtrans_channel']),
|
|
||||||
"usage_limit" => 4,
|
|
||||||
"expiry" => [
|
|
||||||
"duration" => 24,
|
|
||||||
"unit" => "hours"
|
|
||||||
]
|
|
||||||
];
|
|
||||||
$data = postJsonData($midtrans_server . 'v1/payment-links', $json, ['Authorization: Basic ' . base64_encode($_c['midtrans_server_key'] . ':')]);
|
|
||||||
$json = json_decode($data, true);
|
|
||||||
if (!empty($json['error_messages'])) {
|
|
||||||
sendTelegram(json_encode("Midtrans create Payment error:\n" . alphanumeric($_c['CompanyName']) . "_" . crc32($_c['CompanyName']) . "_" . $trxID . "\n" . $json['error_messages']));
|
|
||||||
}
|
|
||||||
return $json;
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
"order_id": "concert-ticket-05", //traxid
|
|
||||||
"payment_url": "https://app.sandbox.midtrans.com/payment-links/amazing-ticket-payment-123"
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
function midtrans_check_payment($midtranstrxID)
|
|
||||||
{
|
|
||||||
global $midtrans_server, $_c;
|
|
||||||
echo $midtrans_server . 'v2/' . $midtranstrxID . '/status';
|
|
||||||
return json_decode(getData($midtrans_server . 'v2/' . $midtranstrxID . '/status', [
|
|
||||||
'Authorization: Basic ' . base64_encode($_c['midtrans_server_key'] . ':')
|
|
||||||
]), true);
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
"masked_card": "41111111-1111",
|
|
||||||
"approval_code": "1599493766402",
|
|
||||||
"bank": "bni",
|
|
||||||
"channel_response_code": "00",
|
|
||||||
"channel_response_message": "Approved",
|
|
||||||
"transaction_time": "2020-09-07 22:49:26",
|
|
||||||
"gross_amount": "10000.00",
|
|
||||||
"currency": "IDR",
|
|
||||||
"order_id": "SANDBOX-G710367688-806",
|
|
||||||
"payment_type": "credit_card",
|
|
||||||
"signature_key": "4d4abc70f5a88b09f48f3ab5cb91245feb0b3d89181117a677767b42f8cbe477f5a0d38af078487071311f97da646c1eb9542c1bbf0b19fa9f12e64605ac405e",
|
|
||||||
"status_code": "200",
|
|
||||||
"transaction_id": "3853c491-ca9b-4bcc-ac20-3512ff72a5d0",
|
|
||||||
"transaction_status": "cancel",
|
|
||||||
"fraud_status": "challenge",
|
|
||||||
"status_message": "Success, transaction is found",
|
|
||||||
"merchant_id": "G710367688",
|
|
||||||
"card_type": "credit"
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
function getData($url, $headers)
|
|
||||||
{
|
|
||||||
$ch = curl_init();
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
|
||||||
curl_setopt($ch, CURLOPT_POST, 0);
|
|
||||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
|
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
$server_output = curl_exec($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
return $server_output;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function postJsonData($url, $array_post, $headers = [], $basic = null)
|
|
||||||
{
|
|
||||||
$headers[] = 'Content-Type: application/json';
|
|
||||||
$ch = curl_init();
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
|
||||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
|
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
|
||||||
curl_setopt($ch, CURLOPT_VERBOSE, false);
|
|
||||||
curl_setopt($ch, CURLINFO_HEADER_OUT, false);
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($array_post));
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
|
||||||
if (!empty($basic)) {
|
|
||||||
curl_setopt($ch, CURLOPT_USERPWD, $basic);
|
|
||||||
}
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
$server_output = curl_exec($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
return $server_output;
|
|
||||||
}
|
|
@ -1,374 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
|
||||||
**/
|
|
||||||
|
|
||||||
|
|
||||||
use PEAR2\Net\RouterOS;
|
|
||||||
|
|
||||||
function rechargeUser($id_customer, $router_name, $plan_id, $gateway, $channel){
|
|
||||||
global $_c,$_L;
|
|
||||||
$date_now = date("Y-m-d H:i:s");
|
|
||||||
$date_only = date("Y-m-d");
|
|
||||||
$time = date("H:i:s");
|
|
||||||
|
|
||||||
if ($id_customer == '' or $router_name == '' or $plan_id == '') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
|
|
||||||
$p = ORM::for_table('tbl_plans')->where('id', $plan_id)->where('enabled', '1')->find_one();
|
|
||||||
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->find_one();
|
|
||||||
|
|
||||||
$mikrotik = Router::_info($router_name);
|
|
||||||
if($p['validity_unit']=='Months'){
|
|
||||||
$date_exp = date("Y-m-d", strtotime('+'.$p['validity'].' month'));
|
|
||||||
}else if($p['validity_unit']=='Days'){
|
|
||||||
$date_exp = date("Y-m-d", strtotime('+'.$p['validity'].' day'));
|
|
||||||
}else if($p['validity_unit']=='Hrs'){
|
|
||||||
$datetime = explode(' ',date("Y-m-d H:i:s", strtotime('+'.$p['validity'].' hour')));
|
|
||||||
$date_exp = $datetime[0];
|
|
||||||
$time = $datetime[1];
|
|
||||||
}else if($p['validity_unit']=='Mins'){
|
|
||||||
$datetime = explode(' ',date("Y-m-d H:i:s", strtotime('+'.$p['validity'].' minute')));
|
|
||||||
$date_exp = $datetime[0];
|
|
||||||
$time = $datetime[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($p['type'] == 'Hotspot') {
|
|
||||||
if ($b) {
|
|
||||||
if(!$_c['radius_mode']){
|
|
||||||
try {
|
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot user print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $c['username'])
|
|
||||||
);
|
|
||||||
$userName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
|
||||||
$client(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $userName)
|
|
||||||
);
|
|
||||||
/* iBNuX Added:
|
|
||||||
* Time limit to Mikrotik
|
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
|
||||||
*/
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
|
||||||
if ($p['typebp'] == "Limited") {
|
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Data_Limit") {
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Both_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$b->customer_id = $id_customer;
|
|
||||||
$b->username = $c['username'];
|
|
||||||
$b->plan_id = $plan_id;
|
|
||||||
$b->namebp = $p['name_plan'];
|
|
||||||
$b->recharged_on = $date_only;
|
|
||||||
$b->expiration = $date_exp;
|
|
||||||
$b->time = $time;
|
|
||||||
$b->status = "on";
|
|
||||||
$b->method = "admin";
|
|
||||||
$b->routers = $router_name;
|
|
||||||
$b->type = "Hotspot";
|
|
||||||
$b->save();
|
|
||||||
|
|
||||||
// insert table transactions
|
|
||||||
$t = ORM::for_table('tbl_transactions')->create();
|
|
||||||
$t->invoice = "INV-" . _raid(5);
|
|
||||||
$t->username = $c['username'];
|
|
||||||
$t->plan_name = $p['name_plan'];
|
|
||||||
$t->price = $p['price'];
|
|
||||||
$t->recharged_on = $date_only;
|
|
||||||
$t->expiration = $date_exp;
|
|
||||||
$t->time = $time;
|
|
||||||
$t->method = "admin";
|
|
||||||
$t->routers = $router_name;
|
|
||||||
$t->type = "Hotspot";
|
|
||||||
$t->save();
|
|
||||||
} else {
|
|
||||||
if(!$_c['radius_mode']){
|
|
||||||
try {
|
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* iBNuX Added:
|
|
||||||
* Time limit to Mikrotik
|
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
|
||||||
*/
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
|
||||||
if ($p['typebp'] == "Limited") {
|
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Data_Limit") {
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Both_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$d = ORM::for_table('tbl_user_recharges')->create();
|
|
||||||
$d->customer_id = $id_customer;
|
|
||||||
$d->username = $c['username'];
|
|
||||||
$d->plan_id = $plan_id;
|
|
||||||
$d->namebp = $p['name_plan'];
|
|
||||||
$d->recharged_on = $date_only;
|
|
||||||
$d->expiration = $date_exp;
|
|
||||||
$d->time = $time;
|
|
||||||
$d->status = "on";
|
|
||||||
$d->method = "admin";
|
|
||||||
$d->routers = $router_name;
|
|
||||||
$d->type = "Hotspot";
|
|
||||||
$d->save();
|
|
||||||
|
|
||||||
// insert table transactions
|
|
||||||
$t = ORM::for_table('tbl_transactions')->create();
|
|
||||||
$t->invoice = "INV-" . _raid(5);
|
|
||||||
$t->username = $c['username'];
|
|
||||||
$t->plan_name = $p['name_plan'];
|
|
||||||
$t->price = $p['price'];
|
|
||||||
$t->recharged_on = $date_only;
|
|
||||||
$t->expiration = $date_exp;
|
|
||||||
$t->time = $time;
|
|
||||||
$t->method = "admin";
|
|
||||||
$t->routers = $router_name;
|
|
||||||
$t->type = "Hotspot";
|
|
||||||
$t->save();
|
|
||||||
}
|
|
||||||
sendTelegram( "#$c[username] #buy #Hotspot \n".$p['name_plan'].
|
|
||||||
"\nRouter: ".$router_name.
|
|
||||||
"\nGateway: ".$gateway.
|
|
||||||
"\nChannel: ".$channel.
|
|
||||||
"\nPrice: ".$p['price']);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if ($b) {
|
|
||||||
if(!$_c['radius_mode']){
|
|
||||||
try {
|
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ppp secret print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $c['username'])
|
|
||||||
);
|
|
||||||
$userName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/secret/remove');
|
|
||||||
$client(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $userName)
|
|
||||||
);
|
|
||||||
|
|
||||||
$addRequest = new RouterOS\Request('/ppp/secret/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('service', 'pppoe')
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$b->customer_id = $id_customer;
|
|
||||||
$b->username = $c['username'];
|
|
||||||
$b->plan_id = $plan_id;
|
|
||||||
$b->namebp = $p['name_plan'];
|
|
||||||
$b->recharged_on = $date_only;
|
|
||||||
$b->expiration = $date_exp;
|
|
||||||
$b->time = $time;
|
|
||||||
$b->status = "on";
|
|
||||||
$b->method = "admin";
|
|
||||||
$b->routers = $router_name;
|
|
||||||
$b->type = "PPPOE";
|
|
||||||
$b->save();
|
|
||||||
|
|
||||||
// insert table transactions
|
|
||||||
$t = ORM::for_table('tbl_transactions')->create();
|
|
||||||
$t->invoice = "INV-" . _raid(5);
|
|
||||||
$t->username = $c['username'];
|
|
||||||
$t->plan_name = $p['name_plan'];
|
|
||||||
$t->price = $p['price'];
|
|
||||||
$t->recharged_on = $date_only;
|
|
||||||
$t->expiration = $date_exp;
|
|
||||||
$t->time = $time;
|
|
||||||
$t->method = "admin";
|
|
||||||
$t->routers = $router_name;
|
|
||||||
$t->type = "PPPOE";
|
|
||||||
$t->save();
|
|
||||||
} else {
|
|
||||||
if(!$_c['radius_mode']){
|
|
||||||
try {
|
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ppp/secret/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('service', 'pppoe')
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$d = ORM::for_table('tbl_user_recharges')->create();
|
|
||||||
$d->customer_id = $id_customer;
|
|
||||||
$d->username = $c['username'];
|
|
||||||
$d->plan_id = $plan_id;
|
|
||||||
$d->namebp = $p['name_plan'];
|
|
||||||
$d->recharged_on = $date_only;
|
|
||||||
$d->expiration = $date_exp;
|
|
||||||
$d->time = $time;
|
|
||||||
$d->status = "on";
|
|
||||||
$d->method = "admin";
|
|
||||||
$d->routers = $router_name;
|
|
||||||
$d->type = "PPPOE";
|
|
||||||
$d->save();
|
|
||||||
|
|
||||||
// insert table transactions
|
|
||||||
$t = ORM::for_table('tbl_transactions')->create();
|
|
||||||
$t->invoice = "INV-" . _raid(5);
|
|
||||||
$t->username = $c['username'];
|
|
||||||
$t->plan_name = $p['name_plan'];
|
|
||||||
$t->price = $p['price'];
|
|
||||||
$t->recharged_on = $date_only;
|
|
||||||
$t->expiration = $date_exp;
|
|
||||||
$t->time = $time;
|
|
||||||
$t->method = "admin";
|
|
||||||
$t->routers = $router_name;
|
|
||||||
$t->type = "PPPOE";
|
|
||||||
$t->save();
|
|
||||||
}
|
|
||||||
sendTelegram( "#$c[username] #buy #PPPOE \n".$p['name_plan'].
|
|
||||||
"\nRouter: ".$router_name.
|
|
||||||
"\nGateway: ".$gateway.
|
|
||||||
"\nChannel: ".$channel.
|
|
||||||
"\nPrice: ".$p['price']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$in = ORM::for_table('tbl_transactions')->where('username', $c['username'])->order_by_desc('id')->find_one();
|
|
||||||
|
|
||||||
sendWhatsapp($c['username'], "*$_c[CompanyName]*\n".
|
|
||||||
"$_c[address]\n".
|
|
||||||
"$_c[phone]\n".
|
|
||||||
"\n\n".
|
|
||||||
"INVOICE: *$in[invoice]*\n".
|
|
||||||
"$_L[Date] : $date_now\n".
|
|
||||||
"$gateway $channel\n".
|
|
||||||
"\n\n".
|
|
||||||
"$_L[Type] : *$in[type]*\n".
|
|
||||||
"$_L[Plan_Name] : *$in[plan_name]*\n".
|
|
||||||
"$_L[Plan_Price] : *$_c[currency_code] ".number_format($in['price'],2,$_c['dec_point'],$_c['thousands_sep'])."*\n\n".
|
|
||||||
"$_L[Username] : *$in[username]*\n".
|
|
||||||
"$_L[Password] : **********\n\n".
|
|
||||||
"$_L[Created_On] :\n*".date($_c['date_format'], strtotime($in['recharged_on']))." $in[time]*\n".
|
|
||||||
"$_L[Expires_On] :\n*".date($_c['date_format'], strtotime($in['expiration']))." $in[time]*\n".
|
|
||||||
"\n\n".
|
|
||||||
"$_c[note]");
|
|
||||||
return true;
|
|
||||||
}
|
|
@ -21,7 +21,7 @@ switch ($action) {
|
|||||||
echo "done";
|
echo "done";
|
||||||
break;
|
break;
|
||||||
case 'tripay':
|
case 'tripay':
|
||||||
echo "done";
|
echo '{"success": true}';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
echo "not found";
|
echo "not found";
|
||||||
|
@ -9,10 +9,6 @@ $action = $routes['1'];
|
|||||||
$user = User::_info();
|
$user = User::_info();
|
||||||
$ui->assign('_user', $user);
|
$ui->assign('_user', $user);
|
||||||
|
|
||||||
|
|
||||||
require('system/autoload/Paymentgateway.php');
|
|
||||||
require('system/autoload/Recharge.php');
|
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'voucher':
|
case 'voucher':
|
||||||
$ui->assign('_title', $_L['Order_Voucher'] . ' - ' . $config['CompanyName']);
|
$ui->assign('_title', $_L['Order_Voucher'] . ' - ' . $config['CompanyName']);
|
||||||
@ -51,12 +47,12 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
if ($routes['3'] == 'check') {
|
if ($routes['3'] == 'check') {
|
||||||
if ($trx['gateway'] == 'xendit') {
|
if ($trx['gateway'] == 'xendit') {
|
||||||
$result = xendit_get_invoice($trx['gateway_trx_id']);
|
$pg = new PGXendit($trx,$user);
|
||||||
|
$result = $pg->getInvoice($trx['gateway_trx_id']);
|
||||||
if ($result['status'] == 'PENDING') {
|
if ($result['status'] == 'PENDING') {
|
||||||
r2(U . "order/view/" . $trxid, 'w', Lang::T("Transaction still unpaid."));
|
r2(U . "order/view/" . $trxid, 'w', Lang::T("Transaction still unpaid."));
|
||||||
} else if (in_array($result['status'],['PAID','SETTLED']) && $trx['status'] != 2) {
|
} else if (in_array($result['status'],['PAID','SETTLED']) && $trx['status'] != 2) {
|
||||||
|
if (!Package::rechargeUser($user['id'], $trx['routers'], $trx['plan_id'], $trx['gateway'], $result['payment_method'] . ' ' . $result['payment_channel'])) {
|
||||||
if (!rechargeUser($user['id'], $trx['routers'], $trx['plan_id'], 'xendit', $result['payment_method'] . ' ' . $result['payment_channel'])) {
|
|
||||||
r2(U . "order/view/" . $trxid, 'd', Lang::T("Failed to activate your Package, try again later."));
|
r2(U . "order/view/" . $trxid, 'd', Lang::T("Failed to activate your Package, try again later."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,13 +72,40 @@ switch ($action) {
|
|||||||
}else if($trx['status'] == 2){
|
}else if($trx['status'] == 2){
|
||||||
r2(U . "order/view/" . $trxid, 'd', Lang::T("Transaction has been paid.."));
|
r2(U . "order/view/" . $trxid, 'd', Lang::T("Transaction has been paid.."));
|
||||||
}
|
}
|
||||||
|
r2(U . "order/view/" . $trxid, 'd', Lang::T("Unknown Command."));
|
||||||
|
} else if ($trx['gateway'] == 'tripay') {
|
||||||
|
$pg = new PGTripay($trx,$user);
|
||||||
|
$result = $pg->getStatus($trx['gateway_trx_id']);
|
||||||
|
if ($result['success']!=1) {
|
||||||
print_r($result);
|
print_r($result);
|
||||||
die();
|
die();
|
||||||
r2(U . "order/view/" . $trxid, 'd', Lang::T("Unknown Command."));
|
sendTelegram("Tripay payment status failed\n\n".json_encode($result, JSON_PRETTY_PRINT));
|
||||||
} else if ($trx['gateway'] == 'midtrans') {
|
r2(U . "order/view/" . $trxid, 'w', Lang::T("Payment check failed."));
|
||||||
$result = midtrans_check_payment($trx['gateway_trx_id']);
|
}
|
||||||
print_r($result);
|
$result = $result['data'];
|
||||||
} else if ($trx['gateway'] == 'tripay') {
|
if ($result['status'] == 'UNPAID') {
|
||||||
|
r2(U . "order/view/" . $trxid, 'w', Lang::T("Transaction still unpaid."));
|
||||||
|
} else if (in_array($result['status'],['PAID','SETTLED']) && $trx['status'] != 2) {
|
||||||
|
if (!Package::rechargeUser($user['id'], $trx['routers'], $trx['plan_id'], $trx['gateway'], $result['payment_method'] . ' ' . $result['payment_channel'])) {
|
||||||
|
r2(U . "order/view/" . $trxid, 'd', Lang::T("Failed to activate your Package, try again later."));
|
||||||
|
}
|
||||||
|
|
||||||
|
$trx->pg_paid_response = json_encode($result);
|
||||||
|
$trx->payment_method = $result['payment_method'];
|
||||||
|
$trx->payment_channel = $result['payment_name'];
|
||||||
|
$trx->paid_date = date('Y-m-d H:i:s', $result['paid_at']);
|
||||||
|
$trx->status = 2;
|
||||||
|
$trx->save();
|
||||||
|
|
||||||
|
r2(U . "order/view/" . $trxid, 's', Lang::T("Transaction has been paid."));
|
||||||
|
} else if (in_array($result['status'],['EXPIRED','FAILED','REFUND'])) {
|
||||||
|
$trx->pg_paid_response = json_encode($result);
|
||||||
|
$trx->status = 3;
|
||||||
|
$trx->save();
|
||||||
|
r2(U . "order/view/" . $trxid, 'd', Lang::T("Transaction expired."));
|
||||||
|
}else if($trx['status'] == 2){
|
||||||
|
r2(U . "order/view/" . $trxid, 'd', Lang::T("Transaction has been paid.."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if ($routes['3'] == 'cancel') {
|
} else if ($routes['3'] == 'cancel') {
|
||||||
$trx->pg_paid_response = '{}';
|
$trx->pg_paid_response = '{}';
|
||||||
@ -110,6 +133,9 @@ switch ($action) {
|
|||||||
$ui->display('user-orderView.tpl');
|
$ui->display('user-orderView.tpl');
|
||||||
break;
|
break;
|
||||||
case 'buy':
|
case 'buy':
|
||||||
|
if ($_c['payment_gateway'] == 'none') {
|
||||||
|
r2(U . 'home', 'e', Lang::T("No Payment Gateway Available"));
|
||||||
|
}
|
||||||
$back = "order/package";
|
$back = "order/package";
|
||||||
$router = ORM::for_table('tbl_routers')->where('enabled', '1')->find_one($routes['2'] * 1);
|
$router = ORM::for_table('tbl_routers')->where('enabled', '1')->find_one($routes['2'] * 1);
|
||||||
$plan = ORM::for_table('tbl_plans')->where('enabled', '1')->find_one($routes['3'] * 1);
|
$plan = ORM::for_table('tbl_plans')->where('enabled', '1')->find_one($routes['3'] * 1);
|
||||||
@ -152,7 +178,8 @@ switch ($action) {
|
|||||||
r2(U . $back, 'e', Lang::T("Admin has not yet setup Xendit payment gateway, please tell admin"));
|
r2(U . $back, 'e', Lang::T("Admin has not yet setup Xendit payment gateway, please tell admin"));
|
||||||
}
|
}
|
||||||
if ($id) {
|
if ($id) {
|
||||||
$result = xendit_create_invoice($id, $plan['price'], $user['username'], $plan['name_plan']);
|
$pg = new PGXendit($d,$user);
|
||||||
|
$result = $pg->createInvoice($id, $plan['price'], $user['username'], $plan['name_plan']);
|
||||||
if (!$result['id']) {
|
if (!$result['id']) {
|
||||||
r2(U . $back, 'e', Lang::T("Failed to create transaction."));
|
r2(U . $back, 'e', Lang::T("Failed to create transaction."));
|
||||||
}
|
}
|
||||||
@ -170,37 +197,40 @@ switch ($action) {
|
|||||||
} else {
|
} else {
|
||||||
r2(U . "order/view/" . $d['id'], 'w', Lang::T("Failed to create Transaction.."));
|
r2(U . "order/view/" . $d['id'], 'w', Lang::T("Failed to create Transaction.."));
|
||||||
}
|
}
|
||||||
} else if ($_c['payment_gateway'] == 'midtrans') {
|
} else if ($_c['payment_gateway'] == 'tripay') {
|
||||||
if (empty($_c['midtrans_server_key'])) {
|
if (empty($_c['tripay_secret_key'])) {
|
||||||
sendTelegram("Midtrans payment gateway not configured");
|
sendTelegram("Tripay payment gateway not configured");
|
||||||
r2(U . $back, 'e', Lang::T("Admin has not yet setup Midtrans payment gateway, please tell admin"));
|
r2(U . $back, 'e', Lang::T("Admin has not yet setup Tripay payment gateway, please tell admin"));
|
||||||
|
}
|
||||||
|
if(!in_array($routes['4'],explode(",",$_c['tripay_channel']))){
|
||||||
|
$ui->assign('_title', 'Tripay Channel - ' . $config['CompanyName']);
|
||||||
|
$ui->assign('channels', json_decode(file_get_contents('system/paymentgateway/channel_tripay.json'), true));
|
||||||
|
$ui->assign('tripay_channels', explode(",",$_c['tripay_channel']));
|
||||||
|
$ui->assign('path', $routes['2'].'/'.$routes['3']);
|
||||||
|
$ui->display('tripay_channel.tpl');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if ($id) {
|
if ($id) {
|
||||||
$invoiceID = alphanumeric(strtolower($_c['CompanyName'])) . "-" . crc32($_c['CompanyName'] . $id) . "-" . $id;
|
$pg = new PGTripay($d,$user);
|
||||||
$result = midtrans_create_payment($id, $invoiceID, $plan['price'],$plan['name_plan']);
|
$result = $pg->createTransaction($routes['4']);
|
||||||
if (!$result['payment_url']) {
|
if ($result['success']!=1) {
|
||||||
sendTelegram("Midtrans payment failed\n\n".json_encode($result, JSON_PRETTY_PRINT));
|
sendTelegram("Tripay payment failed\n\n".json_encode($result, JSON_PRETTY_PRINT));
|
||||||
r2(U . $back, 'e', Lang::T("Failed to create transaction."));
|
r2(U . $back, 'e', Lang::T("Failed to create transaction."));
|
||||||
}
|
}
|
||||||
$d = ORM::for_table('tbl_payment_gateway')
|
$d = ORM::for_table('tbl_payment_gateway')
|
||||||
->where('username', $user['username'])
|
->where('username', $user['username'])
|
||||||
->where('status', 1)
|
->where('status', 1)
|
||||||
->find_one();
|
->find_one();
|
||||||
$d->gateway_trx_id = $invoiceID;
|
$d->gateway_trx_id = $result['data']['reference'];
|
||||||
$d->pg_url_payment = $result['payment_url'];
|
$d->pg_url_payment = $result['data']['checkout_url'];
|
||||||
$d->pg_request = json_encode($result);
|
$d->pg_request = json_encode($result);
|
||||||
$d->expired_date = date('Y-m-d H:i:s', strtotime("+1 days"));
|
$d->expired_date = date('Y-m-d H:i:s', $result['data']['expired_time']);
|
||||||
$d->save();
|
$d->save();
|
||||||
r2(U . "order/view/" . $id, 'w', Lang::T("Create Transaction Success"));
|
r2(U . "order/view/" . $id, 'w', Lang::T("Create Transaction Success"));
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
r2(U . "order/view/" . $d['id'], 'w', Lang::T("Failed to create Transaction.."));
|
r2(U . "order/view/" . $d['id'], 'w', Lang::T("Failed to create Transaction.."));
|
||||||
}
|
}
|
||||||
} else if ($_c['payment_gateway'] == 'tripay') {
|
|
||||||
if (empty($_c['tripay_secret_key'])) {
|
|
||||||
sendTelegram("Tripay payment gateway not configured");
|
|
||||||
r2(U . $back, 'e', Lang::T("Admin has not yet setup Tripay payment gateway, please tell admin"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -282,3 +282,6 @@ $_L['Checking_payment'] = 'Checking payment';
|
|||||||
$_L['Create_Transaction_Success'] = 'Create Transaction Success';
|
$_L['Create_Transaction_Success'] = 'Create Transaction Success';
|
||||||
$_L['You_have_unpaid_transaction'] = 'You have unpaid transaction';
|
$_L['You_have_unpaid_transaction'] = 'You have unpaid transaction';
|
||||||
$_L['CANCELED'] = 'CANCELED';
|
$_L['CANCELED'] = 'CANCELED';
|
||||||
|
$_L['TripayPayment_Channel'] = 'TripayPayment Channel';
|
||||||
|
$_L['Payment_Channel'] = 'Payment Channel';
|
||||||
|
$_L['Payment_check_failed'] = 'Payment check failed.';
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-2 control-label">Callback URL</label>
|
<label class="col-md-2 control-label">Notification URL</label>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<input type="text" readonly class="form-control" onclick="this.select()" value="{$_url}callback/tripay">
|
<input type="text" readonly class="form-control" onclick="this.select()" value="{$_url}callback/tripay">
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
<a href="{$_url}bandwidth/add" class="btn btn-primary btn-block waves-effect"><i class="ion ion-android-add"> </i> {$_L['New_Bandwidth']}</a>
|
<a href="{$_url}bandwidth/add" class="btn btn-primary btn-block waves-effect"><i class="ion ion-android-add"> </i> {$_L['New_Bandwidth']}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-bordered">
|
<table class="table table-striped table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -47,6 +47,7 @@
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
{$paginator['contents']}
|
{$paginator['contents']}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
<a href="{$_url}customers/add" class="btn btn-primary btn-block waves-effect"><i class="ion ion-android-add"> </i> {$_L['Add_Contact']}</a>
|
<a href="{$_url}customers/add" class="btn btn-primary btn-block waves-effect"><i class="ion ion-android-add"> </i> {$_L['Add_Contact']}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
<table class="table table-bordered table-striped">
|
<table class="table table-bordered table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -51,6 +51,7 @@
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
{$paginator['contents']}
|
{$paginator['contents']}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -85,6 +85,7 @@
|
|||||||
<div class="panel panel-default mb20 panel-hovered project-stats table-responsive">
|
<div class="panel panel-default mb20 panel-hovered project-stats table-responsive">
|
||||||
<div class="panel-heading">Vouchers Stock</div>
|
<div class="panel-heading">Vouchers Stock</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
<div class="table-responsive">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -108,11 +109,13 @@
|
|||||||
<td>{$stocks['used']}</td>
|
<td>{$stocks['used']}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel panel-default mb20 panel-hovered project-stats table-responsive">
|
<div class="panel panel-default mb20 panel-hovered project-stats table-responsive">
|
||||||
<div class="panel-heading">{$_L['User_Expired_Today']}</div>
|
<div class="panel-heading">{$_L['User_Expired_Today']}</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
<div class="table-responsive">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -137,8 +140,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
|
<div class="panel panel-default panel-hovered mb20 activities">
|
||||||
|
<div class="panel-heading">{Lang::T('Payment Gateway')}: {$_c['payment_gateway']}</div>
|
||||||
|
</div>
|
||||||
<div class="panel panel-default panel-hovered mb20 activities">
|
<div class="panel panel-default panel-hovered mb20 activities">
|
||||||
<div class="panel-heading">{$_L['Activity_Log']}</div>
|
<div class="panel-heading">{$_L['Activity_Log']}</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="md-whiteframe-z1 mb20 text-center" style="padding: 15px">
|
<div class="md-whiteframe-z1 mb20 text-center" style="padding: 15px">
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
|
|
||||||
<form id="site-search" method="post" action="{$_url}pool/list/">
|
<form id="site-search" method="post" action="{$_url}pool/list/">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-addon">
|
<div class="input-group-addon">
|
||||||
@ -24,6 +23,7 @@
|
|||||||
<a href="{$_url}pool/add" class="btn btn-primary btn-block waves-effect"><i class="ion ion-android-add"> </i> {$_L['New_Pool']}</a>
|
<a href="{$_url}pool/add" class="btn btn-primary btn-block waves-effect"><i class="ion ion-android-add"> </i> {$_L['New_Pool']}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-bordered">
|
<table class="table table-striped table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -50,6 +50,7 @@
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
{$paginator['contents']}
|
{$paginator['contents']}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
<a href="{$_url}prepaid/recharge" class="btn btn-primary btn-block waves-effect"><i class="ion ion-android-add"> </i> {$_L['Recharge_Account']}</a>
|
<a href="{$_url}prepaid/recharge" class="btn btn-primary btn-block waves-effect"><i class="ion ion-android-add"> </i> {$_L['Recharge_Account']}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
<table id="datatable" class="table table-striped table-bordered">
|
<table id="datatable" class="table table-striped table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -55,6 +55,7 @@
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
{$paginator['contents']}
|
{$paginator['contents']}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div id="printable">
|
<div id="printable">
|
||||||
<h4>{$_L['All_Transactions_at_Date']}: {date($_c['date_format'], strtotime($mdate))}</h4>
|
<h4>{$_L['All_Transactions_at_Date']}: {date($_c['date_format'], strtotime($mdate))}</h4>
|
||||||
|
<div class="table-responsive">
|
||||||
<table class="table table-condensed table-bordered" style="background: #ffffff">
|
<table class="table table-condensed table-bordered" style="background: #ffffff">
|
||||||
<th class="text-center">{$_L['Username']}</th>
|
<th class="text-center">{$_L['Username']}</th>
|
||||||
<th class="text-center">{$_L['Plan_Name']}</th>
|
<th class="text-center">{$_L['Plan_Name']}</th>
|
||||||
@ -45,6 +46,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
<div class="clearfix text-right total-sum mb10">
|
<div class="clearfix text-right total-sum mb10">
|
||||||
<h4 class="text-uppercase text-bold">{$_L['Total_Income']}:</h4>
|
<h4 class="text-uppercase text-bold">{$_L['Total_Income']}:</h4>
|
||||||
<h3 class="sum">{$_c['currency_code']} {number_format($dr,2,$_c['dec_point'],$_c['thousands_sep'])}</h3>
|
<h3 class="sum">{$_c['currency_code']} {number_format($dr,2,$_c['dec_point'],$_c['thousands_sep'])}</h3>
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div id="printable">
|
<div id="printable">
|
||||||
<h4>{$_L['All_Transactions_at_Date']}: {date( $_c['date_format'], strtotime($fdate))} - {date( $_c['date_format'], strtotime($tdate))}</h4>
|
<h4>{$_L['All_Transactions_at_Date']}: {date( $_c['date_format'], strtotime($fdate))} - {date( $_c['date_format'], strtotime($tdate))}</h4>
|
||||||
|
<div class="table-responsive">
|
||||||
<table class="table table-condensed table-bordered" style="background: #ffffff">
|
<table class="table table-condensed table-bordered" style="background: #ffffff">
|
||||||
<th class="text-center">{$_L['Username']}</th>
|
<th class="text-center">{$_L['Username']}</th>
|
||||||
<th class="text-center">{$_L['Plan_Name']}</th>
|
<th class="text-center">{$_L['Plan_Name']}</th>
|
||||||
@ -45,6 +46,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
<div class="clearfix text-right total-sum mb10">
|
<div class="clearfix text-right total-sum mb10">
|
||||||
<h4 class="text-uppercase text-bold">{$_L['Total_Income']}:</h4>
|
<h4 class="text-uppercase text-bold">{$_L['Total_Income']}:</h4>
|
||||||
<h3 class="sum">{$_c['currency_code']} {number_format($dr,2,$_c['dec_point'],$_c['thousands_sep'])}</h3>
|
<h3 class="sum">{$_c['currency_code']} {number_format($dr,2,$_c['dec_point'],$_c['thousands_sep'])}</h3>
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
<a href="{$_url}export/pdf-by-date" class="btn btn-default"><i class="fa fa-file-pdf-o"></i>{$_L['Export_to_PDF']}</a>
|
<a href="{$_url}export/pdf-by-date" class="btn btn-default"><i class="fa fa-file-pdf-o"></i>{$_L['Export_to_PDF']}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
<table class="table table-bordered invoice-table mb10">
|
<table class="table table-bordered invoice-table mb10">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -46,7 +47,7 @@
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
{$paginator['contents']}
|
{$paginator['contents']}
|
||||||
|
|
||||||
<div class="clearfix text-right total-sum mb10">
|
<div class="clearfix text-right total-sum mb10">
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
<table class="table table-bordered invoice-table mb10">
|
<table class="table table-bordered invoice-table mb10">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -56,7 +57,7 @@
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
<div class="clearfix text-right total-sum mb10">
|
<div class="clearfix text-right total-sum mb10">
|
||||||
<h4 class="text-uppercase text-bold">{$_L['Total_Income']}:</h4>
|
<h4 class="text-uppercase text-bold">{$_L['Total_Income']}:</h4>
|
||||||
<h3 class="sum">{$_c['currency_code']} {number_format($dr,2,$_c['dec_point'],$_c['thousands_sep'])}</h3>
|
<h3 class="sum">{$_c['currency_code']} {number_format($dr,2,$_c['dec_point'],$_c['thousands_sep'])}</h3>
|
||||||
|
19
ui/ui/tripay_channel.tpl
Normal file
19
ui/ui/tripay_channel.tpl
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{include file="sections/user-header.tpl"}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="panel panel-info panel-hovered">
|
||||||
|
<div class="panel-heading">Tripay {Lang::T('Payment Channel')}</div>
|
||||||
|
<div class="panel-body row">
|
||||||
|
{foreach $channels as $channel}
|
||||||
|
{if in_array($channel['id'], $tripay_channels)}
|
||||||
|
<div class="col-sm-4 mb20">
|
||||||
|
<a href="{$_url}order/buy/{$path}/{$channel['id']}"
|
||||||
|
onclick="return confirm('{$channel['name']}')"
|
||||||
|
class="btn btn-block btn-default">{$channel['name']}</a>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{/foreach}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{include file="sections/user-footer.tpl"}
|
@ -5,12 +5,13 @@
|
|||||||
<div class="panel mb20 panel-hovered panel-default">
|
<div class="panel mb20 panel-hovered panel-default">
|
||||||
<div class="panel-heading">{$_L['List_Activated_Voucher']}</div>
|
<div class="panel-heading">{$_L['List_Activated_Voucher']}</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
<div class="table-responsive">
|
||||||
<table id="datatable" class="table table-striped table-bordered">
|
<table id="datatable" class="table table-striped table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{$_L['Username']}</th>
|
<th>{$_L['Username']}</th>
|
||||||
<th>{$_L['Plan_Name']}</th>
|
<th>{$_L['Plan_Name']}</th>
|
||||||
|
<th>{$_L['Plan_Price']}</th>
|
||||||
<th>{$_L['Type']}</th>
|
<th>{$_L['Type']}</th>
|
||||||
<th>{$_L['Created_On']}</th>
|
<th>{$_L['Created_On']}</th>
|
||||||
<th>{$_L['Expires_On']}</th>
|
<th>{$_L['Expires_On']}</th>
|
||||||
@ -22,6 +23,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{$ds['username']}</td>
|
<td>{$ds['username']}</td>
|
||||||
<td>{$ds['plan_name']}</td>
|
<td>{$ds['plan_name']}</td>
|
||||||
|
<td>{$ds['price']}</td>
|
||||||
<td>{$ds['type']}</td>
|
<td>{$ds['type']}</td>
|
||||||
<td class="text-success">{date($_c['date_format'], strtotime($ds['recharged_on']))} {$ds['time']}</td>
|
<td class="text-success">{date($_c['date_format'], strtotime($ds['recharged_on']))} {$ds['time']}</td>
|
||||||
<td class="text-danger">{date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']}</td>
|
<td class="text-danger">{date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']}</td>
|
||||||
@ -30,6 +32,7 @@
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
{$paginator['contents']}
|
{$paginator['contents']}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user