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 GetPaymentParams $query
137: * @param CallContext $callContext
138: * @return PaymentResponse
139: *
140: * @throws IdempotenceException
141: * @throws ValidationException
142: * @throws AuthorizationException
143: * @throws ReferenceException
144: * @throws PlatformException
145: * @throws ApiException
146: * @throws InvalidResponseException
147: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/get.html Get payment
148: */
149: public function get($paymentId, GetPaymentParams $query, CallContext $callContext = null)
150: {
151: $this->context['paymentId'] = $paymentId;
152: $responseClassMap = new ResponseClassMap();
153: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentResponse';
154: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
155: try {
156: return $this->getCommunicator()->get(
157: $responseClassMap,
158: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}'),
159: $this->getClientMetaInfo(),
160: $query,
161: $callContext
162: );
163: } catch (ErrorResponseException $e) {
164: throw $this->getResponseExceptionFactory()->createException(
165: $e->getHttpStatusCode(),
166: $e->getErrorResponse(),
167: $callContext
168: );
169: }
170: }
171:
172: /**
173: * Resource /{merchantId}/payments/{paymentId}/complete - Complete payment
174: *
175: * @param string $paymentId
176: * @param CompletePaymentRequest $body
177: * @param CallContext $callContext
178: * @return CompletePaymentResponse
179: *
180: * @throws IdempotenceException
181: * @throws ValidationException
182: * @throws AuthorizationException
183: * @throws ReferenceException
184: * @throws PlatformException
185: * @throws ApiException
186: * @throws InvalidResponseException
187: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/complete.html Complete payment
188: */
189: public function complete($paymentId, CompletePaymentRequest $body, CallContext $callContext = null)
190: {
191: $this->context['paymentId'] = $paymentId;
192: $responseClassMap = new ResponseClassMap();
193: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CompletePaymentResponse';
194: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
195: try {
196: return $this->getCommunicator()->post(
197: $responseClassMap,
198: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/complete'),
199: $this->getClientMetaInfo(),
200: $body,
201: null,
202: $callContext
203: );
204: } catch (ErrorResponseException $e) {
205: throw $this->getResponseExceptionFactory()->createException(
206: $e->getHttpStatusCode(),
207: $e->getErrorResponse(),
208: $callContext
209: );
210: }
211: }
212:
213: /**
214: * Resource /{merchantId}/payments/{paymentId}/thirdpartystatus - Third party status poll
215: *
216: * @param string $paymentId
217: * @param CallContext $callContext
218: * @return ThirdPartyStatusResponse
219: *
220: * @throws IdempotenceException
221: * @throws ValidationException
222: * @throws AuthorizationException
223: * @throws ReferenceException
224: * @throws PlatformException
225: * @throws ApiException
226: * @throws InvalidResponseException
227: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/thirdPartyStatus.html Third party status poll
228: */
229: public function thirdPartyStatus($paymentId, CallContext $callContext = null)
230: {
231: $this->context['paymentId'] = $paymentId;
232: $responseClassMap = new ResponseClassMap();
233: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ThirdPartyStatusResponse';
234: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
235: try {
236: return $this->getCommunicator()->get(
237: $responseClassMap,
238: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/thirdpartystatus'),
239: $this->getClientMetaInfo(),
240: null,
241: $callContext
242: );
243: } catch (ErrorResponseException $e) {
244: throw $this->getResponseExceptionFactory()->createException(
245: $e->getHttpStatusCode(),
246: $e->getErrorResponse(),
247: $callContext
248: );
249: }
250: }
251:
252: /**
253: * Resource /{merchantId}/payments/{paymentId}/tokenize - Create a token from payment
254: *
255: * @param string $paymentId
256: * @param TokenizePaymentRequest $body
257: * @param CallContext $callContext
258: * @return CreateTokenResponse
259: *
260: * @throws IdempotenceException
261: * @throws ValidationException
262: * @throws AuthorizationException
263: * @throws ReferenceException
264: * @throws PlatformException
265: * @throws ApiException
266: * @throws InvalidResponseException
267: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/tokenize.html Create a token from payment
268: */
269: public function tokenize($paymentId, TokenizePaymentRequest $body, CallContext $callContext = null)
270: {
271: $this->context['paymentId'] = $paymentId;
272: $responseClassMap = new ResponseClassMap();
273: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CreateTokenResponse';
274: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
275: try {
276: return $this->getCommunicator()->post(
277: $responseClassMap,
278: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/tokenize'),
279: $this->getClientMetaInfo(),
280: $body,
281: null,
282: $callContext
283: );
284: } catch (ErrorResponseException $e) {
285: throw $this->getResponseExceptionFactory()->createException(
286: $e->getHttpStatusCode(),
287: $e->getErrorResponse(),
288: $callContext
289: );
290: }
291: }
292:
293: /**
294: * Resource /{merchantId}/payments/{paymentId}/processchallenged - Approves challenged payment
295: *
296: * @param string $paymentId
297: * @param CallContext $callContext
298: * @return PaymentResponse
299: *
300: * @throws IdempotenceException
301: * @throws ValidationException
302: * @throws AuthorizationException
303: * @throws ReferenceException
304: * @throws PlatformException
305: * @throws ApiException
306: * @throws InvalidResponseException
307: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/processchallenged.html Approves challenged payment
308: */
309: public function processchallenged($paymentId, CallContext $callContext = null)
310: {
311: $this->context['paymentId'] = $paymentId;
312: $responseClassMap = new ResponseClassMap();
313: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentResponse';
314: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
315: try {
316: return $this->getCommunicator()->post(
317: $responseClassMap,
318: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/processchallenged'),
319: $this->getClientMetaInfo(),
320: null,
321: null,
322: $callContext
323: );
324: } catch (ErrorResponseException $e) {
325: throw $this->getResponseExceptionFactory()->createException(
326: $e->getHttpStatusCode(),
327: $e->getErrorResponse(),
328: $callContext
329: );
330: }
331: }
332:
333: /**
334: * Resource /{merchantId}/payments/{paymentId}/approve - Approve payment
335: *
336: * @param string $paymentId
337: * @param ApprovePaymentRequest $body
338: * @param CallContext $callContext
339: * @return PaymentApprovalResponse
340: *
341: * @throws IdempotenceException
342: * @throws ValidationException
343: * @throws AuthorizationException
344: * @throws ReferenceException
345: * @throws PlatformException
346: * @throws ApiException
347: * @throws InvalidResponseException
348: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/approve.html Approve payment
349: */
350: public function approve($paymentId, ApprovePaymentRequest $body, CallContext $callContext = null)
351: {
352: $this->context['paymentId'] = $paymentId;
353: $responseClassMap = new ResponseClassMap();
354: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentApprovalResponse';
355: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
356: try {
357: return $this->getCommunicator()->post(
358: $responseClassMap,
359: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/approve'),
360: $this->getClientMetaInfo(),
361: $body,
362: null,
363: $callContext
364: );
365: } catch (ErrorResponseException $e) {
366: throw $this->getResponseExceptionFactory()->createException(
367: $e->getHttpStatusCode(),
368: $e->getErrorResponse(),
369: $callContext
370: );
371: }
372: }
373:
374: /**
375: * Resource /{merchantId}/payments/{paymentId}/capture - Capture payment
376: *
377: * @param string $paymentId
378: * @param CapturePaymentRequest $body
379: * @param CallContext $callContext
380: * @return CaptureResponse
381: *
382: * @throws IdempotenceException
383: * @throws ValidationException
384: * @throws AuthorizationException
385: * @throws ReferenceException
386: * @throws PlatformException
387: * @throws ApiException
388: * @throws InvalidResponseException
389: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/capture.html Capture payment
390: */
391: public function capture($paymentId, CapturePaymentRequest $body, CallContext $callContext = null)
392: {
393: $this->context['paymentId'] = $paymentId;
394: $responseClassMap = new ResponseClassMap();
395: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CaptureResponse';
396: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
397: try {
398: return $this->getCommunicator()->post(
399: $responseClassMap,
400: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/capture'),
401: $this->getClientMetaInfo(),
402: $body,
403: null,
404: $callContext
405: );
406: } catch (ErrorResponseException $e) {
407: throw $this->getResponseExceptionFactory()->createException(
408: $e->getHttpStatusCode(),
409: $e->getErrorResponse(),
410: $callContext
411: );
412: }
413: }
414:
415: /**
416: * Resource /{merchantId}/payments/{paymentId}/finalizecapture - Finalize capture
417: *
418: * @param string $paymentId
419: * @param CallContext $callContext
420: * @return PaymentResponse
421: *
422: * @throws IdempotenceException
423: * @throws ValidationException
424: * @throws AuthorizationException
425: * @throws ReferenceException
426: * @throws PlatformException
427: * @throws ApiException
428: * @throws InvalidResponseException
429: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/finalizecapture.html Finalize capture
430: */
431: public function finalizecapture($paymentId, CallContext $callContext = null)
432: {
433: $this->context['paymentId'] = $paymentId;
434: $responseClassMap = new ResponseClassMap();
435: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\PaymentResponse';
436: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
437: try {
438: return $this->getCommunicator()->post(
439: $responseClassMap,
440: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/finalizecapture'),
441: $this->getClientMetaInfo(),
442: null,
443: null,
444: $callContext
445: );
446: } catch (ErrorResponseException $e) {
447: throw $this->getResponseExceptionFactory()->createException(
448: $e->getHttpStatusCode(),
449: $e->getErrorResponse(),
450: $callContext
451: );
452: }
453: }
454:
455: /**
456: * Resource /{merchantId}/payments/{paymentId}/cancelapproval - Undo capture payment
457: *
458: * @param string $paymentId
459: * @param CallContext $callContext
460: * @return CancelApprovalPaymentResponse
461: *
462: * @throws IdempotenceException
463: * @throws ValidationException
464: * @throws AuthorizationException
465: * @throws ReferenceException
466: * @throws PlatformException
467: * @throws ApiException
468: * @throws InvalidResponseException
469: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/cancelapproval.html Undo capture payment
470: */
471: public function cancelapproval($paymentId, CallContext $callContext = null)
472: {
473: $this->context['paymentId'] = $paymentId;
474: $responseClassMap = new ResponseClassMap();
475: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CancelApprovalPaymentResponse';
476: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
477: try {
478: return $this->getCommunicator()->post(
479: $responseClassMap,
480: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/cancelapproval'),
481: $this->getClientMetaInfo(),
482: null,
483: null,
484: $callContext
485: );
486: } catch (ErrorResponseException $e) {
487: throw $this->getResponseExceptionFactory()->createException(
488: $e->getHttpStatusCode(),
489: $e->getErrorResponse(),
490: $callContext
491: );
492: }
493: }
494:
495: /**
496: * Resource /{merchantId}/payments/{paymentId}/captures - Get captures of payment
497: *
498: * @param string $paymentId
499: * @param CallContext $callContext
500: * @return CapturesResponse
501: *
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/captures.html Get captures of payment
510: */
511: public function captures($paymentId, CallContext $callContext = null)
512: {
513: $this->context['paymentId'] = $paymentId;
514: $responseClassMap = new ResponseClassMap();
515: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CapturesResponse';
516: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
517: try {
518: return $this->getCommunicator()->get(
519: $responseClassMap,
520: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/captures'),
521: $this->getClientMetaInfo(),
522: null,
523: $callContext
524: );
525: } catch (ErrorResponseException $e) {
526: throw $this->getResponseExceptionFactory()->createException(
527: $e->getHttpStatusCode(),
528: $e->getErrorResponse(),
529: $callContext
530: );
531: }
532: }
533:
534: /**
535: * Resource /{merchantId}/payments/{paymentId}/refund - Create refund
536: *
537: * @param string $paymentId
538: * @param RefundRequest $body
539: * @param CallContext $callContext
540: * @return RefundResponse
541: *
542: * @throws DeclinedRefundException
543: * @throws IdempotenceException
544: * @throws ValidationException
545: * @throws AuthorizationException
546: * @throws ReferenceException
547: * @throws PlatformException
548: * @throws ApiException
549: * @throws InvalidResponseException
550: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/refund.html Create refund
551: */
552: public function refund($paymentId, RefundRequest $body, CallContext $callContext = null)
553: {
554: $this->context['paymentId'] = $paymentId;
555: $responseClassMap = new ResponseClassMap();
556: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\RefundResponse';
557: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\RefundErrorResponse';
558: try {
559: return $this->getCommunicator()->post(
560: $responseClassMap,
561: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/refund'),
562: $this->getClientMetaInfo(),
563: $body,
564: null,
565: $callContext
566: );
567: } catch (ErrorResponseException $e) {
568: throw $this->getResponseExceptionFactory()->createException(
569: $e->getHttpStatusCode(),
570: $e->getErrorResponse(),
571: $callContext
572: );
573: }
574: }
575:
576: /**
577: * Resource /{merchantId}/payments/{paymentId}/refunds - Get refunds of payment
578: *
579: * @param string $paymentId
580: * @param CallContext $callContext
581: * @return RefundsResponse
582: *
583: * @throws IdempotenceException
584: * @throws ValidationException
585: * @throws AuthorizationException
586: * @throws ReferenceException
587: * @throws PlatformException
588: * @throws ApiException
589: * @throws InvalidResponseException
590: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/refunds.html Get refunds of payment
591: */
592: public function refunds($paymentId, CallContext $callContext = null)
593: {
594: $this->context['paymentId'] = $paymentId;
595: $responseClassMap = new ResponseClassMap();
596: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\RefundsResponse';
597: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
598: try {
599: return $this->getCommunicator()->get(
600: $responseClassMap,
601: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/refunds'),
602: $this->getClientMetaInfo(),
603: null,
604: $callContext
605: );
606: } catch (ErrorResponseException $e) {
607: throw $this->getResponseExceptionFactory()->createException(
608: $e->getHttpStatusCode(),
609: $e->getErrorResponse(),
610: $callContext
611: );
612: }
613: }
614:
615: /**
616: * Resource /{merchantId}/payments/{paymentId}/cancel - Cancel payment
617: *
618: * @param string $paymentId
619: * @param CallContext $callContext
620: * @return CancelPaymentResponse
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/cancel.html Cancel payment
630: */
631: public function cancel($paymentId, CallContext $callContext = null)
632: {
633: $this->context['paymentId'] = $paymentId;
634: $responseClassMap = new ResponseClassMap();
635: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\CancelPaymentResponse';
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}/cancel'),
641: $this->getClientMetaInfo(),
642: null,
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}/dispute - Create dispute
657: *
658: * @param string $paymentId
659: * @param CreateDisputeRequest $body
660: * @param CallContext $callContext
661: * @return DisputeResponse
662: *
663: * @throws IdempotenceException
664: * @throws ValidationException
665: * @throws AuthorizationException
666: * @throws ReferenceException
667: * @throws PlatformException
668: * @throws ApiException
669: * @throws InvalidResponseException
670: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/dispute.html Create dispute
671: */
672: public function dispute($paymentId, CreateDisputeRequest $body, CallContext $callContext = null)
673: {
674: $this->context['paymentId'] = $paymentId;
675: $responseClassMap = new ResponseClassMap();
676: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\DisputeResponse';
677: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
678: try {
679: return $this->getCommunicator()->post(
680: $responseClassMap,
681: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/dispute'),
682: $this->getClientMetaInfo(),
683: $body,
684: null,
685: $callContext
686: );
687: } catch (ErrorResponseException $e) {
688: throw $this->getResponseExceptionFactory()->createException(
689: $e->getHttpStatusCode(),
690: $e->getErrorResponse(),
691: $callContext
692: );
693: }
694: }
695:
696: /**
697: * Resource /{merchantId}/payments/{paymentId}/disputes - Get disputes
698: *
699: * @param string $paymentId
700: * @param CallContext $callContext
701: * @return DisputesResponse
702: *
703: * @throws IdempotenceException
704: * @throws ValidationException
705: * @throws AuthorizationException
706: * @throws ReferenceException
707: * @throws PlatformException
708: * @throws ApiException
709: * @throws InvalidResponseException
710: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/disputes.html Get disputes
711: */
712: public function disputes($paymentId, CallContext $callContext = null)
713: {
714: $this->context['paymentId'] = $paymentId;
715: $responseClassMap = new ResponseClassMap();
716: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\DisputesResponse';
717: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
718: try {
719: return $this->getCommunicator()->get(
720: $responseClassMap,
721: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/disputes'),
722: $this->getClientMetaInfo(),
723: null,
724: $callContext
725: );
726: } catch (ErrorResponseException $e) {
727: throw $this->getResponseExceptionFactory()->createException(
728: $e->getHttpStatusCode(),
729: $e->getErrorResponse(),
730: $callContext
731: );
732: }
733: }
734:
735: /**
736: * Resource /{merchantId}/payments/{paymentId}/devicefingerprint - Get Device Fingerprint details
737: *
738: * @param string $paymentId
739: * @param CallContext $callContext
740: * @return DeviceFingerprintDetails
741: *
742: * @throws IdempotenceException
743: * @throws ValidationException
744: * @throws AuthorizationException
745: * @throws ReferenceException
746: * @throws PlatformException
747: * @throws ApiException
748: * @throws InvalidResponseException
749: * @link https://apireference.connect.worldline-solutions.com/s2sapi/v1/en_US/php/payments/devicefingerprint.html Get Device Fingerprint details
750: */
751: public function devicefingerprint($paymentId, CallContext $callContext = null)
752: {
753: $this->context['paymentId'] = $paymentId;
754: $responseClassMap = new ResponseClassMap();
755: $responseClassMap->defaultSuccessResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\DeviceFingerprintDetails';
756: $responseClassMap->defaultErrorResponseClassName = '\Worldline\Connect\Sdk\V1\Domain\ErrorResponse';
757: try {
758: return $this->getCommunicator()->get(
759: $responseClassMap,
760: $this->instantiateUri('/v1/{merchantId}/payments/{paymentId}/devicefingerprint'),
761: $this->getClientMetaInfo(),
762: null,
763: $callContext
764: );
765: } catch (ErrorResponseException $e) {
766: throw $this->getResponseExceptionFactory()->createException(
767: $e->getHttpStatusCode(),
768: $e->getErrorResponse(),
769: $callContext
770: );
771: }
772: }
773:
774: /** @return ExceptionFactory */
775: private function getResponseExceptionFactory()
776: {
777: if (is_null($this->responseExceptionFactory)) {
778: $this->responseExceptionFactory = new ExceptionFactory();
779: }
780: return $this->responseExceptionFactory;
781: }
782: }
783: