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