1: <?php
2: /*
3: * This file was automatically generated.
4: */
5: namespace Worldline\Acquiring\Sdk\V1\Acquirer\Merchant\Cardrefunds;
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\ApiActionResponseForRefund;
15: use Worldline\Acquiring\Sdk\V1\Domain\ApiCaptureRequestForRefund;
16: use Worldline\Acquiring\Sdk\V1\Domain\ApiRefundRequest;
17: use Worldline\Acquiring\Sdk\V1\Domain\ApiRefundResource;
18: use Worldline\Acquiring\Sdk\V1\Domain\ApiRefundResponse;
19: use Worldline\Acquiring\Sdk\V1\Domain\ApiRefundReversalRequest;
20: use Worldline\Acquiring\Sdk\V1\ExceptionFactory;
21: use Worldline\Acquiring\Sdk\V1\PlatformException;
22: use Worldline\Acquiring\Sdk\V1\ReferenceException;
23: use Worldline\Acquiring\Sdk\V1\ValidationException;
24:
25: /**
26: * CardRefunds client.
27: *
28: * @package Worldline\Acquiring\Sdk\V1\Acquirer\Merchant\Cardrefunds
29: */
30: class CardRefundsClient extends ApiResource
31: {
32: /**
33: * @var ExceptionFactory|null
34: */
35: private ?ExceptionFactory $responseExceptionFactory = null;
36:
37: /**
38: * Resource /processing/v1/{acquirerId}/{merchantId}/refunds - Create standalone card refund
39: *
40: * @param ApiRefundRequest $body
41: * @param CallContext|null $callContext
42: *
43: * @return ApiRefundResponse
44: * @throws ValidationException
45: * @throws AuthorizationException
46: * @throws ReferenceException
47: * @throws PlatformException
48: * @throws ApiException
49: * @throws InvalidResponseException
50: * @link https://docs.acquiring.worldline-solutions.com/api-reference#tag/Card-Refunds/operation/processStandaloneRefund Create standalone card refund
51: */
52: public function processStandaloneRefund(ApiRefundRequest $body, ?CallContext $callContext = null): ApiRefundResponse
53: {
54: $responseClassMap = new ResponseClassMap();
55: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiRefundResponse';
56: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentErrorResponse';
57: try {
58: return $this->getCommunicator()->post(
59: $responseClassMap,
60: $this->instantiateUri('/processing/v1/{acquirerId}/{merchantId}/refunds'),
61: $body,
62: null,
63: $callContext
64: );
65: } catch (ErrorResponseException $e) {
66: throw $this->getResponseExceptionFactory()->createException(
67: $e->getHttpStatusCode(),
68: $e->getErrorResponse(),
69: $callContext
70: );
71: }
72: }
73:
74: /**
75: * Resource /processing/v1/{acquirerId}/{merchantId}/refunds/{refundId} - Retrieve card refund
76: *
77: * @param string $refundId
78: * @param GetRefundParams $query
79: * @param CallContext|null $callContext
80: *
81: * @return ApiRefundResource
82: * @throws ValidationException
83: * @throws AuthorizationException
84: * @throws ReferenceException
85: * @throws PlatformException
86: * @throws ApiException
87: * @throws InvalidResponseException
88: * @link https://docs.acquiring.worldline-solutions.com/api-reference#tag/Card-Refunds/operation/getRefund Retrieve card refund
89: */
90: public function getRefund(string $refundId, GetRefundParams $query, ?CallContext $callContext = null): ApiRefundResource
91: {
92: $this->context['refundId'] = $refundId;
93: $responseClassMap = new ResponseClassMap();
94: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiRefundResource';
95: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentErrorResponse';
96: try {
97: return $this->getCommunicator()->get(
98: $responseClassMap,
99: $this->instantiateUri('/processing/v1/{acquirerId}/{merchantId}/refunds/{refundId}'),
100: $query,
101: $callContext
102: );
103: } catch (ErrorResponseException $e) {
104: throw $this->getResponseExceptionFactory()->createException(
105: $e->getHttpStatusCode(),
106: $e->getErrorResponse(),
107: $callContext
108: );
109: }
110: }
111:
112: /**
113: * Resource /processing/v1/{acquirerId}/{merchantId}/refunds/{refundId}/captures - Capture refund
114: *
115: * @param string $refundId
116: * @param ApiCaptureRequestForRefund $body
117: * @param CallContext|null $callContext
118: *
119: * @return ApiActionResponseForRefund
120: * @throws ValidationException
121: * @throws AuthorizationException
122: * @throws ReferenceException
123: * @throws PlatformException
124: * @throws ApiException
125: * @throws InvalidResponseException
126: * @link https://docs.acquiring.worldline-solutions.com/api-reference#tag/Card-Refunds/operation/captureRefund Capture refund
127: */
128: public function captureRefund(string $refundId, ApiCaptureRequestForRefund $body, ?CallContext $callContext = null): ApiActionResponseForRefund
129: {
130: $this->context['refundId'] = $refundId;
131: $responseClassMap = new ResponseClassMap();
132: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiActionResponseForRefund';
133: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentErrorResponse';
134: try {
135: return $this->getCommunicator()->post(
136: $responseClassMap,
137: $this->instantiateUri('/processing/v1/{acquirerId}/{merchantId}/refunds/{refundId}/captures'),
138: $body,
139: null,
140: $callContext
141: );
142: } catch (ErrorResponseException $e) {
143: throw $this->getResponseExceptionFactory()->createException(
144: $e->getHttpStatusCode(),
145: $e->getErrorResponse(),
146: $callContext
147: );
148: }
149: }
150:
151: /**
152: * Resource /processing/v1/{acquirerId}/{merchantId}/refunds/{refundId}/authorization-reversals - Reverse refund authorization
153: *
154: * @param string $refundId
155: * @param ApiRefundReversalRequest $body
156: * @param CallContext|null $callContext
157: *
158: * @return ApiActionResponseForRefund
159: * @throws ValidationException
160: * @throws AuthorizationException
161: * @throws ReferenceException
162: * @throws PlatformException
163: * @throws ApiException
164: * @throws InvalidResponseException
165: * @link https://docs.acquiring.worldline-solutions.com/api-reference#tag/Card-Refunds/operation/reverseRefundAuthorization Reverse refund authorization
166: */
167: public function reverseRefundAuthorization(string $refundId, ApiRefundReversalRequest $body, ?CallContext $callContext = null): ApiActionResponseForRefund
168: {
169: $this->context['refundId'] = $refundId;
170: $responseClassMap = new ResponseClassMap();
171: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiActionResponseForRefund';
172: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentErrorResponse';
173: try {
174: return $this->getCommunicator()->post(
175: $responseClassMap,
176: $this->instantiateUri('/processing/v1/{acquirerId}/{merchantId}/refunds/{refundId}/authorization-reversals'),
177: $body,
178: null,
179: $callContext
180: );
181: } catch (ErrorResponseException $e) {
182: throw $this->getResponseExceptionFactory()->createException(
183: $e->getHttpStatusCode(),
184: $e->getErrorResponse(),
185: $callContext
186: );
187: }
188: }
189:
190: /**
191: * @return ExceptionFactory
192: */
193: private function getResponseExceptionFactory(): ExceptionFactory
194: {
195: if (is_null($this->responseExceptionFactory)) {
196: $this->responseExceptionFactory = new ExceptionFactory();
197: }
198: return $this->responseExceptionFactory;
199: }
200: }
201: