1 package com.srv4pos.server.api.integration.dibs;
2
3 import com.srv4pos.server.api.infrastructure.HttpMethod;
4 import com.srv4pos.server.api.infrastructure.IdentifierInfo;
5 import com.srv4pos.server.api.infrastructure.StringConnectionWriter;
6 import com.srv4pos.server.api.infrastructure.credentials.Credentials;
7 import com.srv4pos.server.api.infrastructure.http.HttpHelper;
8 import com.srv4pos.server.api.infrastructure.http.Transport;
9
10 import java.net.URL;
11
12 import static com.srv4pos.server.api.infrastructure.request.RequestHelper.requestString;
13 import static java.lang.String.format;
14
15 public class DibsIntegrationService {
16 private URL url;
17 private Credentials credentials;
18 private Transport transport;
19
20
21
22
23
24
25
26
27 public DibsIntegrationService(URL url, Credentials credentials, Transport transport) {
28 this.url = url;
29 this.credentials = credentials;
30 this.transport = transport;
31 }
32
33 public DibsPaymentNotifyInfo payByTicket(String country, String corporateId, String orderIdentifier, DibsPaymentInfo paymentInfo) {
34 return DibsPaymentNotifyInfo.fromJsonToDibsPaymentNotifyInfo(
35 requestString(format("/dibs/payment/%s%s/%s", country, corporateId, orderIdentifier),
36 HttpMethod.POST,
37 url,
38 credentials.toAuthentication(),
39 null,
40 null,
41 new StringConnectionWriter(paymentInfo.toJson()),
42 HttpHelper.CONTENT_TYPE_APPLICATION_JSON,
43 transport).getContent());
44 }
45
46 }