4
4
5
5
namespace Upmind \ProvisionProviders \DomainNames \TPPWholesale \Helper ;
6
6
7
+ use Illuminate \Support \Str ;
7
8
use Upmind \ProvisionBase \Exception \ProvisionFunctionError ;
8
9
9
10
class TPPWholesaleResponse implements \JsonSerializable
@@ -107,7 +108,7 @@ private function throwError(string $message, int $errorCode): void
107
108
{
108
109
throw ProvisionFunctionError::create (sprintf ('Provider API Error: %d: %s ' , $ errorCode , $ message ))
109
110
->withData ([
110
- 'response ' => $ this ->response ,
111
+ 'response ' => Str:: limit ( $ this ->response , 500 ) ,
111
112
]);
112
113
}
113
114
@@ -121,6 +122,10 @@ private function throwResponseError(?string $response = null): void
121
122
{
122
123
$ errorDescription = 'Unknown error ' ;
123
124
125
+ if (!Str::contains ($ this ->response , "ERR: " )) {
126
+ $ this ->throwError ('Unknown error ' , 0 );
127
+ }
128
+
124
129
list (, $ errorData ) = explode ("ERR: " , $ response ?? $ this ->response , 2 );
125
130
if (str_contains ($ errorData , ', ' )) {
126
131
list ($ errorCode , $ errorDescription ) = explode (", " , $ errorData , 2 );
@@ -140,7 +145,7 @@ private function throwResponseError(?string $response = null): void
140
145
public function parseAuthResponse (): string
141
146
{
142
147
$ sessionId = "" ;
143
- if (str_starts_with ($ this ->response , "ERR: " )) {
148
+ if (str_starts_with ($ this ->response , "ERR: " ) || !Str:: contains ( $ this -> response , " OK: " ) ) {
144
149
$ this ->throwResponseError ();
145
150
} else {
146
151
list (, $ sessionId ) = explode ("OK: " , $ this ->response , 2 );
0 commit comments