Skip to content

Commit fc08005

Browse files
authored
Javadoc improvements (#1556)
* Add javadoc * Remove unused
1 parent 56baa6d commit fc08005

File tree

5 files changed

+88
-54
lines changed

5 files changed

+88
-54
lines changed

src/main/java/com/adyen/constants/ErrorTypeCodes.java

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/main/java/com/adyen/model/notification/NotificationRequest.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,22 @@
3030
import java.util.List;
3131
import java.util.stream.Collectors;
3232

33-
/** NotificationRequest model class */
33+
/**
34+
* NotificationRequest model class
35+
* This class represents the payload of the Adyen webhooks related to Payments
36+
**/
3437
public class NotificationRequest {
38+
39+
/**
40+
* True when the event happened on the 'live' environment, false when it happened on 'test'
41+
*/
3542
@SerializedName("live")
3643
private String live = null;
3744

45+
/**
46+
* List of NotificationRequestItem that includes only one NotificationRequestItem
47+
* Developers should always fetch the first (and only) NotificationRequestItem
48+
*/
3849
@SerializedName("notificationItems")
3950
private List<NotificationRequestItemContainer> notificationItemContainers = null;
4051

src/main/java/com/adyen/model/notification/NotificationRequestItem.java

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
import java.util.List;
2121
import java.util.Map;
2222

23-
/** NotificationRequestItem model class */
23+
/**
24+
* NotificationRequestItem model class
25+
* This class represents the NotificationRequestItem object that includes the information about the webhook event.
26+
**/
2427
public class NotificationRequestItem {
2528

2629
// Standard Event codes
@@ -74,18 +77,33 @@ public class NotificationRequestItem {
7477
public static final String EVENT_CODE_MANUAL_REVIEW_ACCEPT = "MANUAL_REVIEW_ACCEPT";
7578
public static final String EVENT_CODE_MANUAL_REVIEW_REJECT = "MANUAL_REVIEW_REJECT";
7679

80+
/**
81+
* The payment amount. For HTTP POST notifications, currency and value are returned as URL parameters.
82+
*/
7783
@SerializedName("amount")
7884
private Amount amount = null;
7985

86+
/**
87+
* The type of event the notification item is for.
88+
*/
8089
@SerializedName("eventCode")
8190
private String eventCode = null;
8291

92+
/**
93+
* The time when the event was generated. Format: ISO 8601; yyyy-MM-DDThh:mm:ssTZD
94+
*/
8395
@SerializedName("eventDate")
8496
private Date eventDate = null;
8597

98+
/**
99+
* The merchant account identifier used in the transaction the notification item is for.
100+
*/
86101
@SerializedName("merchantAccountCode")
87102
private String merchantAccountCode = null;
88103

104+
/**
105+
* Your reference to uniquely identify the payment.
106+
*/
89107
@SerializedName("merchantReference")
90108
private String merchantReference = null;
91109

@@ -95,21 +113,42 @@ public class NotificationRequestItem {
95113
@SerializedName("originalPsp")
96114
private String originalPsp = null;
97115

116+
/**
117+
* Adyen's 16-character unique reference associated with the transaction or request.
118+
* This value is globally unique. Use it when communicating with us about this request.
119+
*/
98120
@SerializedName("pspReference")
99121
private String pspReference = null;
100122

123+
/**
124+
* If success = true and paymentMethod = visa, mc, or amex then this field contains the following details:
125+
* Authorisation code, last 4 digits of the card, card expiry date. In case of failure, this contains information
126+
* about the authorisation failure
127+
*/
101128
@SerializedName("reason")
102129
private String reason = null;
103130

131+
/**
132+
* If true: The payment request was successful. If false: The payment request failed. Check the reason field for failure information.
133+
*/
104134
@SerializedName("success")
105135
private boolean success;
106136

137+
/**
138+
* The payment method used in the transaction.
139+
*/
107140
@SerializedName("paymentMethod")
108141
private String paymentMethod;
109142

143+
/**
144+
* The operations indicate the supported follow-up actions concerning the payment.
145+
*/
110146
@SerializedName("operations")
111147
private List<String> operations;
112148

149+
/**
150+
* This object is a generic container that can hold extra fields.
151+
*/
113152
@SerializedName("additionalData")
114153
private Map<String, String> additionalData = null;
115154

src/main/java/com/adyen/model/terminal/TerminalAPIRequest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@
2424
import com.google.gson.annotations.SerializedName;
2525
import java.util.Objects;
2626

27-
/** Terminal API Request */
27+
/**
28+
* TerminalAPIRequest model class
29+
* This class represents the payload of the Adyen webhooks related to the Terminal API
30+
**/
2831
public class TerminalAPIRequest {
2932
@SerializedName("SaleToPOIRequest")
3033
private SaleToPOIRequest saleToPOIRequest;
3134

3235
/**
33-
* Gets sale to POI request.
36+
* Gets saleToPOIRequest.
3437
*
3538
* @return the sale to POI request
3639
*/
@@ -39,7 +42,7 @@ public SaleToPOIRequest getSaleToPOIRequest() {
3942
}
4043

4144
/**
42-
* Sets sale to POI request.
45+
* Sets saleToPOIRequest.
4346
*
4447
* @param saleToPOIRequest the sale to POI request
4548
*/

src/main/java/com/adyen/notification/WebhookHandler.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,51 @@
2828
import com.google.gson.reflect.TypeToken;
2929
import java.io.IOException;
3030

31-
/** Notification converter */
31+
32+
/**
33+
* Handler for Adyen webhooks.
34+
* It provides methods to parse incoming JSON webhook payloads into Java objects.
35+
*/
3236
public class WebhookHandler {
33-
private static final Gson GSON = new Gson();
3437
private final Gson terminalGson;
3538

39+
/**
40+
* Initializes a new instance of the {@link WebhookHandler}.
41+
*/
3642
public WebhookHandler() {
3743
terminalGson = TerminalAPIGsonBuilder.create();
3844
}
3945

46+
/**
47+
* Deserializes a JSON string into a {@link NotificationRequest} object.
48+
* This method uses Gson for deserialization.
49+
*
50+
* @param json The JSON string to deserialize.
51+
* @return The deserialized {@link NotificationRequest}.
52+
* @throws IOException if the JSON string cannot be deserialized.
53+
*/
4054
public NotificationRequest handleNotificationJson(String json) throws IOException {
4155
return NotificationRequest.fromJson(json);
4256
}
4357

58+
/**
59+
* Deserializes a JSON string into a {@link NotificationRequest} object using Jackson.
60+
*
61+
* @param json The JSON string to deserialize.
62+
* @return The deserialized {@link NotificationRequest}.
63+
* @throws IOException if the JSON string cannot be deserialized.
64+
*/
4465
public NotificationRequest handleNotificationJsonJackson(String json) throws IOException {
4566
return JSON.getMapper().readValue(json, NotificationRequest.class);
4667
}
4768

48-
// Note that terminal notifications are structured as TerminalAPIRequest objects
69+
/**
70+
* Deserializes a terminal notification JSON string into a {@link TerminalAPIRequest} object.
71+
* Note that terminal notifications are structured as {@link TerminalAPIRequest} objects.
72+
*
73+
* @param json The JSON string to deserialize.
74+
* @return The deserialized {@link TerminalAPIRequest}.
75+
*/
4976
public TerminalAPIRequest handleTerminalNotificationJson(String json) {
5077
return terminalGson.fromJson(json, new TypeToken<TerminalAPIRequest>() {}.getType());
5178
}

0 commit comments

Comments
 (0)