• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Adyen / adyen-java-api-library / #2934

11 Dec 2023 05:06PM CUT coverage: 12.835%. First build
#2934

push

web-flow
Merge 0111dd892 into d70611050

173 of 797 new or added lines in 39 files covered. (21.71%)

12464 of 97111 relevant lines covered (12.83%)

0.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.75
/src/main/java/com/adyen/service/checkout/PaymentsApi.java
1
/*
2
 * Adyen Checkout API
3
 *
4
 * The version of the OpenAPI document: 71
5
 * 
6
 *
7
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
8
 * https://openapi-generator.tech
9
 * Do not edit the class manually.
10
 */
11

12
package com.adyen.service.checkout;
13

14
import com.adyen.Client;
15
import com.adyen.Service;
16
import com.adyen.constants.ApiConstants;
17
import com.adyen.model.checkout.CardDetailsRequest;
18
import com.adyen.model.checkout.CardDetailsResponse;
19
import com.adyen.model.checkout.CreateCheckoutSessionRequest;
20
import com.adyen.model.checkout.CreateCheckoutSessionResponse;
21
import com.adyen.model.checkout.DonationPaymentRequest;
22
import com.adyen.model.checkout.DonationPaymentResponse;
23
import com.adyen.model.checkout.PaymentDetailsRequest;
24
import com.adyen.model.checkout.PaymentDetailsResponse;
25
import com.adyen.model.checkout.PaymentMethodsRequest;
26
import com.adyen.model.checkout.PaymentMethodsResponse;
27
import com.adyen.model.checkout.PaymentRequest;
28
import com.adyen.model.checkout.PaymentResponse;
29
import com.adyen.model.checkout.ServiceError;
30
import com.adyen.model.checkout.SessionResultResponse;
31
import com.adyen.model.RequestOptions;
32
import com.adyen.service.exception.ApiException;
33
import com.adyen.service.resource.Resource;
34

35
import java.io.IOException;
36
import java.util.HashMap;
37
import java.util.Map;
38

39
public class PaymentsApi extends Service {
40

41
    public static final String API_VERSION = "71";
42

43
    protected String baseURL;
44

45
    /**
46
    *  constructor in {@link com.adyen.service.checkout package}.
47
    * @param client {@link Client } (required)
48
    */
49
    public PaymentsApi(Client client) {
50
        super(client);
1✔
51
        this.baseURL = createBaseURL("https://checkout-test.adyen.com/v71");
1✔
52
    }
1✔
53

54
    /**
55
    *  constructor in {@link com.adyen.service.checkout package}.
56
    * Please use this constructor only if you would like to pass along your own url for routing or testing purposes. The latest API version is defined in this class as a constant.
57
    * @param client {@link Client } (required)
58
    * @param baseURL {@link String } (required)
59
    */
60
    public PaymentsApi(Client client, String baseURL) {
61
        super(client);
×
62
        this.baseURL = baseURL;
×
63
    }
×
64

65
    /**
66
    * Get the list of brands on the card
67
    *
68
    * @param cardDetailsRequest {@link CardDetailsRequest }  (required)
69
    * @return {@link CardDetailsResponse }
70
    * @throws ApiException if fails to make API call
71
    */
72
    public CardDetailsResponse cardDetails(CardDetailsRequest cardDetailsRequest) throws ApiException, IOException {
73
        return cardDetails(cardDetailsRequest, null);
1✔
74
    }
75

76
    /**
77
    * Get the list of brands on the card
78
    *
79
    * @param cardDetailsRequest {@link CardDetailsRequest }  (required)
80
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
81
    * @return {@link CardDetailsResponse }
82
    * @throws ApiException if fails to make API call
83
    */
84
    public CardDetailsResponse cardDetails(CardDetailsRequest cardDetailsRequest, RequestOptions requestOptions) throws ApiException, IOException {
85

86
        String requestBody = cardDetailsRequest.toJson();
1✔
87
        Resource resource = new Resource(this, this.baseURL + "/cardDetails", null);
1✔
88
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, null);
1✔
89
        return CardDetailsResponse.fromJson(jsonResult);
1✔
90
    }
91

92
    /**
93
    * Start a transaction for donations
94
    *
95
    * @param donationPaymentRequest {@link DonationPaymentRequest }  (required)
96
    * @return {@link DonationPaymentResponse }
97
    * @throws ApiException if fails to make API call
98
    */
99
    public DonationPaymentResponse donations(DonationPaymentRequest donationPaymentRequest) throws ApiException, IOException {
100
        return donations(donationPaymentRequest, null);
1✔
101
    }
102

103
    /**
104
    * Start a transaction for donations
105
    *
106
    * @param donationPaymentRequest {@link DonationPaymentRequest }  (required)
107
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
108
    * @return {@link DonationPaymentResponse }
109
    * @throws ApiException if fails to make API call
110
    */
111
    public DonationPaymentResponse donations(DonationPaymentRequest donationPaymentRequest, RequestOptions requestOptions) throws ApiException, IOException {
112

113
        String requestBody = donationPaymentRequest.toJson();
1✔
114
        Resource resource = new Resource(this, this.baseURL + "/donations", null);
1✔
115
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, null);
1✔
116
        return DonationPaymentResponse.fromJson(jsonResult);
1✔
117
    }
118

119
    /**
120
    * Get the result of a payment session
121
    *
122
    * @param sessionId {@link String } A unique identifier of the session. (required)
123
    * @param sessionResult {@link String } The `sessionResult` value from the Drop-in or Component. (required)
124
    * @return {@link SessionResultResponse }
125
    * @throws ApiException if fails to make API call
126
    */
127
    public SessionResultResponse getResultOfPaymentSession(String sessionId, String sessionResult) throws ApiException, IOException {
NEW
128
        return getResultOfPaymentSession(sessionId, sessionResult,  null);
×
129
    }
130

131
    /**
132
    * Get the result of a payment session
133
    *
134
    * @param sessionId {@link String } A unique identifier of the session. (required)
135
    * @param sessionResult {@link String } Query: The `sessionResult` value from the Drop-in or Component. (required)
136
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
137
    * @return {@link SessionResultResponse }
138
    * @throws ApiException if fails to make API call
139
    */
140
    public SessionResultResponse getResultOfPaymentSession(String sessionId, String sessionResult, RequestOptions requestOptions) throws ApiException, IOException {
141
        //Add path params
NEW
142
        Map<String, String> pathParams = new HashMap<>();
×
NEW
143
        if (sessionId == null) {
×
NEW
144
            throw new IllegalArgumentException("Please provide the sessionId path parameter");
×
145
        }
NEW
146
        pathParams.put("sessionId", sessionId);
×
147
        //Add query params
NEW
148
        Map<String, String> queryParams = new HashMap<>();
×
NEW
149
        if (sessionResult != null) {
×
NEW
150
        queryParams.put("sessionResult", sessionResult);
×
151
        }
152

NEW
153
        String requestBody = null;
×
NEW
154
        Resource resource = new Resource(this, this.baseURL + "/sessions/{sessionId}", null);
×
NEW
155
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.GET, pathParams, queryParams);
×
NEW
156
        return SessionResultResponse.fromJson(jsonResult);
×
157
    }
158

159
    /**
160
    * Get a list of available payment methods
161
    *
162
    * @param paymentMethodsRequest {@link PaymentMethodsRequest }  (required)
163
    * @return {@link PaymentMethodsResponse }
164
    * @throws ApiException if fails to make API call
165
    */
166
    public PaymentMethodsResponse paymentMethods(PaymentMethodsRequest paymentMethodsRequest) throws ApiException, IOException {
167
        return paymentMethods(paymentMethodsRequest, null);
1✔
168
    }
169

170
    /**
171
    * Get a list of available payment methods
172
    *
173
    * @param paymentMethodsRequest {@link PaymentMethodsRequest }  (required)
174
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
175
    * @return {@link PaymentMethodsResponse }
176
    * @throws ApiException if fails to make API call
177
    */
178
    public PaymentMethodsResponse paymentMethods(PaymentMethodsRequest paymentMethodsRequest, RequestOptions requestOptions) throws ApiException, IOException {
179

180
        String requestBody = paymentMethodsRequest.toJson();
1✔
181
        Resource resource = new Resource(this, this.baseURL + "/paymentMethods", null);
1✔
182
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, null);
1✔
183
        return PaymentMethodsResponse.fromJson(jsonResult);
1✔
184
    }
185

186
    /**
187
    * Start a transaction
188
    *
189
    * @param paymentRequest {@link PaymentRequest }  (required)
190
    * @return {@link PaymentResponse }
191
    * @throws ApiException if fails to make API call
192
    */
193
    public PaymentResponse payments(PaymentRequest paymentRequest) throws ApiException, IOException {
194
        return payments(paymentRequest, null);
1✔
195
    }
196

197
    /**
198
    * Start a transaction
199
    *
200
    * @param paymentRequest {@link PaymentRequest }  (required)
201
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
202
    * @return {@link PaymentResponse }
203
    * @throws ApiException if fails to make API call
204
    */
205
    public PaymentResponse payments(PaymentRequest paymentRequest, RequestOptions requestOptions) throws ApiException, IOException {
206

207
        String requestBody = paymentRequest.toJson();
1✔
208
        Resource resource = new Resource(this, this.baseURL + "/payments", null);
1✔
209
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, null);
1✔
210
        return PaymentResponse.fromJson(jsonResult);
1✔
211
    }
212

213
    /**
214
    * Submit details for a payment
215
    *
216
    * @param paymentDetailsRequest {@link PaymentDetailsRequest }  (required)
217
    * @return {@link PaymentDetailsResponse }
218
    * @throws ApiException if fails to make API call
219
    */
220
    public PaymentDetailsResponse paymentsDetails(PaymentDetailsRequest paymentDetailsRequest) throws ApiException, IOException {
221
        return paymentsDetails(paymentDetailsRequest, null);
1✔
222
    }
223

224
    /**
225
    * Submit details for a payment
226
    *
227
    * @param paymentDetailsRequest {@link PaymentDetailsRequest }  (required)
228
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
229
    * @return {@link PaymentDetailsResponse }
230
    * @throws ApiException if fails to make API call
231
    */
232
    public PaymentDetailsResponse paymentsDetails(PaymentDetailsRequest paymentDetailsRequest, RequestOptions requestOptions) throws ApiException, IOException {
233

234
        String requestBody = paymentDetailsRequest.toJson();
1✔
235
        Resource resource = new Resource(this, this.baseURL + "/payments/details", null);
1✔
236
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, null);
1✔
237
        return PaymentDetailsResponse.fromJson(jsonResult);
1✔
238
    }
239

240
    /**
241
    * Create a payment session
242
    *
243
    * @param createCheckoutSessionRequest {@link CreateCheckoutSessionRequest }  (required)
244
    * @return {@link CreateCheckoutSessionResponse }
245
    * @throws ApiException if fails to make API call
246
    */
247
    public CreateCheckoutSessionResponse sessions(CreateCheckoutSessionRequest createCheckoutSessionRequest) throws ApiException, IOException {
248
        return sessions(createCheckoutSessionRequest, null);
1✔
249
    }
250

251
    /**
252
    * Create a payment session
253
    *
254
    * @param createCheckoutSessionRequest {@link CreateCheckoutSessionRequest }  (required)
255
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
256
    * @return {@link CreateCheckoutSessionResponse }
257
    * @throws ApiException if fails to make API call
258
    */
259
    public CreateCheckoutSessionResponse sessions(CreateCheckoutSessionRequest createCheckoutSessionRequest, RequestOptions requestOptions) throws ApiException, IOException {
260

261
        String requestBody = createCheckoutSessionRequest.toJson();
1✔
262
        Resource resource = new Resource(this, this.baseURL + "/sessions", null);
1✔
263
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, null);
1✔
264
        return CreateCheckoutSessionResponse.fromJson(jsonResult);
1✔
265
    }
266
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc