Add TAPI utility helpers for PredefinedContent and SaleToAcquirerData#1913
Add TAPI utility helpers for PredefinedContent and SaleToAcquirerData#1913
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces several helper classes—PredefinedContentHelper, SaleDataHelper, and SaleToAcquirerData—to handle the parsing of terminal API data, including URL query-like strings and SaleToAcquirerData in both Base64-encoded JSON and form-encoded formats. The review feedback highlights an opportunity to improve efficiency by avoiding redundant Base64 decoding in SaleDataHelper and suggests explicitly defining the UTF-8 charset when converting bytes to strings in SaleToAcquirerData for better environment consistency.
27e02df to
4e32d8e
Compare
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| public class SaleToAcquirerData { | ||
|
|
||
| private static final ObjectMapper MAPPER = |
There was a problem hiding this comment.
Do we need a dedicated object mapper here? Can we just use com.adyen.model.tapi.JSON?
There was a problem hiding this comment.
@thomasc-adyen This one seems better to leave as-is:
com.adyen.model.tapi.JSONregisters several features (like JavaTimeModule) that are not needed herecom.adyen.model.tapi.JSONis auto-generated while the utility classes are not- local
mapperis light (set the only config it needs) and immutable (unlike tapi JSON)
Summary
Introduces hand-written utility helpers in
com.adyen.util.tapito work with fields from the auto-generated TAPI models that require additional parsing logic:PredefinedContent.ReferenceIDstring with URL query string formatSaleData.SaleToAcquirerDatastring with either JSON or key-value pairsNew classes
PredefinedContentHelperParses the
PredefinedContent.ReferenceIDURL query string into typed accessors:getEvent(),getTransactionId(),getTimeStamp(), andget(key).SaleToAcquirerDataA Jackson-based POJO representing the decoded acquirer data. Supports both formats described in the Adyen docs:
fromBase64)fromKeyValuePairs)SaleDataHelperWraps a
tapi.SaleDatainstance and exposesgetSaleToAcquirerData(), auto-detecting the format of the underlying string.Notes
com.adyen.model.tapiwhich is auto-generated from the OpenAPI speccom.adyen.model.terminalpackagejava.util.Base64and Jackson throughout, consistent with the rest of the TAPI stack