1: | <?php |
2: | |
3: | |
4: | |
5: | namespace Worldline\Acquiring\Sdk\V1\Acquirer\Merchant\Technicalreversals; |
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\ApiTechnicalReversalRequest; |
15: | use Worldline\Acquiring\Sdk\V1\Domain\ApiTechnicalReversalResponse; |
16: | use Worldline\Acquiring\Sdk\V1\ExceptionFactory; |
17: | use Worldline\Acquiring\Sdk\V1\PlatformException; |
18: | use Worldline\Acquiring\Sdk\V1\ReferenceException; |
19: | use Worldline\Acquiring\Sdk\V1\ValidationException; |
20: | |
21: | |
22: | |
23: | |
24: | class TechnicalReversalsClient extends ApiResource |
25: | { |
26: | |
27: | private $responseExceptionFactory = null; |
28: | |
29: | |
30: | |
31: | |
32: | |
33: | |
34: | |
35: | |
36: | |
37: | |
38: | |
39: | |
40: | |
41: | |
42: | |
43: | |
44: | |
45: | public function technicalReversal($operationId, ApiTechnicalReversalRequest $body, CallContext $callContext = null) |
46: | { |
47: | $this->context['operationId'] = $operationId; |
48: | $responseClassMap = new ResponseClassMap(); |
49: | $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiTechnicalReversalResponse'; |
50: | $responseClassMap->defaultErrorResponseClassName = '\Worldline\Acquiring\Sdk\V1\Domain\ApiPaymentErrorResponse'; |
51: | try { |
52: | return $this->getCommunicator()->post( |
53: | $responseClassMap, |
54: | $this->instantiateUri('/processing/v1/{acquirerId}/{merchantId}/operations/{operationId}/reverse'), |
55: | $body, |
56: | null, |
57: | $callContext |
58: | ); |
59: | } catch (ErrorResponseException $e) { |
60: | throw $this->getResponseExceptionFactory()->createException( |
61: | $e->getHttpStatusCode(), |
62: | $e->getErrorResponse(), |
63: | $callContext |
64: | ); |
65: | } |
66: | } |
67: | |
68: | |
69: | private function getResponseExceptionFactory() |
70: | { |
71: | if (is_null($this->responseExceptionFactory)) { |
72: | $this->responseExceptionFactory = new ExceptionFactory(); |
73: | } |
74: | return $this->responseExceptionFactory; |
75: | } |
76: | } |
77: | |