|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* MIT License |
|
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\Ratepay\Business\Api; |
|
9
|
|
|
|
|
10
|
|
|
use Spryker\Zed\Kernel\Business\AbstractBusinessFactory; |
|
11
|
|
|
use SprykerEco\Zed\Ratepay\Business\Api\Builder\BuilderFactory; |
|
12
|
|
|
use SprykerEco\Zed\Ratepay\Business\Api\Constants as ApiConstants; |
|
13
|
|
|
use SprykerEco\Zed\Ratepay\Business\Api\Model\Deliver\Confirm as DeliverConfirm; |
|
14
|
|
|
use SprykerEco\Zed\Ratepay\Business\Api\Model\Payment\Calculation as PaymentCalculation; |
|
15
|
|
|
use SprykerEco\Zed\Ratepay\Business\Api\Model\Payment\Cancel as PaymentCancel; |
|
16
|
|
|
use SprykerEco\Zed\Ratepay\Business\Api\Model\Payment\Configuration as PaymentConfiguration; |
|
17
|
|
|
use SprykerEco\Zed\Ratepay\Business\Api\Model\Payment\Confirm as PaymentConfirm; |
|
18
|
|
|
use SprykerEco\Zed\Ratepay\Business\Api\Model\Payment\Init as PaymentInit; |
|
19
|
|
|
use SprykerEco\Zed\Ratepay\Business\Api\Model\Payment\Refund as PaymentRefund; |
|
20
|
|
|
use SprykerEco\Zed\Ratepay\Business\Api\Model\Payment\Request as PaymentRequest; |
|
21
|
|
|
use SprykerEco\Zed\Ratepay\Business\Api\Model\RequestModelBuilder; |
|
22
|
|
|
use SprykerEco\Zed\Ratepay\Business\Api\Model\Service\Profile as ProfileRequest; |
|
23
|
|
|
|
|
24
|
|
|
class ApiFactory extends AbstractBusinessFactory |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* @var \SprykerEco\Zed\Ratepay\Business\Api\Builder\BuilderFactory |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $builderFactory; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param \SprykerEco\Zed\Ratepay\Business\Api\Builder\BuilderFactory $builderFactory |
|
33
|
|
|
*/ |
|
34
|
|
|
public function __construct(BuilderFactory $builderFactory) |
|
35
|
|
|
{ |
|
36
|
|
|
$this->builderFactory = $builderFactory; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @return \SprykerEco\Zed\Ratepay\Business\Api\Model\RequestModelBuilderInterface |
|
41
|
|
|
*/ |
|
42
|
|
|
public function createRequestModelBuilder() |
|
43
|
|
|
{ |
|
44
|
|
|
$builder = (new RequestModelBuilder()) |
|
45
|
|
|
->registerBuilder(ApiConstants::REQUEST_MODEL_PAYMENT_INIT, $this->createInitModel()) |
|
46
|
|
|
->registerBuilder(ApiConstants::REQUEST_MODEL_PAYMENT_REQUEST, $this->createPaymentRequestModel()) |
|
47
|
|
|
->registerBuilder(ApiConstants::REQUEST_MODEL_PAYMENT_CONFIRM, $this->createPaymentConfirmModel()) |
|
48
|
|
|
->registerBuilder(ApiConstants::REQUEST_MODEL_DELIVER_CONFIRM, $this->createDeliverConfirmModel()) |
|
49
|
|
|
->registerBuilder(ApiConstants::REQUEST_MODEL_PAYMENT_CANCEL, $this->createCancelPayment()) |
|
50
|
|
|
->registerBuilder(ApiConstants::REQUEST_MODEL_PAYMENT_REFUND, $this->createRefundPayment()) |
|
51
|
|
|
->registerBuilder(ApiConstants::REQUEST_MODEL_CONFIGURATION_REQUEST, $this->createConfigurationRequest()) |
|
52
|
|
|
->registerBuilder(ApiConstants::REQUEST_MODEL_CALCULATION_REQUEST, $this->createCalculationRequest()) |
|
53
|
|
|
->registerBuilder(ApiConstants::REQUEST_MODEL_PROFILE, $this->createProfileRequest()); |
|
54
|
|
|
|
|
55
|
|
|
return $builder; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @return \SprykerEco\Zed\Ratepay\Business\Api\Model\RequestInterface |
|
60
|
|
|
*/ |
|
61
|
|
|
protected function createInitModel() |
|
62
|
|
|
{ |
|
63
|
|
|
return new PaymentInit( |
|
64
|
|
|
$this->builderFactory->createHead() |
|
65
|
|
|
); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return \SprykerEco\Zed\Ratepay\Business\Api\Model\RequestInterface |
|
70
|
|
|
*/ |
|
71
|
|
|
protected function createPaymentRequestModel() |
|
72
|
|
|
{ |
|
73
|
|
|
return new PaymentRequest( |
|
74
|
|
|
$this->builderFactory->createHead(), |
|
75
|
|
|
$this->builderFactory->createCustomer(), |
|
76
|
|
|
$this->builderFactory->createShoppingBasket(), |
|
77
|
|
|
$this->builderFactory->createPayment() |
|
78
|
|
|
); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @return \SprykerEco\Zed\Ratepay\Business\Api\Model\RequestInterface |
|
83
|
|
|
*/ |
|
84
|
|
|
protected function createPaymentConfirmModel() |
|
85
|
|
|
{ |
|
86
|
|
|
return new PaymentConfirm( |
|
87
|
|
|
$this->builderFactory->createHead() |
|
88
|
|
|
); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return \SprykerEco\Zed\Ratepay\Business\Api\Model\RequestInterface |
|
93
|
|
|
*/ |
|
94
|
|
|
protected function createDeliverConfirmModel() |
|
95
|
|
|
{ |
|
96
|
|
|
return new DeliverConfirm( |
|
97
|
|
|
$this->builderFactory->createHead(), |
|
98
|
|
|
$this->builderFactory->createShoppingBasket() |
|
99
|
|
|
); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @return \SprykerEco\Zed\Ratepay\Business\Api\Model\RequestInterface |
|
104
|
|
|
*/ |
|
105
|
|
|
protected function createCancelPayment() |
|
106
|
|
|
{ |
|
107
|
|
|
return new PaymentCancel( |
|
108
|
|
|
$this->builderFactory->createHead(), |
|
109
|
|
|
$this->builderFactory->createShoppingBasket() |
|
110
|
|
|
); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @return \SprykerEco\Zed\Ratepay\Business\Api\Model\RequestInterface |
|
115
|
|
|
*/ |
|
116
|
|
|
protected function createRefundPayment() |
|
117
|
|
|
{ |
|
118
|
|
|
return new PaymentRefund( |
|
119
|
|
|
$this->builderFactory->createHead(), |
|
120
|
|
|
$this->builderFactory->createShoppingBasket() |
|
121
|
|
|
); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @return \SprykerEco\Zed\Ratepay\Business\Api\Model\RequestInterface |
|
126
|
|
|
*/ |
|
127
|
|
|
protected function createConfigurationRequest() |
|
128
|
|
|
{ |
|
129
|
|
|
return new PaymentConfiguration( |
|
130
|
|
|
$this->builderFactory->createHead() |
|
131
|
|
|
); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @return \SprykerEco\Zed\Ratepay\Business\Api\Model\RequestInterface |
|
136
|
|
|
*/ |
|
137
|
|
|
protected function createCalculationRequest() |
|
138
|
|
|
{ |
|
139
|
|
|
return new PaymentCalculation( |
|
140
|
|
|
$this->builderFactory->createHead(), |
|
141
|
|
|
$this->builderFactory->createInstallmentCalculation() |
|
142
|
|
|
); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* @return \SprykerEco\Zed\Ratepay\Business\Api\Model\RequestInterface |
|
147
|
|
|
*/ |
|
148
|
|
|
protected function createProfileRequest() |
|
149
|
|
|
{ |
|
150
|
|
|
return new ProfileRequest( |
|
151
|
|
|
$this->builderFactory->createHead() |
|
152
|
|
|
); |
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
|
|
|