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