1
|
|
|
<?php |
2
|
|
|
namespace Omnipay\ZipPay\Message; |
3
|
|
|
|
4
|
|
|
use Omnipay\ZipPay\Message\RestCompleteAuthorizeResponse; |
5
|
|
|
|
6
|
|
|
class RestCompleteAuthorizeRequest extends AbstractRequest |
7
|
|
|
{ |
8
|
6 |
|
public function getEndpoint() |
9
|
|
|
{ |
10
|
6 |
|
return parent::getEndpoint() . '/charges'; |
11
|
|
|
} |
12
|
|
|
|
13
|
6 |
|
public function getHttpMethod() |
14
|
|
|
{ |
15
|
6 |
|
return 'POST'; |
16
|
|
|
} |
17
|
|
|
|
18
|
6 |
|
public function getReference() |
19
|
|
|
{ |
20
|
6 |
|
return $this->getParameter('reference'); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function setReference($value) |
24
|
|
|
{ |
25
|
|
|
return $this->setParameter('reference', $value); |
26
|
|
|
} |
27
|
|
|
|
28
|
6 |
|
public function hasReference() |
29
|
|
|
{ |
30
|
6 |
|
return !empty($this->getReference()); |
31
|
|
|
} |
32
|
|
|
|
33
|
6 |
|
public function getAuthorityType() |
34
|
|
|
{ |
35
|
6 |
|
return $this->getParameter('authorityType'); |
36
|
|
|
} |
37
|
|
|
|
38
|
6 |
|
public function setAuthorityType($value) |
39
|
|
|
{ |
40
|
6 |
|
return $this->setParameter('authorityType', $value); |
41
|
|
|
} |
42
|
|
|
|
43
|
6 |
|
public function getAuthorityValue() |
44
|
|
|
{ |
45
|
6 |
|
return $this->getParameter('authorityValue'); |
46
|
|
|
} |
47
|
|
|
|
48
|
6 |
|
public function setAuthorityValue($value) |
49
|
|
|
{ |
50
|
6 |
|
return $this->setParameter('authorityValue', $value); |
51
|
|
|
} |
52
|
|
|
|
53
|
6 |
|
public function getCaptureFunds() |
54
|
|
|
{ |
55
|
6 |
|
return $this->getParameter('captureFunds'); |
56
|
|
|
} |
57
|
|
|
|
58
|
6 |
|
public function setCaptureFunds($value) |
59
|
|
|
{ |
60
|
6 |
|
return $this->setParameter('captureFunds', $value); |
61
|
|
|
} |
62
|
|
|
|
63
|
6 |
|
public function getData() |
64
|
|
|
{ |
65
|
6 |
|
$this->validate('amount', 'authorityType', 'authorityValue', 'captureFunds', 'currency'); |
66
|
|
|
|
67
|
6 |
|
$data = $this->getBaseData(); |
68
|
|
|
|
69
|
6 |
|
$data['authority'] = $this->getAuthority(); |
70
|
6 |
|
$data['amount'] = $this->getAmount(); |
71
|
6 |
|
$data['currency'] = $this->getCurrency(); |
72
|
6 |
|
$data['capture'] = $this->getCaptureFunds(); |
73
|
|
|
|
74
|
6 |
|
if ($this->hasReference()) { |
75
|
|
|
$data['reference'] = $this->getReference(); |
76
|
|
|
} |
77
|
|
|
|
78
|
6 |
|
return $data; |
79
|
|
|
} |
80
|
|
|
|
81
|
6 |
|
public function getAuthority() |
82
|
|
|
{ |
83
|
|
|
return [ |
84
|
6 |
|
'type' => $this->getAuthorityType(), |
85
|
6 |
|
'value' => $this->getAuthorityValue(), |
86
|
2 |
|
]; |
87
|
|
|
} |
88
|
|
|
|
89
|
6 |
|
protected function createResponse($data, $headers = [], $status = 404) |
90
|
|
|
{ |
91
|
6 |
|
return $this->response = new RestCompleteAuthorizeResponse($this, $data, $headers, $status); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|