|
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
|
16 |
|
public function getPhone() |
|
18
|
|
|
{ |
|
19
|
16 |
|
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
|
2 |
|
public function setPhone($value) |
|
30
|
|
|
{ |
|
31
|
2 |
|
return $this->setParameter('phone', $value); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Get custom field 2. |
|
36
|
|
|
* |
|
37
|
|
|
* @return string |
|
38
|
|
|
*/ |
|
39
|
8 |
|
public function getCf2() |
|
40
|
|
|
{ |
|
41
|
8 |
|
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
|
2 |
|
public function setCf2($value) |
|
52
|
|
|
{ |
|
53
|
2 |
|
return $this->setParameter('cf2', $value); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Get custom field 3. |
|
58
|
|
|
* |
|
59
|
|
|
* @return string |
|
60
|
|
|
*/ |
|
61
|
8 |
|
public function getCf3() |
|
62
|
|
|
{ |
|
63
|
8 |
|
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
|
2 |
|
public function setCf3($value) |
|
74
|
|
|
{ |
|
75
|
2 |
|
return $this->setParameter('cf3', $value); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Get callback URL. |
|
80
|
|
|
* |
|
81
|
|
|
* @return string |
|
82
|
|
|
*/ |
|
83
|
8 |
|
public function getCallbackUrl() |
|
84
|
|
|
{ |
|
85
|
8 |
|
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
|
2 |
|
public function setCallbackUrl($value) |
|
96
|
|
|
{ |
|
97
|
2 |
|
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
|
8 |
|
public function getData() |
|
107
|
|
|
{ |
|
108
|
8 |
|
$this->validate( |
|
109
|
8 |
|
'amount', |
|
110
|
8 |
|
'card', |
|
111
|
8 |
|
'transactionId', |
|
112
|
8 |
|
'clientIp', |
|
113
|
|
|
'returnUrl' |
|
114
|
8 |
|
); |
|
115
|
|
|
|
|
116
|
8 |
|
$card = $this->getCard(); |
|
117
|
|
|
|
|
118
|
8 |
|
$card->validate(); |
|
119
|
|
|
|
|
120
|
|
|
$data = array( |
|
121
|
8 |
|
'opcode' => 0, |
|
122
|
8 |
|
'product_id' => $this->getProductId(), |
|
123
|
8 |
|
'amount' => $this->getAmount(), |
|
124
|
8 |
|
'cf' => $this->getTransactionId(), |
|
125
|
8 |
|
'ip_address' => $this->getClientIp(), |
|
126
|
8 |
|
'pan' => $card->getNumber(), |
|
127
|
8 |
|
'cardholder' => $card->getName(), |
|
128
|
8 |
|
'exp_month' => $card->getExpiryMonth(), |
|
129
|
8 |
|
'exp_year' => $card->getExpiryYear(), |
|
130
|
8 |
|
'cvv' => $card->getCvv(), |
|
131
|
8 |
|
'pp_identity' => 'card', |
|
132
|
8 |
|
'token' => $this->getRequestToken(), |
|
133
|
8 |
|
); |
|
134
|
|
|
|
|
135
|
8 |
|
if($this->getPhone()) { |
|
136
|
2 |
|
$data['phone'] = $this->getPhone(); |
|
137
|
2 |
|
} |
|
138
|
8 |
|
if ($this->getCf2()) { |
|
139
|
2 |
|
$data['cf2'] = $this->getCf2(); |
|
140
|
2 |
|
} |
|
141
|
8 |
|
if ($this->getCf3()) { |
|
142
|
2 |
|
$data['cf3'] = $this->getCf3(); |
|
143
|
2 |
|
} |
|
144
|
8 |
|
if ($this->getCallbackUrl()) { |
|
145
|
2 |
|
$data['cb_url'] = $this->getCallbackUrl(); |
|
146
|
2 |
|
} |
|
147
|
|
|
|
|
148
|
8 |
|
return $data; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* Get a request token. |
|
153
|
|
|
* |
|
154
|
|
|
* @return string |
|
155
|
|
|
*/ |
|
156
|
16 |
|
public function getRequestToken() |
|
157
|
|
|
{ |
|
158
|
16 |
|
return md5($this->getMerchantId().$this->getProductId().$this->getAmount().$this->getTransactionId().$this->getPhone().$this->getSecretWord()); |
|
159
|
|
|
} |
|
160
|
|
|
} |
|
161
|
|
|
|