Skip to content

Commit 7688e8d

Browse files
committed
Handle auth and validation api failed error
1 parent cca4df3 commit 7688e8d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/AddressValidation.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ public function validate(String $client_id, String $client_secret)
6666
$res = json_decode($response);
6767

6868
if (!isset($res->XAVResponse)) {
69-
$error = $res->response->errors[0]->message;
69+
if (isset($res->response)) {
70+
$error = $res->response->errors[0]->message;
71+
} else {
72+
$error = "Address Validation Failed! Please try again.";
73+
}
7074
return ['status' => 'fail', 'msg' => $error];
7175
}
7276

src/Auth.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ public function authenticate(String $client_id, String $client_secret)
4242
$res = json_decode($response);
4343

4444
if (!isset($res->access_token)) {
45-
$error = $res->response->errors[0]->message;
45+
if (isset($res->response)) {
46+
$error = $res->response->errors[0]->message;
47+
} else {
48+
$error = "Authentication Failed! Please try again.";
49+
}
4650
return ['status' => 'fail', 'msg' => $error];
4751
}
4852

0 commit comments

Comments
 (0)