1 | <?php |
||||
2 | |||||
3 | namespace Vrajroham\LaravelBitpay\Traits; |
||||
4 | |||||
5 | use BitPaySDK\Client as BitpayClient; |
||||
6 | use BitPaySDK\Env; |
||||
7 | use BitPaySDK\Tokens; |
||||
8 | use Vrajroham\LaravelBitpay\Exceptions\InvalidConfigurationException; |
||||
9 | |||||
10 | trait LaravelBitpayTrait |
||||
11 | { |
||||
12 | public function authenticate() |
||||
13 | { |
||||
14 | $this->validateAndLoadConfig(); |
||||
15 | |||||
16 | $this->client = BitpayClient::create()->withData( |
||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||||
17 | 'testnet' == $this->config['network'] ? Env::Test : Env::Prod, |
||||
18 | $this->config['private_key'], |
||||
19 | new Tokens( |
||||
20 | $this->config['token'] //merchant |
||||
21 | ), |
||||
22 | $this->config['key_storage_password'] //used to decrypt your private key, if encrypted |
||||
23 | ); |
||||
24 | } |
||||
25 | |||||
26 | public function validateAndLoadConfig() |
||||
27 | { |
||||
28 | $config = config('laravel-bitpay'); |
||||
0 ignored issues
–
show
The function
config was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
29 | |||||
30 | if ('livenet' != $config['network'] && 'testnet' != $config['network']) { |
||||
31 | throw InvalidConfigurationException::invalidNetworkName(); |
||||
32 | } |
||||
33 | |||||
34 | if (!class_exists($config['key_storage'])) { |
||||
35 | throw InvalidConfigurationException::invalidStorageClass(); |
||||
36 | } |
||||
37 | |||||
38 | if ('' === trim($config['key_storage_password'])) { |
||||
39 | throw InvalidConfigurationException::invalidOrEmptyPassword(); |
||||
40 | } |
||||
41 | |||||
42 | if ('' === trim($config['token'])) { |
||||
43 | throw InvalidConfigurationException::emptyToken(); |
||||
44 | } |
||||
45 | |||||
46 | $this->config = $config; |
||||
0 ignored issues
–
show
|
|||||
47 | } |
||||
48 | } |
||||
49 |