Skip to content

Commit cea6b80

Browse files
committed
Limited support for acceptNotification
Reads the data and parses it into a a Notification object, but does not yet interpret the result or extract pertinant IDs, messages and status summaries.
1 parent 0fe999c commit cea6b80

File tree

4 files changed

+52
-51
lines changed

4 files changed

+52
-51
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"require": {
2727
"omnipay/common": "^3",
28-
"academe/authorizenet-objects": "^0.6",
28+
"academe/authorizenet-objects": "^0.7",
2929
"symfony/property-access": "^3.2"
3030
},
3131
"require-dev": {

src/ApiGateway.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Omnipay\AuthorizeNetApi\Message\VoidRequest;
1414
use Omnipay\AuthorizeNetApi\Message\RefundRequest;
1515
use Omnipay\AuthorizeNetApi\Message\FetchTransactionRequest;
16+
use Omnipay\AuthorizeNetApi\Message\AcceptNotification;
1617

1718
class ApiGateway extends AbstractGateway
1819
{
@@ -78,4 +79,15 @@ public function fetchTransaction(array $parameters = [])
7879
$parameters
7980
);
8081
}
82+
83+
/**
84+
* Accept a notification.
85+
*/
86+
public function acceptNotification(array $parameters = [])
87+
{
88+
return $this->createRequest(
89+
AcceptNotification::class,
90+
$parameters
91+
);
92+
}
8193
}

src/HostedPageGateway.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Omnipay\AuthorizeNetApi\Message\VoidRequest;
1515
use Omnipay\AuthorizeNetApi\Message\RefundRequest;
1616
use Omnipay\AuthorizeNetApi\Message\FetchTransactionRequest;
17+
use Omnipay\AuthorizeNetApi\Message\AcceptNotification;
1718

1819
class HostedPageGateway extends AbstractGateway
1920
{
@@ -81,4 +82,15 @@ public function fetchTransaction(array $parameters = [])
8182
$parameters
8283
);
8384
}
85+
86+
/**
87+
* Accept a notification.
88+
*/
89+
public function acceptNotification(array $parameters = [])
90+
{
91+
return $this->createRequest(
92+
AcceptNotification::class,
93+
$parameters
94+
);
95+
}
8496
}

src/Message/AcceptNotification.php

Lines changed: 27 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,40 @@
77
*/
88

99
use Omnipay\Common\Message\NotificationInterface;
10-
use Omnipay\Common\Http\Client;
11-
use Omnipay\Common\Message\AbstractRequest as OmnipayAbstractRequest;
10+
use Omnipay\Common\Http\ClientInterface;
1211
use Omnipay\Common\Message\RequestInterface;
12+
use Symfony\Component\HttpFoundation\Request as HttpRequest;
1313

14+
use Omnipay\AuthorizeNetApi\Traits\HasGatewayParams;
1415
use Academe\AuthorizeNet\ServerRequest\Notification;
1516

16-
class AcceptNotification implements NotificationInterface, RequestInterface
17+
class AcceptNotification extends AbstractRequest implements NotificationInterface //, RequestInterface
1718
{
19+
use HasGatewayParams;
20+
21+
protected $data;
22+
1823
/**
1924
* The reponse data parsed into nested value objects.
2025
*/
2126
protected $parsedData;
2227

23-
public function __construct(Client $client, $data)
28+
protected $notification;
29+
30+
public function __construct(ClientInterface $httpClient, HttpRequest $httpRequest)
2431
{
25-
// Parse the raw data into a response message value object.
26-
//$this->setParsedData(new Notification($data));
27-
var_dump($client);
28-
echo "<hr />";
29-
var_dump($data);
32+
// The request is a \Symfony/Component/HttpFoundation/Request object
33+
// and not (yet) a PSR-7 message.
34+
35+
if ($httpRequest->getContentType() === 'json') {
36+
$body = (string)$httpRequest->getContent();
37+
} else {
38+
$body = '{}';
39+
}
40+
41+
$this->data = json_decode($body, true);
42+
43+
$this->parsedData = new Notification($this->data);
3044
}
3145

3246
/**
@@ -45,10 +59,6 @@ public function getParsedData()
4559
return $this->parsedData;
4660
}
4761

48-
// Interface methods.
49-
50-
// Interface NotificationInterface
51-
5262
/**
5363
* Get the raw data array for this message.
5464
* The raw data will be passed in the body as JSON.
@@ -57,6 +67,7 @@ public function getParsedData()
5767
*/
5868
public function getData()
5969
{
70+
return $this->data;
6071
}
6172

6273
/**
@@ -66,6 +77,7 @@ public function getData()
6677
*/
6778
public function getTransactionReference()
6879
{
80+
// TODO.
6981
}
7082

7183
/**
@@ -76,6 +88,7 @@ public function getTransactionReference()
7688
*/
7789
public function getTransactionStatus()
7890
{
91+
// TODO.
7992
}
8093

8194
/**
@@ -85,43 +98,7 @@ public function getTransactionStatus()
8598
*/
8699
public function getMessage()
87100
{
88-
}
89-
90-
// Interface RequestInterface
91-
92-
/**
93-
* Initialize request with parameters
94-
* @param array $parameters The parameters to send
95-
*/
96-
public function initialize(array $parameters = [])
97-
{
98-
}
99-
100-
/**
101-
* Get all request parameters
102-
*
103-
* @return array
104-
*/
105-
public function getParameters()
106-
{
107-
}
108-
109-
/**
110-
* Get the response to this request (if the request has been sent)
111-
*
112-
* @return ResponseInterface
113-
*/
114-
public function getResponse()
115-
{
116-
}
117-
118-
/**
119-
* Send the request
120-
*
121-
* @return ResponseInterface
122-
*/
123-
public function send()
124-
{
101+
// TODO.
125102
}
126103

127104
/**

0 commit comments

Comments
 (0)