Commit f4669db2 by irul

Menambahkan fake BJB-UIM & Rest Samsat Banten

1 parent c28e13e8
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
// Autoload files using composer // Autoload files using composer
require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/rpc/samsat-banten.php'; require_once __DIR__ . '/rpc/samsat-banten.php';
require_once __DIR__ . '/rest/bjb-uim.php';
require_once __DIR__ . '/rest/samsat-banten-new.php';
// Use this namespace // Use this namespace
use Steampixel\Route; use Steampixel\Route;
...@@ -21,6 +23,18 @@ Route::add('/samsat-banten', function () { ...@@ -21,6 +23,18 @@ Route::add('/samsat-banten', function () {
new SamsatBanten(); new SamsatBanten();
}, 'post'); }, 'post');
Route::add('/bjb-uim', function () {
bjbUIM::login();
}, 'post');
Route::add('/samsat-banten-new', function () {
SamsatBantenNew::inquiry();
}, 'get');
Route::add('/samsat-banten-new', function () {
SamsatBantenNew::payment();
}, 'post');
// Run the router // Run the router
$baseUrl = '/fake-api'; $baseUrl = '/fake-api';
Route::run($baseUrl); Route::run($baseUrl);
deny from all
<?php
// irul @ 20200522
/**
* Fake bjb UIM
* Dibuat berdasarkan Draft Spesifikasi API UIM v1.0
*/
class bjbUIM
{
public static function login()
{
// PAYLOAD:
// {
// "userId": "I816",
// "password": "eyJpdiI6IjQzK2N6NXpxVTFiTEJ0ajR0WVwva2tnPT0iLCJ2YWx1ZSI6InlyeEU4M1BibHNNTXg1XC9xU3NwS3NBUjBMXC9jdUtwejBQc0hoQU1WdnB0ST0iLCJtYWMiOiIzNDdiY2Q5MGFmZjViNGY0YWVmNDNiNzNkN2EyZmMwYzc0NzdlMjUzODRmMDlkOGM4ZDVlZWVhMGY0MGNlODA0In0=",
// "appId": 148
// }
$rawData = file_get_contents("php://input");
$payload = json_decode($rawData, true);
if (!$payload) {
self::echo_json(self::error_response());
} else {
extract($payload);
if (!isset($userId) || !isset($password) || !isset($appId)) {
self::echo_json(self::error_response());
} else {
self::echo_json(self::login_response());
}
}
}
private static function login_response()
{
$fake_response = array(
'status' => 'success',
'rc' => '00',
'response' => array(
'nama' => 'ANDRI MUHAMAD RAMADHAN SATRIA RASPATI',
'nip' => '15.88.9871',
'userId' => 'I816',
'kodeCabang' => 'P060',
'namaCabang' => 'GRUP HEAD OFFICE APPLICATION',
'kodeInduk' => 'P009',
'namaInduk' => 'DIVISI TEKNOLOGI INFORMASI',
'kodeKanwil' => 'K001',
'namaKanwil' => 'KANWIL 1',
'jabatan' => 'STAF G4',
'posisiPenempatan' => '-',
'hp' => '085624203225',
'email' => 'araspati@bankbjb.co.id',
'kodeGrade' => '0085',
'namaGrade' => 'G4',
'idFungsi' => '495',
'fungsiTambahan' => '-',
'limitDebet' => '0',
'limitKredit' => '0',
'id' => '20151002103451P0938539',
),
'message' => 'Transaction success.',
);
return $fake_response;
}
private static function error_response()
{
// error required user id
$error[] = array(
'status' => 'warning',
'rc' => '62',
'response' => array(
'userId' => array(
0 => 'The user id field is required.',
),
),
'message' => 'Expect required condition(s) but not given in the request parameter(s).',
);
// error required password
$error[] = array(
'status' => 'warning',
'rc' => '62',
'response' => array(
'password' => array(
0 => 'The password field is required when user id is present.',
),
),
'message' => 'Expect required condition(s) but not given in the request parameter(s).',
);
// error required app id
$error[] = array(
'status' => 'warning',
'rc' => '62',
'response' => array(
'appId' => array(
0 => 'The app id field is required.',
),
),
'message' => 'Expect required condition(s) but not given in the request parameter(s).',
);
// error wrong password
$error[] = array(
'status' => 'warning',
'rc' => '63',
'response' => 'not_valid_credentials',
'message' => 'Credentials is not valid. Please provide a correct credentials.',
);
// error app id is not found
$error[] = array(
'status' => 'info',
'rc' => '44',
'response' => array(),
'message' => 'The requested resource is not found.',
);
// error client not registered yet
$error[] = array(
'status' => 'warning',
'rc' => '52',
'response' => 'client_server_not_registered',
'message' => 'Unregister client server trying to access server.',
);
// error client got blacklist
$error[] = array(
'status' => 'warning',
'rc' => '43',
'response' => 'server_blacklisted',
'message' => ' Cannot continue the transaction. Forbidden Access.',
);
$random_number = rand(0, count($error) - 1);
return $error[$random_number];
}
private static function echo_json($data = array())
{
header('Content-type: application/json');
echo json_encode($data) . PHP_EOL;
}
private static function echo_text($data = '')
{
header('Content-type: text/html; charset=UTF-8');
echo $data . PHP_EOL;
}
}
<?php
// irul @ 20200522
/**
* fake samsat-banten-new (samsat banten pos/sts)
*
* inquiry: http://36.67.59.193:8383/bjb/bayarbjb.php/?token=TDA0YTFRUWRIS2FlQjlvUUxoYTNPQzZtTHZ3ZFpWM0cxVGs3UUJ5SDU3bz0=&nopol=B6461JAA&kdpolda=1
* payment: http://36.67.59.193:8383/bjb/statusbjb.php/?token=TDA0YTFRUWRIS2FlQjlvUUxoYTNPQzZtTHZ3ZFpWM0cxVGs3UUJ5SDU3bz0=&status=3&nopol=B6461JAA&kdpolda=1
*
*/
class SamsatBantenNew
{
public static function inquiry()
{
// QUERY PARAMS:
// token=TDA0YTFRUWRIS2FlQjlvUUxoYTNPQzZtTHZ3ZFpWM0cxVGs3UUJ5SDU3bz0=&nopol=B6461XXX&kdpolda=1
$token = isset($_GET['token']) ? $_GET['token'] : '';
$nopol = isset($_GET['nopol']) ? $_GET['nopol'] : '';
$kdpolda = isset($_GET['kdpolda']) ? $_GET['kdpolda'] : '';
if (empty($token) || empty($nopol) || empty($kdpolda)) {
self::echo_text('Paramater harus lengkap dan diisi semua.');
} else {
$params = compact("token", "nopol", "kdpolda");
// self::echo_json($params);
self::echo_json(self::inquiry_response($params));
}
}
public static function payment()
{
// QUERY PARAMS:
// token=TDA0YTFRUWRIS2FlQjlvUUxoYTNPQzZtTHZ3ZFpWM0cxVGs3UUJ5SDU3bz0=&status=3&nopol=B6461JAA&kdpolda=1
$token = isset($_GET['token']) ? $_GET['token'] : '';
$status = isset($_GET['status']) ? $_GET['status'] : '';
$nopol = isset($_GET['nopol']) ? $_GET['nopol'] : '';
$kdpolda = isset($_GET['kdpolda']) ? $_GET['kdpolda'] : '';
if (empty($token) || empty($nopol) || empty($kdpolda) || empty($status)) {
self::echo_json(array(
'status' => 'fail',
'message' => 'data tidak ditemukan',
'data' => array(),
));
} else {
$params = compact("token", "nopol", "kdpolda");
// self::echo_json($params);
self::echo_json(self::payment_response($params));
}
}
private static function inquiry_response($params = array())
{
$fake_response = array(
'status' => 'OK',
'Data' => array(
'no_polisi' => $params['nopol'],
'nm_pemilik' => 'PT. KENCANA LAJU MANDIRI',
'al_pemilik' => 'MEDANG LESTARI BLOK A.IV/M7 RT.001 RW. 011 KEL. MEDANG PAGEDANGAN',
'jenis_kb' => '702',
'merek_kb' => 'VIAR',
'tipe_kb' => 'V 10 R',
'warna_kb' => 'BIRU',
'tahun_buatan' => '2019',
'no_rangka' => 'MGRVR10TAKL002430',
'no_mesin' => 'YX151FMG19002063',
'no_ktp' => '0',
'cc' => '100',
'bbm' => '1',
'kd_plat_nomor' => '1',
'no_bpkb' => 'Q00768295',
'tgl_stnk' => '19-05-2025',
'kd_nama' => '1',
'no_hp' => '',
'nm_jenis' => '702',
'tgl_pajak' => '19-05-2020',
'tgl_akhir_stnk' => '19-05-2025',
'tgl_pajak_yad' => '19-05-2021',
'bbnkb' => '2025000',
'bbnkb_den' => '0',
'pkb' => '283500',
'pkb_den' => '0',
'swdkllj' => '35000',
'swdkllj_den' => '0',
'bea_adm' => ' 100000',
'bea_plat' => ' 60000',
'total_bayar' => '2503500',
),
);
return $fake_response;
}
private static function payment_response($params = array())
{
$fake_response = array(
'status' => 'OK',
'data' => array(
'no_polisi' => $params['nopol'],
'nm_pemilik' => 'PT. KENCANA LAJU MANDIRI',
'al_pemilik' => 'MEDANG LESTARI BLOK A.IV/M7 RT.001 RW. 011 KEL. MEDANG PAGEDANGAN',
'jenis_kb' => '702',
'merek_kb' => 'VIAR',
'tipe_kb' => 'V 10 R',
'warna_kb' => 'BIRU',
'tahun_buatan' => '2019',
'no_rangka' => 'MGRVR10TAKL002430',
'no_mesin' => 'YX151FMG19002063',
'no_ktp' => '0',
'cc' => '100',
'bbm' => '1',
'kd_plat_nomor' => '1',
'no_bpkb' => 'Q00768295',
'tgl_stnk' => '19-05-2025',
'kd_nama' => '1',
'no_hp' => '',
'nm_jenis' => '702',
'tgl_pajak' => '19-05-2020',
'tgl_akhir_stnk' => '19-05-2025',
'tgl_pajak_yad' => '19-05-2021',
'bbnkb' => '2025000',
'bbnkb_den' => '0',
'pkb' => '283500',
'pkb_den' => '0',
'swdkllj' => '35000',
'swdkllj_den' => '0',
'bea_adm' => ' 100000',
'bea_plat' => ' 60000',
'total_bayar' => '2503500',
),
);
return $fake_response;
}
private static function echo_json($data = array())
{
header('Content-type: application/json');
echo json_encode($data) . PHP_EOL;
}
private static function echo_text($data = '')
{
header('Content-type: text/html; charset=UTF-8');
echo $data . PHP_EOL;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!