Error handling

In PHP; I'm using this line to charge customer:
$api_response = $client->getPaymentsApi()->createPayment($body);

 

To get the error message (in proper format so I can save it) I use:

$errors = print_r($api_response->getErrors(), true);
$errors = preg_replace('/[^a-z]/i','',$errors);

 

As results, in one case I received this error message:

ArraySquareModelsErrorObjectcategorySquareModelsErrorprivatePAYMENTMETHODERRORcodeSquareModelsErrorprivateTRANSACTIONLIMITdetailSquareModelsErrorprivateAuthorizationerrorTRANSACTIONLIMITfieldSquareModelsErrorprivate

My first question is, what does this error message mean?

My second question is, I need to get one no special character error message so I can display this to customer. How do I get this in PHP?
Instead of me having to troubleshoot each time I just want to be able to display directly to customer what the error is but worried the message might have a quote or double quote and mess something up 😕
I don't want an array result, just one sentence.


Any help? 😕
Thank you.

280 Views
Message 1 of 1
Report
0 REPLIES 0