-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
FetchOrderRequest.php
executable file
·64 lines (55 loc) · 1.44 KB
/
FetchOrderRequest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace Omnipay\Mollie\Message\Request;
use Omnipay\Common\Exception\InvalidRequestException;
use Omnipay\Mollie\Message\Response\FetchOrderResponse;
/**
* Retrieve a single order object by its payment token.
*
* @see https://docs.mollie.com/reference/v2/payments-api/get-order
* @method FetchOrderResponse send()
*/
class FetchOrderRequest extends AbstractMollieRequest
{
/**
* @return array
* @throws InvalidRequestException
*/
public function getData()
{
$this->validate('apiKey', 'transactionReference');
$data = [];
$data['id'] = $this->getTransactionReference();
return $data;
}
/**
* @return bool
*/
public function hasIncludePayments()
{
return (bool) $this->getParameter('includePayments');
}
/**
* @param array $data
* @return FetchOrderResponse
*/
public function sendData($data)
{
$response = $this->sendRequest(
self::GET,
\sprintf(
'/orders/%s%s',
$data['id'],
$this->hasIncludePayments() ? '?embed=payments' : ''
)
);
return $this->response = new FetchOrderResponse($this, $response);
}
/**
* @param bool $includePayments
* @return self
*/
public function setIncludePayments($includePayments)
{
return $this->setParameter('includePayments', $includePayments);
}
}