|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* MIT License |
|
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Yves\Braintree\Form; |
|
9
|
|
|
|
|
10
|
|
|
use Braintree\ClientToken; |
|
11
|
|
|
use Braintree\Configuration; |
|
12
|
|
|
use Generated\Shared\Transfer\BraintreePaymentTransfer; |
|
|
|
|
|
|
13
|
|
|
use Spryker\Shared\Config\Config; |
|
14
|
|
|
use Spryker\Yves\StepEngine\Dependency\Form\AbstractSubFormType; |
|
15
|
|
|
use Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface; |
|
16
|
|
|
use Spryker\Yves\StepEngine\Dependency\Form\SubFormProviderNameInterface; |
|
17
|
|
|
use SprykerEco\Shared\Braintree\BraintreeConfig; |
|
18
|
|
|
use SprykerEco\Shared\Braintree\BraintreeConstants; |
|
19
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
20
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
abstract class AbstractSubForm extends AbstractSubFormType implements SubFormInterface, SubFormProviderNameInterface |
|
23
|
|
|
{ |
|
24
|
|
|
protected const CLIENT_TOKEN = 'clientToken'; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var string |
|
28
|
|
|
*/ |
|
29
|
|
|
protected static $clientToken; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver |
|
33
|
|
|
* |
|
34
|
|
|
* @return void |
|
35
|
|
|
*/ |
|
36
|
|
|
public function configureOptions(OptionsResolver $resolver) |
|
37
|
|
|
{ |
|
38
|
|
|
$resolver->setDefaults([ |
|
39
|
|
|
'data_class' => BraintreePaymentTransfer::class, |
|
40
|
|
|
SubFormInterface::OPTIONS_FIELD_NAME => [], |
|
41
|
|
|
]); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @return string |
|
46
|
|
|
*/ |
|
47
|
|
|
public function getProviderName() |
|
48
|
|
|
{ |
|
49
|
|
|
return BraintreeConfig::PROVIDER_NAME; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Generate client token and store it in static class attribute to ensure |
|
54
|
|
|
* we do not invoke the API twice here for multiple sub forms. |
|
55
|
|
|
* |
|
56
|
|
|
* @return string |
|
57
|
|
|
*/ |
|
58
|
|
|
protected function generateClientToken() |
|
59
|
|
|
{ |
|
60
|
|
|
if (static::$clientToken) { |
|
61
|
|
|
return static::$clientToken; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
$environment = Config::get(BraintreeConstants::ENVIRONMENT); |
|
65
|
|
|
$merchantId = Config::get(BraintreeConstants::MERCHANT_ID); |
|
66
|
|
|
$publicKey = Config::get(BraintreeConstants::PUBLIC_KEY); |
|
67
|
|
|
$privateKey = Config::get(BraintreeConstants::PRIVATE_KEY); |
|
68
|
|
|
Configuration::environment($environment); |
|
69
|
|
|
Configuration::merchantId($merchantId); |
|
70
|
|
|
Configuration::publicKey($publicKey); |
|
71
|
|
|
Configuration::privateKey($privateKey); |
|
72
|
|
|
|
|
73
|
|
|
static::$clientToken = ClientToken::generate(); |
|
74
|
|
|
|
|
75
|
|
|
return static::$clientToken; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths