• 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

19.64
/src/main/java/com/adyen/service/checkout/ModificationsApi.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.PaymentAmountUpdateRequest;
18
import com.adyen.model.checkout.PaymentAmountUpdateResponse;
19
import com.adyen.model.checkout.PaymentCancelRequest;
20
import com.adyen.model.checkout.PaymentCancelResponse;
21
import com.adyen.model.checkout.PaymentCaptureRequest;
22
import com.adyen.model.checkout.PaymentCaptureResponse;
23
import com.adyen.model.checkout.PaymentRefundRequest;
24
import com.adyen.model.checkout.PaymentRefundResponse;
25
import com.adyen.model.checkout.PaymentReversalRequest;
26
import com.adyen.model.checkout.PaymentReversalResponse;
27
import com.adyen.model.checkout.ServiceError;
28
import com.adyen.model.checkout.StandalonePaymentCancelRequest;
29
import com.adyen.model.checkout.StandalonePaymentCancelResponse;
30
import com.adyen.model.RequestOptions;
31
import com.adyen.service.exception.ApiException;
32
import com.adyen.service.resource.Resource;
33

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

38
public class ModificationsApi extends Service {
39

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

42
    protected String baseURL;
43

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

53
    /**
54
    *  constructor in {@link com.adyen.service.checkout package}.
55
    * 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.
56
    * @param client {@link Client } (required)
57
    * @param baseURL {@link String } (required)
58
    */
59
    public ModificationsApi(Client client, String baseURL) {
60
        super(client);
×
61
        this.baseURL = baseURL;
×
62
    }
×
63

64
    /**
65
    * Cancel an authorised payment
66
    *
67
    * @param standalonePaymentCancelRequest {@link StandalonePaymentCancelRequest }  (required)
68
    * @return {@link StandalonePaymentCancelResponse }
69
    * @throws ApiException if fails to make API call
70
    */
71
    public StandalonePaymentCancelResponse cancelAuthorisedPayment(StandalonePaymentCancelRequest standalonePaymentCancelRequest) throws ApiException, IOException {
72
        return cancelAuthorisedPayment(standalonePaymentCancelRequest, null);
×
73
    }
74

75
    /**
76
    * Cancel an authorised payment
77
    *
78
    * @param standalonePaymentCancelRequest {@link StandalonePaymentCancelRequest }  (required)
79
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
80
    * @return {@link StandalonePaymentCancelResponse }
81
    * @throws ApiException if fails to make API call
82
    */
83
    public StandalonePaymentCancelResponse cancelAuthorisedPayment(StandalonePaymentCancelRequest standalonePaymentCancelRequest, RequestOptions requestOptions) throws ApiException, IOException {
84

85
        String requestBody = standalonePaymentCancelRequest.toJson();
×
86
        Resource resource = new Resource(this, this.baseURL + "/cancels", null);
×
87
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, null);
×
88
        return StandalonePaymentCancelResponse.fromJson(jsonResult);
×
89
    }
90

91
    /**
92
    * Cancel an authorised payment
93
    *
94
    * @param paymentPspReference {@link String } The [`pspReference`](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/payments__resParam_pspReference) of the payment that you want to cancel.  (required)
95
    * @param paymentCancelRequest {@link PaymentCancelRequest }  (required)
96
    * @return {@link PaymentCancelResponse }
97
    * @throws ApiException if fails to make API call
98
    */
99
    public PaymentCancelResponse cancelAuthorisedPaymentByPspReference(String paymentPspReference, PaymentCancelRequest paymentCancelRequest) throws ApiException, IOException {
100
        return cancelAuthorisedPaymentByPspReference(paymentPspReference, paymentCancelRequest, null);
×
101
    }
102

103
    /**
104
    * Cancel an authorised payment
105
    *
106
    * @param paymentPspReference {@link String } The [`pspReference`](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/payments__resParam_pspReference) of the payment that you want to cancel.  (required)
107
    * @param paymentCancelRequest {@link PaymentCancelRequest }  (required)
108
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
109
    * @return {@link PaymentCancelResponse }
110
    * @throws ApiException if fails to make API call
111
    */
112
    public PaymentCancelResponse cancelAuthorisedPaymentByPspReference(String paymentPspReference, PaymentCancelRequest paymentCancelRequest, RequestOptions requestOptions) throws ApiException, IOException {
113
        //Add path params
114
        Map<String, String> pathParams = new HashMap<>();
×
115
        if (paymentPspReference == null) {
×
116
            throw new IllegalArgumentException("Please provide the paymentPspReference path parameter");
×
117
        }
118
        pathParams.put("paymentPspReference", paymentPspReference);
×
119

120
        String requestBody = paymentCancelRequest.toJson();
×
121
        Resource resource = new Resource(this, this.baseURL + "/payments/{paymentPspReference}/cancels", null);
×
122
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, pathParams);
×
123
        return PaymentCancelResponse.fromJson(jsonResult);
×
124
    }
125

126
    /**
127
    * Capture an authorised payment
128
    *
129
    * @param paymentPspReference {@link String } The [&#x60;pspReference&#x60;](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/payments__resParam_pspReference) of the payment that you want to capture. (required)
130
    * @param paymentCaptureRequest {@link PaymentCaptureRequest }  (required)
131
    * @return {@link PaymentCaptureResponse }
132
    * @throws ApiException if fails to make API call
133
    */
134
    public PaymentCaptureResponse captureAuthorisedPayment(String paymentPspReference, PaymentCaptureRequest paymentCaptureRequest) throws ApiException, IOException {
135
        return captureAuthorisedPayment(paymentPspReference, paymentCaptureRequest, null);
×
136
    }
137

138
    /**
139
    * Capture an authorised payment
140
    *
141
    * @param paymentPspReference {@link String } The [&#x60;pspReference&#x60;](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/payments__resParam_pspReference) of the payment that you want to capture. (required)
142
    * @param paymentCaptureRequest {@link PaymentCaptureRequest }  (required)
143
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
144
    * @return {@link PaymentCaptureResponse }
145
    * @throws ApiException if fails to make API call
146
    */
147
    public PaymentCaptureResponse captureAuthorisedPayment(String paymentPspReference, PaymentCaptureRequest paymentCaptureRequest, RequestOptions requestOptions) throws ApiException, IOException {
148
        //Add path params
149
        Map<String, String> pathParams = new HashMap<>();
×
150
        if (paymentPspReference == null) {
×
151
            throw new IllegalArgumentException("Please provide the paymentPspReference path parameter");
×
152
        }
153
        pathParams.put("paymentPspReference", paymentPspReference);
×
154

155
        String requestBody = paymentCaptureRequest.toJson();
×
156
        Resource resource = new Resource(this, this.baseURL + "/payments/{paymentPspReference}/captures", null);
×
157
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, pathParams);
×
158
        return PaymentCaptureResponse.fromJson(jsonResult);
×
159
    }
160

161
    /**
162
    * Refund a captured payment
163
    *
164
    * @param paymentPspReference {@link String } The [&#x60;pspReference&#x60;](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/payments__resParam_pspReference) of the payment that you want to refund. (required)
165
    * @param paymentRefundRequest {@link PaymentRefundRequest }  (required)
166
    * @return {@link PaymentRefundResponse }
167
    * @throws ApiException if fails to make API call
168
    */
169
    public PaymentRefundResponse refundCapturedPayment(String paymentPspReference, PaymentRefundRequest paymentRefundRequest) throws ApiException, IOException {
170
        return refundCapturedPayment(paymentPspReference, paymentRefundRequest, null);
×
171
    }
172

173
    /**
174
    * Refund a captured payment
175
    *
176
    * @param paymentPspReference {@link String } The [&#x60;pspReference&#x60;](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/payments__resParam_pspReference) of the payment that you want to refund. (required)
177
    * @param paymentRefundRequest {@link PaymentRefundRequest }  (required)
178
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
179
    * @return {@link PaymentRefundResponse }
180
    * @throws ApiException if fails to make API call
181
    */
182
    public PaymentRefundResponse refundCapturedPayment(String paymentPspReference, PaymentRefundRequest paymentRefundRequest, RequestOptions requestOptions) throws ApiException, IOException {
183
        //Add path params
184
        Map<String, String> pathParams = new HashMap<>();
×
185
        if (paymentPspReference == null) {
×
186
            throw new IllegalArgumentException("Please provide the paymentPspReference path parameter");
×
187
        }
188
        pathParams.put("paymentPspReference", paymentPspReference);
×
189

190
        String requestBody = paymentRefundRequest.toJson();
×
191
        Resource resource = new Resource(this, this.baseURL + "/payments/{paymentPspReference}/refunds", null);
×
192
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, pathParams);
×
193
        return PaymentRefundResponse.fromJson(jsonResult);
×
194
    }
195

196
    /**
197
    * Refund or cancel a payment
198
    *
199
    * @param paymentPspReference {@link String } The [&#x60;pspReference&#x60;](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/payments__resParam_pspReference) of the payment that you want to reverse.  (required)
200
    * @param paymentReversalRequest {@link PaymentReversalRequest }  (required)
201
    * @return {@link PaymentReversalResponse }
202
    * @throws ApiException if fails to make API call
203
    */
204
    public PaymentReversalResponse refundOrCancelPayment(String paymentPspReference, PaymentReversalRequest paymentReversalRequest) throws ApiException, IOException {
205
        return refundOrCancelPayment(paymentPspReference, paymentReversalRequest, null);
×
206
    }
207

208
    /**
209
    * Refund or cancel a payment
210
    *
211
    * @param paymentPspReference {@link String } The [&#x60;pspReference&#x60;](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/payments__resParam_pspReference) of the payment that you want to reverse.  (required)
212
    * @param paymentReversalRequest {@link PaymentReversalRequest }  (required)
213
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
214
    * @return {@link PaymentReversalResponse }
215
    * @throws ApiException if fails to make API call
216
    */
217
    public PaymentReversalResponse refundOrCancelPayment(String paymentPspReference, PaymentReversalRequest paymentReversalRequest, RequestOptions requestOptions) throws ApiException, IOException {
218
        //Add path params
219
        Map<String, String> pathParams = new HashMap<>();
×
220
        if (paymentPspReference == null) {
×
221
            throw new IllegalArgumentException("Please provide the paymentPspReference path parameter");
×
222
        }
223
        pathParams.put("paymentPspReference", paymentPspReference);
×
224

225
        String requestBody = paymentReversalRequest.toJson();
×
226
        Resource resource = new Resource(this, this.baseURL + "/payments/{paymentPspReference}/reversals", null);
×
227
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, pathParams);
×
228
        return PaymentReversalResponse.fromJson(jsonResult);
×
229
    }
230

231
    /**
232
    * Update an authorised amount
233
    *
234
    * @param paymentPspReference {@link String } The [&#x60;pspReference&#x60;](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/payments__resParam_pspReference) of the payment. (required)
235
    * @param paymentAmountUpdateRequest {@link PaymentAmountUpdateRequest }  (required)
236
    * @return {@link PaymentAmountUpdateResponse }
237
    * @throws ApiException if fails to make API call
238
    */
239
    public PaymentAmountUpdateResponse updateAuthorisedAmount(String paymentPspReference, PaymentAmountUpdateRequest paymentAmountUpdateRequest) throws ApiException, IOException {
240
        return updateAuthorisedAmount(paymentPspReference, paymentAmountUpdateRequest, null);
1✔
241
    }
242

243
    /**
244
    * Update an authorised amount
245
    *
246
    * @param paymentPspReference {@link String } The [&#x60;pspReference&#x60;](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/payments__resParam_pspReference) of the payment. (required)
247
    * @param paymentAmountUpdateRequest {@link PaymentAmountUpdateRequest }  (required)
248
    * @param requestOptions {@link RequestOptions } Object to store additional data such as idempotency-keys (optional)
249
    * @return {@link PaymentAmountUpdateResponse }
250
    * @throws ApiException if fails to make API call
251
    */
252
    public PaymentAmountUpdateResponse updateAuthorisedAmount(String paymentPspReference, PaymentAmountUpdateRequest paymentAmountUpdateRequest, RequestOptions requestOptions) throws ApiException, IOException {
253
        //Add path params
254
        Map<String, String> pathParams = new HashMap<>();
1✔
255
        if (paymentPspReference == null) {
1✔
NEW
256
            throw new IllegalArgumentException("Please provide the paymentPspReference path parameter");
×
257
        }
258
        pathParams.put("paymentPspReference", paymentPspReference);
1✔
259

260
        String requestBody = paymentAmountUpdateRequest.toJson();
1✔
261
        Resource resource = new Resource(this, this.baseURL + "/payments/{paymentPspReference}/amountUpdates", null);
1✔
262
        String jsonResult = resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, pathParams);
1✔
263
        return PaymentAmountUpdateResponse.fromJson(jsonResult);
1✔
264
    }
265
}
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