Penambahan thema pada Menu Laporan per pintu pos
This commit is contained in:
BIN
app/.DS_Store
vendored
Normal file
BIN
app/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -89,13 +89,19 @@ public function run()
|
||||
|
||||
private function checkPgcrypto()
|
||||
{
|
||||
$result = DB::select("
|
||||
SELECT 1
|
||||
FROM pg_extension
|
||||
WHERE extname = 'pgcrypto'
|
||||
");
|
||||
// $result = DB::select("
|
||||
// SELECT 1
|
||||
// FROM pg_extension
|
||||
// WHERE extname = 'pgcrypto'
|
||||
// ");
|
||||
|
||||
return !empty($result);
|
||||
// return !empty($result);
|
||||
try {
|
||||
DB::select("SELECT digest('test','sha1')");
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function checkPegawaiColumns()
|
||||
|
||||
69
app/Services/BcaServices.php
Normal file
69
app/Services/BcaServices.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class BcaService
|
||||
{
|
||||
protected $apiKey;
|
||||
protected $apiSecret;
|
||||
protected $baseUrl = 'https://sandbox.bca.co.id';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->apiKey = env('BCA_API_KEY');
|
||||
$this->apiSecret = env('BCA_API_SECRET');
|
||||
}
|
||||
|
||||
public function getAccessToken()
|
||||
{
|
||||
$response = Http::asForm()
|
||||
->withBasicAuth($this->apiKey, $this->apiSecret)
|
||||
->post($this->baseUrl . '/api/oauth/token', [
|
||||
'grant_type' => 'client_credentials'
|
||||
]);
|
||||
|
||||
return $response->json()['access_token'];
|
||||
}
|
||||
|
||||
private function generateSignature($method, $relativeUrl, $token, $body, $timestamp)
|
||||
{
|
||||
$bodyHash = hash('sha256', $body);
|
||||
|
||||
$stringToSign = strtoupper($method) . ':' .
|
||||
$relativeUrl . ':' .
|
||||
$token . ':' .
|
||||
strtolower($bodyHash) . ':' .
|
||||
$timestamp;
|
||||
|
||||
return hash_hmac('sha256', $stringToSign, $this->apiSecret);
|
||||
}
|
||||
|
||||
public function getAccount($corporateId, $accountNumber)
|
||||
{
|
||||
$token = $this->getAccessToken();
|
||||
|
||||
$method = 'GET';
|
||||
$relativeUrl = "/banking/v3/corporates/$corporateId/accounts/$accountNumber";
|
||||
$timestamp = now()->format('Y-m-d\TH:i:s.vP');
|
||||
$body = '';
|
||||
|
||||
$signature = $this->generateSignature(
|
||||
$method,
|
||||
$relativeUrl,
|
||||
$token,
|
||||
$body,
|
||||
$timestamp
|
||||
);
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'Authorization' => 'Bearer ' . $token,
|
||||
'X-BCA-Key' => $this->apiKey,
|
||||
'X-BCA-Timestamp' => $timestamp,
|
||||
'X-BCA-Signature' => $signature,
|
||||
])->get($this->baseUrl . $relativeUrl);
|
||||
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
102
app/Services/BcaSignatureService.php
Normal file
102
app/Services/BcaSignatureService.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
// use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BcaSignatureService
|
||||
{
|
||||
|
||||
public function generateSignature($method, $relativeUrl, $accessToken, $body, $timestamp, $apiSecret)
|
||||
{
|
||||
$bodyHash = hash('sha256', $body);
|
||||
|
||||
$stringToSign = strtoupper($method) . ':' .
|
||||
$relativeUrl . ':' .
|
||||
$accessToken . ':' .
|
||||
strtolower($bodyHash) . ':' .
|
||||
$timestamp;
|
||||
|
||||
return hash_hmac('sha256', $stringToSign, $apiSecret);
|
||||
}
|
||||
|
||||
// public function test_generate_signature_post()
|
||||
// {
|
||||
// $method = 'POST';
|
||||
// $relativeUrl = '/test/api';
|
||||
// $accessToken = 'dummy_token';
|
||||
// $timestamp = '2026-04-10T10:00:00.000+07:00';
|
||||
// $apiSecret = 'secret123';
|
||||
|
||||
// $body = json_encode([
|
||||
// "foo" => "bar"
|
||||
// ]);
|
||||
|
||||
// $signature = $this->generateSignature(
|
||||
// $method,
|
||||
// $relativeUrl,
|
||||
// $accessToken,
|
||||
// $body,
|
||||
// $timestamp,
|
||||
// $apiSecret
|
||||
// );
|
||||
|
||||
// // Expected manual calculation (hardcode hasil dari tool / Postman)
|
||||
// $expected = hash_hmac('sha256',
|
||||
// 'POST:/test/api:dummy_token:' . hash('sha256', $body) . ':' . $timestamp,
|
||||
// $apiSecret
|
||||
// );
|
||||
|
||||
// $this->assertEquals($expected, $signature);
|
||||
// }
|
||||
|
||||
// public function test_generate_signature_get_empty_body()
|
||||
// {
|
||||
// $method = 'GET';
|
||||
// $relativeUrl = '/test/api';
|
||||
// $accessToken = 'dummy_token';
|
||||
// $timestamp = '2026-04-10T10:00:00.000+07:00';
|
||||
// $apiSecret = 'secret123';
|
||||
|
||||
// $body = '';
|
||||
|
||||
// $signature = $this->generateSignature(
|
||||
// $method,
|
||||
// $relativeUrl,
|
||||
// $accessToken,
|
||||
// $body,
|
||||
// $timestamp,
|
||||
// $apiSecret
|
||||
// );
|
||||
|
||||
// $expectedBodyHash = hash('sha256', '');
|
||||
|
||||
// $expected = hash_hmac('sha256',
|
||||
// 'GET:/test/api:dummy_token:' . $expectedBodyHash . ':' . $timestamp,
|
||||
// $apiSecret
|
||||
// );
|
||||
|
||||
// $this->assertEquals($expected, $signature);
|
||||
// }
|
||||
|
||||
// public function test_string_to_sign_format()
|
||||
// {
|
||||
// $method = 'post'; // sengaja lowercase
|
||||
// $relativeUrl = '/test/api';
|
||||
// $accessToken = 'token';
|
||||
// $timestamp = '2026-04-10T10:00:00.000+07:00';
|
||||
// $body = '{"a":1}';
|
||||
|
||||
// $bodyHash = hash('sha256', $body);
|
||||
|
||||
// $stringToSign = strtoupper($method) . ':' .
|
||||
// $relativeUrl . ':' .
|
||||
// $accessToken . ':' .
|
||||
// strtolower($bodyHash) . ':' .
|
||||
// $timestamp;
|
||||
|
||||
// $this->assertStringStartsWith('POST:', $stringToSign);
|
||||
// $this->assertStringContainsString($relativeUrl, $stringToSign);
|
||||
// $this->assertStringContainsString($accessToken, $stringToSign);
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user