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