1: <?php
2: /*
3: * This file was automatically generated.
4: */
5: namespace Worldline\Acquiring\Sdk\V1\Acquirer\Merchant\Payments;
6:
7: use Worldline\Acquiring\Sdk\ApiResource;
8: use Worldline\Acquiring\Sdk\CallContext;
9: use Worldline\Acquiring\Sdk\Communication\ErrorResponseException;
10: use Worldline\Acquiring\Sdk\Communication\InvalidResponseException;
11: use Worldline\Acquiring\Sdk\Communication\ResponseClassMap;
12: use Worldline\Acquiring\Sdk\V1\ApiException;
13: use Worldline\Acquiring\Sdk\V1\AuthorizationException;
14: use Worldline\Acquiring\Sdk\V1\Domain\ApiActionResponse;
15: use Worldline\Acquiring\Sdk\V1\Domain\ApiActionResponseForRefund;
16: use Worldline\Acquiring\Sdk\V1\Domain\ApiCaptureRequest;
17: use Worldline\Acquiring\Sdk\V1\Domain\ApiIncrementRequest;
18: use Worldline\Acquiring\Sdk\V1\Domain\ApiIncrementResponse;
19: use Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentRefundRequest;
20: use Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentRequest;
21: use Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentResource;
22: use Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentResponse;
23: use Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentReversalRequest;
24: use Worldline\Acquiring\Sdk\V1\Domain\ApiReversalResponse;
25: use Worldline\Acquiring\Sdk\V1\ExceptionFactory;
26: use Worldline\Acquiring\Sdk\V1\PlatformException;
27: use Worldline\Acquiring\Sdk\V1\ReferenceException;
28: use Worldline\Acquiring\Sdk\V1\ValidationException;
29:
30: /**
31: * Payments client.
32: */
33: class PaymentsClient extends ApiResource
34: {
35: /** @var ExceptionFactory|null */
36: private $responseExceptionFactory = null;
37:
38: /**
39: * Resource /processing/v1/{acquirerId}/{merchantId}/payments - Create payment
40: *
41: * @param ApiPaymentRequest $body
42: * @param CallContext|null $callContext
43: * @return ApiPaymentResponse
44: *
45: * @throws ValidationException
46: * @throws AuthorizationException
47: * @throws ReferenceException
48: * @throws PlatformException
49: * @throws ApiException
50: * @throws InvalidResponseException
51: * @link https://docs.acquiring.worldline-solutions.com/api-reference#tag/Payments/operation/processPayment Create payment
52: */
53: public function processPayment(ApiPaymentRequest $body, CallContext $callContext = null)
54: {
55: $responseClassMap = new ResponseClassMap();
56: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentResponse';
57: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentErrorResponse';
58: try {
59: return $this->getCommunicator()->post(
60: $responseClassMap,
61: $this->instantiateUri('/processing/v1/{acquirerId}/{merchantId}/payments'),
62: $body,
63: null,
64: $callContext
65: );
66: } catch (ErrorResponseException $e) {
67: throw $this->getResponseExceptionFactory()->createException(
68: $e->getHttpStatusCode(),
69: $e->getErrorResponse(),
70: $callContext
71: );
72: }
73: }
74:
75: /**
76: * Resource /processing/v1/{acquirerId}/{merchantId}/payments/{paymentId} - Retrieve payment
77: *
78: * @param string $paymentId
79: * @param GetPaymentStatusParams $query
80: * @param CallContext|null $callContext
81: * @return ApiPaymentResource
82: *
83: * @throws ValidationException
84: * @throws AuthorizationException
85: * @throws ReferenceException
86: * @throws PlatformException
87: * @throws ApiException
88: * @throws InvalidResponseException
89: * @link https://docs.acquiring.worldline-solutions.com/api-reference#tag/Payments/operation/getPaymentStatus Retrieve payment
90: */
91: public function getPaymentStatus($paymentId, GetPaymentStatusParams $query, CallContext $callContext = null)
92: {
93: $this->context['paymentId'] = $paymentId;
94: $responseClassMap = new ResponseClassMap();
95: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentResource';
96: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentErrorResponse';
97: try {
98: return $this->getCommunicator()->get(
99: $responseClassMap,
100: $this->instantiateUri('/processing/v1/{acquirerId}/{merchantId}/payments/{paymentId}'),
101: $query,
102: $callContext
103: );
104: } catch (ErrorResponseException $e) {
105: throw $this->getResponseExceptionFactory()->createException(
106: $e->getHttpStatusCode(),
107: $e->getErrorResponse(),
108: $callContext
109: );
110: }
111: }
112:
113: /**
114: * Resource /processing/v1/{acquirerId}/{merchantId}/payments/{paymentId}/captures - Capture payment
115: *
116: * @param string $paymentId
117: * @param ApiCaptureRequest $body
118: * @param CallContext|null $callContext
119: * @return ApiActionResponse
120: *
121: * @throws ValidationException
122: * @throws AuthorizationException
123: * @throws ReferenceException
124: * @throws PlatformException
125: * @throws ApiException
126: * @throws InvalidResponseException
127: * @link https://docs.acquiring.worldline-solutions.com/api-reference#tag/Payments/operation/simpleCaptureOfPayment Capture payment
128: */
129: public function simpleCaptureOfPayment($paymentId, ApiCaptureRequest $body, CallContext $callContext = null)
130: {
131: $this->context['paymentId'] = $paymentId;
132: $responseClassMap = new ResponseClassMap();
133: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiActionResponse';
134: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentErrorResponse';
135: try {
136: return $this->getCommunicator()->post(
137: $responseClassMap,
138: $this->instantiateUri('/processing/v1/{acquirerId}/{merchantId}/payments/{paymentId}/captures'),
139: $body,
140: null,
141: $callContext
142: );
143: } catch (ErrorResponseException $e) {
144: throw $this->getResponseExceptionFactory()->createException(
145: $e->getHttpStatusCode(),
146: $e->getErrorResponse(),
147: $callContext
148: );
149: }
150: }
151:
152: /**
153: * Resource /processing/v1/{acquirerId}/{merchantId}/payments/{paymentId}/authorization-reversals - Reverse authorization
154: *
155: * @param string $paymentId
156: * @param ApiPaymentReversalRequest $body
157: * @param CallContext|null $callContext
158: * @return ApiReversalResponse
159: *
160: * @throws ValidationException
161: * @throws AuthorizationException
162: * @throws ReferenceException
163: * @throws PlatformException
164: * @throws ApiException
165: * @throws InvalidResponseException
166: * @link https://docs.acquiring.worldline-solutions.com/api-reference#tag/Payments/operation/reverseAuthorization Reverse authorization
167: */
168: public function reverseAuthorization($paymentId, ApiPaymentReversalRequest $body, CallContext $callContext = null)
169: {
170: $this->context['paymentId'] = $paymentId;
171: $responseClassMap = new ResponseClassMap();
172: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiReversalResponse';
173: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentErrorResponse';
174: try {
175: return $this->getCommunicator()->post(
176: $responseClassMap,
177: $this->instantiateUri('/processing/v1/{acquirerId}/{merchantId}/payments/{paymentId}/authorization-reversals'),
178: $body,
179: null,
180: $callContext
181: );
182: } catch (ErrorResponseException $e) {
183: throw $this->getResponseExceptionFactory()->createException(
184: $e->getHttpStatusCode(),
185: $e->getErrorResponse(),
186: $callContext
187: );
188: }
189: }
190:
191: /**
192: * Resource /processing/v1/{acquirerId}/{merchantId}/payments/{paymentId}/increments - Increment authorization
193: *
194: * @param string $paymentId
195: * @param ApiIncrementRequest $body
196: * @param CallContext|null $callContext
197: * @return ApiIncrementResponse
198: *
199: * @throws ValidationException
200: * @throws AuthorizationException
201: * @throws ReferenceException
202: * @throws PlatformException
203: * @throws ApiException
204: * @throws InvalidResponseException
205: * @link https://docs.acquiring.worldline-solutions.com/api-reference#tag/Payments/operation/incrementPayment Increment authorization
206: */
207: public function incrementPayment($paymentId, ApiIncrementRequest $body, CallContext $callContext = null)
208: {
209: $this->context['paymentId'] = $paymentId;
210: $responseClassMap = new ResponseClassMap();
211: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiIncrementResponse';
212: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentErrorResponse';
213: try {
214: return $this->getCommunicator()->post(
215: $responseClassMap,
216: $this->instantiateUri('/processing/v1/{acquirerId}/{merchantId}/payments/{paymentId}/increments'),
217: $body,
218: null,
219: $callContext
220: );
221: } catch (ErrorResponseException $e) {
222: throw $this->getResponseExceptionFactory()->createException(
223: $e->getHttpStatusCode(),
224: $e->getErrorResponse(),
225: $callContext
226: );
227: }
228: }
229:
230: /**
231: * Resource /processing/v1/{acquirerId}/{merchantId}/payments/{paymentId}/refunds - Refund payment
232: *
233: * @param string $paymentId
234: * @param ApiPaymentRefundRequest $body
235: * @param CallContext|null $callContext
236: * @return ApiActionResponseForRefund
237: *
238: * @throws ValidationException
239: * @throws AuthorizationException
240: * @throws ReferenceException
241: * @throws PlatformException
242: * @throws ApiException
243: * @throws InvalidResponseException
244: * @link https://docs.acquiring.worldline-solutions.com/api-reference#tag/Payments/operation/createRefund Refund payment
245: */
246: public function createRefund($paymentId, ApiPaymentRefundRequest $body, CallContext $callContext = null)
247: {
248: $this->context['paymentId'] = $paymentId;
249: $responseClassMap = new ResponseClassMap();
250: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiActionResponseForRefund';
251: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentErrorResponse';
252: try {
253: return $this->getCommunicator()->post(
254: $responseClassMap,
255: $this->instantiateUri('/processing/v1/{acquirerId}/{merchantId}/payments/{paymentId}/refunds'),
256: $body,
257: null,
258: $callContext
259: );
260: } catch (ErrorResponseException $e) {
261: throw $this->getResponseExceptionFactory()->createException(
262: $e->getHttpStatusCode(),
263: $e->getErrorResponse(),
264: $callContext
265: );
266: }
267: }
268:
269: /** @return ExceptionFactory */
270: private function getResponseExceptionFactory()
271: {
272: if (is_null($this->responseExceptionFactory)) {
273: $this->responseExceptionFactory = new ExceptionFactory();
274: }
275: return $this->responseExceptionFactory;
276: }
277: }
278: