|
1
|
|
|
<?php declare(strict_types = 1); |
|
2
|
|
|
|
|
3
|
|
|
namespace SlevomatCsobGateway; |
|
4
|
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
|
6
|
|
|
use SlevomatCsobGateway\Api\HttpMethod; |
|
7
|
|
|
use SlevomatCsobGateway\Call\Button\PaymentButtonBrand; |
|
8
|
|
|
use SlevomatCsobGateway\Call\PayMethod; |
|
9
|
|
|
use SlevomatCsobGateway\Call\PayOperation; |
|
10
|
|
|
|
|
11
|
|
|
class RequestFactoryTest extends TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
|
|
14
|
|
|
/** @var RequestFactory */ |
|
15
|
|
|
private $requestFactory; |
|
16
|
|
|
|
|
17
|
|
|
protected function setUp(): void |
|
18
|
|
|
{ |
|
19
|
|
|
$this->requestFactory = new RequestFactory('012345'); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function testCreateInitPayment(): void |
|
23
|
|
|
{ |
|
24
|
|
|
$cart = new Cart( |
|
25
|
|
|
Currency::get(Currency::CZK) |
|
26
|
|
|
); |
|
27
|
|
|
$cart->addItem('Nákup na vasobchodcz', 1, 1789600, 'Lenovo ThinkPad Edge E540'); |
|
28
|
|
|
$cart->addItem('Poštovné', 1, 0, 'Doprava PPL'); |
|
29
|
|
|
|
|
30
|
|
|
$this->requestFactory->createInitPayment( |
|
31
|
|
|
'5547', |
|
32
|
|
|
PayOperation::get(PayOperation::PAYMENT), |
|
33
|
|
|
PayMethod::get(PayMethod::CARD), |
|
34
|
|
|
true, |
|
35
|
|
|
'https://vasobchod.cz/gateway-return', |
|
36
|
|
|
HttpMethod::get(HttpMethod::POST), |
|
37
|
|
|
$cart, |
|
38
|
|
|
'some-base64-encoded-merchant-data', |
|
39
|
|
|
'123', |
|
40
|
|
|
Language::get(Language::CZ), |
|
41
|
|
|
1800, |
|
42
|
|
|
1, |
|
43
|
|
|
1 |
|
44
|
|
|
); |
|
45
|
|
|
|
|
46
|
|
|
self::assertTrue(true); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function testCreateProcessPayment(): void |
|
50
|
|
|
{ |
|
51
|
|
|
$this->requestFactory->createProcessPayment('123456789'); |
|
52
|
|
|
|
|
53
|
|
|
self::assertTrue(true); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function testCreatePaymentStatus(): void |
|
57
|
|
|
{ |
|
58
|
|
|
$this->requestFactory->createPaymentStatus('123456789'); |
|
59
|
|
|
|
|
60
|
|
|
self::assertTrue(true); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function testCreateReversePayment(): void |
|
64
|
|
|
{ |
|
65
|
|
|
$this->requestFactory->createReversePayment('123456789'); |
|
66
|
|
|
|
|
67
|
|
|
self::assertTrue(true); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function testCreateClosePayment(): void |
|
71
|
|
|
{ |
|
72
|
|
|
$this->requestFactory->createClosePayment('123456789'); |
|
73
|
|
|
|
|
74
|
|
|
self::assertTrue(true); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function testCreateRefundPayment(): void |
|
78
|
|
|
{ |
|
79
|
|
|
$this->requestFactory->createRefundPayment('123456789'); |
|
80
|
|
|
|
|
81
|
|
|
self::assertTrue(true); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
public function testCreateEchoRequest(): void |
|
85
|
|
|
{ |
|
86
|
|
|
$this->requestFactory->createEchoRequest(); |
|
87
|
|
|
|
|
88
|
|
|
self::assertTrue(true); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
public function testCreatePostEchoRequest(): void |
|
92
|
|
|
{ |
|
93
|
|
|
$this->requestFactory->createPostEchoRequest(); |
|
94
|
|
|
|
|
95
|
|
|
self::assertTrue(true); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function testCreateCustomerInfo(): void |
|
99
|
|
|
{ |
|
100
|
|
|
$this->requestFactory->createCustomerInfo('[email protected]'); |
|
101
|
|
|
|
|
102
|
|
|
self::assertTrue(true); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
public function testCreateReceivePayment(): void |
|
106
|
|
|
{ |
|
107
|
|
|
$this->requestFactory->createReceivePaymentRequest(); |
|
108
|
|
|
|
|
109
|
|
|
self::assertTrue(true); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
public function testCreateOneclickInitPayment(): void |
|
113
|
|
|
{ |
|
114
|
|
|
$this->requestFactory->createOneclickInitPayment( |
|
115
|
|
|
'ef08b6e9f22345c', |
|
116
|
|
|
'5547123', |
|
117
|
|
|
'127.0.0.1', |
|
118
|
|
|
new Price(1789600, Currency::get(Currency::CZK)), |
|
119
|
|
|
'Nákup na vasobchod.cz (Lenovo ThinkPad Edge E540, Doprava PPL)' |
|
120
|
|
|
); |
|
121
|
|
|
|
|
122
|
|
|
self::assertTrue(true); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
public function testCreateOneclickStartPayment(): void |
|
126
|
|
|
{ |
|
127
|
|
|
$this->requestFactory->createOneclickStartPayment('ef08b6e9f22345c'); |
|
128
|
|
|
|
|
129
|
|
|
self::assertTrue(true); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
public function testCreateMasterpassBasicCheckoutRequest(): void |
|
133
|
|
|
{ |
|
134
|
|
|
$this->requestFactory->createMasterpassBasicCheckoutRequest('ef08b6e9f22345c', 'https://www.example.com/callback'); |
|
135
|
|
|
|
|
136
|
|
|
self::assertTrue(true); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
public function testCreateMasterpassBasicFinishRequest(): void |
|
140
|
|
|
{ |
|
141
|
|
|
$callbackParams = [ |
|
142
|
|
|
'mpstatus' => 'success', |
|
143
|
|
|
'oauthToken' => '6a79bf9e320a0460d08aee7ad154f7dab4e19503', |
|
144
|
|
|
'checkoutResourceUrl' => 'https://sandbox.api.mastercard.com/masterpass/v6/checkout/616764812', |
|
145
|
|
|
'oauthVerifier' => 'fc8f41bb76ed7d43ea6d714cb8fdefa606611a7d', |
|
146
|
|
|
]; |
|
147
|
|
|
$this->requestFactory->createMasterpassBasicFinishRequest('ef08b6e9f22345c', $callbackParams); |
|
148
|
|
|
|
|
149
|
|
|
self::assertTrue(true); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
public function testCreateMasterpassStandardCheckoutRequest(): void |
|
153
|
|
|
{ |
|
154
|
|
|
$this->requestFactory->createMasterpassStandardCheckoutRequest('ef08b6e9f22345c', 'https://www.example.com/callback', 'SP123'); |
|
155
|
|
|
|
|
156
|
|
|
self::assertTrue(true); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
public function testCreateMasterpassStandardExtractRequest(): void |
|
160
|
|
|
{ |
|
161
|
|
|
$callbackParams = [ |
|
162
|
|
|
'mpstatus' => 'success', |
|
163
|
|
|
'oauthToken' => '6a79bf9e320a0460d08aee7ad154f7dab4e19503', |
|
164
|
|
|
'checkoutResourceUrl' => 'https://sandbox.api.mastercard.com/masterpass/v6/checkout/616764812', |
|
165
|
|
|
'oauthVerifier' => 'fc8f41bb76ed7d43ea6d714cb8fdefa606611a7d', |
|
166
|
|
|
]; |
|
167
|
|
|
$this->requestFactory->createMasterpassStandardExtractRequest('ef08b6e9f22345c', $callbackParams); |
|
168
|
|
|
|
|
169
|
|
|
self::assertTrue(true); |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
public function testCreateMasterpassStandardFinishRequest(): void |
|
173
|
|
|
{ |
|
174
|
|
|
$this->requestFactory->createMasterpassStandardFinishRequest('ef08b6e9f22345c', '123456789', 15000); |
|
175
|
|
|
|
|
176
|
|
|
self::assertTrue(true); |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
public function testCreatePaymentButtonRequest(): void |
|
180
|
|
|
{ |
|
181
|
|
|
$this->requestFactory->createPaymentButtonRequest( |
|
182
|
|
|
'123456', |
|
183
|
|
|
'::1', |
|
184
|
|
|
new Price(12500, Currency::get(Currency::CZK)), |
|
185
|
|
|
'https://www.example.com/return', |
|
186
|
|
|
HttpMethod::get(HttpMethod::GET), |
|
187
|
|
|
PaymentButtonBrand::get(PaymentButtonBrand::ERA), |
|
188
|
|
|
null, |
|
189
|
|
|
Language::get(Language::EN) |
|
190
|
|
|
); |
|
191
|
|
|
|
|
192
|
|
|
self::assertTrue(true); |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
public function testCreateApplePayInitRequest(): void |
|
196
|
|
|
{ |
|
197
|
|
|
$this->requestFactory->createApplePayInitRequest( |
|
198
|
|
|
'1234567', |
|
199
|
|
|
'127.0.0.1', |
|
200
|
|
|
new Price(1789600, Currency::get(Currency::CZK)), |
|
201
|
|
|
true, |
|
202
|
|
|
'Order from example.com', |
|
203
|
|
|
null |
|
204
|
|
|
); |
|
205
|
|
|
|
|
206
|
|
|
self::assertTrue(true); |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
public function testCreateApplePayStartRequest(): void |
|
210
|
|
|
{ |
|
211
|
|
|
$this->requestFactory->createApplePayStartRequest( |
|
212
|
|
|
'ef08b6e9f22345c', |
|
213
|
|
|
[] |
|
214
|
|
|
); |
|
215
|
|
|
|
|
216
|
|
|
self::assertTrue(true); |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
public function testCreateOneClickEchoRequest(): void |
|
220
|
|
|
{ |
|
221
|
|
|
$this->requestFactory->createOneClickEchoRequest('ef08b6e9f22345c'); |
|
222
|
|
|
|
|
223
|
|
|
self::assertTrue(true); |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
} |
|
227
|
|
|
|