Display PayPal exception issues (WIP)

This commit is contained in:
dinamiko 2022-01-28 17:40:44 +01:00
parent 74490c40c9
commit f454c60292
2 changed files with 10 additions and 0 deletions

View file

@ -110,4 +110,8 @@ class PayPalApiException extends RuntimeException {
} }
return false; return false;
} }
public function issues(): array {
return $this->response->issues ?? array();
}
} }

View file

@ -298,6 +298,12 @@ trait ProcessPaymentTrait {
); );
} }
$error_message = $error->getMessage();
if($error->issues()) {
$error_message = $error->issues()[0]->issue . ' ' . $error->issues()[0]->description;
}
wc_add_notice($error_message, 'error');
$this->session_handler->destroy_session_data(); $this->session_handler->destroy_session_data();
} catch ( RuntimeException $error ) { } catch ( RuntimeException $error ) {
$this->handle_failure( $wc_order, $error ); $this->handle_failure( $wc_order, $error );