diff --git a/system/paymentgateway/channel_duitku.json b/system/paymentgateway/channel_duitku.json deleted file mode 100644 index a0e5cc7..0000000 --- a/system/paymentgateway/channel_duitku.json +++ /dev/null @@ -1,90 +0,0 @@ -[ - { - "id": "BC", - "name": "BCA" - }, - { - "id": "M2", - "name": "Mandiri" - }, - { - "id": "VA", - "name": "Maybank" - }, - { - "id": "I1", - "name": "BNI" - }, - { - "id": "B1", - "name": "CIMB Niaga" - }, - { - "id": "BT", - "name": "Permata Bank" - }, - { - "id": "A1", - "name": "ATM Bersama" - }, - { - "id": "AG", - "name": "Artha Graha" - }, - { - "id": "BR", - "name": "BRIVA" - }, - { - "id": "S1", - "name": "Bank Sahabat Sampoerna" - }, - { - "id": "OV", - "name": "OVO" - }, - { - "id": "SA", - "name": "Shopee Pay" - }, - { - "id": "LF", - "name": "LinkAja Apps (Fixed Fee)" - }, - { - "id": "LA", - "name": "LinkAja Apps (Percentage Fee)" - }, - { - "id": "DA", - "name": "DANA" - }, - { - "id": "SP", - "name": "QRIS Shopee Pay" - }, - { - "id": "LQ", - "name": "QRIS LinkAja" - }, - { - "id": "NQ", - "name": "QRIS Nobu" - }, - { - "id": "FT", - "name": "Pegadaian/ALFA/Pos" - }, - { - "id": "A2", - "name": "POS Indonesia" - }, - { - "id": "IR", - "name": "Indomaret" - }, - { - "id": "VC", - "name": "Credit Card (Visa / Master Card / JCB)" - } -] diff --git a/system/paymentgateway/channel_tripay.json b/system/paymentgateway/channel_tripay.json deleted file mode 100644 index 6dd0577..0000000 --- a/system/paymentgateway/channel_tripay.json +++ /dev/null @@ -1,74 +0,0 @@ -[ - { - "id": "PERMATAVA", - "name": "Permata Bank" - }, - { - "id": "MYBVA", - "name": "Maybank" - }, - { - "id": "BNIVA", - "name": "BNI" - }, - { - "id": "BRIVA", - "name": "BRI" - }, - { - "id": "MANDIRIVA", - "name": "Mandiri" - }, - { - "id": "BCAVA", - "name": "BCA" - }, - { - "id": "SMSVA", - "name": "Sinarmas" - }, - { - "id": "MUAMALATVA", - "name": "Muamalat" - }, - { - "id": "SAMPOERNAVA", - "name": "Sahabat Sampoerna" - }, - { - "id": "BSIVA", - "name": "BSI" - }, - { - "id": "ALFAMART", - "name": "Alfamart " - }, - { - "id": "INDOMARET", - "name": "Indomaret " - }, - { - "id": "ALFAMIDI", - "name": "Alfamidi " - }, - { - "id": "OVO", - "name": "OVO" - }, - { - "id": "QRIS", - "name": "QRIS by ShopeePay" - }, - { - "id": "QRISC", - "name": "QRIS (Customizable)" - }, - { - "id": "QRIS2", - "name": "QRIS" - }, - { - "id": "SHOPEEPAY", - "name": "ShopeePay " - } -] diff --git a/system/paymentgateway/channel_xendit.json b/system/paymentgateway/channel_xendit.json deleted file mode 100644 index 6141f87..0000000 --- a/system/paymentgateway/channel_xendit.json +++ /dev/null @@ -1,66 +0,0 @@ -[ - { - "id": "CREDIT_CARD", - "name": "CREDIT CARD" - }, - { - "id": "PERMATA", - "name": "Permata Bank" - }, - { - "id": "BNI", - "name": "BNI" - }, - { - "id": "BRI", - "name": "BRI" - }, - { - "id": "MANDIRI", - "name": "Mandiri" - }, - { - "id": "BCA", - "name": "BCA" - }, - { - "id": "BSI", - "name": "BSI" - }, - { - "id": "DD_BRI", - "name": "Direct Debit BRI" - }, - { - "id": "DD_BCA_KLIKPAY", - "name": "Direct Debit BCA KLIKPAY" - }, - { - "id": "ALFAMART", - "name": "Alfamart " - }, - { - "id": "INDOMARET", - "name": "Indomaret " - }, - { - "id": "OVO", - "name": "OVO" - }, - { - "id": "DANA", - "name": "DANA" - }, - { - "id": "LINKAJA", - "name": "LinkAja" - }, - { - "id": "SHOPEEPAY", - "name": "ShopeePay " - }, - { - "id": "QRIS", - "name": "QRIS" - } -] diff --git a/system/paymentgateway/duitku.php b/system/paymentgateway/duitku.php deleted file mode 100644 index dfeb105..0000000 --- a/system/paymentgateway/duitku.php +++ /dev/null @@ -1,170 +0,0 @@ -assign('_title', 'Duitku - Payment Gateway - ' . $config['CompanyName']); - $ui->assign('channels', json_decode(file_get_contents('system/paymentgateway/channel_duitku.json'), true)); - $ui->display('pg-duitku.tpl'); -} - -function duitku_save_config() -{ - global $admin; - $duitku_merchant_id = _post('duitku_merchant_id'); - $duitku_merchant_key = _post('duitku_merchant_key'); - $d = ORM::for_table('tbl_appconfig')->where('setting', 'duitku_merchant_id')->find_one(); - if ($d) { - $d->value = $duitku_merchant_id; - $d->save(); - } else { - $d = ORM::for_table('tbl_appconfig')->create(); - $d->setting = 'duitku_merchant_id'; - $d->value = $duitku_merchant_id; - $d->save(); - } - $d = ORM::for_table('tbl_appconfig')->where('setting', 'duitku_merchant_key')->find_one(); - if ($d) { - $d->value = $duitku_merchant_key; - $d->save(); - } else { - $d = ORM::for_table('tbl_appconfig')->create(); - $d->setting = 'duitku_merchant_key'; - $d->value = $duitku_merchant_key; - $d->save(); - } - $d = ORM::for_table('tbl_appconfig')->where('setting', 'duitku_channel')->find_one(); - if ($d) { - $d->value = implode(',', $_POST['duitku_channel']); - $d->save(); - } else { - $d = ORM::for_table('tbl_appconfig')->create(); - $d->setting = 'duitku_channel'; - $d->value = implode(',', $_POST['duitku_channel']); - $d->save(); - } - _log('[' . $admin['username'] . ']: Duitku ' . Lang::T('Settings_Saved_Successfully'), 'Admin', $admin['id']); - r2(U . 'paymentgateway/duitku', 's', Lang::T('Settings_Saved_Successfully')); -} - -function duitku_create_transaction($trx, $user) -{ - global $config, $routes, $ui; - - $channels = json_decode(file_get_contents('system/paymentgateway/channel_duitku.json'), true); - if (!in_array($routes[4], explode(",", $config['duitku_channel']))) { - $ui->assign('_title', 'Duitku Channel - ' . $config['CompanyName']); - $ui->assign('channels', $channels); - $ui->assign('duitku_channels', explode(",", $config['duitku_channel'])); - $ui->assign('path', $routes['2'] . '/' . $routes['3']); - $ui->display('duitku_channel.tpl'); - die(); - } - - $json = [ - 'paymentMethod' => $routes[4], - 'paymentAmount' => $trx['price'], - 'merchantCode' => $config['duitku_merchant_id'], - 'merchantOrderId' => $trx['id'], - 'productDetails' => $trx['plan_name'], - 'merchantUserInfo' => $user['fullname'], - 'customerVaName' => $user['fullname'], - 'email' => (empty($user['email'])) ? $user['username'] . '@' . $_SERVER['HTTP_HOST'] : $user['email'], - 'phoneNumber' => $user['phonenumber'], - 'itemDetails' => [ - [ - 'name' => $trx['plan_name'], - 'price' => $trx['price'], - 'quantity' => 1 - ] - ], - 'returnUrl' => U . 'order/view/' . $trx['id'] . '/check', - 'signature' => md5($config['duitku_merchant_id'] . $trx['id'] . $trx['price'] . $config['duitku_merchant_key']) - ]; - - $result = json_decode(Http::postJsonData(duitku_get_server() . 'v2/inquiry', $json), true); - - if (empty($result['paymentUrl'])) { - sendTelegram("Duitku payment failed\n\n" . json_encode($result, JSON_PRETTY_PRINT)); - r2(U . 'order/package', '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 = $result['reference']; - $d->pg_url_payment = $result['paymentUrl']; - $d->payment_method = $routes['4']; - foreach ($channels as $channel) { - if ($channel['id'] == $routes['4']) { - $d->payment_channel = $channel['name']; - break; - } - } - $d->pg_request = json_encode($result); - $d->expired_date = date('Y-m-d H:i:s', strtotime("+1 day")); - $d->save(); - r2(U . "order/view/" . $d['id'], 's', Lang::T("Create Transaction Success")); -} - -function duitku_get_status($trx, $user) -{ - global $config; - $json = [ - 'merchantCode' => $config['duitku_merchant_id'], - 'merchantOrderId' => $trx['id'], - 'signature' => md5($config['duitku_merchant_id'] . $trx['id'] . $config['duitku_merchant_key']) - ]; - $result = json_decode(Http::postJsonData(duitku_get_server() . 'transactionStatus', $json), true); - if ($result['reference'] != $trx['gateway_trx_id']) { - sendTelegram("Duitku payment status failed\n\n" . json_encode($result, JSON_PRETTY_PRINT)); - r2(U . "order/view/" . $trx['id'], 'w', Lang::T("Payment check failed.")); - } - if ($result['statusCode'] == '01') { - r2(U . "order/view/" . $trx['id'], 'w', Lang::T("Transaction still unpaid.")); - } else if ($result['statusCode'] == '00' && $trx['status'] != 2) { - if (!Package::rechargeUser($user['id'], $trx['routers'], $trx['plan_id'], $trx['gateway'], $trx['payment_channel'])) { - r2(U . "order/view/" . $trx['id'], 'd', Lang::T("Failed to activate your Package, try again later.")); - } - - $trx->pg_paid_response = json_encode($result); - $trx->paid_date = date('Y-m-d H:i:s'); - $trx->status = 2; - $trx->save(); - - r2(U . "order/view/" . $trx['id'], 's', Lang::T("Transaction has been paid.")); - } else if ($result['statusCode'] == '02') { - $trx->pg_paid_response = json_encode($result); - $trx->status = 3; - $trx->save(); - r2(U . "order/view/" . $trx['id'], 'd', Lang::T("Transaction expired or Failed.")); - } else if ($trx['status'] == 2) { - r2(U . "order/view/" . $trx['id'], 'd', Lang::T("Transaction has been paid..")); - } -} - -function duitku_get_server() -{ - global $_app_stage; - if ($_app_stage == 'Live') { - return 'https://passport.duitku.com/webapi/api/merchant/'; - } else { - return 'https://sandbox.duitku.com/webapi/api/merchant/'; - } -} diff --git a/system/paymentgateway/tripay.php b/system/paymentgateway/tripay.php deleted file mode 100644 index 3faff6b..0000000 --- a/system/paymentgateway/tripay.php +++ /dev/null @@ -1,172 +0,0 @@ - -assign('_title', 'Tripay - Payment Gateway - ' . $config['CompanyName']); - $ui->assign('channels', json_decode(file_get_contents('system/paymentgateway/channel_tripay.json'), true)); - $ui->display('pg-tripay.tpl'); -} - -function tripay_save_config() -{ - global $admin, $_L; - $tripay_merchant = _post('tripay_merchant'); - $tripay_api_key = _post('tripay_api_key'); - $tripay_secret_key = _post('tripay_secret_key'); - $d = ORM::for_table('tbl_appconfig')->where('setting', 'tripay_merchant')->find_one(); - if ($d) { - $d->value = $tripay_merchant; - $d->save(); - } else { - $d = ORM::for_table('tbl_appconfig')->create(); - $d->setting = 'tripay_merchant'; - $d->value = $tripay_merchant; - $d->save(); - } - $d = ORM::for_table('tbl_appconfig')->where('setting', 'tripay_api_key')->find_one(); - if ($d) { - $d->value = $tripay_api_key; - $d->save(); - } else { - $d = ORM::for_table('tbl_appconfig')->create(); - $d->setting = 'tripay_api_key'; - $d->value = $tripay_api_key; - $d->save(); - } - $d = ORM::for_table('tbl_appconfig')->where('setting', 'tripay_secret_key')->find_one(); - if ($d) { - $d->value = $tripay_secret_key; - $d->save(); - } else { - $d = ORM::for_table('tbl_appconfig')->create(); - $d->setting = 'tripay_secret_key'; - $d->value = $tripay_secret_key; - $d->save(); - } - $d = ORM::for_table('tbl_appconfig')->where('setting', 'tripay_channel')->find_one(); - if ($d) { - $d->value = implode(',', $_POST['tripay_channel']); - $d->save(); - } else { - $d = ORM::for_table('tbl_appconfig')->create(); - $d->setting = 'tripay_channel'; - $d->value = implode(',', $_POST['tripay_channel']); - $d->save(); - } - - _log('[' . $admin['username'] . ']: Tripay ' . $_L['Settings_Saved_Successfully'] . json_encode($_POST['tripay_channel']), 'Admin', $admin['id']); - - r2(U . 'paymentgateway/tripay', 's', $_L['Settings_Saved_Successfully']); -} - - -function tripay_create_transaction($trx, $user) -{ - global $config, $routes, $ui; - $channels = json_decode(file_get_contents('system/paymentgateway/channel_tripay.json'), true); - if (!in_array($routes[4], explode(",", $config['tripay_channel']))) { - $ui->assign('_title', 'Tripay Channel - ' . $config['CompanyName']); - $ui->assign('channels', $channels); - $ui->assign('tripay_channels', explode(",", $config['tripay_channel'])); - $ui->assign('path', $routes[2] . '/' . $routes[3]); - $ui->display('tripay_channel.tpl'); - die(); - } - $json = [ - 'method' => $routes[4], - 'amount' => $trx['price'], - 'merchant_ref' => $trx['id'], - 'customer_name' => $user['fullname'], - 'customer_email' => (empty($user['email'])) ? $user['username'] . '@' . $_SERVER['HTTP_HOST'] : $user['email'], - 'customer_phone' => $user['phonenumber'], - 'order_items' => [ - [ - 'name' => $trx['plan_name'], - 'price' => $trx['price'], - 'quantity' => 1 - ] - ], - 'return_url' => U . 'order/view/' . $trx['id'] . '/check', - 'signature' => hash_hmac('sha256', $config['tripay_merchant'] . $trx['id'] . $trx['price'], $config['tripay_secret_key']) - ]; - $result = json_decode(Http::postJsonData(tripay_get_server() . 'transaction/create', $json, ['Authorization: Bearer ' . $config['tripay_api_key']]), true); - if ($result['success'] != 1) { - sendTelegram("Tripay payment failed\n\n" . json_encode($result, JSON_PRETTY_PRINT)); - r2(U . 'order/package', '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 = $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', $result['data']['expired_time']); - $d->save(); - r2(U . "order/view/" . $d['id'], 's', Lang::T("Create Transaction Success")); - -} - -function tripay_get_status($trx, $user) -{ - global $config; - $result = json_decode(Http::getData(tripay_get_server() . 'transaction/detail?' . http_build_query(['reference' => $trx['gateway_trx_id']]), [ - 'Authorization: Bearer ' . $config['tripay_api_key'] - ]), true); - if ($result['success'] != 1) { - sendTelegram("Tripay payment status failed\n\n" . json_encode($result, JSON_PRETTY_PRINT)); - r2(U . "order/view/" . $trx['id'], 'w', Lang::T("Payment check failed.")); - } - $result = $result['data']; - if ($result['status'] == 'UNPAID') { - r2(U . "order/view/" . $trx['id'], '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_name'])) { - r2(U . "order/view/" . $trx['id'], '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/" . $trx['id'], '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/" . $trx['id'], 'd', Lang::T("Transaction expired.")); - } else if ($trx['status'] == 2) { - r2(U . "order/view/" . $trx['id'], 'd', Lang::T("Transaction has been paid..")); - } -} - -function tripay_get_server() -{ - 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/paymentgateway/xendit.php b/system/paymentgateway/xendit.php deleted file mode 100644 index ed5436a..0000000 --- a/system/paymentgateway/xendit.php +++ /dev/null @@ -1,150 +0,0 @@ - -assign('_title', 'Xendit - Payment Gateway - ' . $config['CompanyName']); - $ui->assign('channels', json_decode(file_get_contents('system/paymentgateway/channel_xendit.json'), true)); - $ui->display('pg-xendit.tpl'); -} - -function xendit_save_config() -{ - global $admin, $_L; - $xendit_secret_key = _post('xendit_secret_key'); - $xendit_verification_token = _post('xendit_verification_token'); - $d = ORM::for_table('tbl_appconfig')->where('setting', 'xendit_secret_key')->find_one(); - if ($d) { - $d->value = $xendit_secret_key; - $d->save(); - } else { - $d = ORM::for_table('tbl_appconfig')->create(); - $d->setting = 'xendit_secret_key'; - $d->value = $xendit_secret_key; - $d->save(); - } - $d = ORM::for_table('tbl_appconfig')->where('setting', 'xendit_verification_token')->find_one(); - if ($d) { - $d->value = $xendit_verification_token; - $d->save(); - } else { - $d = ORM::for_table('tbl_appconfig')->create(); - $d->setting = 'xendit_verification_token'; - $d->value = $xendit_verification_token; - $d->save(); - } - $d = ORM::for_table('tbl_appconfig')->where('setting', 'xendit_channel')->find_one(); - if ($d) { - $d->value = implode(',', $_POST['xendit_channel']); - $d->save(); - } else { - $d = ORM::for_table('tbl_appconfig')->create(); - $d->setting = 'xendit_channel'; - $d->value = implode(',', $_POST['xendit_channel']); - $d->save(); - } - - _log('[' . $admin['username'] . ']: Xendit ' . $_L['Settings_Saved_Successfully'], 'Admin', $admin['id']); - - r2(U . 'paymentgateway/xendit', 's', $_L['Settings_Saved_Successfully']); -} - - -function xendit_create_transaction($trx, $user) -{ - global $config; - $json = [ - 'external_id' => $trx['id'], - 'amount' => $trx['price'], - 'description' => $trx['plan_name'], - 'customer' => [ - 'mobile_number' => $user['phonenumber'], - ], - 'customer_notification_preference' => [ - 'invoice_created' => ['whatsapp', 'sms'], - 'invoice_reminder' => ['whatsapp', 'sms'], - 'invoice_paid' => ['whatsapp', 'sms'], - 'invoice_expired' => ['whatsapp', 'sms'] - ], - 'payment_methods ' => explode(',', $config['xendit_channel']), - 'success_redirect_url' => U . 'order/view/' . $trx['id'] . '/check', - 'failure_redirect_url' => U . 'order/view/' . $trx['id'] . '/check' - ]; - - $result = json_decode(Http::postJsonData(xendit_get_server() . 'invoices', $json, ['Authorization: Basic ' . base64_encode($config['xendit_secret_key'] . ':')]), true); - if (!$result['id']) { - r2(U . 'order/package', '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 = $result['id']; - $d->pg_url_payment = $result['invoice_url']; - $d->pg_request = json_encode($result); - $d->expired_date = date('Y-m-d H:i:s', strtotime($result['expiry_date'])); - $d->save(); - header('Location: ' . $result['invoice_url']); - exit(); -} - -function xendit_get_status($trx, $user) -{ - global $config; - $result = json_decode(Http::getData(xendit_get_server() . 'invoices/' . $trx['gateway_trx_id'], [ - 'Authorization: Basic ' . base64_encode($config['xendit_secret_key'] . ':') - ]), true); - - if ($result['status'] == 'PENDING') { - r2(U . "order/view/" . $trx['id'], '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_channel'])) { - r2(U . "order/view/" . $trx['id'], '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_channel']; - $trx->paid_date = date('Y-m-d H:i:s', strtotime($result['updated'])); - $trx->status = 2; - $trx->save(); - - r2(U . "order/view/" . $trx['id'], 's', Lang::T("Transaction has been paid.")); - } else if ($result['status'] == 'EXPIRED') { - $trx->pg_paid_response = json_encode($result); - $trx->status = 3; - $trx->save(); - r2(U . "order/view/" . $trx['id'], 'd', Lang::T("Transaction expired.")); - } else if ($trx['status'] == 2) { - r2(U . "order/view/" . $trx['id'], 'd', Lang::T("Transaction has been paid..")); - }else{ - sendTelegram("xendit_get_status: unknown result\n\n".json_encode($result, JSON_PRETTY_PRINT)); - r2(U . "order/view/" . $trx['id'], 'd', Lang::T("Unknown Command.")); - } -} - -function xendit_get_server() -{ - global $_app_stage; - if ($_app_stage == 'Live') { - return 'https://api.xendit.co/v2/'; - } else { - return 'https://api.xendit.co/v2/'; - } -}