|
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\OneclickInitPaymentRequest; |
|
11
|
|
|
use SlevomatCsobGateway\Call\OneclickStartPaymentRequest; |
|
12
|
|
|
use SlevomatCsobGateway\Call\PaymentStatusRequest; |
|
13
|
|
|
use SlevomatCsobGateway\Call\PayMethod; |
|
14
|
|
|
use SlevomatCsobGateway\Call\PayOperation; |
|
15
|
|
|
use SlevomatCsobGateway\Call\PostEchoRequest; |
|
16
|
|
|
use SlevomatCsobGateway\Call\ProcessPaymentRequest; |
|
17
|
|
|
use SlevomatCsobGateway\Call\ReceivePaymentRequest; |
|
18
|
|
|
use SlevomatCsobGateway\Call\RefundPaymentRequest; |
|
19
|
|
|
use SlevomatCsobGateway\Call\ReversePaymentRequest; |
|
20
|
|
|
|
|
21
|
|
|
class RequestFactoryTest extends \PHPUnit_Framework_TestCase |
|
22
|
|
|
{ |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var RequestFactory |
|
26
|
|
|
*/ |
|
27
|
|
|
private $requestFactory; |
|
28
|
|
|
|
|
29
|
|
|
protected function setUp() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->requestFactory = new RequestFactory('012345'); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function testCreateInitPayment() |
|
35
|
|
|
{ |
|
36
|
|
|
$cart = new Cart( |
|
37
|
|
|
new Currency(Currency::CZK) |
|
38
|
|
|
); |
|
39
|
|
|
$cart->addItem('Nákup na vasobchodcz', 1, 1789600, 'Lenovo ThinkPad Edge E540'); |
|
40
|
|
|
$cart->addItem('Poštovné', 1, 0, 'Doprava PPL'); |
|
41
|
|
|
|
|
42
|
|
|
$request = $this->requestFactory->createInitPayment( |
|
43
|
|
|
'5547', |
|
44
|
|
|
new PayOperation(PayOperation::PAYMENT), |
|
45
|
|
|
new PayMethod(PayMethod::CARD), |
|
46
|
|
|
true, |
|
47
|
|
|
'https://vasobchod.cz/gateway-return', |
|
48
|
|
|
new HttpMethod(HttpMethod::POST), |
|
49
|
|
|
$cart, |
|
50
|
|
|
'Nákup na vasobchod.cz (Lenovo ThinkPad Edge E540, Doprava PPL)', |
|
51
|
|
|
'some-base64-encoded-merchant-data', |
|
52
|
|
|
'123', |
|
53
|
|
|
new Language(Language::CZ), |
|
54
|
|
|
1800, |
|
55
|
|
|
1, |
|
56
|
|
|
1 |
|
57
|
|
|
); |
|
58
|
|
|
|
|
59
|
|
|
$this->assertInstanceOf(InitPaymentRequest::class, $request); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function testCreateProcessPayment() |
|
63
|
|
|
{ |
|
64
|
|
|
$request = $this->requestFactory->createProcessPayment('123456789'); |
|
65
|
|
|
|
|
66
|
|
|
$this->assertInstanceOf(ProcessPaymentRequest::class, $request); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function testCreatePaymentStatus() |
|
70
|
|
|
{ |
|
71
|
|
|
$request = $this->requestFactory->createPaymentStatus('123456789'); |
|
72
|
|
|
|
|
73
|
|
|
$this->assertInstanceOf(PaymentStatusRequest::class, $request); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function testCreateReversePayment() |
|
77
|
|
|
{ |
|
78
|
|
|
$request = $this->requestFactory->createReversePayment('123456789'); |
|
79
|
|
|
|
|
80
|
|
|
$this->assertInstanceOf(ReversePaymentRequest::class, $request); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function testCreateClosePayment() |
|
84
|
|
|
{ |
|
85
|
|
|
$request = $this->requestFactory->createClosePayment('123456789'); |
|
86
|
|
|
|
|
87
|
|
|
$this->assertInstanceOf(ClosePaymentRequest::class, $request); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function testCreateRefundPayment() |
|
91
|
|
|
{ |
|
92
|
|
|
$request = $this->requestFactory->createRefundPayment('123456789'); |
|
93
|
|
|
|
|
94
|
|
|
$this->assertInstanceOf(RefundPaymentRequest::class, $request); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function testCreateEchoRequest() |
|
98
|
|
|
{ |
|
99
|
|
|
$request = $this->requestFactory->createEchoRequest(); |
|
100
|
|
|
|
|
101
|
|
|
$this->assertInstanceOf(EchoRequest::class, $request); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function testCreatePostEchoRequest() |
|
105
|
|
|
{ |
|
106
|
|
|
$request = $this->requestFactory->createPostEchoRequest(); |
|
107
|
|
|
|
|
108
|
|
|
$this->assertInstanceOf(PostEchoRequest::class, $request); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
public function testCreateCustomerInfo() |
|
112
|
|
|
{ |
|
113
|
|
|
$request = $this->requestFactory->createCustomerInfo('[email protected]'); |
|
114
|
|
|
|
|
115
|
|
|
$this->assertInstanceOf(CustomerInfoRequest::class, $request); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
public function testCreateReceivePayment() |
|
119
|
|
|
{ |
|
120
|
|
|
$request = $this->requestFactory->createReceivePaymentRequest(); |
|
121
|
|
|
|
|
122
|
|
|
$this->assertInstanceOf(ReceivePaymentRequest::class, $request); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
public function testCreateOneclickInitPayment() |
|
126
|
|
|
{ |
|
127
|
|
|
$request = $this->requestFactory->createOneclickInitPayment( |
|
128
|
|
|
'ef08b6e9f22345c', |
|
129
|
|
|
'5547123', |
|
130
|
|
|
new Price(1789600, new Currency(Currency::CZK)), |
|
131
|
|
|
'Nákup na vasobchod.cz (Lenovo ThinkPad Edge E540, Doprava PPL)' |
|
132
|
|
|
); |
|
133
|
|
|
|
|
134
|
|
|
$this->assertInstanceOf(OneclickInitPaymentRequest::class, $request); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
public function testCreateOneclickStartPayment() |
|
138
|
|
|
{ |
|
139
|
|
|
$request = $this->requestFactory->createOneclickStartPayment('ef08b6e9f22345c'); |
|
140
|
|
|
|
|
141
|
|
|
$this->assertInstanceOf(OneclickStartPaymentRequest::class, $request); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
} |
|
145
|
|
|
|