|
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 RequestFactory |
|
22
|
|
|
{ |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
private $merchantId; |
|
28
|
|
|
|
|
29
|
12 |
|
public function __construct(string $merchantId) |
|
30
|
|
|
{ |
|
31
|
12 |
|
$this->merchantId = $merchantId; |
|
32
|
12 |
|
} |
|
33
|
|
|
|
|
34
|
1 |
|
public function createInitPayment( |
|
35
|
|
|
string $orderId, |
|
36
|
|
|
PayOperation $payOperation, |
|
37
|
|
|
PayMethod $payMethod, |
|
38
|
|
|
bool $closePayment, |
|
39
|
|
|
string $returnUrl, |
|
40
|
|
|
HttpMethod $returnMethod, |
|
41
|
|
|
Cart $cart, |
|
42
|
|
|
string $description, |
|
43
|
|
|
string $merchantData = null, |
|
44
|
|
|
string $customerId = null, |
|
45
|
|
|
Language $language, |
|
46
|
|
|
int $ttlSec = null, |
|
47
|
|
|
int $logoVersion = null, |
|
48
|
|
|
int $colorSchemeVersion = null |
|
49
|
|
|
): InitPaymentRequest |
|
50
|
|
|
{ |
|
51
|
1 |
|
return new InitPaymentRequest( |
|
52
|
1 |
|
$this->merchantId, |
|
53
|
|
|
$orderId, |
|
54
|
|
|
$payOperation, |
|
55
|
|
|
$payMethod, |
|
56
|
|
|
$closePayment, |
|
57
|
|
|
$returnUrl, |
|
58
|
|
|
$returnMethod, |
|
59
|
|
|
$cart, |
|
60
|
|
|
$description, |
|
61
|
|
|
$merchantData, |
|
62
|
|
|
$customerId, |
|
63
|
|
|
$language, |
|
64
|
|
|
$ttlSec, |
|
65
|
|
|
$logoVersion, |
|
66
|
|
|
$colorSchemeVersion |
|
67
|
|
|
); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
1 |
|
public function createProcessPayment(string $payId): ProcessPaymentRequest |
|
71
|
|
|
{ |
|
72
|
1 |
|
return new ProcessPaymentRequest( |
|
73
|
1 |
|
$this->merchantId, |
|
74
|
|
|
$payId |
|
75
|
|
|
); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
1 |
|
public function createPaymentStatus(string $payId): PaymentStatusRequest |
|
79
|
|
|
{ |
|
80
|
1 |
|
return new PaymentStatusRequest( |
|
81
|
1 |
|
$this->merchantId, |
|
82
|
|
|
$payId |
|
83
|
|
|
); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
1 |
|
public function createReversePayment(string $payId): ReversePaymentRequest |
|
87
|
|
|
{ |
|
88
|
1 |
|
return new ReversePaymentRequest( |
|
89
|
1 |
|
$this->merchantId, |
|
90
|
|
|
$payId |
|
91
|
|
|
); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
1 |
|
public function createClosePayment(string $payId): ClosePaymentRequest |
|
95
|
|
|
{ |
|
96
|
1 |
|
return new ClosePaymentRequest( |
|
97
|
1 |
|
$this->merchantId, |
|
98
|
|
|
$payId |
|
99
|
|
|
); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
1 |
|
public function createRefundPayment(string $payId, int $amount = null): RefundPaymentRequest |
|
103
|
|
|
{ |
|
104
|
1 |
|
return new RefundPaymentRequest( |
|
105
|
1 |
|
$this->merchantId, |
|
106
|
|
|
$payId, |
|
107
|
|
|
$amount |
|
108
|
|
|
); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
1 |
|
public function createEchoRequest(): EchoRequest |
|
112
|
|
|
{ |
|
113
|
1 |
|
return new EchoRequest( |
|
114
|
1 |
|
$this->merchantId |
|
115
|
|
|
); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
1 |
|
public function createPostEchoRequest(): PostEchoRequest |
|
119
|
|
|
{ |
|
120
|
1 |
|
return new PostEchoRequest( |
|
121
|
1 |
|
$this->merchantId |
|
122
|
|
|
); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
1 |
|
public function createCustomerInfo(string $customerId): CustomerInfoRequest |
|
126
|
|
|
{ |
|
127
|
1 |
|
return new CustomerInfoRequest( |
|
128
|
1 |
|
$this->merchantId, |
|
129
|
|
|
$customerId |
|
130
|
|
|
); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
1 |
|
public function createReceivePaymentRequest(): ReceivePaymentRequest |
|
134
|
|
|
{ |
|
135
|
1 |
|
return new ReceivePaymentRequest(); |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
1 |
|
public function createOneclickInitPayment( |
|
139
|
|
|
string $origPayId, |
|
140
|
|
|
string $orderId, |
|
141
|
|
|
Price $price = null, |
|
142
|
|
|
string $description = null |
|
143
|
|
|
): OneclickInitPaymentRequest |
|
144
|
|
|
{ |
|
145
|
1 |
|
return new OneclickInitPaymentRequest( |
|
146
|
1 |
|
$this->merchantId, |
|
147
|
|
|
$origPayId, |
|
148
|
|
|
$orderId, |
|
149
|
|
|
$price, |
|
150
|
|
|
$description |
|
151
|
|
|
); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
1 |
|
public function createOneclickStartPayment(string $payId): OneclickStartPaymentRequest |
|
155
|
|
|
{ |
|
156
|
1 |
|
return new OneclickStartPaymentRequest( |
|
157
|
1 |
|
$this->merchantId, |
|
158
|
|
|
$payId |
|
159
|
|
|
); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
} |
|
163
|
|
|
|