Merge pull request #1562 from woocommerce/PCP-1742-upgrade-tracking-integration

Upgrade tracking integration (1742)
This commit is contained in:
Emili Castells 2023-09-07 09:54:11 +02:00 committed by GitHub
commit 867949cce0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 3188 additions and 1199 deletions

View file

@ -17,6 +17,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\ApiClient\Factory\WebhookEventFactory;
use WooCommerce\PayPalCommerce\ApiClient\Factory\WebhookFactory;
use Psr\Log\LoggerInterface;
use WP_Error;
/**
* Class WebhookEndpoint
@ -193,7 +194,7 @@ class WebhookEndpoint {
);
$response = $this->request( $url, $args );
if ( is_wp_error( $response ) ) {
if ( $response instanceof WP_Error ) {
throw new RuntimeException(
__( 'Not able to delete the webhook.', 'woocommerce-paypal-payments' )
);
@ -201,10 +202,7 @@ class WebhookEndpoint {
$status_code = (int) wp_remote_retrieve_response_code( $response );
if ( 204 !== $status_code ) {
$json = null;
if ( is_array( $response ) ) {
$json = json_decode( $response['body'] );
}
$json = json_decode( $response['body'] ) ?? null;
throw new PayPalApiException(
$json,
$status_code