Store your data on Omise with the Metadata API

One of our long-standing feature requests has been an ability to attach customer-specific metadata such as order ID or tracking number to a Charge object. This surprisingly small feature has a number of uses, for example:

  • Attach an Order ID to each payment for cross-referencing later.
  • Add shipment or product variation information directly into the Charge object and use our dashboard as an ad-hoc order tracking system.
  • Provide more information to your financial team so they don't have to wait for your fulfillment team.
  • Although not recommended, with this you can use Omise API as your application's only database.

Previously we have been advising our merchants to put custom JSON into the description field as a work around. And we have noticed a large number of merchants utilizing this approach.

Today you no longer have to resort to that workaround anymore as we are updating our Charge and Customer API with a new metadata key which you can add any free-form JSON to. The only restriction is that the top-level object be a JSON hash.

Example for PHP:

<?php

$charge = OmiseCharge::create(array(
    'description' => 'Payment for Order #3947',
    'currency' => 'thb',
    'amount' => 10000,
    'card' => 'tokn_test_58307zpezucfvb6u1ty',
    'metadata' => array(
        'order_id' => '3947'
    )
));

Example JSON response:

{
  "object": "charge",
  "description": "Payment for Order #3947",
  "metadata": {
    "order_id": "3947"
  },
  "...": "..."
}

If this has helped simplify your application or you came up with a use case that we have not thought about, or even for bug reports please pop onto Gitter and let us know!