Skip to content

Commit a2c5fb3

Browse files
authored
Merge pull request #28 from incarnate/auth-fix
Add auth to Rapid requests
2 parents 4a0f2e0 + a87b270 commit a2c5fb3

7 files changed

+35
-9
lines changed

src/Message/RapidCaptureRequest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,12 @@ public function getEndpoint()
5454

5555
public function sendData($data)
5656
{
57-
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [
57+
$headers = [
58+
'Authorization' => 'Basic ' . base64_encode($this->getApiKey() . ':' . $this->getPassword()),
5859
'content-type' => 'application/json',
59-
], json_encode($data));
60+
];
61+
62+
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, json_encode($data));
6063

6164
return $this->response = new RapidResponse($this, json_decode((string) $httpResponse->getBody(), true));
6265
}

src/Message/RapidDirectAbstractRequest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ protected function getBaseData()
101101

102102
public function sendData($data)
103103
{
104-
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], json_encode($data));
104+
$headers = [
105+
'Authorization' => 'Basic ' . base64_encode($this->getApiKey() . ':' . $this->getPassword())
106+
];
107+
108+
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, json_encode($data));
105109

106110
return $this->response = new RapidResponse($this, json_decode((string) $httpResponse->getBody(), true));
107111
}

src/Message/RapidDirectCreateCardRequest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ protected function getEndpoint()
7676

7777
public function sendData($data)
7878
{
79-
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], json_encode($data));
79+
$headers = [
80+
'Authorization' => 'Basic ' . base64_encode($this->getApiKey() . ':' . $this->getPassword())
81+
];
82+
83+
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, json_encode($data));
8084

8185
$this->response = new RapidDirectCreateCardResponse(
8286
$this,

src/Message/RapidDirectUpdateCardRequest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ protected function getEndpoint()
8181

8282
public function sendData($data)
8383
{
84-
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], json_encode($data));
84+
$headers = [
85+
'Authorization' => 'Basic ' . base64_encode($this->getApiKey() . ':' . $this->getPassword())
86+
];
87+
88+
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, json_encode($data));
8589

8690
return $this->response = new RapidDirectCreateCardResponse(
8791
$this,

src/Message/RapidDirectVoidRequest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ protected function getEndpoint()
2424

2525
public function sendData($data)
2626
{
27-
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [
27+
$headers = [
28+
'Authorization' => 'Basic ' . base64_encode($this->getApiKey() . ':' . $this->getPassword()),
2829
'content-type' => 'application/json',
29-
], json_encode($data));
30+
];
31+
32+
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, json_encode($data));
3033

3134
return $this->response = new RapidResponse($this, json_decode((string) $httpResponse->getBody(), true));
3235
}

src/Message/RapidPurchaseRequest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ public function getData()
3939

4040
public function sendData($data)
4141
{
42-
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], json_encode($data));
42+
$headers = [
43+
'Authorization' => 'Basic ' . base64_encode($this->getApiKey() . ':' . $this->getPassword())
44+
];
45+
46+
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, json_encode($data));
4347

4448
return $this->response = new RapidResponse($this, json_decode((string) $httpResponse->getBody(), true));
4549
}

src/Message/RapidSharedPurchaseRequest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ public function getData()
4949

5050
public function sendData($data)
5151
{
52-
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], json_encode($data));
52+
$headers = [
53+
'Authorization' => 'Basic ' . base64_encode($this->getApiKey() . ':' . $this->getPassword())
54+
];
55+
56+
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, json_encode($data));
5357

5458
return $this->response = new RapidSharedResponse($this, json_decode((string) $httpResponse->getBody(), true));
5559
}

0 commit comments

Comments
 (0)