Skip to content

Add TAPI utility helpers for PredefinedContent and SaleToAcquirerData#1913

Open
gcatanese wants to merge 2 commits intomainfrom
add-tapi-util
Open

Add TAPI utility helpers for PredefinedContent and SaleToAcquirerData#1913
gcatanese wants to merge 2 commits intomainfrom
add-tapi-util

Conversation

@gcatanese
Copy link
Copy Markdown
Contributor

@gcatanese gcatanese commented Apr 14, 2026

Summary

Introduces hand-written utility helpers in com.adyen.util.tapi to work with fields from the auto-generated TAPI models that require additional parsing logic:

  • PredefinedContent.ReferenceID string with URL query string format
  • SaleData.SaleToAcquirerData string with either JSON or key-value pairs

New classes

PredefinedContentHelper
Parses the PredefinedContent.ReferenceID URL query string into typed accessors: getEvent(), getTransactionId(), getTimeStamp(), and get(key).

SaleToAcquirerData
A Jackson-based POJO representing the decoded acquirer data. Supports both formats described in the Adyen docs:

  • Base64-encoded JSON (fromBase64)
  • Form-encoded key-value pairs (fromKeyValuePairs)

SaleDataHelper
Wraps a tapi.SaleData instance and exposes getSaleToAcquirerData(), auto-detecting the format of the underlying string.

Notes

  • All helpers live outside com.adyen.model.tapi which is auto-generated from the OpenAPI spec
  • No dependency on the legacy com.adyen.model.terminal package
  • Uses java.util.Base64 and Jackson throughout, consistent with the rest of the TAPI stack

@gcatanese gcatanese requested review from a team as code owners April 14, 2026 11:54
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/main/java/com/adyen/util/tapi/SaleDataHelper.java Outdated
Comment thread src/main/java/com/adyen/util/tapi/SaleToAcquirerData.java Outdated
Comment thread src/main/java/com/adyen/util/tapi/PredefinedContentHelper.java Outdated
Comment thread src/main/java/com/adyen/util/tapi/PredefinedContentHelper.java
Comment thread src/main/java/com/adyen/util/tapi/PredefinedContentHelper.java
Comment thread src/main/java/com/adyen/util/tapi/SaleDataHelper.java
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SaleToAcquirerData {

private static final ObjectMapper MAPPER =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a dedicated object mapper here? Can we just use com.adyen.model.tapi.JSON?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thomasc-adyen This one seems better to leave as-is:

  • com.adyen.model.tapi.JSON registers several features (like JavaTimeModule) that are not needed here
  • com.adyen.model.tapi.JSON is auto-generated while the utility classes are not
  • local mapper is light (set the only config it needs) and immutable (unlike tapi JSON)

Comment thread src/main/java/com/adyen/util/tapi/SaleToAcquirerData.java Outdated
@gcatanese gcatanese requested a review from thomasc-adyen April 16, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants