2

When I catch the exception from the square charge object, I am returned with [HTTP/1.1 400 Bad Request] {"errors":[{"category":"INVALID_REQUEST_ERROR","code":"CARD_TOKEN_USED","detail":"Card nonce already used; please request new nonce."}]}

I want to extract only "detail" to convey to the user. How do I do this. I tried $e->getDetail() and $e->getMessage()->getDetail() and $e['detail'] and $e['errors'][0]['detail'] but nothing is working. How do I do this? Using php connect library

1 Answers1

1

I figured it out. I was catching a standard exception but square has a library for that -> if you need the answer: catch (\SquareConnect\ApiException $e) { echo $e->getResponseBody()->errors[0]->detail; }