1
|
|
|
<?php namespace Ntholenaar\MultiSafepayClient\Request; |
2
|
|
|
|
3
|
|
|
class CreateDirectOrderRequest extends CreateOrderRequest implements RequestInterface |
4
|
|
|
{ |
5
|
|
|
/** |
6
|
|
|
* @param $environment |
7
|
|
|
* @param array $parameters |
8
|
|
|
* @param \Http\Message\MessageFactory|null $messageFactory |
9
|
|
|
*/ |
10
|
|
|
public function __construct($environment, array $parameters, $messageFactory) |
11
|
|
|
{ |
12
|
|
|
parent::__construct($environment, $parameters, $messageFactory); |
13
|
|
|
|
14
|
|
|
$this->setType('direct'); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Get the recurring identifier. |
19
|
|
|
* |
20
|
|
|
* @return string|null |
21
|
|
|
*/ |
22
|
|
|
public function getRecurringId() |
23
|
|
|
{ |
24
|
|
|
return $this->getRequestBodyParameter('recurring_id'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Set the recurring identifier. |
29
|
|
|
* |
30
|
|
|
* @param $recurringId |
31
|
|
|
* @return $this |
32
|
|
|
*/ |
33
|
|
|
public function setRecurringId($recurringId) |
34
|
|
|
{ |
35
|
|
|
$this->setRequestBodyParameter('recurring_id', $recurringId); |
36
|
|
|
|
37
|
|
|
return $this; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Get the gateway info. |
42
|
|
|
* |
43
|
|
|
* @return array|null |
44
|
|
|
*/ |
45
|
|
|
public function getGatewayInfo() |
46
|
|
|
{ |
47
|
|
|
return $this->getRequestBodyParameter('gateway_info'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Set the gateway info. |
52
|
|
|
* |
53
|
|
|
* @param array $gatewayInfo |
54
|
|
|
* @return $this |
55
|
|
|
*/ |
56
|
|
|
public function setGatewayInfo(array $gatewayInfo) |
57
|
|
|
{ |
58
|
|
|
// @todo validate, and filter invalid array keys. |
59
|
|
|
|
60
|
|
|
$this->setRequestBodyParameter('gateway_info', $gatewayInfo); |
61
|
|
|
|
62
|
|
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* {@inheritdoc} |
67
|
|
|
*/ |
68
|
|
|
public function validate() |
69
|
|
|
{ |
70
|
|
|
if (parent::validate() === false || |
71
|
|
|
is_null($this->getGatewayId()) || |
72
|
|
|
is_null($this->getGatewayInfo()) || |
73
|
|
|
is_null($this->getRecurringId()) |
74
|
|
|
) { |
75
|
|
|
return false; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
return true; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|