77 */
88
99use Omnipay \Common \Message \NotificationInterface ;
10- use Omnipay \Common \Http \Client ;
11- use Omnipay \Common \Message \AbstractRequest as OmnipayAbstractRequest ;
10+ use Omnipay \Common \Http \ClientInterface ;
1211use Omnipay \Common \Message \RequestInterface ;
12+ use Symfony \Component \HttpFoundation \Request as HttpRequest ;
1313
14+ use Omnipay \AuthorizeNetApi \Traits \HasGatewayParams ;
1415use 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