Fix null access

This commit is contained in:
Alex P 2021-10-13 17:34:47 +03:00
parent 92eef9ceb9
commit d91131cb06
2 changed files with 10 additions and 7 deletions

View file

@ -173,8 +173,9 @@ class Capture {
'invoice_id' => $this->invoice_id(),
'custom_id' => $this->custom_id(),
);
if ( $this->status()->details() ) {
$data['status_details'] = array( 'reason' => $this->status()->details()->reason() );
$details = $this->status()->details();
if ( $details ) {
$data['status_details'] = array( 'reason' => $details->reason() );
}
return $data;
}

View file

@ -55,8 +55,9 @@ trait PaymentsStatusHandlingTrait {
): void {
$status = $capture->status();
if ( $status->details() ) {
$this->add_status_details_note( $wc_order, $status->name(), $status->details()->text() );
$details = $status->details();
if ( $details ) {
$this->add_status_details_note( $wc_order, $status->name(), $details->text() );
}
switch ( $status->name() ) {
@ -95,8 +96,9 @@ trait PaymentsStatusHandlingTrait {
): void {
$status = $authorization->status();
if ( $status->details() ) {
$this->add_status_details_note( $wc_order, $status->name(), $status->details()->text() );
$details = $status->details();
if ( $details ) {
$this->add_status_details_note( $wc_order, $status->name(), $details->text() );
}
switch ( $status->name() ) {