1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omnipay\Komerci; |
4
|
|
|
|
5
|
|
|
use Omnipay\Common\Message\AbstractRequest; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Komerci Authorize Request |
9
|
|
|
*/ |
10
|
|
|
abstract class BaseRequest extends AbstractRequest |
11
|
|
|
{ |
12
|
|
|
protected $endpoint = 'https://ecommerce.userede.com.br/pos_virtual/wskomerci/cap.asmx/'; |
13
|
|
|
protected $endpointTest = 'https://ecommerce.userede.com.br/pos_virtual/wskomerci/cap_teste.asmx/'; |
14
|
|
|
|
15
|
10 |
|
public function getEndpoint($method) |
16
|
|
|
{ |
17
|
10 |
|
return $this->getTestMode() ? $this->endpointTest . $method . "Tst" : $this->endpoint . $method; |
18
|
|
|
} |
19
|
|
|
|
20
|
16 |
|
public function getApiKey() |
21
|
|
|
{ |
22
|
16 |
|
return $this->getParameter('apikey'); |
23
|
|
|
} |
24
|
|
|
|
25
|
20 |
|
public function setApiKey($value) |
26
|
|
|
{ |
27
|
20 |
|
return $this->setParameter('apikey', $value); |
28
|
|
|
} |
29
|
|
|
|
30
|
16 |
|
public function getTestMode() |
31
|
|
|
{ |
32
|
16 |
|
return $this->getParameter('testMode'); |
33
|
|
|
} |
34
|
|
|
|
35
|
20 |
|
public function setTestMode($value) |
36
|
|
|
{ |
37
|
20 |
|
return $this->setParameter('testMode', $value); |
38
|
|
|
} |
39
|
|
|
|
40
|
10 |
|
public function getUsername() |
41
|
|
|
{ |
42
|
10 |
|
if ($this->getTestMode()) { |
43
|
1 |
|
return 'testews'; |
44
|
|
|
} |
45
|
9 |
|
return $this->getParameter('username'); |
46
|
|
|
} |
47
|
|
|
|
48
|
20 |
|
public function setUsername($value) |
49
|
|
|
{ |
50
|
20 |
|
return $this->setParameter('username', $value); |
51
|
|
|
} |
52
|
|
|
|
53
|
10 |
|
public function getPassword() |
54
|
|
|
{ |
55
|
10 |
|
if ($this->getTestMode()) { |
56
|
1 |
|
return 'testews'; |
57
|
|
|
} |
58
|
9 |
|
return $this->getParameter('password'); |
59
|
|
|
} |
60
|
|
|
|
61
|
20 |
|
public function setPassword($value) |
62
|
|
|
{ |
63
|
20 |
|
return $this->setParameter('password', $value); |
64
|
|
|
} |
65
|
|
|
|
66
|
6 |
|
public function getTransactionReference() |
67
|
|
|
{ |
68
|
6 |
|
return $this->getParameter('transactionReference'); |
69
|
|
|
} |
70
|
|
|
|
71
|
6 |
|
public function setTransactionReference($value) |
72
|
|
|
{ |
73
|
6 |
|
return $this->setParameter('transactionReference', $value); |
74
|
|
|
} |
75
|
|
|
|
76
|
6 |
|
public function getNumAutor() |
77
|
|
|
{ |
78
|
6 |
|
return $this->getParameter('numautor'); |
79
|
|
|
} |
80
|
|
|
|
81
|
6 |
|
public function setNumAutor($value) |
82
|
|
|
{ |
83
|
6 |
|
return $this->setParameter('numautor', $value); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function getDate() |
87
|
|
|
{ |
88
|
|
|
return $this->getParameter('date'); |
89
|
|
|
} |
90
|
|
|
|
91
|
5 |
|
public function getFormattedDate() |
92
|
|
|
{ |
93
|
5 |
|
return $this->getParameter('date') |
94
|
5 |
|
? date('Ymd', strtotime(str_replace('/', '-', $this->getParameter('date')))) |
95
|
5 |
|
: date('Ymd'); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function setDate($value) |
99
|
|
|
{ |
100
|
|
|
return $this->setParameter('date', $value); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* |
105
|
|
|
* @param type $data |
106
|
|
|
* @param string $method |
107
|
|
|
* @return \Omnipay\Common\Message\RequestInterface |
108
|
|
|
*/ |
109
|
10 |
|
protected function prepareSendData($data, $method) |
110
|
|
|
{ |
111
|
10 |
|
if (!is_array($data)) { |
112
|
|
|
$data = array(); |
113
|
|
|
} |
114
|
|
|
|
115
|
10 |
|
$httpResponse = $this->httpClient->post($this->getEndpoint($method), null, $data)->send(); |
116
|
|
|
|
117
|
10 |
|
return $httpResponse; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
} |
121
|
|
|
|