How can we help?
How to store your data on Omise with the Metadata API
Last updated on May 10, 2022You can attach customer-specific metadata such as order ID or tracking number to a Charge object using metadata. This 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.
Previously, merchants were advised to manually input custom JSON into the description field of the Charge objects to store desired metadata. Now, you have a more convenient alternative: metadata API, that you can add any free-form JSON to. The only restriction is that the top-level object be a JSON hash.
Example 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; if you came up with a use case that we have not thought about; or even for bug reports, please contact support@omise.co to let us know.
Can’t find your answer?
Get in touch with us and we’ll get back to you as soon as possible