Skip to content

Commit 49ffb08

Browse files
feat: bkash payment
1 parent 74d8253 commit 49ffb08

4 files changed

Lines changed: 19 additions & 12 deletions

File tree

‎src/app/Service/BkashAuthService.php‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ public function getToken()
2727
if (!$idToken) {
2828
$idToken = $this->grantToken()['id_token'];
2929
Cache::put($cacheKey, $idToken, now()->addMinutes(55)); // cache for 55 minutes
30-
Log::info("bkashAuthService---> new token generated and cached");
31-
} else {
32-
Log::info("bkashAuthService---Token from existing cache");
30+
if ($this->credential->logEnabled) {
31+
Log::info("BkashAuthService -> New Token Generated and Cached");
32+
}
33+
} else if ($this->credential->logEnabled) {
34+
Log::info("BkashAuthService -> Token from existing Cache");
3335
}
3436

3537
return $idToken;

‎src/app/Service/PaymentService.php‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,17 @@ public function __construct()
2222

2323
private function storeLog($apiName, $url, $headers, $body, $response): void
2424
{
25-
$log = [
26-
'url' => $url,
27-
'headers' => $headers,
28-
'body' => $body,
29-
'response' => $response,
30-
];
31-
$key = 'bkash:log:' . $apiName;
32-
33-
Log::info($key . "=>" . json_encode($log));
25+
if($this->credential->logEnabled) {
26+
$log = [
27+
'url' => $url,
28+
'headers' => $headers,
29+
'body' => $body,
30+
'response' => $response,
31+
];
32+
$key = 'bkash:log:' . $apiName;
33+
34+
Log::info($key . "=>" . json_encode($log));
35+
}
3436
}
3537

3638
public function grantToken()

‎src/app/Util/BkashCredential.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class BkashCredential
1111
public $appSecret;
1212
public $username;
1313
public $password;
14+
public $logEnabled;
1415

1516
public function __construct($arr)
1617
{
@@ -22,6 +23,7 @@ public function __construct($arr)
2223
$this->password = $arr['bkash_password'];
2324
$this->callbackUrl = $arr['bkash_callback_url'];
2425
$this->sandbox = $arr['bkash_sandbox'];
26+
$this->logEnabled = $arr['bkash_log_enabled'];
2527
}
2628

2729
public function getURL($path): string

‎src/config/bkash.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
return [
4+
"bkash_log_enabled" => env("BKASH_LOG_ENABLED", false),
45
"bkash_sandbox" => env("BKASH_SANDBOX", true),
56
"bkash_username" => env("BKASH_USERNAME", "sandboxTokenizedUser02"),
67
"bkash_password" => env("BKASH_PASSWORD", "sandboxTokenizedUser02@12345"),

0 commit comments

Comments
 (0)