Completed
Push — master ( 3a2f0f...dbf695 )
by Ashley
13s
created

Braintree   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 28
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A verify() 0 12 2
A configure() 0 7 1
A headers() 0 4 1
1
<?php
2
3
namespace Clarkeash\Shield\Services;
4
5
use Braintree_Configuration;
6
use Braintree_Exception_InvalidSignature;
7
use Braintree_WebhookNotification;
8
use Illuminate\Http\Request;
9
10
class Braintree extends BaseService
11
{
12
    public function verify(Request $request): bool
13
    {
14
        $this->configure();
15
16
        try {
17
            Braintree_WebhookNotification::parse($request->bt_signature, $request->bt_payload);
18
        } catch (Braintree_Exception_InvalidSignature $exception) {
0 ignored issues
show
Bug introduced by
The class Braintree_Exception_InvalidSignature does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
19
            return false;
20
        }
21
22
        return true;
23
    }
24
25
    protected function configure()
26
    {
27
        Braintree_Configuration::environment(config('shield.services.braintree.environment'));
28
        Braintree_Configuration::merchantId(config('shield.services.braintree.merchant_id'));
29
        Braintree_Configuration::publicKey(config('shield.services.braintree.public_key'));
30
        Braintree_Configuration::privateKey(config('shield.services.braintree.private_key'));
31
    }
32
33
    public function headers(): array
34
    {
35
        return [];
36
    }
37
}
38