fix payment gateway and table

This commit is contained in:
Ibnu Maksum
2022-09-16 11:38:03 +07:00
parent b6204a5f94
commit 1c18f6091d
4 changed files with 23 additions and 13 deletions

View File

@ -78,7 +78,7 @@ function tripay_save_config()
}
function tripay_create_transaction($channel, $trx, $user)
function tripay_create_transaction($trx, $user)
{
global $config, $routes, $ui;
$channels = json_decode(file_get_contents('system/paymentgateway/channel_tripay.json'), true);
@ -91,7 +91,7 @@ function tripay_create_transaction($channel, $trx, $user)
die();
}
$json = [
'method' => $channel,
'method' => $routes[4],
'amount' => $trx['price'],
'merchant_ref' => $trx['id'],
'customer_name' => $user['fullname'],
@ -128,7 +128,7 @@ function tripay_create_transaction($channel, $trx, $user)
function tripay_get_status($trx, $user)
{
global $config;
$result = json_decode(Http::getData(tripay_get_server() . 'transaction/detail?' . http_build_query(['reference' => $trx['id']]), [
$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) {

View File

@ -8,6 +8,14 @@
* Payment Gateway xendit.com
**/
function xendit_validate_config()
{
global $config;
if (empty($config['xendit_secret_key']) || empty($config['xendit_verification_token'])) {
sendTelegram("Xendit payment gateway not configured");
r2(U . 'order/package', 'w', Lang::T("Admin has not yet setup Xendit payment gateway, please tell admin"));
}
}
function xendit_show_config()
{
@ -100,7 +108,7 @@ function xendit_create_transaction($trx, $user)
function xendit_get_status($trx, $user)
{
global $config;
$result = json_decode(Http::getData(xendit_get_server() . 'invoices/' . $trx['id'], [
$result = json_decode(Http::getData(xendit_get_server() . 'invoices/' . $trx['gateway_trx_id'], [
'Authorization: Basic ' . base64_encode($config['xendit_secret_key'] . ':')
]), true);
@ -125,8 +133,10 @@ function xendit_get_status($trx, $user)
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."));
}
r2(U . "order/view/" . $trx['id'], 'd', Lang::T("Unknown Command."));
}
function xendit_get_server()