@@ -88,13 +88,12 @@ private function setRequestOptions()
88
88
{
89
89
$ authBearer = 'Bearer ' . $ this ->secretKey ;
90
90
91
- $ this ->client = new Client (['base_uri ' => $ this ->baseUrl ]);
92
-
93
- $ this ->client ->setDefaultOption ('headers ' , [
94
- 'Authorization ' => $ authBearer ,
95
- 'Content-Type ' => 'application/json ' ,
96
- 'Accept ' => 'application/json '
97
- ]);
91
+ $ this ->client = new Client (['base_uri ' => $ this ->baseUrl ,
92
+ 'headers ' => [
93
+ 'Authorization ' => $ authBearer ,
94
+ 'Content-Type ' => 'application/json ' ,
95
+ 'Accept ' => 'application/json '
96
+ ]]);
98
97
}
99
98
100
99
/**
@@ -143,7 +142,7 @@ public function getAuthorizationUrl()
143
142
{
144
143
$ this ->makePaymentRequest ();
145
144
146
- $ this ->url = $ this ->response -> json ()[" data " ][ " authorization_url " ];
145
+ $ this ->url = $ this ->getResponse ()[' data ' ][ ' authorization_url ' ];
147
146
148
147
return $ this ;
149
148
}
@@ -169,7 +168,7 @@ public function isTransactionVerificationValid()
169
168
{
170
169
$ this ->verifyTransactionAtGateway ();
171
170
172
- $ result = $ this ->response -> json ()[" message " ];
171
+ $ result = $ this ->getResponse ()[' message ' ];
173
172
174
173
switch ($ result )
175
174
{
@@ -195,7 +194,7 @@ public function isTransactionVerificationValid()
195
194
public function getPaymentData ()
196
195
{
197
196
if ($ this ->isTransactionVerificationValid ()) {
198
- return $ this ->response -> json ();
197
+ return $ this ->getResponse ();
199
198
} else {
200
199
throw new PaymentVerificationFailedException ("Invalid Transaction Reference " );
201
200
}
@@ -216,7 +215,7 @@ public function redirectNow()
216
215
*/
217
216
public function getAccessCode ()
218
217
{
219
- return $ this ->response -> json ()[" data " ][ " access_code " ];
218
+ return $ this ->getResponse ()[' data ' ][ ' access_code ' ];
220
219
}
221
220
222
221
/**
@@ -262,12 +261,21 @@ public function getAllTransactions()
262
261
}
263
262
264
263
/**
265
- * Get the response from a get operation
264
+ * Get the whole response from a get operation
265
+ * @return array
266
+ */
267
+ private function getResponse ()
268
+ {
269
+ return json_decode ($ this ->response ->getBody (), true );
270
+ }
271
+
272
+ /**
273
+ * Get the data response from a get operation
266
274
* @return array
267
275
*/
268
276
private function getData ()
269
277
{
270
- return $ this ->response -> json ()[" data " ];
278
+ return $ this ->getResponse ()[' data ' ];
271
279
}
272
280
273
281
}
0 commit comments