|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ByTIC\Omnipay\Paylike\Message; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class PurchaseRequest |
|
7
|
|
|
* @package ByTIC\Omnipay\Paylike\Message |
|
8
|
|
|
* |
|
9
|
|
|
* @method PurchaseResponse send() |
|
10
|
|
|
*/ |
|
11
|
|
|
class PurchaseRequest extends AbstractRequest |
|
12
|
|
|
{ |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @inheritdoc |
|
16
|
|
|
*/ |
|
17
|
|
|
public function initialize(array $parameters = []) |
|
18
|
|
|
{ |
|
19
|
|
|
$parameters['identifier'] = isset($parameters['identifier']) ? |
|
20
|
|
|
$parameters['identifier'] : 'anonymous'.microtime(true); |
|
21
|
|
|
|
|
22
|
|
|
return parent::initialize($parameters); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @return array |
|
27
|
|
|
* @throws \Omnipay\Common\Exception\InvalidRequestException |
|
28
|
|
|
*/ |
|
29
|
|
|
public function getData() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->validate( |
|
32
|
|
|
'publicKey', |
|
33
|
|
|
'amount', |
|
34
|
|
|
'currency', |
|
35
|
|
|
'description', |
|
36
|
|
|
'orderId', |
|
37
|
|
|
'returnUrl', |
|
38
|
|
|
'card' |
|
39
|
|
|
); |
|
40
|
|
|
|
|
41
|
|
|
$data = [ |
|
42
|
|
|
'publicKey' => $this->getPublicKey(), |
|
43
|
|
|
'returnUrl' => $this->getReturnUrl(), |
|
44
|
|
|
'identifier' => $this->getIdentifier(), |
|
45
|
|
|
'orderId' => $this->getOrderId(), |
|
46
|
|
|
'amount' => $this->getAmount(), |
|
47
|
|
|
'currency' => $this->getCurrency(), |
|
48
|
|
|
'title' => $this->getTitle(), |
|
49
|
|
|
'description' => $this->getDescription(), |
|
50
|
|
|
'clientIp' => $this->getClientIp(), |
|
51
|
|
|
]; |
|
52
|
|
|
|
|
53
|
|
|
$card = $this->getCard(); |
|
54
|
|
|
|
|
55
|
|
|
$data['firstName'] = $card->getBillingFirstName(); |
|
56
|
|
|
$data['lastName'] = $card->getBillingLastName(); |
|
57
|
|
|
$data['address'] = $card->getBillingAddress1(); |
|
58
|
|
|
$data['phone'] = $card->getBillingPhone(); |
|
59
|
|
|
$data['email'] = $card->getEmail(); |
|
60
|
|
|
|
|
61
|
|
|
return $data; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @return mixed |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getIdentifier() |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->getParameter('identifier'); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @param $value |
|
74
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest |
|
75
|
|
|
*/ |
|
76
|
|
|
public function setIdentifier($value) |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->setParameter('identifier', $value); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @return mixed |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getOrderId() |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->getParameter('orderId'); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param $value |
|
91
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest |
|
92
|
|
|
*/ |
|
93
|
|
|
public function setOrderId($value) |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->setParameter('orderId', $value); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @return mixed |
|
100
|
|
|
*/ |
|
101
|
|
|
public function getTitle() |
|
102
|
|
|
{ |
|
103
|
|
|
return $this->getParameter('title'); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @param $value |
|
108
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest |
|
109
|
|
|
*/ |
|
110
|
|
|
public function setTitle($value) |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->setParameter('title', $value); |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|