diff --git a/src/PaymentMethod/SoftbankPayload.php b/src/PaymentMethod/SoftbankPayload.php index d1fe7db..8c80dd4 100644 --- a/src/PaymentMethod/SoftbankPayload.php +++ b/src/PaymentMethod/SoftbankPayload.php @@ -203,7 +203,13 @@ public function setHashKey($hashKey): Payload */ public function getAuthUsername(): ?string { - return $this->merchantId . $this->serviceId; + $username = $this->merchantId . $this->serviceId; + + if ($username) { + return $username; + } + + return config('laravel-softbank.merchant_id') . config('laravel-softbank.service_id'); } /** @@ -214,7 +220,13 @@ public function getAuthUsername(): ?string */ public function getAuthPassword(): ?string { - return $this->hashKey; + $password = $this->hashKey; + + if ($password) { + return $password; + } + + return config('laravel-softbank.hash_key'); } /** diff --git a/src/Traits/HttpClient/SoftbankHttpClient.php b/src/Traits/HttpClient/SoftbankHttpClient.php index be2e1b8..59b345c 100644 --- a/src/Traits/HttpClient/SoftbankHttpClient.php +++ b/src/Traits/HttpClient/SoftbankHttpClient.php @@ -11,9 +11,7 @@ trait SoftbankHttpClient public function postData(string $xmlData, array $auth = []): Response { - return Http::withBasicAuth( - $auth['username'] ?? config('laravel-softbank.merchant_id') . config('laravel-softbank.service_id'), - $auth['password'] ?? config('laravel-softbank.hash_key')) + return Http::withBasicAuth($auth['username'], $auth['password']) ->withBody($xmlData, 'application/xml') ->post(config('laravel-softbank.api_endpoint') ?? $this->apiEndpoint); }