Description

The wpforms_square_process_get_payment_args_single filter lets you modify the Square single-payment request arguments before they are sent. You can use it to inject dynamic data, run Smart Tags in the payment note, or adjust metadata.

Use this filter to run WPForms Smart Tags inside the Square note field so your transaction detail in Square can include form values. The Square note field is limited to 500 characters, so trim your output accordingly.

parametertypedescription
$argsarraySquare single payment arguments. Common keys include amount_money, customer_id, and note.
$processProcessThe Square Process instance for the current submission. Provides access to $process->form_data and $process->fields.

Source

wpforms\src\Integrations\Square\Process.php

Example

// Process Smart Tags in the Square payment note and trim to 500 chars.
function wpf_dev_square_single_payment_args( $args, $process ) {
    if ( isset( $args['note'] ) ) {
        $note        = apply_filters(
            'wpforms_process_smart_tags',
            $args['note'],
            $process->form_data,
            $process->fields,
            0
        );
        $args['note'] = wp_html_excerpt( $note, 500 );
    }
    return $args;
}
add_filter( 'wpforms_square_process_get_payment_args_single', 'wpf_dev_square_single_payment_args', 10, 2 );

Reference Article