1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omnipay\BillPay; |
4
|
|
|
|
5
|
|
|
use Omnipay\BillPay\Message\AuthorizeRequest; |
6
|
|
|
use Omnipay\BillPay\Message\CaptureRequest; |
7
|
|
|
use Omnipay\BillPay\Message\InvoiceCreatedRequest; |
8
|
|
|
use Omnipay\BillPay\Message\RefundRequest; |
9
|
|
|
use Omnipay\Common\AbstractGateway; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class Gateway |
13
|
|
|
* |
14
|
|
|
* @author Andreas Lange <[email protected]> |
15
|
|
|
* @copyright 2016, Connox GmbH |
16
|
|
|
* @license MIT |
17
|
|
|
*/ |
18
|
|
|
class Gateway extends AbstractGateway |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Create a authorize request. |
22
|
|
|
* |
23
|
|
|
* @param array $parameters |
24
|
|
|
* |
25
|
|
|
* @return AuthorizeRequest |
26
|
|
|
*/ |
27
|
11 |
|
public function authorize(array $parameters = []) |
28
|
|
|
{ |
29
|
11 |
|
return $this->createRequest(AuthorizeRequest::class, $parameters); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param array $parameters |
34
|
|
|
* |
35
|
|
|
* @return CaptureRequest |
36
|
|
|
*/ |
37
|
4 |
|
public function capture(array $parameters = []) |
38
|
|
|
{ |
39
|
4 |
|
return $this->createRequest(CaptureRequest::class, $parameters); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return array |
44
|
|
|
*/ |
45
|
37 |
|
public function getDefaultParameters() |
46
|
|
|
{ |
47
|
|
|
return [ |
48
|
37 |
|
'merchantId' => '', |
49
|
37 |
|
'portalId' => '', |
50
|
37 |
|
'securityKey' => '', |
51
|
37 |
|
'testMode' => false, |
52
|
37 |
|
]; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return int Merchant ID |
57
|
|
|
*/ |
58
|
1 |
|
public function getMerchantId() |
59
|
|
|
{ |
60
|
1 |
|
return $this->getParameter('merchantId'); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Get gateway display name |
65
|
|
|
* This can be used by carts to get the display name for each gateway. |
66
|
|
|
*/ |
67
|
1 |
|
public function getName() |
68
|
|
|
{ |
69
|
1 |
|
return 'BillPay'; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return int Portal ID |
74
|
|
|
*/ |
75
|
1 |
|
public function getPortalId() |
76
|
|
|
{ |
77
|
1 |
|
return $this->getParameter('portalId'); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return string MD5 hash of the security key generated for this portal. (generated and delivered by BillPay) |
82
|
|
|
*/ |
83
|
1 |
|
public function getSecurityKey() |
84
|
|
|
{ |
85
|
1 |
|
return $this->getParameter('securityKey'); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Creates a invoice created request |
90
|
|
|
* |
91
|
|
|
* @param array $parameters |
92
|
|
|
* |
93
|
|
|
* @return InvoiceCreatedRequest |
94
|
|
|
*/ |
95
|
1 |
|
public function invoiceCreated(array $parameters = []) |
96
|
|
|
{ |
97
|
1 |
|
return $this->createRequest(InvoiceCreatedRequest::class, $parameters); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Create a purchase request (is alias of authorize) |
102
|
|
|
* |
103
|
|
|
* @param array $parameters |
104
|
|
|
* |
105
|
|
|
* @return AuthorizeRequest |
106
|
|
|
*/ |
107
|
2 |
|
public function purchase(array $parameters = []) |
108
|
|
|
{ |
109
|
2 |
|
return $this->authorize($parameters)->setCaptureRequestNecessary(false); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Create a refund request. |
114
|
|
|
* |
115
|
|
|
* @param array $parameters |
116
|
|
|
* |
117
|
|
|
* @return RefundRequest |
118
|
|
|
*/ |
119
|
3 |
|
public function refund(array $parameters = []) |
120
|
|
|
{ |
121
|
3 |
|
return $this->createRequest(RefundRequest::class, $parameters); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @param int $value Merchant ID |
126
|
|
|
* |
127
|
|
|
* @return Gateway |
128
|
|
|
*/ |
129
|
5 |
|
public function setMerchantId($value) |
130
|
|
|
{ |
131
|
5 |
|
$this->setParameter('merchantId', $value); |
132
|
|
|
|
133
|
5 |
|
return $this; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param int $value Portal ID |
138
|
|
|
* |
139
|
|
|
* @return Gateway |
140
|
|
|
*/ |
141
|
5 |
|
public function setPortalId($value) |
142
|
|
|
{ |
143
|
5 |
|
$this->setParameter('portalId', $value); |
144
|
|
|
|
145
|
5 |
|
return $this; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @param string $value MD5 hash of the security key generated for this portal. (generated and delivered by BillPay) |
150
|
|
|
* |
151
|
|
|
* @return Gateway |
152
|
|
|
*/ |
153
|
5 |
|
public function setSecurityKey($value) |
154
|
|
|
{ |
155
|
5 |
|
$this->setParameter('securityKey', $value); |
156
|
|
|
|
157
|
5 |
|
return $this; |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|