diff --git a/system/autoload/Http.php b/system/autoload/Http.php
new file mode 100644
index 0000000..884ddd0
--- /dev/null
+++ b/system/autoload/Http.php
@@ -0,0 +1,43 @@
+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/';
+ }
+ }
+}
diff --git a/system/autoload/PGXendit.php b/system/autoload/PGXendit.php
new file mode 100644
index 0000000..a751024
--- /dev/null
+++ b/system/autoload/PGXendit.php
@@ -0,0 +1,93 @@
+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/';
+ }
+ }
+}
\ No newline at end of file
diff --git a/system/autoload/Package.php b/system/autoload/Package.php
new file mode 100644
index 0000000..241261d
--- /dev/null
+++ b/system/autoload/Package.php
@@ -0,0 +1,378 @@
+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.
" . $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.
" . $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.
" . $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.
" . $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;
+ }
+}
diff --git a/system/autoload/Paymentgateway.php b/system/autoload/Paymentgateway.php
deleted file mode 100644
index ee0f913..0000000
--- a/system/autoload/Paymentgateway.php
+++ /dev/null
@@ -1,189 +0,0 @@
- $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;
-}
diff --git a/system/autoload/Recharge.php b/system/autoload/Recharge.php
deleted file mode 100644
index cb9468c..0000000
--- a/system/autoload/Recharge.php
+++ /dev/null
@@ -1,374 +0,0 @@
-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.
".$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.
".$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.
".$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.
".$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;
-}
\ No newline at end of file
diff --git a/system/controllers/callback.php b/system/controllers/callback.php
index 0f2426e..279805b 100644
--- a/system/controllers/callback.php
+++ b/system/controllers/callback.php
@@ -21,7 +21,7 @@ switch ($action) {
echo "done";
break;
case 'tripay':
- echo "done";
+ echo '{"success": true}';
break;
default:
echo "not found";
diff --git a/system/controllers/order.php b/system/controllers/order.php
index ab4e27f..ce072ef 100644
--- a/system/controllers/order.php
+++ b/system/controllers/order.php
@@ -9,10 +9,6 @@ $action = $routes['1'];
$user = User::_info();
$ui->assign('_user', $user);
-
-require('system/autoload/Paymentgateway.php');
-require('system/autoload/Recharge.php');
-
switch ($action) {
case 'voucher':
$ui->assign('_title', $_L['Order_Voucher'] . ' - ' . $config['CompanyName']);
@@ -51,12 +47,12 @@ switch ($action) {
}
if ($routes['3'] == 'check') {
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') {
r2(U . "order/view/" . $trxid, 'w', Lang::T("Transaction still unpaid."));
} else if (in_array($result['status'],['PAID','SETTLED']) && $trx['status'] != 2) {
-
- if (!rechargeUser($user['id'], $trx['routers'], $trx['plan_id'], 'xendit', $result['payment_method'] . ' ' . $result['payment_channel'])) {
+ 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."));
}
@@ -76,13 +72,40 @@ switch ($action) {
}else if($trx['status'] == 2){
r2(U . "order/view/" . $trxid, 'd', Lang::T("Transaction has been paid.."));
}
- print_r($result);
- die();
r2(U . "order/view/" . $trxid, 'd', Lang::T("Unknown Command."));
- } else if ($trx['gateway'] == 'midtrans') {
- $result = midtrans_check_payment($trx['gateway_trx_id']);
- print_r($result);
} else if ($trx['gateway'] == 'tripay') {
+ $pg = new PGTripay($trx,$user);
+ $result = $pg->getStatus($trx['gateway_trx_id']);
+ if ($result['success']!=1) {
+ print_r($result);
+ die();
+ sendTelegram("Tripay payment status failed\n\n".json_encode($result, JSON_PRETTY_PRINT));
+ r2(U . "order/view/" . $trxid, 'w', Lang::T("Payment check failed."));
+ }
+ $result = $result['data'];
+ 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') {
$trx->pg_paid_response = '{}';
@@ -110,6 +133,9 @@ switch ($action) {
$ui->display('user-orderView.tpl');
break;
case 'buy':
+ if ($_c['payment_gateway'] == 'none') {
+ r2(U . 'home', 'e', Lang::T("No Payment Gateway Available"));
+ }
$back = "order/package";
$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);
@@ -152,7 +178,8 @@ switch ($action) {
r2(U . $back, 'e', Lang::T("Admin has not yet setup Xendit payment gateway, please tell admin"));
}
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']) {
r2(U . $back, 'e', Lang::T("Failed to create transaction."));
}
@@ -170,37 +197,40 @@ switch ($action) {
} else {
r2(U . "order/view/" . $d['id'], 'w', Lang::T("Failed to create Transaction.."));
}
- } else if ($_c['payment_gateway'] == 'midtrans') {
- if (empty($_c['midtrans_server_key'])) {
- sendTelegram("Midtrans payment gateway not configured");
- r2(U . $back, 'e', Lang::T("Admin has not yet setup Midtrans payment gateway, please tell admin"));
+ } 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"));
+ }
+ 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) {
- $invoiceID = alphanumeric(strtolower($_c['CompanyName'])) . "-" . crc32($_c['CompanyName'] . $id) . "-" . $id;
- $result = midtrans_create_payment($id, $invoiceID, $plan['price'],$plan['name_plan']);
- if (!$result['payment_url']) {
- sendTelegram("Midtrans payment failed\n\n".json_encode($result, JSON_PRETTY_PRINT));
+ $pg = new PGTripay($d,$user);
+ $result = $pg->createTransaction($routes['4']);
+ if ($result['success']!=1) {
+ sendTelegram("Tripay payment failed\n\n".json_encode($result, JSON_PRETTY_PRINT));
r2(U . $back, 'e', Lang::T("Failed to create transaction."));
}
$d = ORM::for_table('tbl_payment_gateway')
->where('username', $user['username'])
->where('status', 1)
->find_one();
- $d->gateway_trx_id = $invoiceID;
- $d->pg_url_payment = $result['payment_url'];
+ $d->gateway_trx_id = $result['data']['reference'];
+ $d->pg_url_payment = $result['data']['checkout_url'];
$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();
r2(U . "order/view/" . $id, 'w', Lang::T("Create Transaction Success"));
exit();
} else {
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;
default:
diff --git a/system/lan/indonesia/common.lan.php b/system/lan/indonesia/common.lan.php
index 951fad3..fb635e3 100644
--- a/system/lan/indonesia/common.lan.php
+++ b/system/lan/indonesia/common.lan.php
@@ -282,3 +282,6 @@ $_L['Checking_payment'] = 'Checking payment';
$_L['Create_Transaction_Success'] = 'Create Transaction Success';
$_L['You_have_unpaid_transaction'] = 'You have unpaid transaction';
$_L['CANCELED'] = 'CANCELED';
+$_L['TripayPayment_Channel'] = 'TripayPayment Channel';
+$_L['Payment_Channel'] = 'Payment Channel';
+$_L['Payment_check_failed'] = 'Payment check failed.';
diff --git a/ui/ui/app-tripay.tpl b/ui/ui/app-tripay.tpl
index 0006849..b3efda6 100644
--- a/ui/ui/app-tripay.tpl
+++ b/ui/ui/app-tripay.tpl
@@ -25,7 +25,7 @@
-
-
-
-
- {$_L['BW_Name']} |
- {$_L['Rate_Download']} |
- {$_L['Rate_Upload']} |
- {$_L['Manage']} |
-
-
-
- {foreach $d as $ds}
-
- {$ds['name_bw']} |
- {$ds['rate_down']} {$ds['rate_down_unit']} |
- {$ds['rate_up']} {$ds['rate_up_unit']} |
-
- {$_L['Edit']}
- {$_L['Delete']}
- |
-
- {/foreach}
-
-
+
+
+
+
+ {$_L['BW_Name']} |
+ {$_L['Rate_Download']} |
+ {$_L['Rate_Upload']} |
+ {$_L['Manage']} |
+
+
+
+ {foreach $d as $ds}
+
+ {$ds['name_bw']} |
+ {$ds['rate_down']} {$ds['rate_down_unit']} |
+ {$ds['rate_up']} {$ds['rate_up_unit']} |
+
+ {$_L['Edit']}
+ {$_L['Delete']}
+ |
+
+ {/foreach}
+
+
+
{$paginator['contents']}
diff --git a/ui/ui/customers.tpl b/ui/ui/customers.tpl
index ce3316c..c1ac186 100644
--- a/ui/ui/customers.tpl
+++ b/ui/ui/customers.tpl
@@ -23,34 +23,35 @@
{$_L['Add_Contact']}
-
-
-
-
- {$_L['Username']} |
- {$_L['Full_Name']} |
- {$_L['Phone_Number']} |
- {$_L['Created_On']} |
- {$_L['Recharge']} |
- {$_L['Manage']} |
-
-
-
- {foreach $d as $ds}
-
- {$ds['username']} |
- {$ds['fullname']} |
- {$ds['phonenumber']} |
- {$ds['created_at']} |
- {$_L['Recharge']} |
-
- {$_L['Edit']}
- {$_L['Delete']}
- |
-
- {/foreach}
-
-
+
+
+
+
+ {$_L['Username']} |
+ {$_L['Full_Name']} |
+ {$_L['Phone_Number']} |
+ {$_L['Created_On']} |
+ {$_L['Recharge']} |
+ {$_L['Manage']} |
+
+
+
+ {foreach $d as $ds}
+
+ {$ds['username']} |
+ {$ds['fullname']} |
+ {$ds['phonenumber']} |
+ {$ds['created_at']} |
+ {$_L['Recharge']} |
+
+ {$_L['Edit']}
+ {$_L['Delete']}
+ |
+
+ {/foreach}
+
+
+
{$paginator['contents']}
diff --git a/ui/ui/dashboard.tpl b/ui/ui/dashboard.tpl
index 2ed6291..52dfd61 100644
--- a/ui/ui/dashboard.tpl
+++ b/ui/ui/dashboard.tpl
@@ -85,60 +85,67 @@
Vouchers Stock
-
-
-
- {$_L['Plan_Name']} |
- unused |
- used |
-
-
-
- {foreach $plans as $stok}
-
- {$stok['name_plan']} |
- {$stok['unused']} |
- {$stok['used']} |
-
-
- {/foreach}
-
- Total |
- {$stocks['unused']} |
- {$stocks['used']} |
-
-
+
+
+
+
+ {$_L['Plan_Name']} |
+ unused |
+ used |
+
+
+
+ {foreach $plans as $stok}
+
+ {$stok['name_plan']} |
+ {$stok['unused']} |
+ {$stok['used']} |
+
+
+ {/foreach}
+
+ Total |
+ {$stocks['unused']} |
+ {$stocks['used']} |
+
+
+
{$_L['User_Expired_Today']}
-
-
-
- Id |
- {$_L['Username']} |
- {$_L['Created_On']} |
- {$_L['Expires_On']} |
-
-
-
- {$no = 1}
- {foreach $expire as $expired}
-
- {$no++} |
- {$expired['username']} |
- {date($_c['date_format'], strtotime($expired['recharged_on']))} {$expired['time']} |
- {date($_c['date_format'], strtotime($expired['expiration']))} {$expired['time']} |
-
-
- {/foreach}
-
+
+
+
+
+ Id |
+ {$_L['Username']} |
+ {$_L['Created_On']} |
+ {$_L['Expires_On']} |
+
+
+
+ {$no = 1}
+ {foreach $expire as $expired}
+
+ {$no++} |
+ {$expired['username']} |
+ {date($_c['date_format'], strtotime($expired['recharged_on']))} {$expired['time']} |
+ {date($_c['date_format'], strtotime($expired['expiration']))} {$expired['time']} |
+
+
+ {/foreach}
+
+
+
+
{Lang::T('Payment Gateway')}: {$_c['payment_gateway']}
+
{$_L['Activity_Log']}
@@ -181,22 +188,22 @@
{$_L['Account_Information']}
-
-
{$_L['Username']}
-
{$_bill['username']}
-
-
-
{$_L['Plan_Name']}
-
{$_bill['namebp']}
-
-
-
{$_L['Created_On']}
-
{date($_c['date_format'], strtotime($_bill['recharged_on']))} {$_bill['time']}
-
-
-
{$_L['Expires_On']}
-
{date($_c['date_format'], strtotime($_bill['expiration']))} {$_bill['time']}
-
+
+
{$_L['Username']}
+
{$_bill['username']}
+
+
+
{$_L['Plan_Name']}
+
{$_bill['namebp']}
+
+
+
{$_L['Created_On']}
+
{date($_c['date_format'], strtotime($_bill['recharged_on']))} {$_bill['time']}
+
+
+
{$_L['Expires_On']}
+
{date($_c['date_format'], strtotime($_bill['expiration']))} {$_bill['time']}
+
diff --git a/ui/ui/pool.tpl b/ui/ui/pool.tpl
index f4614bc..00897fc 100644
--- a/ui/ui/pool.tpl
+++ b/ui/ui/pool.tpl
@@ -7,7 +7,6 @@
diff --git a/ui/ui/prepaid.tpl b/ui/ui/prepaid.tpl
index 67661c1..4d48483 100644
--- a/ui/ui/prepaid.tpl
+++ b/ui/ui/prepaid.tpl
@@ -23,39 +23,40 @@
{$_L['Recharge_Account']}
-
-
-
-
- {$_L['Username']} |
- {$_L['Plan_Name']} |
- {$_L['Type']} |
- {$_L['Created_On']} |
- {$_L['Expires_On']} |
- {$_L['Method']} |
- {$_L['Routers']} |
- {$_L['Manage']} |
-
-
-
- {foreach $d as $ds}
-
- {$ds['username']} |
- {$ds['namebp']} |
- {$ds['type']} |
- {$ds['recharged_on']} {$ds['time']} |
- {$ds['expiration']} {$ds['time']} |
- {$ds['method']} |
- {$ds['routers']} |
-
- {$_L['Edit']}
- {$_L['Delete']}
- |
-
- {/foreach}
-
-
- {$paginator['contents']}
+
+
+
+
+ {$_L['Username']} |
+ {$_L['Plan_Name']} |
+ {$_L['Type']} |
+ {$_L['Created_On']} |
+ {$_L['Expires_On']} |
+ {$_L['Method']} |
+ {$_L['Routers']} |
+ {$_L['Manage']} |
+
+
+
+ {foreach $d as $ds}
+
+ {$ds['username']} |
+ {$ds['namebp']} |
+ {$ds['type']} |
+ {$ds['recharged_on']} {$ds['time']} |
+ {$ds['expiration']} {$ds['time']} |
+ {$ds['method']} |
+ {$ds['routers']} |
+
+ {$_L['Edit']}
+ {$_L['Delete']}
+ |
+
+ {/foreach}
+
+
+
+ {$paginator['contents']}
diff --git a/ui/ui/print-by-date.tpl b/ui/ui/print-by-date.tpl
index 1d9c770..a9015af 100644
--- a/ui/ui/print-by-date.tpl
+++ b/ui/ui/print-by-date.tpl
@@ -23,28 +23,30 @@
{$_L['All_Transactions_at_Date']}: {date($_c['date_format'], strtotime($mdate))}
-
- {$_L['Username']} |
- {$_L['Plan_Name']} |
- {$_L['Type']} |
- {$_L['Plan_Price']} |
- {$_L['Created_On']} |
- {$_L['Expires_On']} |
- {$_L['Method']} |
- {$_L['Routers']} |
- {foreach $d as $ds}
-
- {$ds['username']} |
- {$ds['plan_name']} |
- {$ds['type']} |
- {$_c['currency_code']} {number_format($ds['price'],2,$_c['dec_point'],$_c['thousands_sep'])} |
- {date($_c['date_format'], strtotime($ds['recharged_on']))} {$ds['time']} |
- {date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']} |
- {$ds['method']} |
- {$ds['routers']} |
-
- {/foreach}
-
+
+
+ {$_L['Username']} |
+ {$_L['Plan_Name']} |
+ {$_L['Type']} |
+ {$_L['Plan_Price']} |
+ {$_L['Created_On']} |
+ {$_L['Expires_On']} |
+ {$_L['Method']} |
+ {$_L['Routers']} |
+ {foreach $d as $ds}
+
+ {$ds['username']} |
+ {$ds['plan_name']} |
+ {$ds['type']} |
+ {$_c['currency_code']} {number_format($ds['price'],2,$_c['dec_point'],$_c['thousands_sep'])} |
+ {date($_c['date_format'], strtotime($ds['recharged_on']))} {$ds['time']} |
+ {date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']} |
+ {$ds['method']} |
+ {$ds['routers']} |
+
+ {/foreach}
+
+
{$_L['Total_Income']}:
{$_c['currency_code']} {number_format($dr,2,$_c['dec_point'],$_c['thousands_sep'])}
diff --git a/ui/ui/print-by-period.tpl b/ui/ui/print-by-period.tpl
index ed74e66..45e5a81 100644
--- a/ui/ui/print-by-period.tpl
+++ b/ui/ui/print-by-period.tpl
@@ -23,28 +23,30 @@
{$_L['All_Transactions_at_Date']}: {date( $_c['date_format'], strtotime($fdate))} - {date( $_c['date_format'], strtotime($tdate))}
-
- {$_L['Username']} |
- {$_L['Plan_Name']} |
- {$_L['Type']} |
- {$_L['Plan_Price']} |
- {$_L['Created_On']} |
- {$_L['Expires_On']} |
- {$_L['Method']} |
- {$_L['Routers']} |
- {foreach $d as $ds}
-
- {$ds['username']} |
- {$ds['plan_name']} |
- {$ds['type']} |
- {$_c['currency_code']} {number_format($ds['price'],2,$_c['dec_point'],$_c['thousands_sep'])} |
- {date($_c['date_format'], strtotime($ds['recharged_on']))} {$ds['time']} |
- {date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']} |
- {$ds['method']} |
- {$ds['routers']} |
-
- {/foreach}
-
+
+
+ {$_L['Username']} |
+ {$_L['Plan_Name']} |
+ {$_L['Type']} |
+ {$_L['Plan_Price']} |
+ {$_L['Created_On']} |
+ {$_L['Expires_On']} |
+ {$_L['Method']} |
+ {$_L['Routers']} |
+ {foreach $d as $ds}
+
+ {$ds['username']} |
+ {$ds['plan_name']} |
+ {$ds['type']} |
+ {$_c['currency_code']} {number_format($ds['price'],2,$_c['dec_point'],$_c['thousands_sep'])} |
+ {date($_c['date_format'], strtotime($ds['recharged_on']))} {$ds['time']} |
+ {date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']} |
+ {$ds['method']} |
+ {$ds['routers']} |
+
+ {/foreach}
+
+
{$_L['Total_Income']}:
{$_c['currency_code']} {number_format($dr,2,$_c['dec_point'],$_c['thousands_sep'])}
diff --git a/ui/ui/reports-daily.tpl b/ui/ui/reports-daily.tpl
index 51b6ca8..6a66cfc 100644
--- a/ui/ui/reports-daily.tpl
+++ b/ui/ui/reports-daily.tpl
@@ -18,37 +18,38 @@
{$_L['Export_to_PDF']}
-
-
-
- {$_L['Username']} |
- {$_L['Type']} |
- {$_L['Plan_Name']} |
- {$_L['Plan_Price']} |
- {$_L['Created_On']} |
- {$_L['Expires_On']} |
- {$_L['Method']} |
- {$_L['Routers']} |
-
-
-
- {foreach $d as $ds}
-
- {$ds['username']} |
- {$ds['type']} |
- {$ds['plan_name']} |
- {$_c['currency_code']} {number_format($ds['price'],2,$_c['dec_point'],$_c['thousands_sep'])} |
- {date($_c['date_format'], strtotime($ds['recharged_on']))} {$ds['time']} |
- {date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']} |
- {$ds['method']} |
- {$ds['routers']} |
-
- {/foreach}
-
-
-
+
+
+
+
+ {$_L['Username']} |
+ {$_L['Type']} |
+ {$_L['Plan_Name']} |
+ {$_L['Plan_Price']} |
+ {$_L['Created_On']} |
+ {$_L['Expires_On']} |
+ {$_L['Method']} |
+ {$_L['Routers']} |
+
+
+
+ {foreach $d as $ds}
+
+ {$ds['username']} |
+ {$ds['type']} |
+ {$ds['plan_name']} |
+ {$_c['currency_code']} {number_format($ds['price'],2,$_c['dec_point'],$_c['thousands_sep'])} |
+ {date($_c['date_format'], strtotime($ds['recharged_on']))} {$ds['time']} |
+ {date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']} |
+ {$ds['method']} |
+ {$ds['routers']} |
+
+ {/foreach}
+
+
+
{$paginator['contents']}
-
+
{$_L['Total_Income']}:
{$_c['currency_code']} {number_format($dr,2,$_c['dec_point'],$_c['thousands_sep'])}
diff --git a/ui/ui/reports-period-view.tpl b/ui/ui/reports-period-view.tpl
index 72c8a3b..bc8af73 100644
--- a/ui/ui/reports-period-view.tpl
+++ b/ui/ui/reports-period-view.tpl
@@ -28,35 +28,36 @@
-
-
-
- {$_L['Username']} |
- {$_L['Type']} |
- {$_L['Plan_Name']} |
- {$_L['Plan_Price']} |
- {$_L['Created_On']} |
- {$_L['Expires_On']} |
- {$_L['Method']} |
- {$_L['Routers']} |
-
-
-
- {foreach $d as $ds}
-
- {$ds['username']} |
- {$ds['type']} |
- {$ds['plan_name']} |
- {$_c['currency_code']} {number_format($ds['price'],0,$_c['dec_point'],$_c['thousands_sep'])} |
- {date($_c['date_format'], strtotime($ds['recharged_on']))} {$ds['time']} |
- {date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']} |
- {$ds['method']} |
- {$ds['routers']} |
-
- {/foreach}
-
-
-
+
+
+
+
+ {$_L['Username']} |
+ {$_L['Type']} |
+ {$_L['Plan_Name']} |
+ {$_L['Plan_Price']} |
+ {$_L['Created_On']} |
+ {$_L['Expires_On']} |
+ {$_L['Method']} |
+ {$_L['Routers']} |
+
+
+
+ {foreach $d as $ds}
+
+ {$ds['username']} |
+ {$ds['type']} |
+ {$ds['plan_name']} |
+ {$_c['currency_code']} {number_format($ds['price'],0,$_c['dec_point'],$_c['thousands_sep'])} |
+ {date($_c['date_format'], strtotime($ds['recharged_on']))} {$ds['time']} |
+ {date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']} |
+ {$ds['method']} |
+ {$ds['routers']} |
+
+ {/foreach}
+
+
+
{$_L['Total_Income']}:
{$_c['currency_code']} {number_format($dr,2,$_c['dec_point'],$_c['thousands_sep'])}
diff --git a/ui/ui/routers.tpl b/ui/ui/routers.tpl
index 4348398..f75bfee 100644
--- a/ui/ui/routers.tpl
+++ b/ui/ui/routers.tpl
@@ -24,35 +24,35 @@
{$_L['New_Router']}
-
-
-
-
- {$_L['Router_Name']} |
- {$_L['IP_Address']} |
- {$_L['Username']} |
- {$_L['Description']} |
- {Lang::T('Status')} |
- {$_L['Manage']} |
-
-
-
- {foreach $d as $ds}
-
- {$ds['name']} |
- {$ds['ip_address']} |
- {$ds['username']} |
- {$ds['description']} |
- {if $ds['enabled'] == 1}Enabled{else}Disabled{/if} |
-
- {$_L['Edit']}
- |
-
- {/foreach}
-
-
-
- {$paginator['contents']}
+
+
+
+
+ {$_L['Router_Name']} |
+ {$_L['IP_Address']} |
+ {$_L['Username']} |
+ {$_L['Description']} |
+ {Lang::T('Status')} |
+ {$_L['Manage']} |
+
+
+
+ {foreach $d as $ds}
+
+ {$ds['name']} |
+ {$ds['ip_address']} |
+ {$ds['username']} |
+ {$ds['description']} |
+ {if $ds['enabled'] == 1}Enabled{else}Disabled{/if} |
+
+ {$_L['Edit']}
+ |
+
+ {/foreach}
+
+
+
+ {$paginator['contents']}
diff --git a/ui/ui/tripay_channel.tpl b/ui/ui/tripay_channel.tpl
new file mode 100644
index 0000000..8ef809f
--- /dev/null
+++ b/ui/ui/tripay_channel.tpl
@@ -0,0 +1,19 @@
+{include file="sections/user-header.tpl"}
+
+
+
+
Tripay {Lang::T('Payment Channel')}
+
+ {foreach $channels as $channel}
+ {if in_array($channel['id'], $tripay_channels)}
+
+ {/if}
+ {/foreach}
+
+
+
+{include file="sections/user-footer.tpl"}
diff --git a/ui/ui/user-activation-list.tpl b/ui/ui/user-activation-list.tpl
index 5f1bc61..bebbc78 100644
--- a/ui/ui/user-activation-list.tpl
+++ b/ui/ui/user-activation-list.tpl
@@ -5,31 +5,34 @@
{$_L['List_Activated_Voucher']}
-
-
-
-
- {$_L['Username']} |
- {$_L['Plan_Name']} |
- {$_L['Type']} |
- {$_L['Created_On']} |
- {$_L['Expires_On']} |
- {$_L['Method']} |
-
-
-
- {foreach $d as $ds}
-
- {$ds['username']} |
- {$ds['plan_name']} |
- {$ds['type']} |
- {date($_c['date_format'], strtotime($ds['recharged_on']))} {$ds['time']} |
- {date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']} |
- {$ds['method']} |
-
- {/foreach}
-
-
+
+
+
+
+ {$_L['Username']} |
+ {$_L['Plan_Name']} |
+ {$_L['Plan_Price']} |
+ {$_L['Type']} |
+ {$_L['Created_On']} |
+ {$_L['Expires_On']} |
+ {$_L['Method']} |
+
+
+
+ {foreach $d as $ds}
+
+ {$ds['username']} |
+ {$ds['plan_name']} |
+ {$ds['price']} |
+ {$ds['type']} |
+ {date($_c['date_format'], strtotime($ds['recharged_on']))} {$ds['time']} |
+ {date($_c['date_format'], strtotime($ds['expiration']))} {$ds['time']} |
+ {$ds['method']} |
+
+ {/foreach}
+
+
+
{$paginator['contents']}