Skip to content

Commit 2b3624b

Browse files
committed
Merge pull request #106 from felipecwb/feature/transaction-search
Feature to Transaction Search method
2 parents b546d24 + a474c5a commit 2b3624b

7 files changed

+574
-0
lines changed

src/ExpressGateway.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,12 @@ public function fetchCheckout(array $parameters = array())
147147
{
148148
return $this->createRequest('\Omnipay\PayPal\Message\ExpressFetchCheckoutRequest', $parameters);
149149
}
150+
151+
/**
152+
* @return Message\ExpressTransactionSearchRequest
153+
*/
154+
public function transactionSearch(array $parameters = array())
155+
{
156+
return $this->createRequest('\Omnipay\PayPal\Message\ExpressTransactionSearchRequest', $parameters);
157+
}
150158
}
Lines changed: 371 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,371 @@
1+
<?php
2+
3+
namespace Omnipay\PayPal\Message;
4+
5+
use DateTime;
6+
7+
/**
8+
* Paypal Express Checkout - Transaction Search
9+
*
10+
* @see https://developer.paypal.com/docs/classic/api/merchant/TransactionSearch_API_Operation_NVP/
11+
* @see https://developer.paypal.com/docs/classic/express-checkout/ht_searchRetrieveTransactionData-curl-etc/
12+
*
13+
* pt_BR:
14+
* @see https://www.paypal-brasil.com.br/desenvolvedores/tutorial/criando-relatorios-customizados-via-api/
15+
*/
16+
class ExpressTransactionSearchRequest extends AbstractRequest
17+
{
18+
public function getData()
19+
{
20+
$data = $this->getBaseData();
21+
$data['METHOD'] = 'TransactionSearch';
22+
23+
$this->validate('startDate');
24+
25+
$data['STARTDATE'] = $this->getStartDate()->format(DateTime::ISO8601);
26+
27+
if ($this->getEndDate()) {
28+
$data['ENDDATE'] = $this->getEndDate()->format(DateTime::ISO8601);
29+
}
30+
31+
if ($this->getSalutation()) {
32+
$data['SALUTATION'] = $this->getSalutation();
33+
}
34+
35+
if ($this->getFirstName()) {
36+
$data['FIRSTNAME'] = $this->getFirstName();
37+
}
38+
39+
if ($this->getMiddleName()) {
40+
$data['MIDDLENAME'] = $this->getMiddleName();
41+
}
42+
43+
if ($this->getLastName()) {
44+
$data['LASTNAME'] = $this->getLastName();
45+
}
46+
47+
if ($this->getSuffix()) {
48+
$data['SUFFIX'] = $this->getSuffix();
49+
}
50+
51+
if ($this->getEmail()) {
52+
$data['EMAIL'] = $this->getEmail();
53+
}
54+
55+
if ($this->getReceiver()) {
56+
$data['RECEIVER'] = $this->getReceiver();
57+
}
58+
59+
if ($this->getReceiptId()) {
60+
$data['RECEIPTID'] = $this->getReceiptId();
61+
}
62+
63+
if ($this->getTransactionId()) {
64+
$data['TRANSACTIONID'] = $this->getTransactionId();
65+
}
66+
67+
if ($this->getInvoiceNumber()) {
68+
$data['INVNUM'] = $this->getInvoiceNumber();
69+
}
70+
71+
if ($this->getCard()) {
72+
$data['ACCT'] = $this->getCard()->getNumber();
73+
}
74+
75+
if ($this->getAuctionItemNumber()) {
76+
$data['AUCTIONITEMNUMBER'] = $this->getAuctionItemNumber();
77+
}
78+
79+
if ($this->getTransactionClass()) {
80+
$data['TRANSACTIONCLASS'] = $this->getTransactionClass();
81+
}
82+
83+
if ($this->getAmount()) {
84+
$this->validate('currency');
85+
86+
$data['AMT'] = $this->getAmount();
87+
$data['CURRENCYCODE'] = $this->getCurrency();
88+
}
89+
90+
if ($this->getStatus()) {
91+
$data['STATUS'] = $this->getStatus();
92+
}
93+
94+
if ($this->getProfileId()) {
95+
$data['PROFILEID'] = $this->getProfileId();
96+
}
97+
98+
return $data;
99+
}
100+
101+
/**
102+
* @return DateTime|null
103+
*/
104+
public function getStartDate()
105+
{
106+
return $this->getParameter('startDate');
107+
}
108+
109+
/**
110+
* @param DateTime|string $date
111+
* @return \Omnipay\Common\Message\AbstractRequest
112+
*/
113+
public function setStartDate($date)
114+
{
115+
if (! $date instanceof DateTime) {
116+
$date = new DateTime($date);
117+
}
118+
119+
return $this->setParameter('startDate', $date);
120+
}
121+
122+
/**
123+
* @return DateTime|null
124+
*/
125+
public function getEndDate()
126+
{
127+
return $this->getParameter('endDate');
128+
}
129+
130+
/**
131+
* @param DateTime|string $date
132+
* @return \Omnipay\Common\Message\AbstractRequest
133+
*/
134+
public function setEndDate($date)
135+
{
136+
if (! $date instanceof DateTime) {
137+
$date = new DateTime($date);
138+
}
139+
140+
return $this->setParameter('endDate', $date);
141+
}
142+
143+
/**
144+
* @return string
145+
*/
146+
public function getSalutation()
147+
{
148+
return $this->getParameter('salutation');
149+
}
150+
151+
/**
152+
* @param string $salutation
153+
* @return \Omnipay\Common\Message\AbstractRequest
154+
*/
155+
public function setSalutation($salutation)
156+
{
157+
return $this->setParameter('salutation', $salutation);
158+
}
159+
160+
/**
161+
* @return string
162+
*/
163+
public function getFirstName()
164+
{
165+
return $this->getParameter('firstName');
166+
}
167+
168+
/**
169+
* @param string $firstName
170+
* @return \Omnipay\Common\Message\AbstractRequest
171+
*/
172+
public function setFirstName($firstName)
173+
{
174+
return $this->setParameter('firstName', $firstName);
175+
}
176+
177+
/**
178+
* @return string
179+
*/
180+
public function getMiddleName()
181+
{
182+
return $this->getParameter('middleName');
183+
}
184+
185+
/**
186+
* @param string $middleName
187+
* @return \Omnipay\Common\Message\AbstractRequest
188+
*/
189+
public function setMiddleName($middleName)
190+
{
191+
return $this->setParameter('middleName', $middleName);
192+
}
193+
194+
/**
195+
* @return string
196+
*/
197+
public function getLastName()
198+
{
199+
return $this->getParameter('lastName');
200+
}
201+
202+
/**
203+
* @param string $lastName
204+
* @return \Omnipay\Common\Message\AbstractRequest
205+
*/
206+
public function setLastName($lastName)
207+
{
208+
return $this->setParameter('lastName', $lastName);
209+
}
210+
211+
/**
212+
* @return string
213+
*/
214+
public function getSuffix()
215+
{
216+
return $this->getParameter('suffix');
217+
}
218+
219+
/**
220+
* @param string $suffix
221+
* @return \Omnipay\Common\Message\AbstractRequest
222+
*/
223+
public function setSuffix($suffix)
224+
{
225+
return $this->setParameter('suffix', $suffix);
226+
}
227+
228+
/**
229+
* @return string
230+
*/
231+
public function getEmail()
232+
{
233+
return $this->getParameter('email');
234+
}
235+
236+
/**
237+
* @param string $email
238+
* @return \Omnipay\Common\Message\AbstractRequest
239+
*/
240+
public function setEmail($email)
241+
{
242+
return $this->setParameter('email', $email);
243+
}
244+
245+
/**
246+
* @return string
247+
*/
248+
public function getReceiver()
249+
{
250+
return $this->getParameter('receiver');
251+
}
252+
253+
/**
254+
* @param string $receiver
255+
* @return \Omnipay\Common\Message\AbstractRequest
256+
*/
257+
public function setReceiver($receiver)
258+
{
259+
return $this->setParameter('receiver', $receiver);
260+
}
261+
262+
/**
263+
* @return string
264+
*/
265+
public function getReceiptId()
266+
{
267+
return $this->getParameter('receiptId');
268+
}
269+
270+
/**
271+
* @param string $receiptId
272+
* @return \Omnipay\Common\Message\AbstractRequest
273+
*/
274+
public function setReceiptId($receiptId)
275+
{
276+
return $this->setParameter('receiptId', $receiptId);
277+
}
278+
279+
/**
280+
* @return string
281+
*/
282+
public function getInvoiceNumber()
283+
{
284+
return $this->getParameter('invoiceNumber');
285+
}
286+
287+
/**
288+
* @param string $invoiceNumber
289+
* @return \Omnipay\Common\Message\AbstractRequest
290+
*/
291+
public function setInvoiceNumber($invoiceNumber)
292+
{
293+
return $this->setParameter('invoiceNumber', $invoiceNumber);
294+
}
295+
296+
/**
297+
* @return string
298+
*/
299+
public function getAuctionItemNumber()
300+
{
301+
return $this->getParameter('auctionItemNumber');
302+
}
303+
304+
/**
305+
* @param string $auctionItemNumber
306+
* @return \Omnipay\Common\Message\AbstractRequest
307+
*/
308+
public function setAuctionItemNumber($auctionItemNumber)
309+
{
310+
return $this->setParameter('auctionItemNumber', $auctionItemNumber);
311+
}
312+
313+
/**
314+
* @return string
315+
*/
316+
public function getTransactionClass()
317+
{
318+
return $this->getParameter('transactionClass');
319+
}
320+
321+
/**
322+
* @param string $transactionClass
323+
* @return \Omnipay\Common\Message\AbstractRequest
324+
*/
325+
public function setTransactionClass($transactionClass)
326+
{
327+
return $this->setParameter('transactionClass', $transactionClass);
328+
}
329+
330+
/**
331+
* @return string
332+
*/
333+
public function getStatus()
334+
{
335+
return $this->getParameter('status');
336+
}
337+
338+
/**
339+
* @param string $status
340+
* @return \Omnipay\Common\Message\AbstractRequest
341+
*/
342+
public function setStatus($status)
343+
{
344+
return $this->setParameter('status', $status);
345+
}
346+
347+
/**
348+
* @return string
349+
*/
350+
public function getProfileId()
351+
{
352+
return $this->getParameter('profileId');
353+
}
354+
355+
/**
356+
* @param string $profileId
357+
* @return \Omnipay\Common\Message\AbstractRequest
358+
*/
359+
public function setProfileId($profileId)
360+
{
361+
return $this->setParameter('profileId', $profileId);
362+
}
363+
364+
/**
365+
* @return ExpressTransactionSearchResponse
366+
*/
367+
public function createResponse($data)
368+
{
369+
return $this->response = new ExpressTransactionSearchResponse($this, $data);
370+
}
371+
}

0 commit comments

Comments
 (0)