1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omnipay\Sofort\Message; |
4
|
|
|
|
5
|
|
|
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest |
6
|
|
|
{ |
7
|
|
|
protected $endpoint = 'https://api.sofort.com/api/xml'; |
8
|
|
|
|
9
|
|
|
public function getUsername() |
10
|
|
|
{ |
11
|
|
|
return $this->getParameter('username'); |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
public function setUsername($value) |
15
|
|
|
{ |
16
|
|
|
return $this->setParameter('username', $value); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public function getPassword() |
20
|
|
|
{ |
21
|
|
|
return $this->getParameter('password'); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function setPassword($value) |
25
|
|
|
{ |
26
|
|
|
return $this->setParameter('password', $value); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function getProjectId() |
30
|
|
|
{ |
31
|
|
|
return $this->getParameter('projectId'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function setProjectId($value) |
35
|
|
|
{ |
36
|
|
|
return $this->setParameter('projectId', $value); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function getCountry() |
40
|
|
|
{ |
41
|
|
|
return $this->getParameter('country'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function setCountry($value) |
45
|
|
|
{ |
46
|
|
|
return $this->setParameter('country', $value); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function getProtection() |
50
|
|
|
{ |
51
|
|
|
return $this->getParameter('protection'); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function setProtection($value) |
55
|
|
|
{ |
56
|
|
|
return $this->setParameter('protection', $value); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function sendData($data) |
60
|
|
|
{ |
61
|
|
|
$options = ['Authorization' => 'Basic ' . base64_encode($this->getUsername() . ':' . $this->getPassword())]; |
62
|
|
|
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $options, $data->asXML()); |
63
|
|
|
|
64
|
|
|
return $this->createResponse($httpResponse); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
abstract protected function createResponse($httpResponse); |
68
|
|
|
|
69
|
|
|
protected function getEndpoint() |
70
|
|
|
{ |
71
|
|
|
return $this->endpoint; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|