1: <?php
2: /*
3: * This class was auto-generated from the API references found at
4: * https://apireference.connect.worldline-solutions.com/
5: */
6: namespace Worldline\Connect\Sdk\V1\Merchant\Payments;
7:
8: use Worldline\Connect\Sdk\ApiResource;
9: use Worldline\Connect\Sdk\CallContext;
10: use Worldline\Connect\Sdk\Communication\ErrorResponseException;
11: use Worldline\Connect\Sdk\Communication\InvalidResponseException;
12: use Worldline\Connect\Sdk\Communication\ResponseClassMap;
13: use Worldline\Connect\Sdk\V1\ApiException;
14: use Worldline\Connect\Sdk\V1\AuthorizationException;
15: use Worldline\Connect\Sdk\V1\DeclinedPaymentException;
16: use Worldline\Connect\Sdk\V1\DeclinedRefundException;
17: use Worldline\Connect\Sdk\V1\Domain\ApprovePaymentRequest;
18: use Worldline\Connect\Sdk\V1\Domain\CancelApprovalPaymentResponse;
19: use Worldline\Connect\Sdk\V1\Domain\CancelPaymentResponse;
20: use Worldline\Connect\Sdk\V1\Domain\CapturePaymentRequest;
21: use Worldline\Connect\Sdk\V1\Domain\CaptureResponse;
22: use Worldline\Connect\Sdk\V1\Domain\CapturesResponse;
23: use Worldline\Connect\Sdk\V1\Domain\CompletePaymentRequest;
24: use Worldline\Connect\Sdk\V1\Domain\CompletePaymentResponse;
25: use Worldline\Connect\Sdk\V1\Domain\CreateDisputeRequest;
26: use Worldline\Connect\Sdk\V1\Domain\CreatePaymentRequest;
27: use Worldline\Connect\Sdk\V1\Domain\CreatePaymentResponse;
28: use Worldline\Connect\Sdk\V1\Domain\CreateTokenResponse;
29: use Worldline\Connect\Sdk\V1\Domain\DeviceFingerprintDetails;
30: use Worldline\Connect\Sdk\V1\Domain\DisputeResponse;
31: use Worldline\Connect\Sdk\V1\Domain\DisputesResponse;
32: use Worldline\Connect\Sdk\V1\Domain\FindPaymentsResponse;
33: use Worldline\Connect\Sdk\V1\Domain\PaymentApprovalResponse;
34: use Worldline\Connect\Sdk\V1\Domain\PaymentResponse;
35: use Worldline\Connect\Sdk\V1\Domain\RefundRequest;
36: use Worldline\Connect\Sdk\V1\Domain\RefundResponse;
37: use Worldline\Connect\Sdk\V1\Domain\RefundsResponse;
38: use Worldline\Connect\Sdk\V1\Domain\ThirdPartyStatusResponse;
39: use Worldline\Connect\Sdk\V1\Domain\TokenizePaymentRequest;
40: use Worldline\Connect\Sdk\V1\ExceptionFactory;
41: use Worldline\Connect\Sdk\V1\IdempotenceException;
42: use Worldline\Connect\Sdk\V1\PlatformException;
43: use Worldline\Connect\Sdk\V1\ReferenceException;
44: use Worldline\Connect\Sdk\V1\ValidationException;
45:
46: /**
47: * Payments client.
48: *
49: * @package Worldline\Connect\Sdk\V1\Merchant\Payments
50: */
51: class PaymentsClient extends ApiResource
52: {
53: /**
54: * @var ExceptionFactory|null
55: */
56: private ?ExceptionFactory $responseExceptionFactory = null;
57:
58: /**
59: * Resource /{merchantId}/payments - Create payment
60: *
61: * @param CreatePaymentRequest $body
62: * @param CallContext|null $callContext
63: *
64: * @return CreatePaymentResponse
65: * @throws DeclinedPaymentException
66: * @throws IdempotenceException
67: * @throws ValidationException
68: * @throws AuthorizationException
69: * @throws ReferenceException
70: * @throws PlatformException
71: * @throws ApiException
72: * @throws InvalidResponseException
73: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/create.html Create payment
74: */
75: public function create(CreatePaymentRequest $body, ?CallContext $callContext = null): CreatePaymentResponse
76: {
77: $responseClassMap = new ResponseClassMap();
78: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CreatePaymentResponse';
79: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentErrorResponse';
80: try {
81: return $this->getCommunicator()->post(
82: $responseClassMap,
83: $this->instantiateUri('/v1/{merchantId}/payments'),
84: $this->getClientMetaInfo(),
85: $body,
86: null,
87: $callContext
88: );
89: } catch (ErrorResponseException $e) {
90: throw $this->getResponseExceptionFactory()->createException(
91: $e->getHttpStatusCode(),
92: $e->getErrorResponse(),
93: $callContext
94: );
95: }
96: }
97:
98: /**
99: * Resource /{merchantId}/payments - Find payments
100: *
101: * @param FindPaymentsParams $query
102: * @param CallContext|null $callContext
103: *
104: * @return FindPaymentsResponse
105: * @throws IdempotenceException
106: * @throws ValidationException
107: * @throws AuthorizationException
108: * @throws ReferenceException
109: * @throws PlatformException
110: * @throws ApiException
111: * @throws InvalidResponseException
112: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/find.html Find payments
113: */
114: public function find(FindPaymentsParams $query, ?CallContext $callContext = null): FindPaymentsResponse
115: {
116: $responseClassMap = new ResponseClassMap();
117: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\FindPaymentsResponse';
118: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
119: try {
120: return $this->getCommunicator()->get(
121: $responseClassMap,
122: $this->instantiateUri('/v1/{merchantId}/payments'),
123: $this->getClientMetaInfo(),
124: $query,
125: $callContext
126: );
127: } catch (ErrorResponseException $e) {
128: throw $this->getResponseExceptionFactory()->createException(
129: $e->getHttpStatusCode(),
130: $e->getErrorResponse(),
131: $callContext
132: );
133: }
134: }
135:
136: /**
137: * Resource /{merchantId}/payments/{paymentId} - Get payment
138: *
139: * @param string $paymentId
140: * @param GetPaymentParams $query
141: * @param CallContext|null $callContext
142: *
143: * @return PaymentResponse
144: * @throws IdempotenceException
145: * @throws ValidationException
146: * @throws AuthorizationException
147: * @throws ReferenceException
148: * @throws PlatformException
149: * @throws ApiException
150: * @throws InvalidResponseException
151: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/get.html Get payment
152: */
153: public function get(string $paymentId, GetPaymentParams $query, ?CallContext $callContext = null): PaymentResponse
154: {
155: $this->context['paymentId'] = $paymentId;
156: $responseClassMap = new ResponseClassMap();
157: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentResponse';
158: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
159: try {
160: return $this->getCommunicator()->get(
161: $responseClassMap,
162: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}'),
163: $this->getClientMetaInfo(),
164: $query,
165: $callContext
166: );
167: } catch (ErrorResponseException $e) {
168: throw $this->getResponseExceptionFactory()->createException(
169: $e->getHttpStatusCode(),
170: $e->getErrorResponse(),
171: $callContext
172: );
173: }
174: }
175:
176: /**
177: * Resource /{merchantId}/payments/{paymentId}/complete - Complete payment
178: *
179: * @param string $paymentId
180: * @param CompletePaymentRequest $body
181: * @param CallContext|null $callContext
182: *
183: * @return CompletePaymentResponse
184: * @throws IdempotenceException
185: * @throws ValidationException
186: * @throws AuthorizationException
187: * @throws ReferenceException
188: * @throws PlatformException
189: * @throws ApiException
190: * @throws InvalidResponseException
191: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/complete.html Complete payment
192: */
193: public function complete(string $paymentId, CompletePaymentRequest $body, ?CallContext $callContext = null): CompletePaymentResponse
194: {
195: $this->context['paymentId'] = $paymentId;
196: $responseClassMap = new ResponseClassMap();
197: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CompletePaymentResponse';
198: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
199: try {
200: return $this->getCommunicator()->post(
201: $responseClassMap,
202: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/complete'),
203: $this->getClientMetaInfo(),
204: $body,
205: null,
206: $callContext
207: );
208: } catch (ErrorResponseException $e) {
209: throw $this->getResponseExceptionFactory()->createException(
210: $e->getHttpStatusCode(),
211: $e->getErrorResponse(),
212: $callContext
213: );
214: }
215: }
216:
217: /**
218: * Resource /{merchantId}/payments/{paymentId}/thirdpartystatus - Third party status poll
219: *
220: * @param string $paymentId
221: * @param CallContext|null $callContext
222: *
223: * @return ThirdPartyStatusResponse
224: * @throws IdempotenceException
225: * @throws ValidationException
226: * @throws AuthorizationException
227: * @throws ReferenceException
228: * @throws PlatformException
229: * @throws ApiException
230: * @throws InvalidResponseException
231: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/thirdPartyStatus.html Third party status poll
232: */
233: public function thirdPartyStatus(string $paymentId, ?CallContext $callContext = null): ThirdPartyStatusResponse
234: {
235: $this->context['paymentId'] = $paymentId;
236: $responseClassMap = new ResponseClassMap();
237: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ThirdPartyStatusResponse';
238: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
239: try {
240: return $this->getCommunicator()->get(
241: $responseClassMap,
242: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/thirdpartystatus'),
243: $this->getClientMetaInfo(),
244: null,
245: $callContext
246: );
247: } catch (ErrorResponseException $e) {
248: throw $this->getResponseExceptionFactory()->createException(
249: $e->getHttpStatusCode(),
250: $e->getErrorResponse(),
251: $callContext
252: );
253: }
254: }
255:
256: /**
257: * Resource /{merchantId}/payments/{paymentId}/tokenize - Create a token from payment
258: *
259: * @param string $paymentId
260: * @param TokenizePaymentRequest $body
261: * @param CallContext|null $callContext
262: *
263: * @return CreateTokenResponse
264: * @throws IdempotenceException
265: * @throws ValidationException
266: * @throws AuthorizationException
267: * @throws ReferenceException
268: * @throws PlatformException
269: * @throws ApiException
270: * @throws InvalidResponseException
271: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/tokenize.html Create a token from payment
272: */
273: public function tokenize(string $paymentId, TokenizePaymentRequest $body, ?CallContext $callContext = null): CreateTokenResponse
274: {
275: $this->context['paymentId'] = $paymentId;
276: $responseClassMap = new ResponseClassMap();
277: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CreateTokenResponse';
278: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
279: try {
280: return $this->getCommunicator()->post(
281: $responseClassMap,
282: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/tokenize'),
283: $this->getClientMetaInfo(),
284: $body,
285: null,
286: $callContext
287: );
288: } catch (ErrorResponseException $e) {
289: throw $this->getResponseExceptionFactory()->createException(
290: $e->getHttpStatusCode(),
291: $e->getErrorResponse(),
292: $callContext
293: );
294: }
295: }
296:
297: /**
298: * Resource /{merchantId}/payments/{paymentId}/processchallenged - Approves challenged payment
299: *
300: * @param string $paymentId
301: * @param CallContext|null $callContext
302: *
303: * @return PaymentResponse
304: * @throws IdempotenceException
305: * @throws ValidationException
306: * @throws AuthorizationException
307: * @throws ReferenceException
308: * @throws PlatformException
309: * @throws ApiException
310: * @throws InvalidResponseException
311: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/processchallenged.html Approves challenged payment
312: */
313: public function processchallenged(string $paymentId, ?CallContext $callContext = null): PaymentResponse
314: {
315: $this->context['paymentId'] = $paymentId;
316: $responseClassMap = new ResponseClassMap();
317: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentResponse';
318: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
319: try {
320: return $this->getCommunicator()->post(
321: $responseClassMap,
322: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/processchallenged'),
323: $this->getClientMetaInfo(),
324: null,
325: null,
326: $callContext
327: );
328: } catch (ErrorResponseException $e) {
329: throw $this->getResponseExceptionFactory()->createException(
330: $e->getHttpStatusCode(),
331: $e->getErrorResponse(),
332: $callContext
333: );
334: }
335: }
336:
337: /**
338: * Resource /{merchantId}/payments/{paymentId}/approve - Approve payment
339: *
340: * @param string $paymentId
341: * @param ApprovePaymentRequest $body
342: * @param CallContext|null $callContext
343: *
344: * @return PaymentApprovalResponse
345: * @throws IdempotenceException
346: * @throws ValidationException
347: * @throws AuthorizationException
348: * @throws ReferenceException
349: * @throws PlatformException
350: * @throws ApiException
351: * @throws InvalidResponseException
352: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/approve.html Approve payment
353: */
354: public function approve(string $paymentId, ApprovePaymentRequest $body, ?CallContext $callContext = null): PaymentApprovalResponse
355: {
356: $this->context['paymentId'] = $paymentId;
357: $responseClassMap = new ResponseClassMap();
358: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentApprovalResponse';
359: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
360: try {
361: return $this->getCommunicator()->post(
362: $responseClassMap,
363: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/approve'),
364: $this->getClientMetaInfo(),
365: $body,
366: null,
367: $callContext
368: );
369: } catch (ErrorResponseException $e) {
370: throw $this->getResponseExceptionFactory()->createException(
371: $e->getHttpStatusCode(),
372: $e->getErrorResponse(),
373: $callContext
374: );
375: }
376: }
377:
378: /**
379: * Resource /{merchantId}/payments/{paymentId}/capture - Capture payment
380: *
381: * @param string $paymentId
382: * @param CapturePaymentRequest $body
383: * @param CallContext|null $callContext
384: *
385: * @return CaptureResponse
386: * @throws IdempotenceException
387: * @throws ValidationException
388: * @throws AuthorizationException
389: * @throws ReferenceException
390: * @throws PlatformException
391: * @throws ApiException
392: * @throws InvalidResponseException
393: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/capture.html Capture payment
394: */
395: public function capture(string $paymentId, CapturePaymentRequest $body, ?CallContext $callContext = null): CaptureResponse
396: {
397: $this->context['paymentId'] = $paymentId;
398: $responseClassMap = new ResponseClassMap();
399: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CaptureResponse';
400: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
401: try {
402: return $this->getCommunicator()->post(
403: $responseClassMap,
404: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/capture'),
405: $this->getClientMetaInfo(),
406: $body,
407: null,
408: $callContext
409: );
410: } catch (ErrorResponseException $e) {
411: throw $this->getResponseExceptionFactory()->createException(
412: $e->getHttpStatusCode(),
413: $e->getErrorResponse(),
414: $callContext
415: );
416: }
417: }
418:
419: /**
420: * Resource /{merchantId}/payments/{paymentId}/finalizecapture - Finalize capture
421: *
422: * @param string $paymentId
423: * @param CallContext|null $callContext
424: *
425: * @return PaymentResponse
426: * @throws IdempotenceException
427: * @throws ValidationException
428: * @throws AuthorizationException
429: * @throws ReferenceException
430: * @throws PlatformException
431: * @throws ApiException
432: * @throws InvalidResponseException
433: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/finalizecapture.html Finalize capture
434: */
435: public function finalizecapture(string $paymentId, ?CallContext $callContext = null): PaymentResponse
436: {
437: $this->context['paymentId'] = $paymentId;
438: $responseClassMap = new ResponseClassMap();
439: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentResponse';
440: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
441: try {
442: return $this->getCommunicator()->post(
443: $responseClassMap,
444: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/finalizecapture'),
445: $this->getClientMetaInfo(),
446: null,
447: null,
448: $callContext
449: );
450: } catch (ErrorResponseException $e) {
451: throw $this->getResponseExceptionFactory()->createException(
452: $e->getHttpStatusCode(),
453: $e->getErrorResponse(),
454: $callContext
455: );
456: }
457: }
458:
459: /**
460: * Resource /{merchantId}/payments/{paymentId}/cancelapproval - Undo capture payment
461: *
462: * @param string $paymentId
463: * @param CallContext|null $callContext
464: *
465: * @return CancelApprovalPaymentResponse
466: * @throws IdempotenceException
467: * @throws ValidationException
468: * @throws AuthorizationException
469: * @throws ReferenceException
470: * @throws PlatformException
471: * @throws ApiException
472: * @throws InvalidResponseException
473: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/cancelapproval.html Undo capture payment
474: */
475: public function cancelapproval(string $paymentId, ?CallContext $callContext = null): CancelApprovalPaymentResponse
476: {
477: $this->context['paymentId'] = $paymentId;
478: $responseClassMap = new ResponseClassMap();
479: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CancelApprovalPaymentResponse';
480: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
481: try {
482: return $this->getCommunicator()->post(
483: $responseClassMap,
484: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/cancelapproval'),
485: $this->getClientMetaInfo(),
486: null,
487: null,
488: $callContext
489: );
490: } catch (ErrorResponseException $e) {
491: throw $this->getResponseExceptionFactory()->createException(
492: $e->getHttpStatusCode(),
493: $e->getErrorResponse(),
494: $callContext
495: );
496: }
497: }
498:
499: /**
500: * Resource /{merchantId}/payments/{paymentId}/captures - Get captures of payment
501: *
502: * @param string $paymentId
503: * @param CallContext|null $callContext
504: *
505: * @return CapturesResponse
506: * @throws IdempotenceException
507: * @throws ValidationException
508: * @throws AuthorizationException
509: * @throws ReferenceException
510: * @throws PlatformException
511: * @throws ApiException
512: * @throws InvalidResponseException
513: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/captures.html Get captures of payment
514: */
515: public function captures(string $paymentId, ?CallContext $callContext = null): CapturesResponse
516: {
517: $this->context['paymentId'] = $paymentId;
518: $responseClassMap = new ResponseClassMap();
519: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CapturesResponse';
520: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
521: try {
522: return $this->getCommunicator()->get(
523: $responseClassMap,
524: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/captures'),
525: $this->getClientMetaInfo(),
526: null,
527: $callContext
528: );
529: } catch (ErrorResponseException $e) {
530: throw $this->getResponseExceptionFactory()->createException(
531: $e->getHttpStatusCode(),
532: $e->getErrorResponse(),
533: $callContext
534: );
535: }
536: }
537:
538: /**
539: * Resource /{merchantId}/payments/{paymentId}/refund - Create refund
540: *
541: * @param string $paymentId
542: * @param RefundRequest $body
543: * @param CallContext|null $callContext
544: *
545: * @return RefundResponse
546: * @throws DeclinedRefundException
547: * @throws IdempotenceException
548: * @throws ValidationException
549: * @throws AuthorizationException
550: * @throws ReferenceException
551: * @throws PlatformException
552: * @throws ApiException
553: * @throws InvalidResponseException
554: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/refund.html Create refund
555: */
556: public function refund(string $paymentId, RefundRequest $body, ?CallContext $callContext = null): RefundResponse
557: {
558: $this->context['paymentId'] = $paymentId;
559: $responseClassMap = new ResponseClassMap();
560: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\RefundResponse';
561: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\RefundErrorResponse';
562: try {
563: return $this->getCommunicator()->post(
564: $responseClassMap,
565: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/refund'),
566: $this->getClientMetaInfo(),
567: $body,
568: null,
569: $callContext
570: );
571: } catch (ErrorResponseException $e) {
572: throw $this->getResponseExceptionFactory()->createException(
573: $e->getHttpStatusCode(),
574: $e->getErrorResponse(),
575: $callContext
576: );
577: }
578: }
579:
580: /**
581: * Resource /{merchantId}/payments/{paymentId}/refunds - Get refunds of payment
582: *
583: * @param string $paymentId
584: * @param CallContext|null $callContext
585: *
586: * @return RefundsResponse
587: * @throws IdempotenceException
588: * @throws ValidationException
589: * @throws AuthorizationException
590: * @throws ReferenceException
591: * @throws PlatformException
592: * @throws ApiException
593: * @throws InvalidResponseException
594: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/refunds.html Get refunds of payment
595: */
596: public function refunds(string $paymentId, ?CallContext $callContext = null): RefundsResponse
597: {
598: $this->context['paymentId'] = $paymentId;
599: $responseClassMap = new ResponseClassMap();
600: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\RefundsResponse';
601: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
602: try {
603: return $this->getCommunicator()->get(
604: $responseClassMap,
605: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/refunds'),
606: $this->getClientMetaInfo(),
607: null,
608: $callContext
609: );
610: } catch (ErrorResponseException $e) {
611: throw $this->getResponseExceptionFactory()->createException(
612: $e->getHttpStatusCode(),
613: $e->getErrorResponse(),
614: $callContext
615: );
616: }
617: }
618:
619: /**
620: * Resource /{merchantId}/payments/{paymentId}/cancel - Cancel payment
621: *
622: * @param string $paymentId
623: * @param CallContext|null $callContext
624: *
625: * @return CancelPaymentResponse
626: * @throws IdempotenceException
627: * @throws ValidationException
628: * @throws AuthorizationException
629: * @throws ReferenceException
630: * @throws PlatformException
631: * @throws ApiException
632: * @throws InvalidResponseException
633: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/cancel.html Cancel payment
634: */
635: public function cancel(string $paymentId, ?CallContext $callContext = null): CancelPaymentResponse
636: {
637: $this->context['paymentId'] = $paymentId;
638: $responseClassMap = new ResponseClassMap();
639: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CancelPaymentResponse';
640: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
641: try {
642: return $this->getCommunicator()->post(
643: $responseClassMap,
644: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/cancel'),
645: $this->getClientMetaInfo(),
646: null,
647: null,
648: $callContext
649: );
650: } catch (ErrorResponseException $e) {
651: throw $this->getResponseExceptionFactory()->createException(
652: $e->getHttpStatusCode(),
653: $e->getErrorResponse(),
654: $callContext
655: );
656: }
657: }
658:
659: /**
660: * Resource /{merchantId}/payments/{paymentId}/dispute - Create dispute
661: *
662: * @param string $paymentId
663: * @param CreateDisputeRequest $body
664: * @param CallContext|null $callContext
665: *
666: * @return DisputeResponse
667: * @throws IdempotenceException
668: * @throws ValidationException
669: * @throws AuthorizationException
670: * @throws ReferenceException
671: * @throws PlatformException
672: * @throws ApiException
673: * @throws InvalidResponseException
674: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/dispute.html Create dispute
675: */
676: public function dispute(string $paymentId, CreateDisputeRequest $body, ?CallContext $callContext = null): DisputeResponse
677: {
678: $this->context['paymentId'] = $paymentId;
679: $responseClassMap = new ResponseClassMap();
680: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\DisputeResponse';
681: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
682: try {
683: return $this->getCommunicator()->post(
684: $responseClassMap,
685: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/dispute'),
686: $this->getClientMetaInfo(),
687: $body,
688: null,
689: $callContext
690: );
691: } catch (ErrorResponseException $e) {
692: throw $this->getResponseExceptionFactory()->createException(
693: $e->getHttpStatusCode(),
694: $e->getErrorResponse(),
695: $callContext
696: );
697: }
698: }
699:
700: /**
701: * Resource /{merchantId}/payments/{paymentId}/disputes - Get disputes
702: *
703: * @param string $paymentId
704: * @param CallContext|null $callContext
705: *
706: * @return DisputesResponse
707: * @throws IdempotenceException
708: * @throws ValidationException
709: * @throws AuthorizationException
710: * @throws ReferenceException
711: * @throws PlatformException
712: * @throws ApiException
713: * @throws InvalidResponseException
714: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/disputes.html Get disputes
715: */
716: public function disputes(string $paymentId, ?CallContext $callContext = null): DisputesResponse
717: {
718: $this->context['paymentId'] = $paymentId;
719: $responseClassMap = new ResponseClassMap();
720: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\DisputesResponse';
721: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
722: try {
723: return $this->getCommunicator()->get(
724: $responseClassMap,
725: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/disputes'),
726: $this->getClientMetaInfo(),
727: null,
728: $callContext
729: );
730: } catch (ErrorResponseException $e) {
731: throw $this->getResponseExceptionFactory()->createException(
732: $e->getHttpStatusCode(),
733: $e->getErrorResponse(),
734: $callContext
735: );
736: }
737: }
738:
739: /**
740: * Resource /{merchantId}/payments/{paymentId}/devicefingerprint - Get Device Fingerprint details
741: *
742: * @param string $paymentId
743: * @param CallContext|null $callContext
744: *
745: * @return DeviceFingerprintDetails
746: * @throws IdempotenceException
747: * @throws ValidationException
748: * @throws AuthorizationException
749: * @throws ReferenceException
750: * @throws PlatformException
751: * @throws ApiException
752: * @throws InvalidResponseException
753: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/devicefingerprint.html Get Device Fingerprint details
754: */
755: public function devicefingerprint(string $paymentId, ?CallContext $callContext = null): DeviceFingerprintDetails
756: {
757: $this->context['paymentId'] = $paymentId;
758: $responseClassMap = new ResponseClassMap();
759: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\DeviceFingerprintDetails';
760: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
761: try {
762: return $this->getCommunicator()->get(
763: $responseClassMap,
764: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/devicefingerprint'),
765: $this->getClientMetaInfo(),
766: null,
767: $callContext
768: );
769: } catch (ErrorResponseException $e) {
770: throw $this->getResponseExceptionFactory()->createException(
771: $e->getHttpStatusCode(),
772: $e->getErrorResponse(),
773: $callContext
774: );
775: }
776: }
777:
778: /**
779: * @return ExceptionFactory
780: */
781: private function getResponseExceptionFactory(): ExceptionFactory
782: {
783: if (is_null($this->responseExceptionFactory)) {
784: $this->responseExceptionFactory = new ExceptionFactory();
785: }
786: return $this->responseExceptionFactory;
787: }
788: }
789: