Completed
Pull Request — master (#16)
by Josef
05:49
created

RequestFactory::createRecurrentPayment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 1
eloc 14
nc 1
nop 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A RequestFactory::createEchoRequest() 0 6 1
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\Oneclick\InitPaymentRequest as InitOneclickPaymentRequest;
11
use SlevomatCsobGateway\Call\Oneclick\StartPaymentRequest;
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
	public function __construct(string $merchantId)
30
	{
31
		$this->merchantId = $merchantId;
32
	}
33
34
	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
		return new InitPaymentRequest(
52
			$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
	public function createProcessPayment(string $payId): ProcessPaymentRequest
71
	{
72
		return new ProcessPaymentRequest(
73
			$this->merchantId,
74
			$payId
75
		);
76
	}
77
78
	public function createPaymentStatus(string $payId): PaymentStatusRequest
79
	{
80
		return new PaymentStatusRequest(
81
			$this->merchantId,
82
			$payId
83
		);
84
	}
85
86
	public function createReversePayment(string $payId): ReversePaymentRequest
87
	{
88
		return new ReversePaymentRequest(
89
			$this->merchantId,
90
			$payId
91
		);
92
	}
93
94
	public function createClosePayment(string $payId): ClosePaymentRequest
95
	{
96
		return new ClosePaymentRequest(
97
			$this->merchantId,
98
			$payId
99
		);
100
	}
101
102
	public function createRefundPayment(string $payId, int $amount = null): RefundPaymentRequest
103
	{
104
		return new RefundPaymentRequest(
105
			$this->merchantId,
106
			$payId,
107
			$amount
108
		);
109
	}
110
111
	public function createEchoRequest(): EchoRequest
112
	{
113
		return new EchoRequest(
114
			$this->merchantId
115
		);
116
	}
117
118
	public function createPostEchoRequest(): PostEchoRequest
119
	{
120
		return new PostEchoRequest(
121
			$this->merchantId
122
		);
123
	}
124
125
	public function createCustomerInfo(string $customerId): CustomerInfoRequest
126
	{
127
		return new CustomerInfoRequest(
128
			$this->merchantId,
129
			$customerId
130
		);
131
	}
132
133
	public function createReceivePaymentRequest(): ReceivePaymentRequest
134
	{
135
		return new ReceivePaymentRequest();
136
	}
137
138
	public function createInitOneclickPayment(
139
		string $origPayId,
140
		string $orderId,
141
		Price $price = null,
142
		string $description = null
143
	): InitOneclickPaymentRequest
144
	{
145
		return new InitOneclickPaymentRequest(
146
			$this->merchantId,
147
			$origPayId,
148
			$orderId,
149
			$price,
150
			$description
151
		);
152
	}
153
154
	public function createStartOneclickPayment(
155
		string $payId
156
	): StartPaymentRequest
157
	{
158
		return new StartPaymentRequest(
159
			$this->merchantId,
160
			$payId
161
		);
162
	}
163
164
}
165