File tree Expand file tree Collapse file tree 2 files changed +39
-4
lines changed Expand file tree Collapse file tree 2 files changed +39
-4
lines changed Original file line number Diff line number Diff line change @@ -149,13 +149,19 @@ protected function getHttpMethod()
149149 */
150150 public function sendData ($ data )
151151 {
152+ $ headers = [
153+ 'Accept ' => 'application/xml ' ,
154+ 'Content-type ' => 'application/xml ' ,
155+ ];
156+
157+ if ($ this ->getAuthorization ()) {
158+ $ headers ['Authorization ' ] = $ this ->getAuthorization ();
159+ }
160+
152161 $ httpResponse = $ this ->httpClient ->request (
153162 $ this ->getHttpMethod (),
154163 $ this ->getEndpoint (),
155- [
156- 'Accept ' => 'application/xml ' ,
157- 'Content-type ' => 'application/xml ' ,
158- ],
164+ $ headers ,
159165 $ this ->getRequestXml ()->asXML ()
160166 );
161167
@@ -209,4 +215,16 @@ public function getApiEndpoint()
209215 {
210216 return $ this ->apiEndpoint ;
211217 }
218+
219+ /**
220+ * @return string|null
221+ */
222+ public function getAuthorization ()
223+ {
224+ if ($ this ->getPassword ()) {
225+ return 'Basic ' . base64_encode ($ this ->getMerchantId () . ': ' . $ this ->getPassword ());
226+ }
227+
228+ return null ;
229+ }
212230}
Original file line number Diff line number Diff line change @@ -777,4 +777,21 @@ public function getHmacKey()
777777 {
778778 return $ this ->getParameter ('hmacKey2 ' ) ?: $ this ->getParameter ('hmacKey1 ' );
779779 }
780+
781+ /**
782+ * @param string password for server-to-server services
783+ * @return $this
784+ */
785+ public function setPassword ($ value )
786+ {
787+ return $ this ->setParameter ('password ' , $ value );
788+ }
789+
790+ /**
791+ * @return string
792+ */
793+ public function getPassword ()
794+ {
795+ return $ this ->getParameter ('password ' );
796+ }
780797}
You can’t perform that action at this time.
0 commit comments