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()
149
149
*/
150
150
public function sendData ($ data )
151
151
{
152
+ $ headers = [
153
+ 'Accept ' => 'application/xml ' ,
154
+ 'Content-type ' => 'application/xml ' ,
155
+ ];
156
+
157
+ if ($ this ->getAuthorization ()) {
158
+ $ headers ['Authorization ' ] = $ this ->getAuthorization ();
159
+ }
160
+
152
161
$ httpResponse = $ this ->httpClient ->request (
153
162
$ this ->getHttpMethod (),
154
163
$ this ->getEndpoint (),
155
- [
156
- 'Accept ' => 'application/xml ' ,
157
- 'Content-type ' => 'application/xml ' ,
158
- ],
164
+ $ headers ,
159
165
$ this ->getRequestXml ()->asXML ()
160
166
);
161
167
@@ -209,4 +215,16 @@ public function getApiEndpoint()
209
215
{
210
216
return $ this ->apiEndpoint ;
211
217
}
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
+ }
212
230
}
Original file line number Diff line number Diff line change @@ -777,4 +777,21 @@ public function getHmacKey()
777
777
{
778
778
return $ this ->getParameter ('hmacKey2 ' ) ?: $ this ->getParameter ('hmacKey1 ' );
779
779
}
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
+ }
780
797
}
You can’t perform that action at this time.
0 commit comments