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 Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface; |
12
|
|
|
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToGlossaryClientInterface; |
13
|
|
|
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToPaymentClientInterface; |
14
|
|
|
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToQuoteClientInterface; |
15
|
|
|
use SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToShipmentClientInterface; |
16
|
|
|
use SprykerEco\Yves\Braintree\Dependency\Service\BraintreeToUtilEncodingServiceInterface; |
17
|
|
|
use SprykerEco\Yves\Braintree\Form\CreditCardSubForm; |
18
|
|
|
use SprykerEco\Yves\Braintree\Form\DataProvider\CheckoutShipmentFormDataProvider; |
19
|
|
|
use SprykerEco\Yves\Braintree\Form\DataProvider\CreditCardDataProvider; |
20
|
|
|
use SprykerEco\Yves\Braintree\Form\DataProvider\PayPalDataProvider; |
21
|
|
|
use SprykerEco\Yves\Braintree\Form\PayPalExpressSubForm; |
22
|
|
|
use SprykerEco\Yves\Braintree\Form\PayPalSubForm; |
23
|
|
|
use SprykerEco\Yves\Braintree\Handler\BraintreeHandler; |
24
|
|
|
use SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapper; |
25
|
|
|
use SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapperInterface; |
26
|
|
|
use SprykerEco\Yves\Braintree\Model\Processor\PaypalResponseProcessor; |
27
|
|
|
use SprykerEco\Yves\Braintree\Model\Processor\PaypalResponseProcessorInterface; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @method \SprykerEco\Yves\Braintree\BraintreeConfig getConfig() |
31
|
|
|
*/ |
32
|
|
|
class BraintreeFactory extends AbstractFactory |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @return \Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface |
36
|
|
|
*/ |
37
|
|
|
public function createPayPalForm() |
38
|
|
|
{ |
39
|
|
|
return new PayPalSubForm(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return \Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface |
44
|
|
|
*/ |
45
|
|
|
public function createPayPalExpressForm() |
46
|
|
|
{ |
47
|
|
|
return new PayPalExpressSubForm(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return \Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface |
52
|
|
|
*/ |
53
|
|
|
public function createCreditCardForm() |
54
|
|
|
{ |
55
|
|
|
return new CreditCardSubForm(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
60
|
|
|
*/ |
61
|
|
|
public function createPayPalFormDataProvider() |
62
|
|
|
{ |
63
|
|
|
return new PayPalDataProvider(); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
68
|
|
|
*/ |
69
|
|
|
public function createPayPalExpressFormDataProvider() |
70
|
|
|
{ |
71
|
|
|
return new PayPalDataProvider(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
76
|
|
|
*/ |
77
|
|
|
public function createCreditCardFormDataProvider() |
78
|
|
|
{ |
79
|
|
|
return new CreditCardDataProvider(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return \SprykerEco\Yves\Braintree\Handler\BraintreeHandlerInterface |
84
|
|
|
*/ |
85
|
|
|
public function createBraintreeHandler() |
86
|
|
|
{ |
87
|
|
|
return new BraintreeHandler($this->getCurrencyPlugin()); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return \Spryker\Yves\Currency\Plugin\CurrencyPluginInterface |
92
|
|
|
*/ |
93
|
|
|
public function getCurrencyPlugin() |
94
|
|
|
{ |
95
|
|
|
return $this->getProvidedDependency(BraintreeDependencyProvider::PLUGIN_CURRENCY); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @return \SprykerEco\Yves\Braintree\Model\Processor\PaypalResponseProcessorInterface |
100
|
|
|
*/ |
101
|
|
|
public function createResponseProcessor(): PaypalResponseProcessorInterface |
102
|
|
|
{ |
103
|
|
|
return new PaypalResponseProcessor( |
104
|
|
|
$this->createPaypalResponseMapper(), |
105
|
|
|
$this->getQuoteClient() |
106
|
|
|
); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return \SprykerEco\Yves\Braintree\Model\Mapper\PaypalResponse\PaypalResponseMapperInterface |
111
|
|
|
*/ |
112
|
|
|
public function createPaypalResponseMapper(): PaypalResponseMapperInterface |
113
|
|
|
{ |
114
|
|
|
return new PaypalResponseMapper($this->getPaymentClient()); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return \SprykerEco\Yves\Braintree\Dependency\Service\BraintreeToUtilEncodingServiceInterface |
119
|
|
|
*/ |
120
|
|
|
public function getUtilEncodingService(): BraintreeToUtilEncodingServiceInterface |
121
|
|
|
{ |
122
|
|
|
return $this->getProvidedDependency(BraintreeDependencyProvider::SERVICE_UTIL_ENCODING); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @return \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToQuoteClientInterface |
127
|
|
|
*/ |
128
|
|
|
public function getQuoteClient(): BraintreeToQuoteClientInterface |
129
|
|
|
{ |
130
|
|
|
return $this->getProvidedDependency(BraintreeDependencyProvider::CLIENT_QUOTE); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @return \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToShipmentClientInterface |
135
|
|
|
*/ |
136
|
|
|
public function getShipmentClient(): BraintreeToShipmentClientInterface |
137
|
|
|
{ |
138
|
|
|
return $this->getProvidedDependency(BraintreeDependencyProvider::CLIENT_SHIPMENT); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @return \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToGlossaryClientInterface |
143
|
|
|
*/ |
144
|
|
|
public function getGlossaryClient(): BraintreeToGlossaryClientInterface |
145
|
|
|
{ |
146
|
|
|
return $this->getProvidedDependency(BraintreeDependencyProvider::CLIENT_GLOSSARY); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @return \SprykerEco\Yves\Braintree\Dependency\Client\BraintreeToPaymentClientInterface |
151
|
|
|
*/ |
152
|
|
|
public function getPaymentClient(): BraintreeToPaymentClientInterface |
153
|
|
|
{ |
154
|
|
|
return $this->getProvidedDependency(BraintreeDependencyProvider::CLIENT_PAYMENT); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @return \Spryker\Shared\Money\Dependency\Plugin\MoneyPluginInterface |
159
|
|
|
*/ |
160
|
|
|
public function getMoneyPlugin() |
161
|
|
|
{ |
162
|
|
|
return $this->getProvidedDependency(BraintreeDependencyProvider::PLUGIN_MONEY); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @return \Spryker\Shared\Kernel\Store |
167
|
|
|
*/ |
168
|
|
|
public function getStore() |
169
|
|
|
{ |
170
|
|
|
return $this->getProvidedDependency(BraintreeDependencyProvider::STORE); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
175
|
|
|
*/ |
176
|
|
|
public function createBraintreePaypalExpressShipmentFormDataProvider(): StepEngineFormDataProviderInterface |
177
|
|
|
{ |
178
|
|
|
return new CheckoutShipmentFormDataProvider( |
179
|
|
|
$this->getShipmentClient(), |
180
|
|
|
$this->getGlossaryClient(), |
181
|
|
|
$this->getStore(), |
182
|
|
|
$this->getMoneyPlugin() |
183
|
|
|
); |
184
|
|
|
} |
185
|
|
|
} |
186
|
|
|
|