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

@ -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;
}