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