1
|
|
|
<?php |
2
|
|
|
namespace Omnipay\Heidelpay\Message; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Payment Request |
6
|
|
|
* |
7
|
|
|
* @method Response send() |
8
|
|
|
*/ |
9
|
|
|
class PaymentRequest extends AbstractRequest |
10
|
|
|
{ |
11
|
|
|
public function getData() |
12
|
|
|
{ |
13
|
|
|
$this->validate('amount', 'currency', 'typeId'); |
14
|
|
|
|
15
|
|
|
$data = []; |
16
|
|
|
$data['amount'] = $this->getAmount(); |
17
|
|
|
$data['currency'] = $this->getCurrency(); |
18
|
|
|
|
19
|
|
|
if ($this->getReturnUrl()) { |
20
|
|
|
$data['returnUrl'] = $this->getReturnUrl(); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
if ($this->getTransactionId()) { |
24
|
|
|
$data['orderId'] = $this->getTransactionId(); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
$data['resources'] = [ |
28
|
|
|
'typeId' => $this->getTypeId() |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
if ($this->getCustomerId()) { |
32
|
|
|
$data['resources']['customerId'] = $this->getCustomerId(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
if ($this->getBasketId()) { |
36
|
|
|
$data['resources']['basketId'] = $this->getBasketId(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
if ($this->getMetaDataId()) { |
40
|
|
|
$data['resources']['metadataid'] = $this->getMetaDataId(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
return $data; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function getMetaDataId() |
47
|
|
|
{ |
48
|
|
|
return $this->getParameter('metadataid'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function setMetaDataId($value) |
52
|
|
|
{ |
53
|
|
|
return $this->setParameter('metadataid', $value); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function getBasketId() |
57
|
|
|
{ |
58
|
|
|
return $this->getParameter('basketId'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function setBasketId($value) |
62
|
|
|
{ |
63
|
|
|
return $this->setParameter('basketId', $value); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function getCustomerId() |
67
|
|
|
{ |
68
|
|
|
return $this->getParameter('customerId'); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function setCustomerId($value) |
72
|
|
|
{ |
73
|
|
|
return $this->setParameter('customerId', $value); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function getTypeId() |
77
|
|
|
{ |
78
|
|
|
return $this->getParameter('typeId'); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function setTypeId($value) |
82
|
|
|
{ |
83
|
|
|
return $this->setParameter('typeId', $value); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function getEndpoint() |
87
|
|
|
{ |
88
|
|
|
return parent::getEndpoint() . 'payments/'; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
protected function createResponse($data) |
92
|
|
|
{ |
93
|
|
|
return $this->response = new PaymentResponse($this, $data); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|