-
Notifications
You must be signed in to change notification settings - Fork 1
/
MockedApi.php
61 lines (53 loc) · 1.42 KB
/
MockedApi.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace PTS\Paysera;
use Http\Message\MessageFactory;
use function League\Uri\create;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\Http\HttpException;
use Payum\Core\HttpClientInterface;
use Payum\Core\Reply\HttpPostRedirect;
use Payum\Core\Reply\HttpResponse;
use Payum\Core\Request\GetHttpRequest;
use Symfony\Component\HttpFoundation\Request;
use WebToPay;
class MockedApi
{
/**
* @var array
*/
protected $options = [];
/**
* Api constructor.
* @param array $options
*/
public function __construct(array $options)
{
$options = ArrayObject::ensureArrayObject($options);
$options->defaults($this->options);
$this->options = $options;
}
public function doPayment(array $fields)
{
$fields['projectid'] = $this->options['projectid'];
$fields['sign_password'] = $this->options['sign_password'];
$this->options['test'] ? $fields['test'] = 1 : $fields['test'] = 0;
$authorizeTokenUrl = $this->getApiEndpoint();
$data = WebToPay::buildRequest($fields);
throw new HttpPostRedirect($authorizeTokenUrl, $data);
}
public function doNotify(array $fields)
{
return true;
}
/**
* @return string
*/
protected function getApiEndpoint()
{
return WebToPay::PAY_URL;
}
public function getApiOptions()
{
return $this->options;
}
}