D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
test
/
app
/
Libs
/
OnlinePayments
/
Sdk
/
Merchant
/
Payments
/
Filename :
PaymentsClient.php
back
Copy
<?php /* * This file was automatically generated. */ namespace App\Libs\OnlinePayments\Sdk\Merchant\Payments; use App\Libs\OnlinePayments\Sdk\Domain\CancelPaymentRequest; use App\Libs\OnlinePayments\Sdk\Domain\CancelPaymentResponse; use App\Libs\OnlinePayments\Sdk\Domain\CapturePaymentRequest; use App\Libs\OnlinePayments\Sdk\Domain\CaptureResponse; use App\Libs\OnlinePayments\Sdk\Domain\CreatePaymentRequest; use App\Libs\OnlinePayments\Sdk\Domain\CreatePaymentResponse; use App\Libs\OnlinePayments\Sdk\Domain\PaymentDetailsResponse; use App\Libs\OnlinePayments\Sdk\Domain\PaymentResponse; use App\Libs\OnlinePayments\Sdk\Domain\RefundRequest; use App\Libs\OnlinePayments\Sdk\Domain\RefundResponse; use App\Libs\OnlinePayments\Sdk\ExceptionFactory; use App\Libs\Sdk\ApiResource; use App\Libs\Sdk\CallContext; use App\Libs\Sdk\Communication\ErrorResponseException; use App\Libs\Sdk\Communication\ResponseClassMap; /** * Payments client. */ class PaymentsClient extends ApiResource implements PaymentsClientInterface { /** @var ExceptionFactory|null */ private ?ExceptionFactory $responseExceptionFactory = null; /** * @inheritdoc */ public function createPayment(CreatePaymentRequest $body, ?CallContext $callContext = null): CreatePaymentResponse { $responseClassMap = new ResponseClassMap(); $responseClassMap->defaultSuccessResponseClassName = '\App\Libs\OnlinePayments\Sdk\Domain\CreatePaymentResponse'; $responseClassMap->defaultErrorResponseClassName = '\App\Libs\OnlinePayments\Sdk\Domain\PaymentErrorResponse'; try { return $this->getCommunicator()->post( $responseClassMap, $this->instantiateUri('/v2/{merchantId}/payments'), $this->getClientMetaInfo(), $body, null, $callContext ); } catch (ErrorResponseException $e) { throw $this->getResponseExceptionFactory()->createException( $e->getHttpStatusCode(), $e->getErrorResponse(), $callContext ); } } /** * @inheritdoc */ public function getPayment(string $paymentId, ?CallContext $callContext = null): PaymentResponse { $this->context['paymentId'] = $paymentId; $responseClassMap = new ResponseClassMap(); $responseClassMap->defaultSuccessResponseClassName = '\App\Libs\OnlinePayments\Sdk\Domain\PaymentResponse'; $responseClassMap->defaultErrorResponseClassName = '\App\Libs\OnlinePayments\Sdk\Domain\ErrorResponse'; try { return $this->getCommunicator()->get( $responseClassMap, $this->instantiateUri('/v2/{merchantId}/payments/{paymentId}'), $this->getClientMetaInfo(), null, $callContext ); } catch (ErrorResponseException $e) { throw $this->getResponseExceptionFactory()->createException( $e->getHttpStatusCode(), $e->getErrorResponse(), $callContext ); } } /** * @inheritdoc */ public function getPaymentDetails(string $paymentId, ?CallContext $callContext = null): PaymentDetailsResponse { $this->context['paymentId'] = $paymentId; $responseClassMap = new ResponseClassMap(); $responseClassMap->defaultSuccessResponseClassName = '\App\Libs\OnlinePayments\Sdk\Domain\PaymentDetailsResponse'; $responseClassMap->defaultErrorResponseClassName = '\App\Libs\OnlinePayments\Sdk\Domain\ErrorResponse'; try { return $this->getCommunicator()->get( $responseClassMap, $this->instantiateUri('/v2/{merchantId}/payments/{paymentId}/details'), $this->getClientMetaInfo(), null, $callContext ); } catch (ErrorResponseException $e) { throw $this->getResponseExceptionFactory()->createException( $e->getHttpStatusCode(), $e->getErrorResponse(), $callContext ); } } /** * @inheritdoc */ public function cancelPayment(string $paymentId, CancelPaymentRequest $body, ?CallContext $callContext = null): CancelPaymentResponse { $this->context['paymentId'] = $paymentId; $responseClassMap = new ResponseClassMap(); $responseClassMap->defaultSuccessResponseClassName = '\App\Libs\OnlinePayments\Sdk\Domain\CancelPaymentResponse'; $responseClassMap->defaultErrorResponseClassName = '\App\Libs\OnlinePayments\Sdk\Domain\ErrorResponse'; try { return $this->getCommunicator()->post( $responseClassMap, $this->instantiateUri('/v2/{merchantId}/payments/{paymentId}/cancel'), $this->getClientMetaInfo(), $body, null, $callContext ); } catch (ErrorResponseException $e) { throw $this->getResponseExceptionFactory()->createException( $e->getHttpStatusCode(), $e->getErrorResponse(), $callContext ); } } /** * @inheritdoc */ public function capturePayment(string $paymentId, CapturePaymentRequest $body, ?CallContext $callContext = null): CaptureResponse { $this->context['paymentId'] = $paymentId; $responseClassMap = new ResponseClassMap(); $responseClassMap->defaultSuccessResponseClassName = '\App\Libs\OnlinePayments\Sdk\Domain\CaptureResponse'; $responseClassMap->defaultErrorResponseClassName = '\App\Libs\OnlinePayments\Sdk\Domain\ErrorResponse'; try { return $this->getCommunicator()->post( $responseClassMap, $this->instantiateUri('/v2/{merchantId}/payments/{paymentId}/capture'), $this->getClientMetaInfo(), $body, null, $callContext ); } catch (ErrorResponseException $e) { throw $this->getResponseExceptionFactory()->createException( $e->getHttpStatusCode(), $e->getErrorResponse(), $callContext ); } } /** * @inheritdoc */ public function refundPayment(string $paymentId, RefundRequest $body, ?CallContext $callContext = null): RefundResponse { $this->context['paymentId'] = $paymentId; $responseClassMap = new ResponseClassMap(); $responseClassMap->defaultSuccessResponseClassName = '\App\Libs\OnlinePayments\Sdk\Domain\RefundResponse'; $responseClassMap->defaultErrorResponseClassName = '\App\Libs\OnlinePayments\Sdk\Domain\RefundErrorResponse'; try { return $this->getCommunicator()->post( $responseClassMap, $this->instantiateUri('/v2/{merchantId}/payments/{paymentId}/refund'), $this->getClientMetaInfo(), $body, null, $callContext ); } catch (ErrorResponseException $e) { throw $this->getResponseExceptionFactory()->createException( $e->getHttpStatusCode(), $e->getErrorResponse(), $callContext ); } } /** @return ExceptionFactory */ private function getResponseExceptionFactory(): ExceptionFactory { if (is_null($this->responseExceptionFactory)) { $this->responseExceptionFactory = new ExceptionFactory(); } return $this->responseExceptionFactory; } }