Passed
Push — master ( 2844e2...c932ad )
by John
03:09
created

DotpayApi::createPaymentLink()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
namespace Evilnet\Dotpay\DotpayApi;
4
5
use Evilnet\Dotpay\DotpayApi\Requests\CreatePaymentLink;
6
7
class DotpayApi
8
{
9
    private $config;
10
    private $client;
11
    private $validator;
12
13
    public function __construct($config)
14
    {
15
        $this->config = $config;
16
        $this->client = new Client($this->config['username'], $this->config['password'], $this->config['base_url']);
17
        $this->validator = new Validator($this->config['pin']);
18
    }
19
20
    public function createPayment($payment)
21
    {
22
        return $this->getPaymentUrl($this->client->makeRequest(new CreatePaymentLink($this->config['shop_id'], $payment)));
23
    }
24
25
    public function getPaymentUrl($payment)
26
    {
27
        return $payment->payment_url;
28
    }
29
30
    public function verifyCallback($data)
31
    {
32
        return $this->validator->verify($data);
33
    }
34
35
    public function paidStatus($status)
36
    {
37
        return (new StatusMapper())->map($status);
38
    }
39
}