Do not log reference transactions checks

This commit is contained in:
Alex P 2022-01-06 14:46:42 +02:00
parent 21aa8980d6
commit 8e703061a8
2 changed files with 21 additions and 6 deletions

View file

@ -120,11 +120,17 @@ class BillingAgreementsEndpoint {
*/
public function reference_transaction_enabled(): bool {
try {
$this->create_token(
'Checking if reference transactions are enabled',
'https://example.com/return',
'https://example.com/cancel'
);
$this->is_request_logging_enabled = false;
try {
$this->create_token(
'Checking if reference transactions are enabled',
'https://example.com/return',
'https://example.com/cancel'
);
} finally {
$this->is_request_logging_enabled = true;
}
return true;
} catch ( PayPalApiException $exception ) {

View file

@ -16,6 +16,13 @@ use WP_Error;
*/
trait RequestTrait {
/**
* Whether to log the detailed request/response info.
*
* @var bool
*/
protected $is_request_logging_enabled = true;
/**
* Performs a request
*
@ -39,7 +46,9 @@ trait RequestTrait {
}
$response = wp_remote_get( $url, $args );
$this->logger->debug( $this->request_response_string( $url, $args, $response ) );
if ( $this->is_request_logging_enabled ) {
$this->logger->debug( $this->request_response_string( $url, $args, $response ) );
}
return $response;
}