diff --git a/modules/ppcp-api-client/src/Entity/Capture.php b/modules/ppcp-api-client/src/Entity/Capture.php index c45f8351a..0aacf49b5 100644 --- a/modules/ppcp-api-client/src/Entity/Capture.php +++ b/modules/ppcp-api-client/src/Entity/Capture.php @@ -164,7 +164,7 @@ class Capture { * @return array */ public function to_array() : array { - $data = array( + $data = array( 'id' => $this->id(), 'status' => $this->status()->name(), 'amount' => $this->amount()->to_array(), @@ -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; } diff --git a/modules/ppcp-wc-gateway/src/Processor/PaymentsStatusHandlingTrait.php b/modules/ppcp-wc-gateway/src/Processor/PaymentsStatusHandlingTrait.php index 5e2929d81..3baebcec6 100644 --- a/modules/ppcp-wc-gateway/src/Processor/PaymentsStatusHandlingTrait.php +++ b/modules/ppcp-wc-gateway/src/Processor/PaymentsStatusHandlingTrait.php @@ -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() ) {