|
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
|
|
|
public function getEndpoint($method) |
|
16
|
|
|
{ |
|
17
|
|
|
return $this->getTestMode() ? $this->endpointTest . $method . "Tst" : $this->endpoint . $method; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
public function getApiKey() |
|
21
|
|
|
{ |
|
22
|
|
|
return $this->getParameter('apikey'); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function setApiKey($value) |
|
26
|
|
|
{ |
|
27
|
|
|
return $this->setParameter('apikey', $value); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function getTestMode() |
|
31
|
|
|
{ |
|
32
|
|
|
return $this->getParameter('testMode'); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function setTestMode($value) |
|
36
|
|
|
{ |
|
37
|
|
|
return $this->setParameter('testMode', $value); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function getUsername() |
|
41
|
|
|
{ |
|
42
|
|
|
if ($this->getTestMode()) { |
|
43
|
|
|
return 'testews'; |
|
44
|
|
|
} |
|
45
|
|
|
return $this->getParameter('username'); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function setUsername($value) |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->setParameter('username', $value); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function getPassword() |
|
54
|
|
|
{ |
|
55
|
|
|
if ($this->getTestMode()) { |
|
56
|
|
|
return 'testews'; |
|
57
|
|
|
} |
|
58
|
|
|
return $this->getParameter('password'); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function setPassword($value) |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->setParameter('password', $value); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function getTransactionReference() |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->getParameter('transactionReference'); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function setTransactionReference($value) |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->setParameter('transactionReference', $value); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function getNumAutor() |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->getParameter('numautor'); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function setNumAutor($value) |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->setParameter('numautor', $value); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* |
|
88
|
|
|
* @param type $data |
|
89
|
|
|
* @param string $method |
|
90
|
|
|
* @return \Omnipay\Common\Message\RequestInterface |
|
91
|
|
|
*/ |
|
92
|
|
|
protected function prepareSendData($data, $method) |
|
93
|
|
|
{ |
|
94
|
|
|
if (!is_array($data)) { |
|
95
|
|
|
$data = array(); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
$httpResponse = $this->httpClient->post($this->getEndpoint($method), null, $data)->send(); |
|
99
|
|
|
|
|
100
|
|
|
return $httpResponse; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
} |
|
104
|
|
|
|