|
1
|
|
|
<?php declare(strict_types = 1); |
|
2
|
|
|
|
|
3
|
|
|
namespace SlevomatCsobGateway; |
|
4
|
|
|
|
|
5
|
|
|
use SlevomatCsobGateway\Api\HttpMethod; |
|
6
|
|
|
use SlevomatCsobGateway\Call\ClosePaymentRequest; |
|
7
|
|
|
use SlevomatCsobGateway\Call\CustomerInfoRequest; |
|
8
|
|
|
use SlevomatCsobGateway\Call\EchoRequest; |
|
9
|
|
|
use SlevomatCsobGateway\Call\InitPaymentRequest; |
|
10
|
|
|
use SlevomatCsobGateway\Call\Masterpass\BasicCheckoutRequest; |
|
11
|
|
|
use SlevomatCsobGateway\Call\Masterpass\BasicFinishRequest; |
|
12
|
|
|
use SlevomatCsobGateway\Call\Masterpass\StandardCheckoutRequest; |
|
13
|
|
|
use SlevomatCsobGateway\Call\Masterpass\StandardExtractRequest; |
|
14
|
|
|
use SlevomatCsobGateway\Call\Masterpass\StandardFinishRequest; |
|
15
|
|
|
use SlevomatCsobGateway\Call\OneclickInitPaymentRequest; |
|
16
|
|
|
use SlevomatCsobGateway\Call\OneclickStartPaymentRequest; |
|
17
|
|
|
use SlevomatCsobGateway\Call\PaymentButtonBrand; |
|
18
|
|
|
use SlevomatCsobGateway\Call\PaymentButtonRequest; |
|
19
|
|
|
use SlevomatCsobGateway\Call\PaymentStatusRequest; |
|
20
|
|
|
use SlevomatCsobGateway\Call\PayMethod; |
|
21
|
|
|
use SlevomatCsobGateway\Call\PayOperation; |
|
22
|
|
|
use SlevomatCsobGateway\Call\PostEchoRequest; |
|
23
|
|
|
use SlevomatCsobGateway\Call\ProcessPaymentRequest; |
|
24
|
|
|
use SlevomatCsobGateway\Call\ReceivePaymentRequest; |
|
25
|
|
|
use SlevomatCsobGateway\Call\RefundPaymentRequest; |
|
26
|
|
|
use SlevomatCsobGateway\Call\ReversePaymentRequest; |
|
27
|
|
|
|
|
28
|
|
|
class RequestFactory |
|
29
|
|
|
{ |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var string |
|
33
|
|
|
*/ |
|
34
|
|
|
private $merchantId; |
|
35
|
|
|
|
|
36
|
18 |
|
public function __construct(string $merchantId) |
|
37
|
|
|
{ |
|
38
|
18 |
|
$this->merchantId = $merchantId; |
|
39
|
18 |
|
} |
|
40
|
|
|
|
|
41
|
1 |
|
public function createInitPayment( |
|
42
|
|
|
string $orderId, |
|
43
|
|
|
PayOperation $payOperation, |
|
44
|
|
|
PayMethod $payMethod, |
|
45
|
|
|
bool $closePayment, |
|
46
|
|
|
string $returnUrl, |
|
47
|
|
|
HttpMethod $returnMethod, |
|
48
|
|
|
Cart $cart, |
|
49
|
|
|
string $description, |
|
50
|
|
|
?string $merchantData, |
|
51
|
|
|
?string $customerId, |
|
52
|
|
|
Language $language, |
|
53
|
|
|
?int $ttlSec = null, |
|
54
|
|
|
?int $logoVersion = null, |
|
55
|
|
|
?int $colorSchemeVersion = null |
|
56
|
|
|
): InitPaymentRequest |
|
57
|
|
|
{ |
|
58
|
1 |
|
return new InitPaymentRequest( |
|
59
|
1 |
|
$this->merchantId, |
|
60
|
1 |
|
$orderId, |
|
61
|
1 |
|
$payOperation, |
|
62
|
1 |
|
$payMethod, |
|
63
|
1 |
|
$closePayment, |
|
64
|
1 |
|
$returnUrl, |
|
65
|
1 |
|
$returnMethod, |
|
66
|
1 |
|
$cart, |
|
67
|
1 |
|
$description, |
|
68
|
1 |
|
$merchantData, |
|
69
|
1 |
|
$customerId, |
|
70
|
1 |
|
$language, |
|
71
|
1 |
|
$ttlSec, |
|
72
|
1 |
|
$logoVersion, |
|
73
|
1 |
|
$colorSchemeVersion |
|
74
|
|
|
); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
1 |
|
public function createProcessPayment(string $payId): ProcessPaymentRequest |
|
78
|
|
|
{ |
|
79
|
1 |
|
return new ProcessPaymentRequest( |
|
80
|
1 |
|
$this->merchantId, |
|
81
|
1 |
|
$payId |
|
82
|
|
|
); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
1 |
|
public function createPaymentStatus(string $payId): PaymentStatusRequest |
|
86
|
|
|
{ |
|
87
|
1 |
|
return new PaymentStatusRequest( |
|
88
|
1 |
|
$this->merchantId, |
|
89
|
1 |
|
$payId |
|
90
|
|
|
); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
1 |
|
public function createReversePayment(string $payId): ReversePaymentRequest |
|
94
|
|
|
{ |
|
95
|
1 |
|
return new ReversePaymentRequest( |
|
96
|
1 |
|
$this->merchantId, |
|
97
|
1 |
|
$payId |
|
98
|
|
|
); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
1 |
|
public function createClosePayment(string $payId, ?int $totalAmount = null): ClosePaymentRequest |
|
102
|
|
|
{ |
|
103
|
1 |
|
return new ClosePaymentRequest( |
|
104
|
1 |
|
$this->merchantId, |
|
105
|
1 |
|
$payId, |
|
106
|
1 |
|
$totalAmount |
|
107
|
|
|
); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
1 |
|
public function createRefundPayment(string $payId, ?int $amount = null): RefundPaymentRequest |
|
111
|
|
|
{ |
|
112
|
1 |
|
return new RefundPaymentRequest( |
|
113
|
1 |
|
$this->merchantId, |
|
114
|
1 |
|
$payId, |
|
115
|
1 |
|
$amount |
|
116
|
|
|
); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
1 |
|
public function createEchoRequest(): EchoRequest |
|
120
|
|
|
{ |
|
121
|
1 |
|
return new EchoRequest( |
|
122
|
1 |
|
$this->merchantId |
|
123
|
|
|
); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
1 |
|
public function createPostEchoRequest(): PostEchoRequest |
|
127
|
|
|
{ |
|
128
|
1 |
|
return new PostEchoRequest( |
|
129
|
1 |
|
$this->merchantId |
|
130
|
|
|
); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
1 |
|
public function createCustomerInfo(string $customerId): CustomerInfoRequest |
|
134
|
|
|
{ |
|
135
|
1 |
|
return new CustomerInfoRequest( |
|
136
|
1 |
|
$this->merchantId, |
|
137
|
1 |
|
$customerId |
|
138
|
|
|
); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
1 |
|
public function createReceivePaymentRequest(): ReceivePaymentRequest |
|
142
|
|
|
{ |
|
143
|
1 |
|
return new ReceivePaymentRequest(); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
1 |
|
public function createOneclickInitPayment( |
|
147
|
|
|
string $origPayId, |
|
148
|
|
|
string $orderId, |
|
149
|
|
|
?Price $price = null, |
|
150
|
|
|
?string $description = null |
|
151
|
|
|
): OneclickInitPaymentRequest |
|
152
|
|
|
{ |
|
153
|
1 |
|
return new OneclickInitPaymentRequest( |
|
154
|
1 |
|
$this->merchantId, |
|
155
|
1 |
|
$origPayId, |
|
156
|
1 |
|
$orderId, |
|
157
|
1 |
|
$price, |
|
158
|
1 |
|
$description |
|
159
|
|
|
); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
1 |
|
public function createOneclickStartPayment(string $payId): OneclickStartPaymentRequest |
|
163
|
|
|
{ |
|
164
|
1 |
|
return new OneclickStartPaymentRequest( |
|
165
|
1 |
|
$this->merchantId, |
|
166
|
1 |
|
$payId |
|
167
|
|
|
); |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
1 |
|
public function createMasterpassBasicCheckoutRequest(string $payId, string $callbackUrl): BasicCheckoutRequest |
|
171
|
|
|
{ |
|
172
|
1 |
|
return new BasicCheckoutRequest( |
|
173
|
1 |
|
$this->merchantId, |
|
174
|
1 |
|
$payId, |
|
175
|
1 |
|
$callbackUrl |
|
176
|
|
|
); |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* @param string $payId |
|
181
|
|
|
* @param mixed[] $callbackParams |
|
182
|
|
|
* @return \SlevomatCsobGateway\Call\Masterpass\BasicFinishRequest |
|
183
|
|
|
*/ |
|
184
|
1 |
|
public function createMasterpassBasicFinishRequest(string $payId, array $callbackParams): BasicFinishRequest |
|
185
|
|
|
{ |
|
186
|
1 |
|
return new BasicFinishRequest( |
|
187
|
1 |
|
$this->merchantId, |
|
188
|
1 |
|
$payId, |
|
189
|
1 |
|
$callbackParams |
|
190
|
|
|
); |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
1 |
|
public function createMasterpassStandardCheckoutRequest(string $payId, string $callbackUrl, ?string $shippingLocationProfile = null): StandardCheckoutRequest |
|
194
|
|
|
{ |
|
195
|
1 |
|
return new StandardCheckoutRequest($this->merchantId, $payId, $callbackUrl, $shippingLocationProfile); |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
/** |
|
199
|
|
|
* @param string $payId |
|
200
|
|
|
* @param mixed[] $callbackParams |
|
201
|
|
|
* @return \SlevomatCsobGateway\Call\Masterpass\StandardExtractRequest |
|
202
|
|
|
*/ |
|
203
|
1 |
|
public function createMasterpassStandardExtractRequest(string $payId, array $callbackParams): StandardExtractRequest |
|
204
|
|
|
{ |
|
205
|
1 |
|
return new StandardExtractRequest($this->merchantId, $payId, $callbackParams); |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
1 |
|
public function createMasterpassStandardFinishRequest(string $payId, string $oauthToken, int $totalAmount): StandardFinishRequest |
|
209
|
|
|
{ |
|
210
|
1 |
|
return new StandardFinishRequest( |
|
211
|
1 |
|
$this->merchantId, |
|
212
|
1 |
|
$payId, |
|
213
|
1 |
|
$oauthToken, |
|
214
|
1 |
|
$totalAmount |
|
215
|
|
|
); |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
1 |
|
public function createPaymentButtonRequest(string $payId, PaymentButtonBrand $brand): PaymentButtonRequest |
|
219
|
|
|
{ |
|
220
|
1 |
|
return new PaymentButtonRequest( |
|
221
|
1 |
|
$this->merchantId, |
|
222
|
1 |
|
$payId, |
|
223
|
1 |
|
$brand |
|
224
|
|
|
); |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
} |
|
228
|
|
|
|