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

DotpayApi   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 31
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A verifyCallback() 0 3 1
A paidStatus() 0 3 1
A __construct() 0 5 1
A getPaymentUrl() 0 3 1
A createPayment() 0 3 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
}