alt

Important information

Updates to Visa secure data field mandate: Read more about the mandatory changes.

Unzer

Manage metadata

Submit additional information about a transaction.

Overview

Metadata is the additional, optional information you can append to individual payments. That way you, as a merchant, can store important order or payment information with every charge or authorize.
Neither the content, nor the amount of metadata, matters for the payment procedure. It’s just an additional service for you, to mark or recognize certain payments.

A metadata resource consists of key-value pairs inside a simple json. It can be created, fetched and updated.

Create metadata

To create a new metadata resource, call the Unzer::createMetadata method, using your private key. As parameter use an UnzerSDK\Resources\Metadata object. Add your desired information to that object using the Metadata::addMetadatamethod. For example, to add your shop’s ID and code, and an invoice number:

Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Metadata metadata = new Metadata();
metadata.addMetadata("invoice-nr", "Rg-2018-11-1")
        .addMetadata("shop-id", "4711")
        .addMetadata("delivery-date", "24.12.2018")
        .addMetadata("reason", "X-mas present");

metadata = unzer.createMetadata(metadata);

The createMetadata method returns a metadataobject that contains the ID from the created metadata resource.

metadata.getId();

Fetch metadata

To fetch an existing metadata resource, call the Unzer.fetchMetadata method, with your metadata resource’s ID as parameter:

Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Metadata metadataFetched = unzer.fetchMetadata('s-mtd-irw2xptx0tng');

The fetchMetadata method returns a Metadata object that contains the data from the Unzer API response.