In order to use the Metadata with the Java SDK you need to create a Metadata object and initialize it with the heidelpay facade. Metadata will be stored as a map data structure.

After creating a metadata resource, you can use the metadata id to inject to any request for payments (Authorize, Charge, Payment Page)

Metadata model

public class Metadata implements PaymentType {
    public Metadata() {
    public Metadata(boolean sorted) {
        if (sorted) {
            metadataMap = new TreeMap<String, String>();
        } else {
            metadataMap = new LinkedHashMap<String, String>();
    private String id;
    private Map<String, String> metadataMap;
    private Heidelpay heidelpay;

Create Metadata

Create and initialize Metadata request

protected Metadata getTestMetadata() {
        return getTestMetadata(false);

protected Metadata getTestMetadata(boolean sorted) {
  Metadata metadata = new Metadata(sorted)
    .addMetadata("invoice-nr", "Rg-2018-11-1")
    .addMetadata("shop-id", "4711")
    .addMetadata("delivery-date", "24.12.2018")
    .addMetadata("reason", "X-mas present");
  return metadata;

Create Metadata

Heidelpay heidelpay = new Heidelpay("s-priv-xxxxxxxxxx");
Metadata metadata = heidelpay.createMetadata(getTestMetadata());