Adding custom metadata to payments

Would you like to add affiliate id to payments so that you can track referrals?

What is the use case?

Let’s say you’re working with affiliates to send prospects to your payment page.

Affiliates send you traffic which includes an affiliate ID in a URL parameter, like this: WP Full Stripe - Affiliate ID passed as URL parameter

You’d need to save the affiliate id as metadata of the payment, so that you can identify payments for which you have to pay an affiliate fee.

How to implement it

If you’d like to add metadata via URL parameters, then you have to do the following:

  1. Pass metadata in URL parameter(s) to the payment page.
  2. Implement a Wordpress filter that processes the URL parameter(s), and add them as metadata.
    (Example implementation provided below)

The following subsections explain these steps in detail.

1) Pass metadata in URL parameters

Add the metadata as URL parameters. In the example below, the affiliate id is passed in the affid URL parameter to demo payment page:

2) Implement a Wordpress filter to process the URL parameter

For the sake of security, the plugin doesn’t let anyone set metadata directly without your consent.

You can give consent by implementing a short piece of code in the form of a Wordpress filter, whick picks URL parameters and adds them as metadata. The code needs to be added to the functions.php file of your active Wordpress theme.

Here is an example implementation, see description below:

In the example above, the code checks whether the $pageParams array contains the affid parameter, and if it does then adds it to the $result_meta array which contains the metadata to be added to the transaction.

Where are metadata on the Stripe dashboard?

Depending on your form type, metadata is saved into different Stripe items.

Please refer to our knowledge base article on where are custom fields on the Stripe dashboard, which explains it in detail (custom fields are also saved as metadata).

Still not finding the solution?

Our support team is happy to help you.

Contact support

Feature requests are always welcome!
We consider each feature request carefully, and examine how it fits the roadmap for the plugin.