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

Braintree::verify()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 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