Skip to content

Commit

Permalink
chore: change get username and password value
Browse files Browse the repository at this point in the history
  • Loading branch information
enggar appkey committed Jun 25, 2022
1 parent d96ea4c commit 5b0eba7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 14 additions & 2 deletions src/PaymentMethod/SoftbankPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand All @@ -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');
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Traits/HttpClient/SoftbankHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5b0eba7

Please sign in to comment.