1
1
<?php
2
+
2
3
namespace Omnipay \Ecopayz \Message ;
3
4
4
5
use Omnipay \Common \Exception \InvalidRequestException ;
@@ -17,8 +18,8 @@ class FetchTransactionRequest extends AbstractRequest
17
18
/**
18
19
* Get the data for this request.
19
20
*
20
- * @throws InvalidRequestException
21
21
* @return string request data
22
+ * @throws InvalidRequestException
22
23
*/
23
24
public function getData ()
24
25
{
@@ -43,7 +44,6 @@ public function getData()
43
44
);
44
45
45
46
if ($ transactionReference = $ this ->getTransactionReference ()) {
46
-
47
47
$ query = $ body ->appendChild (
48
48
$ document ->createElement ('q0:QueryBySVSTransactionID ' )
49
49
);
@@ -63,9 +63,7 @@ public function getData()
63
63
$ request ->appendChild (
64
64
$ document ->createElement ('q0:SVSTxID ' , $ transactionReference )
65
65
);
66
-
67
66
} elseif ($ transactionId = $ this ->getTransactionId ()) {
68
-
69
67
$ query = $ body ->appendChild (
70
68
$ document ->createElement ('q0:QueryByCustomerTransactionID ' )
71
69
);
@@ -85,11 +83,8 @@ public function getData()
85
83
$ request ->appendChild (
86
84
$ document ->createElement ('q0:TxID ' , $ transactionId )
87
85
);
88
-
89
86
} else {
90
-
91
87
throw new InvalidRequestException ('The transactionId or transactionReference parameter is required ' );
92
-
93
88
}
94
89
95
90
return $ document ->saveXML ();
@@ -98,23 +93,21 @@ public function getData()
98
93
/**
99
94
* Send the request with specified data
100
95
*
101
- * @param mixed $data The data to send
102
- * @throws InvalidResponseException
103
- * @throws InvalidRequestException
96
+ * @param mixed $data The data to send
104
97
* @return FetchTransactionResponse
98
+ * @throws InvalidRequestException
99
+ * @throws InvalidResponseException
105
100
*/
106
101
public function sendData ($ data )
107
102
{
108
103
if (strpos ($ data , 'QueryBySVSTransactionID ' ) !== false ) {
109
-
110
104
$ headers = array (
111
105
'Content-Type ' => 'text/xml; charset=utf-8 ' ,
112
106
'SOAPAction ' => 'http://www.ecocard.com/merchantAPI/QueryBySVSTransactionID '
113
107
);
114
108
115
- $ httpRequest = $ this ->httpClient ->createRequest ('POST ' , $ this ->getEndpoint (), $ headers , $ data );
116
- $ httpResponse = $ httpRequest ->send ();
117
- $ xmlResponse = $ httpResponse ->xml ()
109
+ $ httpResponse = $ this ->httpClient ->request ('POST ' , $ this ->getEndpoint (), $ headers , $ data );
110
+ $ xmlResponse = simplexml_load_string ($ httpResponse ->getBody ()->getContents ())
118
111
->children ('http://schemas.xmlsoap.org/soap/envelope/ ' )
119
112
->children ('http://www.ecocard.com/merchantAPI/ ' );
120
113
@@ -132,17 +125,14 @@ public function sendData($data)
132
125
->QueryBySVSTransactionIDResponse
133
126
->TransactionResponse
134
127
);
135
-
136
128
} elseif (strpos ($ data , 'QueryByCustomerTransactionID ' ) !== false ) {
137
-
138
129
$ headers = array (
139
130
'Content-Type ' => 'text/xml; charset=utf-8 ' ,
140
131
'SOAPAction ' => 'http://www.ecocard.com/merchantAPI/QueryByCustomerTransactionID '
141
132
);
142
133
143
- $ httpRequest = $ this ->httpClient ->createRequest ('POST ' , $ this ->getEndpoint (), $ headers , $ data );
144
- $ httpResponse = $ httpRequest ->send ();
145
- $ xmlResponse = $ httpResponse ->xml ()
134
+ $ httpResponse = $ this ->httpClient ->request ('POST ' , $ this ->getEndpoint (), $ headers , $ data );
135
+ $ xmlResponse = simplexml_load_string ($ httpResponse ->getBody ()->getContents ())
146
136
->children ('http://schemas.xmlsoap.org/soap/envelope/ ' )
147
137
->children ('http://www.ecocard.com/merchantAPI/ ' );
148
138
@@ -160,11 +150,8 @@ public function sendData($data)
160
150
->QueryByCustomerTransactionIDResponse
161
151
->TransactionResponse
162
152
);
163
-
164
153
} else {
165
-
166
154
throw new InvalidRequestException ('The transactionId or transactionReference parameter is required ' );
167
-
168
155
}
169
156
}
170
157
}
0 commit comments