-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApi.php
44 lines (35 loc) · 949 Bytes
/
Api.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
<?php
declare(strict_types=1);
namespace Payum\Checkoutcom;
use Checkout\CheckoutSdk;
use Checkout\Environment;
use Checkout\CheckoutApi;
use Payum\Checkoutcom\Checkout\HttpClientBuilder;
class Api
{
const TEST = 'test';
const PRODUCTION = 'production';
/**
* @var array
*/
private $options = [];
/**
* @throws \Payum\Core\Exception\InvalidArgumentException if an option is invalid
*/
public function __construct(array $options)
{
$this->options = $options;
}
public function getCheckoutApi(): CheckoutApi
{
return CheckoutSdk::builder()
->staticKeys()
->secretKey($this->options['secret_key'])
->environment($this->options['environment'] === self::PRODUCTION ? Environment::production() : Environment::sandbox())
->build();
}
public function getOptions(): array
{
return $this->options;
}
}