Custom data

When integrating your application with the gateway, you will sometimes find it useful to store your database IDs or other identifiers on the gateway, together with the created objects.

Later when you retrieve the thus enriched objects, you will receive your custom data back as well.

Adding custom data

Adding custom data is enabled on most of the top-level gateway objects, like Customer, Transaction, CreditCard, Plan, Address and some others.

// set all properties as usual, and then add your custom fields
    ->customData(array('my-field' => 'value', 'my-field2' => 'value2'));

You make sure that you are sending non-binary content, and that you try to keep it lightweight as possible, so not to slow down the objects retrieval later.

Reading custom data

Once you retrieve the same gateway object later, you can easily access your custom data.

$transaction = Pencepay_Transaction::find('transaction_uid');

// Read your custom data field