alt

Important information

There was an update of Unzer TLS/SSL certificates. Learn more

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    = new UnzerSDK\Unzer('s-priv-xxxxxxxxxx');
$metadata = new UnzerSDK\Resources\Metadata();
$metadata->addMetadata('shop_id', 's-001')
  ->addMetadata('shop_code', 'sample001')
  ->addMetadata('invoice_number', 'invoice-4711');

$unzer->createMetadata($metadata);

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

Add metadata to a transaction

After creating a metadata resource, you can add it to a transaction. When making a charges or authorize call, add the metadata object, as metadata parameter:

Fetch metadata

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

The fetchMetadatamethod returns a Metadataobject that contains the data from the PAPI response.

Use your private key for making the request.