1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omnipay\AcquiroPay\Message; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Authorize Request. |
7
|
|
|
* |
8
|
|
|
* @method Response send() |
9
|
|
|
*/ |
10
|
|
|
class AuthorizeRequest extends AbstractRequest |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Get phone. |
14
|
|
|
* |
15
|
|
|
* @return string |
16
|
|
|
*/ |
17
|
24 |
|
public function getPhone() |
18
|
|
|
{ |
19
|
24 |
|
return $this->getParameter('phone'); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Set phone. |
24
|
|
|
* |
25
|
|
|
* @param string $value |
26
|
|
|
* |
27
|
|
|
* @return static|\Omnipay\Common\Message\AbstractRequest |
28
|
|
|
*/ |
29
|
3 |
|
public function setPhone($value) |
30
|
|
|
{ |
31
|
3 |
|
return $this->setParameter('phone', $value); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Get custom field 2. |
36
|
|
|
* |
37
|
|
|
* @return string |
38
|
|
|
*/ |
39
|
12 |
|
public function getCf2() |
40
|
|
|
{ |
41
|
12 |
|
return $this->getParameter('cf2'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Set custom field 2. |
46
|
|
|
* |
47
|
|
|
* @param string $value |
48
|
|
|
* |
49
|
|
|
* @return static|\Omnipay\Common\Message\AbstractRequest |
50
|
|
|
*/ |
51
|
3 |
|
public function setCf2($value) |
52
|
|
|
{ |
53
|
3 |
|
return $this->setParameter('cf2', $value); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Get custom field 3. |
58
|
|
|
* |
59
|
|
|
* @return string |
60
|
|
|
*/ |
61
|
12 |
|
public function getCf3() |
62
|
|
|
{ |
63
|
12 |
|
return $this->getParameter('cf3'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Set custom field 3. |
68
|
|
|
* |
69
|
|
|
* @param string $value |
70
|
|
|
* |
71
|
|
|
* @return static|\Omnipay\Common\Message\AbstractRequest |
72
|
|
|
*/ |
73
|
3 |
|
public function setCf3($value) |
74
|
|
|
{ |
75
|
3 |
|
return $this->setParameter('cf3', $value); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Get callback URL. |
80
|
|
|
* |
81
|
|
|
* @return string |
82
|
|
|
*/ |
83
|
12 |
|
public function getCallbackUrl() |
84
|
|
|
{ |
85
|
12 |
|
return $this->getParameter('callbackUrl'); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Set callback URL. |
90
|
|
|
* |
91
|
|
|
* @param string $value |
92
|
|
|
* |
93
|
|
|
* @return static|\Omnipay\Common\Message\AbstractRequest |
94
|
|
|
*/ |
95
|
3 |
|
public function setCallbackUrl($value) |
96
|
|
|
{ |
97
|
3 |
|
return $this->setParameter('callbackUrl', $value); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Get the raw data array for this message. The format of this varies from gateway to |
102
|
|
|
* gateway, but will usually be either an associative array, or a SimpleXMLElement. |
103
|
|
|
* |
104
|
|
|
* @return array |
105
|
|
|
*/ |
106
|
12 |
|
public function getData() |
107
|
|
|
{ |
108
|
12 |
|
$this->validate( |
109
|
12 |
|
'amount', |
110
|
12 |
|
'card', |
111
|
12 |
|
'transactionId', |
112
|
12 |
|
'clientIp', |
113
|
|
|
'productId' |
114
|
12 |
|
); |
115
|
|
|
|
116
|
12 |
|
$card = $this->getCard(); |
117
|
|
|
|
118
|
12 |
|
$card->validate(); |
119
|
|
|
|
120
|
|
|
$data = array( |
121
|
12 |
|
'opcode' => 0, |
122
|
12 |
|
'product_id' => $this->getProductId(), |
123
|
12 |
|
'amount' => $this->getAmount(), |
124
|
12 |
|
'cf' => $this->getTransactionId(), |
125
|
12 |
|
'ip_address' => $this->getClientIp(), |
126
|
12 |
|
'pan' => $card->getNumber(), |
127
|
12 |
|
'cardholder' => $card->getName(), |
128
|
12 |
|
'exp_month' => $card->getExpiryMonth(), |
129
|
12 |
|
'exp_year' => $card->getExpiryYear(), |
130
|
12 |
|
'cvv' => $card->getCvv(), |
131
|
12 |
|
'pp_identity' => 'card', |
132
|
12 |
|
'token' => $this->getRequestToken(), |
133
|
12 |
|
); |
134
|
|
|
|
135
|
12 |
|
if ($this->getPhone()) { |
136
|
3 |
|
$data['phone'] = $this->getPhone(); |
137
|
3 |
|
} |
138
|
12 |
|
if ($this->getCf2()) { |
139
|
3 |
|
$data['cf2'] = $this->getCf2(); |
140
|
3 |
|
} |
141
|
12 |
|
if ($this->getCf3()) { |
142
|
3 |
|
$data['cf3'] = $this->getCf3(); |
143
|
3 |
|
} |
144
|
12 |
|
if ($this->getCallbackUrl()) { |
145
|
3 |
|
$data['cb_url'] = $this->getCallbackUrl(); |
146
|
3 |
|
} |
147
|
|
|
|
148
|
12 |
|
return $data; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Get a request token. |
153
|
|
|
* |
154
|
|
|
* @return string |
155
|
|
|
*/ |
156
|
24 |
|
public function getRequestToken() |
157
|
|
|
{ |
158
|
24 |
|
return md5($this->getMerchantId().$this->getProductId().$this->getAmount().$this->getTransactionId().$this->getPhone().$this->getSecretWord()); |
159
|
|
|
} |
160
|
|
|
} |
161
|
|
|
|