Skip to content

Commit aa42283

Browse files
authored
feat: add check if api key is empty (#205)
* add check if api key is empty * bump version
1 parent f9f98cf commit aa42283

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# CHANGELOG
2+
## 12.1.6 (2025-11-05)
3+
- check if api key is configured
4+
25
## 12.1.5 (2025-11-03)
36
- fix enable to work as expected
47

Helper/ApiRequest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ public function request(
134134
private function getHeaders($isPublicRequest, $preferredMethod = null, $customHeaders = [])
135135
{
136136
$apiKey = $isPublicRequest ? $this->xendit->getPublicApiKey() : $this->xendit->getApiKey();
137+
138+
if (empty($apiKey) || (is_string($apiKey) && empty(trim($apiKey)))) {
139+
$keyType = $isPublicRequest ? 'Public API Key' : 'Secret API Key';
140+
throw new \Magento\Framework\Exception\LocalizedException(
141+
new Phrase(
142+
'Xendit %1 is not configured. Please refer to the user guide to configure Xendit extension correctly in the admin panel.',
143+
[$keyType]
144+
)
145+
);
146+
}
147+
137148
$auth = $this->cryptoHelper->generateBasicAuth($apiKey);
138149

139150
$headers = [

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "xendit/m2invoice",
33
"description": "Xendit Payment Gateway Module",
44
"type": "magento2-module",
5-
"version": "12.1.5",
5+
"version": "12.1.6",
66
"license": [
77
"GPL-3.0"
88
],

0 commit comments

Comments
 (0)