Documentation

Add_filter | Form, Server & Direct | Modify the Payload Sent to Opayo

We’ve put this guide together as a little helping hand for developers and designers. You’ll need a basic understanding of PHP to make the most of it.

Just a quick heads-up, we can’t provide support for custom code or offer any bespoke tweaks. Think of the snippets below as examples to guide you in the right direction.

Overview

This filter allows developers to modify the payload data being sent to the Opayo API before the transaction is processed. It’s useful if you want to inject custom fields, change values, or perform conditional logic based on the order data.

Usage

To use the ag_opayo_modify_payload filter, add the following snippet to your functions.php file or a custom plugin:

php
12345678910111213141516
/**
 * Modify the Opayo Direct payload before it's sent to the API.
 *
 * This example adds a custom description.
 */

add_filter( 'ag_opayo_modify_payload', 'modify_opayo_payload_example', 10, 2 );

function modify_opayo_payload_example( $data, $order ) {
    // Example: Add a custom field to the description
    if ( $order instanceof WC_Order ) {
        $data['description'] = 'Order #' . $order->get_order_number() . ' - Custom Store';
    }

    return $data;
}

Parameters

  • $data (array)
The full payload array that will be sent to the Opayo API.
You can inspect or modify any fields here.
  • $order (WC_Order)
The WooCommerce order object related to the transaction.

Caution

Ensure that any changes made still comply with Opayo’s payload format, or the transaction may be rejected.

If you’re adding custom data not expected by Opayo, it may cause payment errors.

Was this helpful?

Opayo

Don't already have the plugin? Get access now.

Still need help?

Our team are on hand to provide fast, helpful and professional support.

Support request
All systems operational

Back End Demo

Start exploring our fully functional demo site today.
Gain exclusive admin access to see what's possible.

Create your demo now

Front End Demo

Test drive our plugin on the demo site.

View Demo