@@ -50,12 +50,19 @@ abstract class Base
5050 protected $ sOrderId = null ;
5151
5252 /**
53- * Array or request parameters
53+ * Array of request parameters
5454 *
5555 * @var array
5656 */
5757 protected $ aParameters = [];
5858
59+ /**
60+ * Array of request headers
61+ *
62+ * @var array
63+ */
64+ protected $ aHeaders = [];
65+
5966 /**
6067 * Response of the request
6168 *
@@ -198,6 +205,17 @@ public function addParameter($sKey, $sValue, $blAddAsNullIfEmpty = false)
198205 $ this ->aParameters [$ sKey ] = $ sValue ;
199206 }
200207
208+ /**
209+ * Adds a header to the collection of headers.
210+ *
211+ * @param string $sHeader
212+ * @return void
213+ */
214+ public function addHeader ($ sHeader )
215+ {
216+ $ this ->aHeaders [] = $ sHeader ;
217+ }
218+
201219 /**
202220 * Remove parameter from request
203221 *
@@ -234,6 +252,16 @@ public function getParameters()
234252 {
235253 return $ this ->aParameters ;
236254 }
255+
256+ /**
257+ * Return headers
258+ *
259+ * @return array
260+ */
261+ public function getHeaders ()
262+ {
263+ return $ this ->aHeaders ;
264+ }
237265
238266 /**
239267 * Set response array
@@ -327,6 +355,16 @@ protected function validateParameters()
327355 return true ;
328356 }
329357
358+ /**
359+ * Retrieve the API URL.
360+ *
361+ * @return string
362+ */
363+ protected function getApiUrl ()
364+ {
365+ return $ this ->sApiUrl ;
366+ }
367+
330368 /**
331369 * Send the previously prepared request, log request and response into the database and return the response
332370
@@ -342,9 +380,9 @@ protected function send(?PayoneMethod $oPayment = null)
342380 if (!$ this ->validateParameters ()) {// all base parameters existing?
343381 return ["errormessage " => "Payone API Setup Data not complete (API-URL, MID, AID, PortalID, Key, Mode) " ];
344382 }
345-
346- $ sRequestUrl = $ this ->apiHelper ->getRequestUrl ($ this ->getParameters (), $ this ->sApiUrl );
347- $ aResponse = $ this ->apiHelper ->sendApiRequest ($ sRequestUrl ); // send request to PAYONE
383+
384+ $ sRequestUrl = $ this ->apiHelper ->getRequestUrl ($ this ->getParameters (), $ this ->getApiUrl () );
385+ $ aResponse = $ this ->apiHelper ->sendApiRequest ($ sRequestUrl, $ this -> getHeaders () ); // send request to PAYONE
348386
349387 $ this ->setResponse ($ aResponse );
350388
0 commit comments