-
Notifications
You must be signed in to change notification settings - Fork 16
/
ShopServerAuthorizeRequest.php
262 lines (204 loc) · 6.68 KB
/
ShopServerAuthorizeRequest.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?php
namespace Omnipay\Payone\Message;
/**
* PAYONE Shop Authorize Request
*/
use Omnipay\Payone\AbstractShopGateway;
class ShopServerAuthorizeRequest extends AbstractRequest
{
/**
* The additional financing types.
* In addition to BSV, KLV and KLS.
*/
// Payolution-Invoicing
const FINANCING_TYPE_PYV = 'PYV';
// Payolution-Monthly
const FINANCING_TYPE_PYM = 'PYM';
// Payolution-Installment
const FINANCING_TYPE_PYS = 'PYS';
// Payolution-Debit
const FINANCING_TYPE_PYD = 'PYD';
/**
* The "request" parameter.
*/
protected $request_code = 'preauthorization';
/**
* Base data required for all Server transactions.
*/
protected function getBaseData()
{
$data = [
'mid' => $this->getMerchantId(),
'portalid' => $this->getPortalId(),
// Only md5 is used to encode the key for the Server API (no hashing is
// needed over the secure server-to-server connection).
'key' => md5($this->getPortalKey()),
'api_version' => AbstractShopGateway::API_VERSION,
'mode' => (bool) $this->getTestMode()
? AbstractShopGateway::MODE_TEST
: AbstractShopGateway::MODE_LIVE,
'request' => $this->request_code,
'encoding' => $this->getEncoding(),
'language' => $this->getLanguage(),
];
return $data;
}
/**
* Collect the data together to send to the Gateway.
*/
public function getData()
{
$data = $this->getBaseData();
$data['clearingtype'] = $this->getClearingType();
$data['aid'] = $this->getSubAccountId();
// CC details
$data = array_merge($data, $this->getDataCard());
// Merchant site reference.
$data['reference'] = $this->getTransactionId();
// Amount is in minor units.
$data['amount'] = $this->getAmountInteger();
// Currency is (i.e. has to be) ISO 4217
$data['currency'] = $this->getCurrency();
// Personal data.
$data = array_merge($data, $this->getDataPersonal());
if ($this->getParam() !== null) {
$data['param'] = $this->getParam();
}
if ($this->getDescription()) {
$data['narrative_text'] = substr($this->getDescription(), 0, 80);
}
if ($this->getVatNumber()) {
$data['vatid'] = $this->getVatNumber();
}
// URL orverrides.
$data = array_merge($data, $this->getDataUrl());
// Shipping details.
$data = array_merge($data, $this->getDataShipping());
// Items/Cart details
$data = array_merge($data, $this->getDataItems());
if ($this->getMerchantInvoiceId()) {
$data['invoiceid'] = $this->getMerchantInvoiceId();
}
if ($this->getInvoiceDeliveryMode()) {
$data['invoice_deliverymode'] = $this->getInvoiceDeliveryMode();
}
if ($this->getInvoiceDeliveryDate()) {
$data['invoice_deliverydate'] = $this->getInvoiceDeliveryDate();
}
if ($this->getInvoiceDeliveryEndDate()) {
$data['invoice_deliveryenddate'] = $this->getInvoiceDeliveryEndDate();
}
if ($this->getInvoiceAppendix()) {
$data['invoiceappendix'] = $this->getInvoiceAppendix();
}
if ($this->getWalletType()) {
$data['wallettype'] = $this->getWalletType();
}
if ($this->getOnlinebankTransferType()) {
$data['onlinebanktransfertype'] = $this->getOnlinebankTransferType();
}
if ($this->getBankCountry()) {
$data['bankcountry'] = $this->getBankCountry();
}
if ($this->getIban()) {
$data['iban'] = $this->getIban();
}
if ($this->getMandateId()) {
$data['mandate_identification'] = $this->getMandateId();
}
if ($this->getFinancingtype()) {
$data['financingtype'] = $this->getFinancingtype();
}
return $data;
}
protected function createResponse($data)
{
return $this->response = new ShopServerAuthorizeResponse($this, $data);
}
/**
* See static::INVOICE_DELIVERY_MODE_*
*/
public function setInvoiceDeliveryMode($deliveryMode)
{
return $this->setParameter('invoiceDeliveryMode', $deliveryMode);
}
public function getInvoiceDeliveryMode()
{
return $this->getParameter('invoiceDeliveryMode');
}
public function setInvoiceDeliveryDate($deliveryDate)
{
return $this->setParameter('invoiceDeliveryDate', $deliveryDate);
}
public function getInvoiceDeliveryDate()
{
return $this->getParameter('invoiceDeliveryDate');
}
/**
* @param string $deliveryEndDate Format YYYYMMDD
*/
public function setInvoiceDeliveryEndDate($deliveryEndDate)
{
return $this->setParameter('invoiceDeliveryEndDate', $deliveryEndDate);
}
public function getInvoiceDeliveryEndDate()
{
return $this->getParameter('invoiceDeliveryEndDate');
}
public function setInvoiceAppendix($invoiceAppendix)
{
return $this->setParameter('invoiceAppendix', $invoiceAppendix);
}
public function getInvoiceAppendix()
{
return $this->getParameter('invoiceAppendix');
}
public function setMerchantInvoiceId($invoiceId)
{
return $this->setParameter('merchantInvoiceId', $invoiceId);
}
public function getMerchantInvoiceId()
{
return $this->getParameter('merchantInvoiceId');
}
public function setWalletType($walletType)
{
return $this->setParameter('walletType', $walletType);
}
public function getWalletType()
{
return $this->getParameter('walletType');
}
public function setOnlinebankTransferType($onlinebankTransferType)
{
return $this->setParameter('onlinebankTransferType', $onlinebankTransferType);
}
public function getOnlinebankTransferType()
{
return $this->getParameter('onlinebankTransferType');
}
public function setBankCountry($bankCountry)
{
return $this->setParameter('bankCountry', $bankCountry);
}
public function getBankCountry()
{
return $this->getParameter('bankCountry');
}
public function setIban($iban)
{
return $this->setParameter('iban', $iban);
}
public function getIban()
{
return $this->getParameter('iban');
}
public function getMandateId()
{
return $this->getParameter('mandateId');
}
public function setMandateId($id)
{
return $this->setParameter('mandateId', $id);
}
}