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; |
9
|
|
|
|
10
|
|
|
use Spryker\Yves\Kernel\AbstractFactory; |
11
|
|
|
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToQuoteClientInterface; |
12
|
|
|
use SprykerEco\Yves\Braintree\Dependency\Service\BraintreeToUtilEncodingServiceInterface; |
13
|
|
|
use SprykerEco\Yves\Braintree\Form\CreditCardSubForm; |
14
|
|
|
use SprykerEco\Yves\Braintree\Form\DataProvider\CreditCardDataProvider; |
15
|
|
|
use SprykerEco\Yves\Braintree\Form\DataProvider\PayPalDataProvider; |
16
|
|
|
use SprykerEco\Yves\Braintree\Form\PayPalSubForm; |
17
|
|
|
use SprykerEco\Yves\Braintree\Handler\BraintreeHandler; |
18
|
|
|
use SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapper; |
19
|
|
|
use SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapperInterface; |
20
|
|
|
use SprykerEco\Yves\Braintree\Model\Processor\PaypalResponseProcessor; |
21
|
|
|
use SprykerEco\Yves\Braintree\Model\Processor\PaypalResponseProcessorInterface; |
22
|
|
|
|
23
|
|
|
class BraintreeFactory extends AbstractFactory |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @return \Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface |
27
|
|
|
*/ |
28
|
|
|
public function createPayPalForm() |
29
|
|
|
{ |
30
|
|
|
return new PayPalSubForm(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @return \Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface |
35
|
|
|
*/ |
36
|
|
|
public function createCreditCardForm() |
37
|
|
|
{ |
38
|
|
|
return new CreditCardSubForm(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
43
|
|
|
*/ |
44
|
|
|
public function createPayPalFormDataProvider() |
45
|
|
|
{ |
46
|
|
|
return new PayPalDataProvider(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
51
|
|
|
*/ |
52
|
|
|
public function createCreditCardFormDataProvider() |
53
|
|
|
{ |
54
|
|
|
return new CreditCardDataProvider(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return \SprykerEco\Yves\Braintree\Handler\BraintreeHandlerInterface |
59
|
|
|
*/ |
60
|
|
|
public function createBraintreeHandler() |
61
|
|
|
{ |
62
|
|
|
return new BraintreeHandler($this->getCurrencyPlugin()); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return \Spryker\Yves\Currency\Plugin\CurrencyPluginInterface |
67
|
|
|
*/ |
68
|
|
|
public function getCurrencyPlugin() |
69
|
|
|
{ |
70
|
|
|
return $this->getProvidedDependency(BraintreeDependencyProvider::PLUGIN_CURRENCY); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return \SprykerEco\Yves\Braintree\Model\Processor\PaypalResponseProcessorInterface |
75
|
|
|
*/ |
76
|
|
|
public function createResponseProcessor(): PaypalResponseProcessorInterface |
77
|
|
|
{ |
78
|
|
|
return new PaypalResponseProcessor( |
79
|
|
|
$this->createPaypalResponseMapper(), |
80
|
|
|
$this->getQuoteClient() |
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return \SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapperInterface |
86
|
|
|
*/ |
87
|
|
|
public function createPaypalResponseMapper(): PaypalResponseMapperInterface |
88
|
|
|
{ |
89
|
|
|
return new PaypalResponseMapper(); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return BraintreeToUtilEncodingServiceInterface |
94
|
|
|
*/ |
95
|
|
|
public function getUtilEncodingService(): BraintreeToUtilEncodingServiceInterface |
96
|
|
|
{ |
97
|
|
|
return $this->getProvidedDependency(BraintreeDependencyProvider::SERVICE_UTIL_ENCODING); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return BraintreeToQuoteClientInterface |
102
|
|
|
*/ |
103
|
|
|
public function getQuoteClient(): BraintreeToQuoteClientInterface |
104
|
|
|
{ |
105
|
|
|
return $this->getProvidedDependency(BraintreeDependencyProvider::CLIENT_QUOTE); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|